1) annaucement api integration done
2)Billto and shipTo api integration
This commit is contained in:
parent
ef6ef970bb
commit
ff065bdc16
@ -2,25 +2,59 @@ import 'package:cheminova/utils/api_urls.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
import '../models/annauncement_model.dart';
|
||||
import '../utils/common_api_service.dart';
|
||||
|
||||
class AnnouncementService {
|
||||
final Dio _dio = Dio();
|
||||
|
||||
Future<List<AnnouncementModel>> fetchAnnouncements(String token) async {
|
||||
final String url = ApiUrls.AnnaouncementUrl;
|
||||
|
||||
Future<List<AnnouncementModel>?> fetchAnnouncements(String token) async {
|
||||
try {
|
||||
_dio.options.headers['Authorization'] = 'Bearer $token';
|
||||
final Response response = await _dio.get(url);
|
||||
String url = ApiUrls.AnnaouncementUrl; // Base URL to fetch product manuals
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
|
||||
List<dynamic> data = response.data;
|
||||
return data.map((announcement) => AnnouncementModel.fromJson(announcement)).toList();
|
||||
final response = await commonApiService<List<AnnouncementModel>>(
|
||||
method: "GET",
|
||||
url: url,
|
||||
additionalHeaders: { // Pass the token here
|
||||
'Authorization': 'Bearer $token',
|
||||
},
|
||||
fromJson: (json) {
|
||||
if (json['announcements'] != null) {
|
||||
// If the productManuals key is present, map the response to a list of ProductManualModel objects
|
||||
final List<AnnouncementModel> productManuals = (json['announcements'] as List)
|
||||
.map((manualJson) => AnnouncementModel.fromJson(manualJson))
|
||||
.toList();
|
||||
return productManuals; // Return the list of product manuals
|
||||
} else {
|
||||
throw Exception('Failed to load announcements');
|
||||
return [];
|
||||
}
|
||||
},
|
||||
);
|
||||
return response;
|
||||
} catch (e) {
|
||||
throw Exception('Error occurred while fetching announcements: $e');
|
||||
|
||||
print("fkfgghgh ,${e.toString()}");
|
||||
//print(e.toString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Future<List<AnnouncementModel>> fetchAnnouncements(String token) async {
|
||||
// final String url = ApiUrls.AnnaouncementUrl;
|
||||
// try {
|
||||
// _dio.options.headers['Authorization'] = 'Bearer $token';
|
||||
// final Response response = await _dio.get(url);
|
||||
//
|
||||
// if (response.statusCode == 200) {
|
||||
//
|
||||
// List<dynamic> data = response.data;
|
||||
// return data.map((announcement) => AnnouncementModel.fromJson(announcement)).toList();
|
||||
// } else {
|
||||
// throw Exception('Failed to load announcements');
|
||||
// }
|
||||
// } catch (e) {
|
||||
// throw Exception('Error occurred while fetching announcements: $e');
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
@ -1,38 +1,46 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:cheminova/models/notification_model.dart';
|
||||
import 'package:cheminova/utils/api_urls.dart';
|
||||
|
||||
import '../utils/common_api_service.dart';
|
||||
import '../utils/api_urls.dart';
|
||||
|
||||
class NotificationService {
|
||||
final Dio _dio = Dio();
|
||||
|
||||
Future<List<NotificationModel>?> fetchNotifications(String token, String date) async {
|
||||
final String url = ApiUrls.getNotificationUrl;
|
||||
|
||||
class NotificationApiService {
|
||||
// Function to fetch notifications from the API
|
||||
Future<List<NotificationModel>?> getNotification(String token) async {
|
||||
try {
|
||||
// Set the URL for fetching notifications
|
||||
String url =ApiUrls.getNotificationUrl; // Base URL to fetch product manuals
|
||||
// Make a GET request to the notification API
|
||||
final response = await commonApiService<List<NotificationModel>>(
|
||||
method: "GET",
|
||||
url: url,
|
||||
additionalHeaders: { // Pass the token here
|
||||
final response = await _dio.get(
|
||||
url,
|
||||
options: Options(
|
||||
headers: {
|
||||
'Authorization': 'Bearer $token',
|
||||
},
|
||||
fromJson: (json) {
|
||||
if (json['notifications'] != null) {
|
||||
// If notifications are present in the response, map them to NotificationModel objects
|
||||
final List<NotificationModel> notification = (json['notifications'] as List)
|
||||
.map((manualJson) => NotificationModel.fromJson(manualJson as Map<String, dynamic>))
|
||||
.toList();
|
||||
return notification;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
},
|
||||
),
|
||||
queryParameters: {'Date': date},
|
||||
);
|
||||
return response;
|
||||
} catch (e) {
|
||||
|
||||
print(e.toString());
|
||||
return null;
|
||||
// Ensure the response is not void and contains expected data
|
||||
if (response.statusCode == 200 && response.data != null) {
|
||||
final Map<String, dynamic> data = response.data as Map<String, dynamic>;
|
||||
|
||||
if (data.containsKey('success') && data['success'] == true) {
|
||||
List notifications = data['notifications'] ?? [];
|
||||
List<NotificationModel> notificationModels = notifications.map((notification) {
|
||||
return NotificationModel.fromJson(notification);
|
||||
}).toList();
|
||||
|
||||
return notificationModels; // Return the list of NotificationModel
|
||||
} else {
|
||||
print('Failed to fetch notifications: ${data['message'] ?? 'Unknown error'}');
|
||||
}
|
||||
} else {
|
||||
print('Unexpected response: ${response.statusCode}');
|
||||
}
|
||||
} catch (e) {
|
||||
print('Exception occurred: $e');
|
||||
}
|
||||
|
||||
return null; // Return null if fetching fails
|
||||
}
|
||||
}
|
||||
|
@ -1,50 +1,39 @@
|
||||
import 'package:cheminova/controller/notification_api_service.dart';
|
||||
import 'package:cheminova/controller/product_mannual_service.dart';
|
||||
import 'package:cheminova/models/notification_model.dart';
|
||||
import 'package:cheminova/notification_service.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import '../models/product_mannual_model.dart'; // Your model import
|
||||
// Your service import
|
||||
import 'notification_api_service.dart';
|
||||
|
||||
class NotificationController extends GetxController {
|
||||
|
||||
var isLoading = false.obs;
|
||||
var notificationList = <NotificationModel>[].obs;
|
||||
|
||||
// Service to fetch data
|
||||
final NotificationApiService notificationApiService = NotificationApiService();
|
||||
final NotificationService _notificationApiService = NotificationService();
|
||||
|
||||
// Loading state
|
||||
var isLoading = false.obs;
|
||||
|
||||
// Method to fetch product manuals from the service
|
||||
void fetchNotificationApiService() async {
|
||||
// Function to fetch notifications from the API with the selected date
|
||||
void fetchNotificationApiService(String date) async {
|
||||
try {
|
||||
// Set loading to true
|
||||
isLoading.value = true;
|
||||
isLoading(true);
|
||||
// Retrieve token from a secure source
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
String? token = prefs.getString('token');
|
||||
var manuals = await notificationApiService.getNotification(token!);
|
||||
|
||||
// If data is returned, update the list
|
||||
if (manuals != null) {
|
||||
notificationList .value = manuals;
|
||||
if (token == null) {
|
||||
print("Token is null");
|
||||
return;
|
||||
}
|
||||
|
||||
// Fetch notifications by date
|
||||
List<NotificationModel>? notifications = await _notificationApiService.fetchNotifications(token, date);
|
||||
|
||||
if (notifications != null && notifications.isNotEmpty) {
|
||||
notificationList.value = notifications;
|
||||
} else {
|
||||
notificationList.value = []; // If no data, set an empty list
|
||||
notificationList.clear();
|
||||
}
|
||||
} catch (e) {
|
||||
// Handle error here, for example logging or showing an error message
|
||||
print("Error fetching product manuals: $e");
|
||||
print("Error fetching notifications: $e");
|
||||
} finally {
|
||||
// Set loading to false
|
||||
isLoading.value = false;
|
||||
isLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
// Fetch product manuals when the controller is initialized
|
||||
fetchNotificationApiService();
|
||||
super.onInit();
|
||||
}
|
||||
}
|
||||
|
@ -11,8 +11,9 @@ class ProductService {
|
||||
String url;
|
||||
// Determine the URL based on the presence of a category filter
|
||||
if (category != null && category.isNotEmpty) {
|
||||
url = "${ApiUrls.getCategoryUrl}?page=$page&category=$category";
|
||||
} else {
|
||||
url = "${ApiUrls.getallProductUrl}?page=$page&category=$category";
|
||||
}
|
||||
else {
|
||||
url = "${ApiUrls.getallProductUrl}?page=$page"; // URL without category filter
|
||||
}
|
||||
// Make the API call using the common API service
|
||||
|
@ -28,11 +28,12 @@ class RDOrderPlacedService {
|
||||
);
|
||||
//logger.w("Status code,${response.statusCode}");
|
||||
if (response.statusCode != 200) {
|
||||
showSnackbar("stock not Available");
|
||||
throw Exception('Failed to RD place order');
|
||||
}
|
||||
else if(response.statusCode != 200 && response.statusCode == 400){
|
||||
showSnackbar("stock not Available");
|
||||
}
|
||||
// else if(response.statusCode != 200 && response.statusCode == 400){
|
||||
// showSnackbar("stock not Available");
|
||||
// }
|
||||
}
|
||||
|
||||
Future<void> RDOrderCancel(String token, String orderId, String reason) async {
|
||||
|
39
lib/controller/shiptoandbillto_service.dart
Normal file
39
lib/controller/shiptoandbillto_service.dart
Normal file
@ -0,0 +1,39 @@
|
||||
import '../models/shiping_billing_address_model.dart';
|
||||
import '../utils/api_urls.dart';
|
||||
import '../utils/common_api_service.dart';
|
||||
|
||||
class ShiptoandbilltoService {
|
||||
|
||||
|
||||
Future<List<UserShippingAddress>?> fetchshiptobillAddress(String token) async {
|
||||
try {
|
||||
String url = ApiUrls
|
||||
.ShiptoandBilltoAddressUrl; // Base URL to fetch product manuals
|
||||
|
||||
final response = await commonApiService<List<UserShippingAddress>>(
|
||||
method: "GET",
|
||||
url: url,
|
||||
additionalHeaders: { // Pass the token here
|
||||
'Authorization': 'Bearer $token',
|
||||
},
|
||||
fromJson: (json) {
|
||||
if (json['UserShippingAddress'] != null) {
|
||||
// If the productManuals key is present, map the response to a list of ProductManualModel objects
|
||||
final List<
|
||||
UserShippingAddress> productManuals = (json['UserShippingAddress'] as List)
|
||||
.map((manualJson) => UserShippingAddress.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;
|
||||
}
|
||||
}
|
||||
}
|
99
lib/controller/shiptobilltoController.dart
Normal file
99
lib/controller/shiptobilltoController.dart
Normal file
@ -0,0 +1,99 @@
|
||||
// import 'package:cheminova/controller/shiptoandbillto_service.dart';
|
||||
// import 'package:cheminova/models/shiping_billing_address_model.dart';
|
||||
// import 'package:get/get.dart';
|
||||
// import 'package:shared_preferences/shared_preferences.dart';
|
||||
//
|
||||
// class AddressController extends GetxController {
|
||||
// final ShiptoandbilltoService _productService = ShiptoandbilltoService();
|
||||
//
|
||||
// var addressList = <UserShippingAddress>[].obs; // Observable list of addresses
|
||||
// var selectedShippingAddressId = ''.obs;
|
||||
// var selectedBillingAddressId = ''.obs;
|
||||
//
|
||||
// @override
|
||||
// void onInit() {
|
||||
// super.onInit();
|
||||
// _loadAddresses();
|
||||
// }
|
||||
//
|
||||
// void _loadAddresses() async {
|
||||
// try {
|
||||
// SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
// String? token = prefs.getString('token');
|
||||
// final response = await _productService.fetchshiptobillAddress(token!);
|
||||
// addressList.assignAll(response as Iterable<UserShippingAddress>);
|
||||
//
|
||||
// // Load previously selected addresses
|
||||
// selectedShippingAddressId.value = prefs.getString('selectedShippingAddress') ?? '';
|
||||
// selectedBillingAddressId.value = prefs.getString('selectedBillingAddress') ?? '';
|
||||
//
|
||||
// // Set the default selection to the first address if available
|
||||
// if (addressList.isNotEmpty) {
|
||||
// if (selectedShippingAddressId.value.isEmpty) {
|
||||
// selectedShippingAddressId.value = addressList.first.id;
|
||||
// }
|
||||
// if (selectedBillingAddressId.value.isEmpty) {
|
||||
// selectedBillingAddressId.value = addressList.first.id;
|
||||
// }
|
||||
// }
|
||||
// } catch (e) {
|
||||
// print("Exception: $e");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// void _saveSelectedAddress() async {
|
||||
// SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
// await prefs.setString('selectedShippingAddress', selectedShippingAddressId.value);
|
||||
// await prefs.setString('selectedBillingAddress', selectedBillingAddressId.value);
|
||||
// }
|
||||
//
|
||||
// void onShippingAddressChanged(String? value) {
|
||||
// if (value != null) {
|
||||
// selectedShippingAddressId.value = value;
|
||||
// _saveSelectedAddress();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// void onBillingAddressChanged(String? value) {
|
||||
// if (value != null) {
|
||||
// selectedBillingAddressId.value = value;
|
||||
// _saveSelectedAddress();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
import 'package:cheminova/controller/shiptoandbillto_service.dart';
|
||||
import 'package:get/get_rx/src/rx_types/rx_types.dart';
|
||||
import 'package:get/get_state_manager/src/simple/get_controllers.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../models/shiping_billing_address_model.dart';
|
||||
|
||||
class AddressController extends GetxController {
|
||||
RxList<UserShippingAddress> addressList = <UserShippingAddress>[].obs;
|
||||
RxString selectedShippingAddressId = ''.obs;
|
||||
RxString selectedBillingAddressId = ''.obs;
|
||||
Rx<UserShippingAddress?> selectedShippingAddress = Rx<UserShippingAddress?>(null);
|
||||
Rx<UserShippingAddress?> selectedBillingAddress = Rx<UserShippingAddress?>(null);
|
||||
|
||||
void fetchAddresses() async {
|
||||
// Fetch the addresses from the API
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
String? token = prefs.getString('token');
|
||||
var response = await ShiptoandbilltoService().fetchshiptobillAddress(token!);
|
||||
if (response!= null) {
|
||||
addressList.value = response;
|
||||
}
|
||||
}
|
||||
|
||||
void onShippingAddressChanged(String? value) {
|
||||
selectedShippingAddressId.value = value ?? '';
|
||||
selectedShippingAddress.value = addressList.firstWhere((address) => address.id == value);
|
||||
}
|
||||
|
||||
void onBillingAddressChanged(String? value) {
|
||||
selectedBillingAddressId.value = value ?? '';
|
||||
selectedBillingAddress.value = addressList.firstWhere((address) => address.id == value,);
|
||||
}
|
||||
}
|
@ -1,28 +1,84 @@
|
||||
// class AnnouncementModel {
|
||||
// List<Announcement>? announcements;
|
||||
// int? totalAnnouncements;
|
||||
//
|
||||
// AnnouncementModel({this.announcements, this.totalAnnouncements});
|
||||
//
|
||||
// // Factory constructor to create an instance from a JSON map
|
||||
// factory AnnouncementModel.fromJson(Map<String, dynamic> json) {
|
||||
// return AnnouncementModel(
|
||||
// announcements: json['announcements'] != null
|
||||
// ? List<Announcement>.from(json['announcements'].map((item) => Announcement.fromJson(item)))
|
||||
// : null,
|
||||
// totalAnnouncements: json['totalAnnouncements']?.toString() != null
|
||||
// ? int.tryParse(json['totalAnnouncements'].toString())
|
||||
// : 1,
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// // Method to convert an instance to a JSON map
|
||||
// Map<String, dynamic> toJson() {
|
||||
// return {
|
||||
// 'announcements': announcements?.map((item) => item.toJson()).toList(),
|
||||
// 'totalAnnouncements': totalAnnouncements,
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// // Overriding the toString() method for debugging purposes
|
||||
// @override
|
||||
// String toString() {
|
||||
// return 'AnnouncementModel(announcements: $announcements, totalAnnouncements: $totalAnnouncements)';
|
||||
// }
|
||||
// }
|
||||
|
||||
class AnnouncementModel {
|
||||
final String id;
|
||||
final String uniqueId;
|
||||
final List<String> sentTo;
|
||||
final String message;
|
||||
final DateTime createdAt;
|
||||
final DateTime updatedAt;
|
||||
String? id;
|
||||
List<String>? sentTo;
|
||||
String? message;
|
||||
String? createdAt;
|
||||
String? updatedAt;
|
||||
String? uniqueId;
|
||||
int? version;
|
||||
|
||||
AnnouncementModel({
|
||||
required this.id,
|
||||
required this.uniqueId,
|
||||
required this.sentTo,
|
||||
required this.message,
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
this.id,
|
||||
this.sentTo,
|
||||
this.message,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
this.uniqueId,
|
||||
this.version,
|
||||
});
|
||||
|
||||
// Factory constructor to create an instance from a JSON map
|
||||
factory AnnouncementModel.fromJson(Map<String, dynamic> json) {
|
||||
return AnnouncementModel(
|
||||
id: json['_id']??"",
|
||||
uniqueId: json['uniqueId']??"",
|
||||
sentTo: List<String>.from(json['sentTo']),
|
||||
message: json['message']??"",
|
||||
createdAt: DateTime.parse(json['createdAt']),
|
||||
updatedAt: DateTime.parse(json['updatedAt']),
|
||||
id: json['_id']?.toString(),
|
||||
sentTo: json['sentTo'] != null ? List<String>.from(json['sentTo']) : null,
|
||||
message: json['message']?.toString(),
|
||||
createdAt: json['createdAt']?.toString(),
|
||||
updatedAt: json['updatedAt']?.toString(),
|
||||
uniqueId: json['uniqueId']?.toString(),
|
||||
version: json['__v']?.toString() != null ? int.tryParse(json['__v'].toString()) : null,
|
||||
);
|
||||
}
|
||||
|
||||
// Method to convert an instance to a JSON map
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'_id': id,
|
||||
'sentTo': sentTo,
|
||||
'message': message,
|
||||
'createdAt': createdAt,
|
||||
'updatedAt': updatedAt,
|
||||
'uniqueId': uniqueId,
|
||||
'__v': version,
|
||||
};
|
||||
}
|
||||
|
||||
// Overriding the toString() method for debugging purposes
|
||||
@override
|
||||
String toString() {
|
||||
return 'Announcement(id: $id, sentTo: $sentTo, message: $message, createdAt: $createdAt, updatedAt: $updatedAt, uniqueId: $uniqueId, version: $version)';
|
||||
}
|
||||
}
|
||||
|
@ -1,67 +1,47 @@
|
||||
class NotificationModel {
|
||||
String? id;
|
||||
String? title;
|
||||
String? msg;
|
||||
String? addedFor;
|
||||
String? createdAt;
|
||||
String? updatedAt;
|
||||
int? v;
|
||||
final String id; // Notification ID
|
||||
final String title; // Title of the notification
|
||||
final String message; // Message of the notification
|
||||
final String addedFor; // ID of the user/recipient
|
||||
final DateTime createdAt; // Timestamp when created
|
||||
final DateTime updatedAt; // Timestamp when updated
|
||||
|
||||
NotificationModel({
|
||||
this.id,
|
||||
this.title,
|
||||
this.msg,
|
||||
this.addedFor,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
this.v,
|
||||
required this.id,
|
||||
required this.title,
|
||||
required this.message,
|
||||
required this.addedFor,
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
});
|
||||
|
||||
// Factory method to create a NotificationModel from JSON
|
||||
factory NotificationModel.fromJson(Map<String, dynamic> json) {
|
||||
return NotificationModel(
|
||||
id: json['_id'],
|
||||
title: json['title'],
|
||||
msg: json['msg'],
|
||||
id: json['_id'].toString(),
|
||||
title: json['title'].toString(),
|
||||
message: json['msg'].toString(),
|
||||
addedFor: json['added_for'],
|
||||
createdAt: json['createdAt'],
|
||||
updatedAt: json['updatedAt'],
|
||||
v: json['__v'],
|
||||
createdAt: DateTime.parse(json['createdAt'] as String),
|
||||
updatedAt: DateTime.parse(json['updatedAt']as String),
|
||||
);
|
||||
}
|
||||
|
||||
// Method to convert a NotificationModel to JSON
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'_id': id,
|
||||
'title': title,
|
||||
'msg': msg,
|
||||
'msg': message,
|
||||
'added_for': addedFor,
|
||||
'createdAt': createdAt,
|
||||
'updatedAt': updatedAt,
|
||||
'__v': v,
|
||||
'createdAt': createdAt.toIso8601String(),
|
||||
'updatedAt': updatedAt.toIso8601String(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class NotificationResponse {
|
||||
String? returnMessage;
|
||||
List<NotificationModel>? notifications;
|
||||
|
||||
NotificationResponse({this.returnMessage, this.notifications});
|
||||
|
||||
factory NotificationResponse.fromJson(Map<String, dynamic> json) {
|
||||
return NotificationResponse(
|
||||
returnMessage: json['return_message'],
|
||||
notifications: json['notifications'] != null
|
||||
? List<NotificationModel>.from(json['notifications']
|
||||
.map((notification) => NotificationModel.fromJson(notification)))
|
||||
: null,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'return_message': returnMessage,
|
||||
'notifications': notifications?.map((notification) => notification.toJson()).toList(),
|
||||
};
|
||||
// Override toString method for better readability
|
||||
@override
|
||||
String toString() {
|
||||
return 'NotificationModel{id: $id, title: $title, message: $message, addedFor: $addedFor, createdAt: $createdAt, updatedAt: $updatedAt}';
|
||||
}
|
||||
}
|
||||
|
62
lib/models/shiping_billing_address_model.dart
Normal file
62
lib/models/shiping_billing_address_model.dart
Normal file
@ -0,0 +1,62 @@
|
||||
class UserShippingAddress {
|
||||
final String id;
|
||||
final String street;
|
||||
final String city;
|
||||
final String state;
|
||||
final String postalCode;
|
||||
final String country;
|
||||
String? panNumber;
|
||||
final String tradeName;
|
||||
String? gstNumber;
|
||||
bool? isDefault;
|
||||
|
||||
UserShippingAddress({
|
||||
required this.id,
|
||||
required this.street,
|
||||
required this.city,
|
||||
required this.state,
|
||||
required this.postalCode,
|
||||
required this.country,
|
||||
this.panNumber,
|
||||
required this.tradeName,
|
||||
this.gstNumber,
|
||||
this.isDefault,
|
||||
});
|
||||
|
||||
factory UserShippingAddress.fromJson(Map<String, dynamic> json) {
|
||||
return UserShippingAddress(
|
||||
id: json['_id'],
|
||||
street: json['street'],
|
||||
city: json['city'],
|
||||
state: json['state'],
|
||||
postalCode: json['postalCode'],
|
||||
country: json['country'],
|
||||
panNumber: json['panNumber'],
|
||||
tradeName: json['tradeName'],
|
||||
gstNumber: json['gstNumber'],
|
||||
isDefault: json['isDefault'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'_id': id,
|
||||
'street': street,
|
||||
'city': city,
|
||||
'state': state,
|
||||
'postalCode': postalCode,
|
||||
'country': country,
|
||||
'panNumber': panNumber,
|
||||
'tradeName': tradeName,
|
||||
'gstNumber': gstNumber,
|
||||
'isDefault': isDefault,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// Utility method in UserShippingAddress model to get full address as a string
|
||||
//extension UserShippingAddressExtensions on UserShippingAddress {
|
||||
String toStringFullAddress() {
|
||||
return "$street, $city, $state, $postalCode, $country";
|
||||
}
|
||||
}
|
@ -77,24 +77,33 @@ class _AnnouncementScreenState extends State<AnnouncementScreen> {
|
||||
return ListView.builder(
|
||||
itemCount: _announcementController.announcements.length,
|
||||
itemBuilder: (context, index) {
|
||||
|
||||
return Card(
|
||||
final announcementList = _announcementController.announcements[index];
|
||||
print("asdf,${announcementList}");
|
||||
return Column(
|
||||
children: [
|
||||
Card(
|
||||
child: ListTile(
|
||||
//leading:Text(_announcementController.announcements[index].id),
|
||||
title: Row(
|
||||
|
||||
children: [
|
||||
Text("Message :",style: TextStyle(fontWeight: FontWeight.bold),),
|
||||
Text(_announcementController.announcements[index].message),
|
||||
Text("Message :",style: TextStyle(fontWeight: FontWeight.bold,fontSize: 14),),
|
||||
Text(announcementList.message.toString(),style: TextStyle(fontSize: 12),),
|
||||
|
||||
],
|
||||
),
|
||||
subtitle: Row(
|
||||
children: [
|
||||
Text("UniqueID :" , style: TextStyle(fontWeight: FontWeight.bold),),
|
||||
Text(_announcementController.announcements[index].uniqueId),
|
||||
Text(announcementList.uniqueId.toString()),
|
||||
],
|
||||
),
|
||||
trailing: Text(formatDate(_announcementController.announcements[index].createdAt.toIso8601String())),
|
||||
trailing: Text(formatDate(announcementList.createdAt.toString()),style: TextStyle(fontSize: 10),),
|
||||
),
|
||||
|
||||
),
|
||||
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
|
@ -17,9 +17,6 @@ class NotificationScreen extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// Fetch notifications when the screen is first built
|
||||
notificationController.fetchNotificationApiService();
|
||||
|
||||
return CommonBackground(
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.transparent,
|
||||
@ -33,14 +30,41 @@ class NotificationScreen extends StatelessWidget {
|
||||
padding: const EdgeInsets.only(right: 20),
|
||||
),
|
||||
],
|
||||
title: const Text('Notification',
|
||||
title: const Text(
|
||||
'Notification',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontFamily: 'Anek')),
|
||||
fontFamily: 'Anek',
|
||||
),
|
||||
),
|
||||
backgroundColor: Colors.transparent,
|
||||
elevation: 0,
|
||||
// Add the date picker button in the app bar
|
||||
bottom: PreferredSize(
|
||||
preferredSize: Size.fromHeight(80),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: TextButton(
|
||||
onPressed: () {
|
||||
_selectDate(context);
|
||||
},
|
||||
child:
|
||||
Row(
|
||||
children: [
|
||||
Text("Select Date: ",style: TextStyle(fontWeight: FontWeight.bold,fontSize: 18),),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.calendar_today),
|
||||
onPressed: () {
|
||||
_selectDate(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
drawer: MyDrawer(),
|
||||
body: Obx(() {
|
||||
@ -58,6 +82,23 @@ class NotificationScreen extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Function to show date picker
|
||||
Future<void> _selectDate(BuildContext context) async {
|
||||
DateTime? selectedDate = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: DateTime.now(),
|
||||
firstDate: DateTime(2020), // Adjust the start date as needed
|
||||
lastDate: DateTime.now(),
|
||||
);
|
||||
|
||||
if (selectedDate != null) {
|
||||
// Format the date to dd/MM/yyyy
|
||||
String formattedDate = DateFormat('dd/MM/yyyy').format(selectedDate);
|
||||
// Call the API with the selected date
|
||||
notificationController.fetchNotificationApiService(formattedDate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class MyListView extends StatelessWidget {
|
||||
@ -74,7 +115,7 @@ class MyListView extends StatelessWidget {
|
||||
// Ensure that 'notifications' is not null
|
||||
if (notification != null) {
|
||||
String date = DateFormat("dd MMM yyyy")
|
||||
.format(DateTime.parse(notification.createdAt ?? ''));
|
||||
.format(DateTime.parse(notification.createdAt.toString() ?? ''));
|
||||
if (!groupedNotifications.containsKey(date)) {
|
||||
groupedNotifications[date] = [];
|
||||
}
|
||||
@ -94,15 +135,30 @@ class MyListView extends StatelessWidget {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Display the date once
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8.0),
|
||||
child: Text(
|
||||
// Display the date card
|
||||
Card(
|
||||
elevation: 3,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(10),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
// Display the selected date
|
||||
Text(
|
||||
date,
|
||||
style: const TextStyle(
|
||||
fontSize: 16, fontWeight: FontWeight.bold),
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
// Display notifications for the date
|
||||
...notificationsForDate.map(
|
||||
(notification) {
|
||||
@ -115,9 +171,11 @@ class MyListView extends StatelessWidget {
|
||||
title: Text(
|
||||
notification.title ?? 'No title',
|
||||
style: const TextStyle(
|
||||
fontSize: 17, fontWeight: FontWeight.w500),
|
||||
fontSize: 17,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
subtitle: Text(notification.msg ?? 'No message'),
|
||||
),
|
||||
subtitle: Text(notification.message ?? 'No message'),
|
||||
),
|
||||
);
|
||||
},
|
||||
|
@ -4,6 +4,7 @@ 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/screens/rd%20orders/rd_pending_screen.dart';
|
||||
import 'package:cheminova/screens/rd%20orders/rd_processing_screen.dart';
|
||||
import 'package:cheminova/widgets/my_drawer.dart';
|
||||
import 'package:cheminova/widgets/product_card.dart';
|
||||
import 'package:cheminova/widgets/product_card1.dart';
|
||||
@ -97,10 +98,11 @@ class _PartialPendingDialogScreenState extends State<PartialPendingDialogScreen>
|
||||
await controller.placeRDOrder();
|
||||
showSnackbar("Partial order processed successfully.");
|
||||
|
||||
Future.delayed(const Duration(seconds: 1), () {
|
||||
Get.to(RdOrderPendingScreen());
|
||||
//Navigator.of(context).pop();
|
||||
});
|
||||
// Close the dialog before navigating to another screen
|
||||
Navigator.of(context).pop();
|
||||
|
||||
// Navigate to the pending screen
|
||||
Get.to(RdOrderProcessingScreen());
|
||||
|
||||
setState(() {});
|
||||
},
|
||||
|
@ -358,14 +358,12 @@ class _PartialProcessingDialogScreenState extends State<PartialProcessingDialogS
|
||||
|
||||
await controller.placeRDOrder();
|
||||
showSnackbar("Partial order processed successfully.");
|
||||
Get.to(RdOrderPendingScreen());
|
||||
//Navigator.of(context).pop();
|
||||
// Future.delayed(const Duration(seconds: 1), () {
|
||||
// Get.to(RdOrderPendingScreen());
|
||||
// //Navigator.of(context).pop();
|
||||
// });
|
||||
|
||||
//setState(() {});
|
||||
// Close the dialog before navigating to another screen
|
||||
Navigator.of(context).pop();
|
||||
|
||||
// Navigate to the pending screen
|
||||
Get.to(RdOrderPendingScreen());
|
||||
},
|
||||
child: const Text("Confirm"),
|
||||
),
|
||||
|
@ -16,15 +16,17 @@ import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../../controller/cart_controller.dart';
|
||||
import '../../controller/get_delivered_controller.dart';
|
||||
import '../../models/get_invoice_model.dart';
|
||||
import '../../models/product_model1.dart';
|
||||
|
||||
class RdDeliveredDetailsScreen extends StatefulWidget {
|
||||
//final Product? productModel;
|
||||
// PlacedOrderList and PlacedOrderModel are optional parameters passed to this screen
|
||||
GetDeliveredModel? placedOrderList;
|
||||
GetInvoiceModel? placedInvoiceList;
|
||||
// PlacedOrderModel? placedOrderModel;
|
||||
// Constructor for initializing the screen with placed order details
|
||||
RdDeliveredDetailsScreen({super.key,this.placedOrderList});
|
||||
RdDeliveredDetailsScreen({super.key,this.placedOrderList,this.placedInvoiceList});
|
||||
|
||||
@override
|
||||
State<RdDeliveredDetailsScreen> createState() =>
|
||||
@ -419,211 +421,16 @@ class _RdDeliveredDetailsScreenState
|
||||
const SizedBox(height: 8),
|
||||
SizedBox(
|
||||
height: Get.height* 0.19,
|
||||
child: Card(
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: Get.width,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
||||
child: Text(
|
||||
"Customer Details",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.05,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: Get.width,
|
||||
//height: Get.height*0.09,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
"Name: ",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.04,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text("${"Roshan Garg"}",maxLines: 4,
|
||||
overflow:TextOverflow.ellipsis,)
|
||||
, ],
|
||||
)
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: Get.width,
|
||||
// height: Get.height*0.09,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
"Email: ",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.04,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text("${"roshangarg28@gmail.com"}",maxLines: 4,
|
||||
overflow:TextOverflow.ellipsis,)
|
||||
, ],
|
||||
)
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: Get.width,
|
||||
// height: Get.height*0.09,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
"Mobile Number: ",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.04,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text("${"8876785448"}",maxLines: 4,
|
||||
overflow:TextOverflow.ellipsis,)
|
||||
, ],
|
||||
)
|
||||
),
|
||||
)
|
||||
child:_buildCustomerDetails(),
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Card(
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: Get.width,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
||||
child: Text(
|
||||
"Billing Information",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.05,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: Get.width,
|
||||
height: Get.height*0.06,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
||||
child: Wrap(
|
||||
crossAxisAlignment: WrapCrossAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Address: ",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.04,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text("${"456, Park Street, Kolkata, West Bengal - 700016"}",maxLines: 4,
|
||||
overflow:TextOverflow.ellipsis,)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
_buildBillingInfo(),
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
// Card for displaying shipping information
|
||||
Card(
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: Get.width,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
||||
child: Text(
|
||||
"Shipping Information",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.05,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: Get.width,
|
||||
height: Get.height*0.06,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
||||
child: Wrap(
|
||||
crossAxisAlignment: WrapCrossAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Address: ",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.04,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text("${"456, Park Street, Kolkata, West Bengal - 700016"}",maxLines: 4,
|
||||
overflow:TextOverflow.ellipsis,)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
_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("online-transfer")),
|
||||
// Text("${widget.placedOrderList!.paymentMode}",maxLines: 4,
|
||||
// overflow:TextOverflow.ellipsis,)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
_buildPaymentInfo(),
|
||||
const SizedBox(height: 8),
|
||||
Card(
|
||||
child: Column(
|
||||
@ -740,4 +547,119 @@ class _RdDeliveredDetailsScreenState
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Widget _buildCustomerDetails() {
|
||||
return Card(
|
||||
child: Column(
|
||||
children: [
|
||||
_buildSectionTitle("Customer Details"),
|
||||
_buildRow("Name:", widget.placedInvoiceList!.orderId!.addedBy!.name.toString(), Get.width * 0.04),
|
||||
_buildRow("Email:", widget.placedInvoiceList!.orderId!.addedBy!.email.toString(), Get.width * 0.04),
|
||||
_buildRow("Mobile Number:", widget.placedInvoiceList!.orderId!.addedBy!.mobileNumber.toString(), Get.width * 0.04),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBillingInfo() {
|
||||
return Card(
|
||||
child: Column(
|
||||
children: [
|
||||
_buildSectionTitle("Billing Information"),
|
||||
_buildInfoRow("Address", widget.placedInvoiceList!.orderId!.billTo.toString(), Get.width * 0.04),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildShippingInfo() {
|
||||
return Card(
|
||||
child: Column(
|
||||
children: [
|
||||
_buildSectionTitle("Shipping Information"),
|
||||
_buildInfoRow("Address", widget.placedInvoiceList!.orderId!.shipTo.toString(), Get.width * 0.04),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPaymentInfo() {
|
||||
return Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
"Payment Mode: ",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.04,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
Text(capitalizeFirstLetter(widget.placedInvoiceList!.orderId!.paymentMode.toString())),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
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 _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),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
|
||||
import 'package:cheminova/controller/get_delivered_controller.dart';
|
||||
import 'package:cheminova/controller/get_delivered_service.dart';
|
||||
import 'package:cheminova/controller/rd_get_order_controller.dart';
|
||||
import 'package:cheminova/models/get_delivered_model.dart';
|
||||
import 'package:cheminova/models/rd_get_order_model.dart';
|
||||
@ -16,7 +17,9 @@ 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/get_single_invoice_Service.dart';
|
||||
import '../order_management/order_management_detail_screen.dart';
|
||||
|
||||
class RdDeliveredScreen extends StatefulWidget {
|
||||
@ -70,11 +73,68 @@ class _RdDeliveredScreenState extends State<RdDeliveredScreen> {
|
||||
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);
|
||||
String formattedDate = DateFormat('EEE MMM dd yyyy hh:mm a').format(parsedDate);
|
||||
|
||||
|
||||
return formattedDate; // Return the formatted date string
|
||||
}
|
||||
|
||||
|
||||
|
||||
void onOrderTap(int index) async {
|
||||
try {
|
||||
// Fetch orders and ensure you wait for it to complete
|
||||
await _getRdProductController.getRDDeliveredInvoiceProduct();
|
||||
|
||||
// Log the count of fetched orders
|
||||
print('Fetched orders count: ${_getRdProductController.productProcessingRDList.length}');
|
||||
|
||||
// Check if the productRDList is populated
|
||||
if (_getRdProductController.productProcessingRDList.isNotEmpty) {
|
||||
// Ensure the index is valid
|
||||
if (index >= 0 && index < _getRdProductController.productProcessingRDList.length) {
|
||||
// Get the order ID from the list based on the index
|
||||
final orderId = _getRdProductController.productProcessingRDList[index].id;
|
||||
final orderId1 = _getRdProductController.productProcessingRDList[index].id;
|
||||
// Retrieve the token from SharedPreferences
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
String? token = prefs.getString('token');
|
||||
|
||||
// Check if the token is not null
|
||||
if (token != null) {
|
||||
// Fetch the single order using the order ID, and avoid caching issues
|
||||
final singleOrder = await GetSingleInvoiceService().fetchInvoice(token, orderId);
|
||||
final invoiceOrder = await GetDeliveredService().getRDDeliveredProduct(token);
|
||||
// Check if the single order was fetched successfully
|
||||
if (singleOrder != null) {
|
||||
// Navigate to the details screen with the fetched order
|
||||
Get.to(() => RdDeliveredDetailsScreen(
|
||||
placedOrderList: invoiceOrder![index],
|
||||
placedInvoiceList: singleOrder,
|
||||
));
|
||||
} else {
|
||||
// Handle the case where the single order could not be fetched
|
||||
Get.snackbar("Error", "Unable to fetch order details.");
|
||||
}
|
||||
} else {
|
||||
// Handle the case where the token is null
|
||||
Get.snackbar("Error", "User not authenticated.");
|
||||
}
|
||||
} else {
|
||||
// Handle the case when the index is out of bounds
|
||||
Get.snackbar("Error", "Invalid order selection.");
|
||||
}
|
||||
} else {
|
||||
// Handle the case when the list is empty
|
||||
Get.snackbar("Error", "No orders available to display.");
|
||||
}
|
||||
} catch (e) {
|
||||
// Log any errors that occur during the process
|
||||
print('Error in onOrderTap: $e');
|
||||
Get.snackbar("Error", "An unexpected error occurred.");
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@ -329,10 +389,13 @@ class _RdDeliveredScreenState extends State<RdDeliveredScreen> {
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: ElevatedButton(
|
||||
onPressed: ()=>
|
||||
Get.to(() =>
|
||||
RdDeliveredDetailsScreen(
|
||||
placedOrderList: uniqueOrders[index])), // Navigate to detail screen
|
||||
onPressed: (){
|
||||
onOrderTap(index);
|
||||
},
|
||||
//=>
|
||||
// Get.to(() =>
|
||||
// RdDeliveredDetailsScreen(
|
||||
// placedOrderList: uniqueOrders[index])), // Navigate to detail screen
|
||||
style: ElevatedButton.styleFrom(
|
||||
foregroundColor: Colors.white,
|
||||
backgroundColor: const Color(0xFF004791),
|
||||
|
@ -1,11 +1,13 @@
|
||||
import 'package:auto_size_text/auto_size_text.dart';
|
||||
import 'package:cheminova/controller/get_dispatch_controller.dart';
|
||||
import 'package:cheminova/controller/get_order_placed_controller.dart';
|
||||
import 'package:cheminova/controller/get_single_invoice_controller.dart';
|
||||
import 'package:cheminova/models/get_dispatch_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/screens/rd%20orders/rd_delivered_screen.dart';
|
||||
import 'package:cheminova/utils/show_snackbar.dart';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
@ -17,6 +19,7 @@ import 'package:intl/intl.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../../controller/cart_controller.dart';
|
||||
import '../../models/get_invoice_model.dart';
|
||||
import '../../models/product_model1.dart';
|
||||
|
||||
class RdDispatchedDetailsDetailScreen extends StatefulWidget {
|
||||
@ -24,8 +27,9 @@ class RdDispatchedDetailsDetailScreen extends StatefulWidget {
|
||||
// PlacedOrderList and PlacedOrderModel are optional parameters passed to this screen
|
||||
GetDispatchModel? placedOrderList;
|
||||
PlacedOrderModel? placedOrderModel;
|
||||
GetInvoiceModel? placedInvoiceList;
|
||||
// Constructor for initializing the screen with placed order details
|
||||
RdDispatchedDetailsDetailScreen({super.key,this.placedOrderList,this.placedOrderModel});
|
||||
RdDispatchedDetailsDetailScreen({super.key,this.placedOrderList,this.placedOrderModel,this.placedInvoiceList});
|
||||
|
||||
@override
|
||||
State<RdDispatchedDetailsDetailScreen> createState() =>
|
||||
@ -38,6 +42,7 @@ class _RdDispatchedDetailsDetailScreenState
|
||||
// Controllers for managing cart and placed orders
|
||||
final CartController _cartController = Get.put(CartController());
|
||||
final GetDispatchController _getPlacedOrderController = Get.put(GetDispatchController());
|
||||
final GetSingleInvoiceController _getSingleInvoiceController = Get.put(GetSingleInvoiceController());
|
||||
final GetDispatchController _getDispatchController = Get.put(GetDispatchController());
|
||||
final List<String> statusOptions = [
|
||||
"new",
|
||||
@ -180,6 +185,7 @@ class _RdDispatchedDetailsDetailScreenState
|
||||
// Call your API method here
|
||||
await _getDispatchController.RDDispatchToDeliveredProduct(widget.placedOrderList!.id);
|
||||
showSnackbar("Order Status updated Order Delivered");
|
||||
|
||||
} else {
|
||||
// Show a message if the status is not "Delivered"
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
@ -504,7 +510,7 @@ class _RdDispatchedDetailsDetailScreenState
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10)),
|
||||
),
|
||||
child: Text(widget.placedOrderList!.courierStatus, style: GoogleFonts.roboto(fontSize: 14, fontWeight: FontWeight.w400)),
|
||||
child: Text(capitalizeFirstLetter(widget.placedOrderList!.courierStatus), style: GoogleFonts.roboto(fontSize: 14, fontWeight: FontWeight.w400)),
|
||||
),
|
||||
//Text("₹ ${widget.placedOrderList!.gstTotal}"),
|
||||
],
|
||||
@ -516,214 +522,50 @@ class _RdDispatchedDetailsDetailScreenState
|
||||
),
|
||||
|
||||
|
||||
const SizedBox(height: 8),
|
||||
const SizedBox(height: 8),
|
||||
SizedBox(
|
||||
height: Get.height* 0.19,
|
||||
child: Card(
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: Get.width,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
||||
child: Text(
|
||||
"Customer Details",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.05,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: Get.width,
|
||||
//height: Get.height*0.09,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
"Name: ",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.04,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text("${"Roshan Garg"}",maxLines: 4,
|
||||
overflow:TextOverflow.ellipsis,)
|
||||
, ],
|
||||
)
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: Get.width,
|
||||
// height: Get.height*0.09,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
"Email: ",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.04,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text("${"roshangarg28@gmail.com"}",maxLines: 4,
|
||||
overflow:TextOverflow.ellipsis,)
|
||||
, ],
|
||||
)
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: Get.width,
|
||||
// height: Get.height*0.09,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
"Mobile Number: ",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.04,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text("${"8876785448"}",maxLines: 4,
|
||||
overflow:TextOverflow.ellipsis,)
|
||||
, ],
|
||||
)
|
||||
),
|
||||
)
|
||||
child:_buildCustomerDetails(),
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Card(
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: Get.width,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
||||
child: Text(
|
||||
"Billing Information",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.05,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: Get.width,
|
||||
height: Get.height*0.06,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
||||
child: Wrap(
|
||||
crossAxisAlignment: WrapCrossAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Address: ",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.04,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text("${"456, Park Street, Kolkata, West Bengal - 700016"}",maxLines: 4,
|
||||
overflow:TextOverflow.ellipsis,)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
_buildBillingInfo(),
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
// Card for displaying shipping information
|
||||
Card(
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: Get.width,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
||||
child: Text(
|
||||
"Shipping Information",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.05,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: Get.width,
|
||||
height: Get.height*0.06,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
||||
child: Wrap(
|
||||
crossAxisAlignment: WrapCrossAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Address: ",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.04,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text("${"456, Park Street, Kolkata, West Bengal - 700016"}",maxLines: 4,
|
||||
overflow:TextOverflow.ellipsis,)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
_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("Cheque")),
|
||||
// Text("${widget.placedOrderList!.paymentMode}",maxLines: 4,
|
||||
// overflow:TextOverflow.ellipsis,)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
_buildPaymentInfo(),
|
||||
// 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("Cheque")),
|
||||
// // Text("${widget.placedOrderList!.paymentMode}",maxLines: 4,
|
||||
// // overflow:TextOverflow.ellipsis,)
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
//
|
||||
//
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
const SizedBox(height: 8),
|
||||
Card(
|
||||
child: Column(
|
||||
@ -835,4 +677,119 @@ class _RdDispatchedDetailsDetailScreenState
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Widget _buildCustomerDetails() {
|
||||
return Card(
|
||||
child: Column(
|
||||
children: [
|
||||
_buildSectionTitle("Customer Details"),
|
||||
_buildRow("Name:", widget.placedInvoiceList!.orderId!.addedBy!.name.toString(), Get.width * 0.04),
|
||||
_buildRow("Email:", widget.placedInvoiceList!.orderId!.addedBy!.email.toString(), Get.width * 0.04),
|
||||
_buildRow("Mobile Number:", widget.placedInvoiceList!.orderId!.addedBy!.mobileNumber.toString(), Get.width * 0.04),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBillingInfo() {
|
||||
return Card(
|
||||
child: Column(
|
||||
children: [
|
||||
_buildSectionTitle("Billing Information"),
|
||||
_buildInfoRow("Address", widget.placedInvoiceList!.orderId!.billTo.toString(), Get.width * 0.04),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildShippingInfo() {
|
||||
return Card(
|
||||
child: Column(
|
||||
children: [
|
||||
_buildSectionTitle("Shipping Information"),
|
||||
_buildInfoRow("Address", widget.placedInvoiceList!.orderId!.shipTo.toString(), Get.width * 0.04),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPaymentInfo() {
|
||||
return Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
"Payment Mode: ",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.04,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
Text(capitalizeFirstLetter(widget.placedInvoiceList!.orderId!.paymentMode.toString())),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
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),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
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 _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),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
|
||||
import 'package:cheminova/controller/get_dispatch_service.dart';
|
||||
import 'package:cheminova/controller/get_single_invoice_Service.dart';
|
||||
import 'package:cheminova/controller/rd_get_order_controller.dart';
|
||||
import 'package:cheminova/models/get_dispatch_model.dart';
|
||||
import 'package:cheminova/models/rd_get_order_model.dart';
|
||||
@ -13,8 +15,10 @@ 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/get_dispatch_controller.dart';
|
||||
import '../../controller/get_single_invoice_controller.dart';
|
||||
import '../order_management/order_management_detail_screen.dart';
|
||||
|
||||
class RdDispatchedScreen extends StatefulWidget {
|
||||
@ -36,6 +40,7 @@ class _RdDispatchedScreenState extends State<RdDispatchedScreen> {
|
||||
"delivered",];
|
||||
int _selectedIndex = 0;
|
||||
final GetDispatchController _getRdProductController = Get.put(GetDispatchController());
|
||||
final GetSingleInvoiceController _getSingleInvoiceController = Get.put(GetSingleInvoiceController());
|
||||
final GlobalKey<RefreshIndicatorState> _refreshIndicatorKey = GlobalKey<RefreshIndicatorState>();
|
||||
|
||||
@override
|
||||
@ -58,6 +63,62 @@ class _RdDispatchedScreenState extends State<RdDispatchedScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void onOrderTap(int index) async {
|
||||
try {
|
||||
// Fetch orders and ensure you wait for it to complete
|
||||
await _getRdProductController.getRDDispatchInvoiceProduct();
|
||||
|
||||
// Log the count of fetched orders
|
||||
print('Fetched orders count: ${_getRdProductController.productProcessingRDList.length}');
|
||||
|
||||
// Check if the productRDList is populated
|
||||
if (_getRdProductController.productProcessingRDList.isNotEmpty) {
|
||||
// Ensure the index is valid
|
||||
if (index >= 0 && index < _getRdProductController.productProcessingRDList.length) {
|
||||
// Get the order ID from the list based on the index
|
||||
final orderId = _getRdProductController.productProcessingRDList[index].id;
|
||||
final orderId1 = _getRdProductController.productProcessingRDList[index].id;
|
||||
// Retrieve the token from SharedPreferences
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
String? token = prefs.getString('token');
|
||||
|
||||
// Check if the token is not null
|
||||
if (token != null) {
|
||||
// Fetch the single order using the order ID, and avoid caching issues
|
||||
final singleOrder = await GetSingleInvoiceService().fetchInvoice(token, orderId);
|
||||
final invoiceOrder = await GetDispatchService().getRDDispatchedProduct(token);
|
||||
// Check if the single order was fetched successfully
|
||||
if (singleOrder != null) {
|
||||
// Navigate to the details screen with the fetched order
|
||||
Get.to(() => RdDispatchedDetailsDetailScreen(
|
||||
placedOrderList: invoiceOrder![index],
|
||||
placedInvoiceList: singleOrder,
|
||||
));
|
||||
} else {
|
||||
// Handle the case where the single order could not be fetched
|
||||
Get.snackbar("Error", "Unable to fetch order details.");
|
||||
}
|
||||
} else {
|
||||
// Handle the case where the token is null
|
||||
Get.snackbar("Error", "User not authenticated.");
|
||||
}
|
||||
} else {
|
||||
// Handle the case when the index is out of bounds
|
||||
Get.snackbar("Error", "Invalid order selection.");
|
||||
}
|
||||
} else {
|
||||
// Handle the case when the list is empty
|
||||
Get.snackbar("Error", "No orders available to display.");
|
||||
}
|
||||
} catch (e) {
|
||||
// Log any errors that occur during the process
|
||||
print('Error in onOrderTap: $e');
|
||||
Get.snackbar("Error", "An unexpected error occurred.");
|
||||
}
|
||||
}
|
||||
|
||||
String capitalizeFirstLetter(String text) {
|
||||
if (text.isEmpty) return text;
|
||||
return text[0].toUpperCase() + text.substring(1).toLowerCase();
|
||||
@ -68,7 +129,8 @@ class _RdDispatchedScreenState extends State<RdDispatchedScreen> {
|
||||
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);
|
||||
String formattedDate = DateFormat('EEE MMM dd yyyy hh:mm a').format(parsedDate);
|
||||
|
||||
|
||||
return formattedDate; // Return the formatted date string
|
||||
}
|
||||
@ -336,10 +398,14 @@ class _RdDispatchedScreenState extends State<RdDispatchedScreen> {
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: ElevatedButton(
|
||||
onPressed: ()=>
|
||||
Get.to(() =>
|
||||
RdDispatchedDetailsDetailScreen(
|
||||
placedOrderList: uniqueOrders[index])), // Navigate to detail screen
|
||||
onPressed: (){
|
||||
onOrderTap(index);
|
||||
},
|
||||
// Get.to(() =>
|
||||
// RdDispatchedDetailsDetailScreen(
|
||||
// placedOrderList: uniqueOrders[index],
|
||||
//
|
||||
// )), // Navigate to detail screen
|
||||
style: ElevatedButton.styleFrom(
|
||||
foregroundColor: Colors.white,
|
||||
backgroundColor: const Color(0xFF004791),
|
||||
|
@ -458,6 +458,9 @@ class _RdOrderDetailUpdateScreenState
|
||||
itemCount: widget.placedOrderList!.orderItem!.length ?? 0,
|
||||
itemBuilder: (context, index) {
|
||||
final orderItem = widget.placedOrderList!.orderItem![index];
|
||||
final subTotalProcesssItem = orderItem.price! * orderItem.quantity!.toInt();
|
||||
final GstTotalAmounProcessItem = (orderItem.price! * orderItem.quantity!.toInt()) *(orderItem.gst!/100 );
|
||||
final grandTotalProcessItem = subTotalProcesssItem + GstTotalAmounProcessItem;
|
||||
return orderItem != null
|
||||
? Card(
|
||||
margin: const EdgeInsets.symmetric(vertical: 5.0),
|
||||
@ -486,9 +489,17 @@ class _RdOrderDetailUpdateScreenState
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text("Quantity: ${orderItem.quantity}"),
|
||||
Text("Price: ₹${orderItem.price}"),
|
||||
Text("GST: ${orderItem.gst}%"),
|
||||
Text(
|
||||
"Quantity: ${orderItem.quantity}",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.03,
|
||||
),
|
||||
),
|
||||
Text("Price: ${orderItem.price}"),
|
||||
Text("Subtotal : ${subTotalProcesssItem}"),
|
||||
Text("GST : ${orderItem.gst}%"),
|
||||
Text("GST Amount (₹) : ${GstTotalAmounProcessItem}"),
|
||||
Text("Total Amount : ${grandTotalProcessItem}"),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -667,7 +678,7 @@ class _RdOrderDetailUpdateScreenState
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
style: GoogleFonts.roboto(fontSize: fontSize),
|
||||
style: GoogleFonts.roboto(fontSize: fontSize,fontWeight: FontWeight.bold),
|
||||
),
|
||||
Text(
|
||||
value,
|
||||
|
@ -87,7 +87,8 @@ class _RdOrderScreenState extends State<RdOrderScreen> {
|
||||
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);
|
||||
String formattedDate = DateFormat('EEE MMM dd yyyy hh:mm a').format(parsedDate);
|
||||
|
||||
|
||||
return formattedDate; // Return the formatted date string
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ 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';
|
||||
@ -128,6 +129,11 @@ class _RdOrderPendingScreenDetailScreenState
|
||||
.map((item) => (item.quantity))
|
||||
.join(', ');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
@ -136,6 +142,7 @@ class _RdOrderPendingScreenDetailScreenState
|
||||
selectedStatus= widget.placedOrderList?.status ?? 'new';
|
||||
}
|
||||
|
||||
|
||||
// Future<void> getOrder1() async {
|
||||
// await _getSingleInvoiceController.fetchInvoice(widget.placedOrderList!.id);
|
||||
// if (_getSingleInvoiceController.invoice.isEmpty) {
|
||||
@ -207,7 +214,7 @@ class _RdOrderPendingScreenDetailScreenState
|
||||
|
||||
// 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(() {});
|
||||
|
||||
@ -216,7 +223,7 @@ class _RdOrderPendingScreenDetailScreenState
|
||||
Navigator.of(context).pop(); // Close the dialog
|
||||
});
|
||||
|
||||
return; // Exit here to prevent further processing
|
||||
|
||||
}
|
||||
|
||||
if (selectedStatus == "partial processing") {
|
||||
@ -303,10 +310,21 @@ class _RdOrderPendingScreenDetailScreenState
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
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) {
|
||||
int remainingQuantity = (widget.placedOrderList!.orderItem![0].quantity)! -(widget.placedOrderList!.orderItem![0].remainingQuantity!.toInt());
|
||||
// int remainingQuantity = (widget.placedOrderList!.orderItem![0].quantity)! -(widget.placedOrderList!.orderItem![0].remainingQuantity!.toInt());
|
||||
return Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: AppBar(
|
||||
@ -397,7 +415,7 @@ class _RdOrderPendingScreenDetailScreenState
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text(widget.placedOrderList!.uniqueId.toString()),
|
||||
Text(widget.placeInvoiceList!.invoiceId.toString()),
|
||||
// Text(widget.placedOrderList!.uniqueId),
|
||||
],
|
||||
),
|
||||
@ -420,7 +438,7 @@ class _RdOrderPendingScreenDetailScreenState
|
||||
),
|
||||
SizedBox(height: 10), // Add spacing between the title and the list of items
|
||||
Column(
|
||||
children: widget.placedOrderList!.orderItem!.map((item) {
|
||||
children: widget.placeInvoiceList!.items!.map((item) {
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4.0), // Add some spacing between items
|
||||
@ -436,7 +454,7 @@ class _RdOrderPendingScreenDetailScreenState
|
||||
overflow: TextOverflow.ellipsis, // Handle long text
|
||||
),
|
||||
),
|
||||
Text("x ${remainingQuantity.toString()}"),
|
||||
Text("x ${item.processQuantity.toString()}"),
|
||||
],
|
||||
),
|
||||
);
|
||||
@ -461,32 +479,13 @@ class _RdOrderPendingScreenDetailScreenState
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text("₹ ${widget.placedOrderList!.subtotal}"),
|
||||
Text("₹ ${widget.placeInvoiceList!.subtotal}"),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// SizedBox(
|
||||
// width: Get.width,
|
||||
// child: Padding(
|
||||
// padding:
|
||||
// const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
||||
// child: Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
// children: [
|
||||
// Text(
|
||||
// "Gst %: ",
|
||||
// style: GoogleFonts.roboto(
|
||||
// fontSize: Get.width * 0.04,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// ),
|
||||
// ),
|
||||
// Text(" ${widget.placedOrderList!.orderItem[0].gst}%"),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
|
||||
SizedBox(
|
||||
width: Get.width,
|
||||
child: Padding(
|
||||
@ -502,7 +501,7 @@ class _RdOrderPendingScreenDetailScreenState
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text("₹ ${widget.placedOrderList!.gstTotal}"),
|
||||
Text("₹ ${widget.placeInvoiceList!.gstTotal}"),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -522,7 +521,7 @@ class _RdOrderPendingScreenDetailScreenState
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text("₹ ${widget.placedOrderList!.grandTotal}"),
|
||||
Text("₹ ${widget.placeInvoiceList!.invoiceAmount}"),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -549,19 +548,20 @@ class _RdOrderPendingScreenDetailScreenState
|
||||
// placedOrderList: uniqueOrders[index])), // Navigate to detail screen
|
||||
style: ElevatedButton.styleFrom(
|
||||
foregroundColor: Colors.white,
|
||||
backgroundColor: Colors.orange,
|
||||
backgroundColor:_getCourierStatusColor(widget.placeInvoiceList!.courierStatus.toString()),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10)),
|
||||
),
|
||||
child: Text("Processing"),
|
||||
child: Text(capitalizeFirstLetter(widget.placeInvoiceList!.courierStatus.toString()),
|
||||
// Text(widget.placedOrderList!.status.toString())
|
||||
//Text(widget.placedOrderList!.status, style: GoogleFonts.roboto(fontSize: 14, fontWeight: FontWeight.w400)),
|
||||
),
|
||||
//Text("₹ ${widget.placedOrderList!.gstTotal}"),
|
||||
],
|
||||
)],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -594,6 +594,9 @@ class _RdOrderPendingScreenDetailScreenState
|
||||
itemCount: widget.placedOrderList?.orderItem!.length ?? 0,
|
||||
itemBuilder: (context, index) {
|
||||
final orderItem = widget.placedOrderList!.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),
|
||||
@ -613,10 +616,11 @@ class _RdOrderPendingScreenDetailScreenState
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Column(
|
||||
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
capitalizeFirstLetter(orderItem.name),
|
||||
capitalizeFirstLetter(orderItem.name.toString()),
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.04,
|
||||
fontWeight: FontWeight.bold,
|
||||
@ -628,11 +632,12 @@ class _RdOrderPendingScreenDetailScreenState
|
||||
fontSize: Get.width * 0.03,
|
||||
),
|
||||
),
|
||||
|
||||
Text("Price: ${orderItem.price}"),
|
||||
Text("Subtotal: ${widget.placedOrderList!.subtotal}"),
|
||||
Text("Gst: ${orderItem.gst}%"),
|
||||
Text("GST Total: ${widget.placedOrderList!.gstTotal}"),
|
||||
Text("Total Amount: ${widget.placedOrderList!.grandTotal}"),
|
||||
Text("Subtotal: ${subTotal}"),
|
||||
Text("GSt: ${orderItem.gst}%"),
|
||||
Text("GST Amount (₹): ${GstTotalAmount}"),
|
||||
Text("Total Amount (₹): ${grandTotal}"),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -677,12 +682,17 @@ class _RdOrderPendingScreenDetailScreenState
|
||||
?.where((item) => item.remainingQuantity! > 0)
|
||||
.length ?? 0,
|
||||
itemBuilder: (context, index) {
|
||||
|
||||
|
||||
// Filter items with non-zero quantities
|
||||
final filteredItems = widget.placedOrderList!.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),
|
||||
@ -705,7 +715,7 @@ class _RdOrderPendingScreenDetailScreenState
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
capitalizeFirstLetter(orderItem.name),
|
||||
capitalizeFirstLetter(orderItem.name.toString()),
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.04,
|
||||
fontWeight: FontWeight.bold,
|
||||
@ -713,10 +723,10 @@ class _RdOrderPendingScreenDetailScreenState
|
||||
),
|
||||
Text("Quantity: ${orderItem.remainingQuantity}"),
|
||||
Text("Price: ${orderItem.price}"),
|
||||
Text("Subtotal: ${widget.placedOrderList!.subtotal}"),
|
||||
Text("Subtotal: ${subTotalProcesssItem}"),
|
||||
Text("Gst: ${orderItem.gst}%"),
|
||||
Text("GST Total: ${widget.placedOrderList!.gstTotal}"),
|
||||
Text("Total Amount: ${widget.placedOrderList!.grandTotal}"),
|
||||
Text("GST Total: ${GstTotalAmounProcessItem}"),
|
||||
Text("Total Amount: ${grandTotalProcessItem}"),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -737,180 +747,15 @@ class _RdOrderPendingScreenDetailScreenState
|
||||
const SizedBox(height: 8),
|
||||
SizedBox(
|
||||
height: Get.height* 0.19,
|
||||
child: Card(
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: Get.width,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
||||
child: Text(
|
||||
"Customer Details",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.05,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: Get.width,
|
||||
//height: Get.height*0.09,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
"Name: ",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.04,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text("${"Roshan Garg"}",maxLines: 4,
|
||||
overflow:TextOverflow.ellipsis,)
|
||||
, ],
|
||||
)
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: Get.width,
|
||||
// height: Get.height*0.09,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
"Email: ",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.04,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text("${"roshangarg28@gmail.com"}",maxLines: 4,
|
||||
overflow:TextOverflow.ellipsis,)
|
||||
, ],
|
||||
)
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: Get.width,
|
||||
// height: Get.height*0.09,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
"Mobile Number: ",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.04,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text("${"8876785448"}",maxLines: 4,
|
||||
overflow:TextOverflow.ellipsis,)
|
||||
, ],
|
||||
)
|
||||
),
|
||||
)
|
||||
child:_buildCustomerDetails(),
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Card(
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: Get.width,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
||||
child: Text(
|
||||
"Billing Information",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.05,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: Get.width,
|
||||
height: Get.height*0.06,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
||||
child: Wrap(
|
||||
crossAxisAlignment: WrapCrossAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Address: ",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.04,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text("${widget.placedOrderList!.billTo}",maxLines: 4,
|
||||
overflow:TextOverflow.ellipsis,)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
_buildBillingInfo(),
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
// Card for displaying shipping information
|
||||
Card(
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: Get.width,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
||||
child: Text(
|
||||
"Shipping Information",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.05,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: Get.width,
|
||||
height: Get.height*0.06,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
||||
child: Wrap(
|
||||
crossAxisAlignment: WrapCrossAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Address: ",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.04,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text("${widget.placedOrderList!.shipTo}",maxLines: 4,
|
||||
overflow:TextOverflow.ellipsis,)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
_buildShippingInfo(),
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Card(
|
||||
child: Column(
|
||||
@ -930,7 +775,7 @@ class _RdOrderPendingScreenDetailScreenState
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
Text(capitalizeFirstLetter(widget.placedOrderList!.paymentMode.toString())),
|
||||
Text(capitalizeFirstLetter(widget.placeInvoiceList!.orderId!.paymentMode.toString())),
|
||||
// Text("${widget.placedOrderList!.paymentMode}",maxLines: 4,
|
||||
// overflow:TextOverflow.ellipsis,)
|
||||
],
|
||||
@ -963,7 +808,7 @@ class _RdOrderPendingScreenDetailScreenState
|
||||
),
|
||||
SizedBox(width: Get.width*0.01,),
|
||||
//Text(capitalizeFirstLetter(widget.placedOrderList!.status)),
|
||||
Text("${widget.placedOrderList!.status}",maxLines: 4,
|
||||
Text(capitalizeFirstLetter(widget.placedOrderList!.status.toString()),maxLines: 4,
|
||||
overflow:TextOverflow.ellipsis,)
|
||||
],
|
||||
),
|
||||
@ -1053,4 +898,146 @@ class _RdOrderPendingScreenDetailScreenState
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
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.placeInvoiceList!.courierStatus.toString()), // Call the method here
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
child: Text(widget.placeInvoiceList!.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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
|
||||
import 'package:cheminova/controller/get_rd_pending_controller.dart';
|
||||
import 'package:cheminova/controller/rd_get_order_controller.dart';
|
||||
import 'package:cheminova/controller/rd_processing_invoice_controller.dart';
|
||||
import 'package:cheminova/models/get_rd_pennding_model.dart';
|
||||
import 'package:cheminova/models/rd_get_order_model.dart';
|
||||
import 'package:cheminova/screens/rd%20orders/rd_order_details_screen.dart';
|
||||
@ -16,6 +17,7 @@ import 'package:intl/intl.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../../controller/get_single_invoice_Service.dart';
|
||||
import '../../controller/get_single_invoice_controller.dart';
|
||||
import '../../controller/rd_get_single_service.dart';
|
||||
import '../order_management/order_management_detail_screen.dart';
|
||||
|
||||
@ -38,6 +40,8 @@ class _RdOrderPendingScreenState extends State<RdOrderPendingScreen> {
|
||||
"delivered",];
|
||||
int _selectedIndex = 0;
|
||||
final GetRdPendingController _getRdPendingController = Get.put(GetRdPendingController());
|
||||
final GetSingleInvoiceController _getSingleInvoiceController = Get.put(GetSingleInvoiceController());
|
||||
final GetRDProcessingInvoiceController _getRDProcessingInvoiceController = Get.put(GetRDProcessingInvoiceController());
|
||||
// final GetProductRDController _getRdProductController =
|
||||
// Get.put(GetProductRDController());
|
||||
final GlobalKey<RefreshIndicatorState> _refreshIndicatorKey = GlobalKey<RefreshIndicatorState>();
|
||||
@ -73,7 +77,7 @@ class _RdOrderPendingScreenState extends State<RdOrderPendingScreen> {
|
||||
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);
|
||||
String formattedDate = DateFormat('EEE MMM dd yyyy hh:mm a').format(parsedDate);
|
||||
|
||||
return formattedDate; // Return the formatted date string
|
||||
}
|
||||
@ -84,6 +88,9 @@ class _RdOrderPendingScreenState extends State<RdOrderPendingScreen> {
|
||||
// Fetch orders and ensure you wait for it to complete
|
||||
await _getRdPendingController.getRDPendingProduct();
|
||||
|
||||
// await _getRDProcessingInvoiceController.getRDProcessingInvoiceProduct();
|
||||
|
||||
// await _getSingleInvoiceController.fetchInvoice(_getRDProcessingInvoiceController.productProcessingRDList[0].id);
|
||||
// Log the count of fetched orders
|
||||
print('Fetched orders count: ${_getRdPendingController.productRDList.length}');
|
||||
|
||||
@ -93,7 +100,7 @@ class _RdOrderPendingScreenState extends State<RdOrderPendingScreen> {
|
||||
if (index >= 0 && index < _getRdPendingController.productRDList.length) {
|
||||
// Get the order ID from the list based on the index
|
||||
final orderId = _getRdPendingController.productRDList[index].id;
|
||||
|
||||
final invoiceId = _getRdPendingController.productRDList[index].invoices[0];
|
||||
// Retrieve the token from SharedPreferences
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
String? token = prefs.getString('token');
|
||||
@ -102,7 +109,7 @@ class _RdOrderPendingScreenState extends State<RdOrderPendingScreen> {
|
||||
if (token != null) {
|
||||
// Fetch the single order using the order ID, and avoid caching issues
|
||||
final singleOrder = await GetSingleProductService().getSingleOrder(token, orderId);
|
||||
final singleInvoice = await GetSingleInvoiceService().fetchInvoice(token, orderId);
|
||||
final singleInvoice = await GetSingleInvoiceService().fetchInvoice(token, invoiceId.toString());
|
||||
// Check if the single order was fetched successfully
|
||||
if (singleOrder != null) {
|
||||
// Navigate to the details screen with the fetched order
|
||||
|
@ -1,3 +1,4 @@
|
||||
import 'package:cheminova/screens/rd%20orders/rd_dispatched_scree.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:get/get.dart';
|
||||
@ -122,6 +123,7 @@ class _RdOrderProcessingDetailScreenState extends State<RdOrderProcessingDetailS
|
||||
// Call the API to submit data
|
||||
_getDispatchController.RDProcessingToDispatchProduct(widget.placeInvoiceList!.id.toString(), courierName, courierTrackingId);
|
||||
showSnackbar("Order Status updated Order Dispatched");
|
||||
|
||||
Navigator.of(context).pop(); // Close the dialog after submission
|
||||
},
|
||||
child: Text('Submit'),
|
||||
@ -404,228 +406,18 @@ class _RdOrderProcessingDetailScreenState extends State<RdOrderProcessingDetailS
|
||||
|
||||
const SizedBox(height: 8),
|
||||
SizedBox(
|
||||
height: Get.height * 0.19,
|
||||
child: Card(
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: Get.width,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
||||
child: Text(
|
||||
"Customer Details",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.05,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: Get.width,
|
||||
//height: Get.height*0.09,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
"Name: ",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.04,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text("${widget.placeInvoiceList!.orderId!.addedBy!.name}", maxLines: 4,
|
||||
overflow: TextOverflow
|
||||
.ellipsis,)
|
||||
,
|
||||
],
|
||||
)
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: Get.width,
|
||||
// height: Get.height*0.09,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
"Email: ",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.04,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"${widget.placeInvoiceList!.orderId!.addedBy!.email}",
|
||||
maxLines: 4,
|
||||
overflow: TextOverflow
|
||||
.ellipsis,)
|
||||
,
|
||||
],
|
||||
)
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: Get.width,
|
||||
// height: Get.height*0.09,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
"Mobile Number: ",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.04,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"${widget.placeInvoiceList!.orderId!.addedBy!.mobileNumber}", maxLines: 4,
|
||||
overflow: TextOverflow
|
||||
.ellipsis,)
|
||||
,
|
||||
],
|
||||
)
|
||||
),
|
||||
)
|
||||
height: Get.height* 0.19,
|
||||
child:_buildCustomerDetails(),
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Card(
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: Get.width,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
||||
child: Text(
|
||||
"Billing Information",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.05,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: Get.width,
|
||||
height: Get.height * 0.06,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
||||
child: Wrap(
|
||||
crossAxisAlignment: WrapCrossAlignment
|
||||
.start,
|
||||
children: [
|
||||
Text(
|
||||
"Address: ",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.04,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"${widget.placeInvoiceList!.orderId!.billTo}",
|
||||
maxLines: 4,
|
||||
overflow: TextOverflow.ellipsis,)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
_buildBillingInfo(),
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
// Card for displaying shipping information
|
||||
Card(
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: Get.width,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
||||
child: Text(
|
||||
"Shipping Information",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.05,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: Get.width,
|
||||
height: Get.height * 0.06,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
||||
child: Wrap(
|
||||
crossAxisAlignment: WrapCrossAlignment
|
||||
.start,
|
||||
children: [
|
||||
Text(
|
||||
"Address: ",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.04,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"${widget.placeInvoiceList!.orderId!.shipTo}",
|
||||
maxLines: 4,
|
||||
overflow: TextOverflow.ellipsis,)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
_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.placeInvoiceList!.orderId!.paymentMode.toString())),
|
||||
// Text("${widget.placedOrderList!.paymentMode}",maxLines: 4,
|
||||
// overflow:TextOverflow.ellipsis,)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
_buildPaymentInfo(),
|
||||
const SizedBox(height: 8),
|
||||
Card(
|
||||
child: Column(
|
||||
@ -749,6 +541,115 @@ class _RdOrderProcessingDetailScreenState extends State<RdOrderProcessingDetailS
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCustomerDetails() {
|
||||
return Card(
|
||||
child: Column(
|
||||
children: [
|
||||
_buildSectionTitle("Customer Details"),
|
||||
_buildRow("Name:", widget.placeInvoiceList!.orderId!.addedBy!.name.toString(), Get.width * 0.04),
|
||||
_buildRow("Email:", widget.placeInvoiceList!.orderId!.addedBy!.email.toString(), Get.width * 0.04),
|
||||
_buildRow("Mobile Number:", widget.placeInvoiceList!.orderId!.addedBy!.mobileNumber.toString(), Get.width * 0.04),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBillingInfo() {
|
||||
return Card(
|
||||
child: Column(
|
||||
children: [
|
||||
_buildSectionTitle("Billing Information"),
|
||||
_buildInfoRow("Address", widget.placeInvoiceList!.orderId!.billTo.toString(), Get.width * 0.04),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildShippingInfo() {
|
||||
return Card(
|
||||
child: Column(
|
||||
children: [
|
||||
_buildSectionTitle("Shipping Information"),
|
||||
_buildInfoRow("Address", widget.placeInvoiceList!.orderId!.shipTo.toString(), Get.width * 0.04),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPaymentInfo() {
|
||||
return Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
"Payment Mode: ",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.04,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
Text(capitalizeFirstLetter(widget.placeInvoiceList!.orderId!.paymentMode.toString())),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
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),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
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 _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),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
@ -84,7 +84,8 @@ class _RdOrderProcessingScreenState extends State<RdOrderProcessingScreen> {
|
||||
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);
|
||||
String formattedDate = DateFormat('EEE MMM dd yyyy hh:mm a').format(parsedDate);
|
||||
|
||||
|
||||
return formattedDate; // Return the formatted date string
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ class ApiUrls {
|
||||
|
||||
|
||||
//============================== Notification Details ==============================//
|
||||
static const String getNotificationUrl = '/api/get-notification-pd';
|
||||
static const String getNotificationUrl = '${baseUrl}/api/get-notification-pd/';
|
||||
|
||||
//============================== Kyc Details ==============================//
|
||||
static const String getKycUrl = '${baseUrl}/api/kyc/getAll';
|
||||
@ -78,7 +78,8 @@ class ApiUrls {
|
||||
|
||||
|
||||
//============================== Annaouncement Details ==============================//
|
||||
static const String AnnaouncementUrl = '${baseUrl}/api/announcement/PDs';
|
||||
|
||||
static const String AnnaouncementUrl = '/api/announcement/PDs';
|
||||
|
||||
//============================== Annaouncement Details ==============================//
|
||||
static const String ShiptoandBilltoAddressUrl = '/api/shipping/address/user/address';
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ Future<BodyType?> commonApiService<BodyType>({
|
||||
File? imageFile, // Optional image file for upload
|
||||
bool isformData = true,
|
||||
Map<String, String>? additionalHeaders, // Additional headers for the request
|
||||
Map<String, String>? queryParameters, // Optional query parameters
|
||||
required BodyType Function(Map<String, dynamic>) fromJson,// Function to parse the response data
|
||||
}) async {
|
||||
try {
|
||||
|
@ -4,7 +4,7 @@ import 'package:flutter_svg/svg.dart';
|
||||
class CommonAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
final Widget title;
|
||||
final List<Widget>? actions;
|
||||
final TabBar? bottom;
|
||||
final PreferredSizeWidget? bottom; // Changed to PreferredSizeWidget?
|
||||
|
||||
const CommonAppBar({super.key, required this.title, this.actions, required Color backgroundColor, required int elevation, this.bottom});
|
||||
|
||||
@ -28,5 +28,5 @@ class CommonAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
}
|
||||
|
||||
@override
|
||||
Size get preferredSize => const Size.fromHeight(kToolbarHeight);
|
||||
Size get preferredSize => Size.fromHeight(kToolbarHeight + (bottom?.preferredSize.height ?? 0)); // Adjusted to account for the bottom height
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user