Merge branch 'master' of bitbucket.org:jubilian/nhance_partner
This commit is contained in:
commit
a39cf2ee79
File diff suppressed because one or more lines are too long
@ -6,6 +6,7 @@ import 'package:nhance_partner/presentation/screens/Enquiry/enquiryList.dart';
|
|||||||
import 'package:nhance_partner/presentation/screens/Masters/PaymentMode/paymentList.dart';
|
import 'package:nhance_partner/presentation/screens/Masters/PaymentMode/paymentList.dart';
|
||||||
import 'package:nhance_partner/presentation/screens/UserManagement/Profile/profile_web.dart';
|
import 'package:nhance_partner/presentation/screens/UserManagement/Profile/profile_web.dart';
|
||||||
import 'package:nhance_partner/presentation/screens/dashboard/dashboard.dart';
|
import 'package:nhance_partner/presentation/screens/dashboard/dashboard.dart';
|
||||||
|
import 'package:nhance_partner/presentation/screens/payout/invoice_list.dart';
|
||||||
|
|
||||||
import '../../data/services/auth_service.dart';
|
import '../../data/services/auth_service.dart';
|
||||||
import '../../presentation/providers/manager_provider.dart';
|
import '../../presentation/providers/manager_provider.dart';
|
||||||
@ -24,6 +25,7 @@ import '../../presentation/screens/handler/enquiryList.dart';
|
|||||||
import '../../presentation/screens/handler/enquiryListOld.dart';
|
import '../../presentation/screens/handler/enquiryListOld.dart';
|
||||||
import '../../presentation/screens/home/home_screen.dart';
|
import '../../presentation/screens/home/home_screen.dart';
|
||||||
import '../../presentation/screens/login/login_screen.dart';
|
import '../../presentation/screens/login/login_screen.dart';
|
||||||
|
import '../../presentation/screens/payout/payout_screen.dart';
|
||||||
import '../../presentation/screens/splash/splash_screen.dart';
|
import '../../presentation/screens/splash/splash_screen.dart';
|
||||||
import '../../presentation/screens/staff/Enquiry/enquiry_inline_list.dart';
|
import '../../presentation/screens/staff/Enquiry/enquiry_inline_list.dart';
|
||||||
import '../../presentation/screens/staff/Enquiry/enquiry_list.dart';
|
import '../../presentation/screens/staff/Enquiry/enquiry_list.dart';
|
||||||
@ -52,6 +54,19 @@ final GoRouter appRouter = GoRouter(
|
|||||||
builder: (context, state) => const DashboardScreen(),
|
builder: (context, state) => const DashboardScreen(),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
GoRoute(
|
||||||
|
path: AppRoutes.payout,
|
||||||
|
builder: (context, state) {
|
||||||
|
final editItem = state.extra as Map<String, dynamic>?;
|
||||||
|
return PayOutScreen(editItem: editItem);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
|
||||||
|
GoRoute(
|
||||||
|
path: AppRoutes.invoiceList,
|
||||||
|
builder: (context, state) => const InvoiceList(),
|
||||||
|
),
|
||||||
|
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: AppRoutes.profile,
|
path: AppRoutes.profile,
|
||||||
builder: (context, state) => const Profile(),
|
builder: (context, state) => const Profile(),
|
||||||
|
|||||||
@ -22,6 +22,8 @@ class AppRoutes {
|
|||||||
static const String quotation = '/QuotationScreen';
|
static const String quotation = '/QuotationScreen';
|
||||||
static const String policy = '/PolicyScreen';
|
static const String policy = '/PolicyScreen';
|
||||||
|
|
||||||
|
static const String payout = '/payout';
|
||||||
|
static const String invoiceList = '/invoiceList';
|
||||||
static const String brokerLst = '/brokerLst';
|
static const String brokerLst = '/brokerLst';
|
||||||
static const String paymentModeLst = '/paymentMode';
|
static const String paymentModeLst = '/paymentMode';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1209,4 +1209,99 @@ class ApiService {
|
|||||||
throw Exception('Error fetching options: $e');
|
throw Exception('Error fetching options: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --------------------------------- PayOut Module----------------------------------------------
|
||||||
|
Future<Map<String, dynamic>> getCommissionRateList(data) async {
|
||||||
|
|
||||||
|
final url = Uri.parse('${Env.apiUrl}/invoice/commission-rate-list');
|
||||||
|
|
||||||
|
// final token = await getToken(); // Fetch token
|
||||||
|
|
||||||
|
if (_token == null) {
|
||||||
|
throw Exception('Token not found. Please log in.');
|
||||||
|
}
|
||||||
|
|
||||||
|
print("data------- $data}");
|
||||||
|
|
||||||
|
final headers = {
|
||||||
|
'Authorization': 'Bearer $_token',
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'app-signature': Env.App_Signature,
|
||||||
|
// 'app-signature': 'nhance-partner-2025-signature-35468846JRhH551HK',
|
||||||
|
};
|
||||||
|
|
||||||
|
final response = await _makePostRequestJson(url, data, headers);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> getCreateOrUpdate(data) async {
|
||||||
|
|
||||||
|
final url = Uri.parse('${Env.apiUrl}/invoice/create-or-update');
|
||||||
|
|
||||||
|
// final token = await getToken(); // Fetch token
|
||||||
|
|
||||||
|
if (_token == null) {
|
||||||
|
throw Exception('Token not found. Please log in.');
|
||||||
|
}
|
||||||
|
|
||||||
|
print("data------- $data}");
|
||||||
|
|
||||||
|
final headers = {
|
||||||
|
'Authorization': 'Bearer $_token',
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'app-signature': Env.App_Signature,
|
||||||
|
// 'app-signature': 'nhance-partner-2025-signature-35468846JRhH551HK',
|
||||||
|
};
|
||||||
|
|
||||||
|
final response = await _makePostRequestJson(url, data, headers);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> getInvoiceList() async {
|
||||||
|
// print(_token);
|
||||||
|
if (_token == null) {
|
||||||
|
await _initializeToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
final url = Uri.parse('${Env.apiUrl}invoice/list');
|
||||||
|
|
||||||
|
final headers = {
|
||||||
|
'Authorization': 'Bearer $_token' ?? '',
|
||||||
|
'app-signature': Env.App_Signature,
|
||||||
|
};
|
||||||
|
final response = await _makeGetRequest(url, headers);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> deleteInvoice(ID) async {
|
||||||
|
// print(_token);
|
||||||
|
if (_token == null) {
|
||||||
|
await _initializeToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
final url = Uri.parse('${Env.apiUrl}invoice/delete?id=$ID');
|
||||||
|
|
||||||
|
final headers = {
|
||||||
|
'Authorization': 'Bearer $_token' ?? '',
|
||||||
|
'app-signature': Env.App_Signature,
|
||||||
|
};
|
||||||
|
final response = await _makeGetRequest(url, headers);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> getInvoiceDetails(ID) async {
|
||||||
|
// print(_token);
|
||||||
|
if (_token == null) {
|
||||||
|
await _initializeToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
final url = Uri.parse('${Env.apiUrl}invoice/details?id=$ID');
|
||||||
|
|
||||||
|
final headers = {
|
||||||
|
'Authorization': 'Bearer $_token' ?? '',
|
||||||
|
'app-signature': Env.App_Signature,
|
||||||
|
};
|
||||||
|
final response = await _makeGetRequest(url, headers);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -267,6 +267,19 @@ class _AppHeaderState extends ConsumerState<AppHeader> {
|
|||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
],
|
],
|
||||||
|
|
||||||
|
// Pay Out button for admin
|
||||||
|
if (role == 'admin') ...[
|
||||||
|
_buildMenuItem(
|
||||||
|
icon: Icons.checklist_outlined,
|
||||||
|
label: "Pay Out",
|
||||||
|
onTap: () async {
|
||||||
|
_hidePopup();
|
||||||
|
await _clearDashboardFilters();
|
||||||
|
context.go(AppRoutes.invoiceList);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
|
|
||||||
// Raise Enquiry button for agents
|
// Raise Enquiry button for agents
|
||||||
|
|||||||
@ -139,6 +139,8 @@ class _LoginScreenState extends ConsumerState<LoginScreen> {
|
|||||||
role = "handler";
|
role = "handler";
|
||||||
} else if (roleId.toString() == "3") {
|
} else if (roleId.toString() == "3") {
|
||||||
role = "staff";
|
role = "staff";
|
||||||
|
} else if (roleId.toString() == "4") {
|
||||||
|
role = "admin";
|
||||||
} else {
|
} else {
|
||||||
role = "agent"; // fallback if unexpected value
|
role = "agent"; // fallback if unexpected value
|
||||||
}
|
}
|
||||||
@ -341,7 +343,7 @@ class _LoginScreenState extends ConsumerState<LoginScreen> {
|
|||||||
if (userRole == 'staff') {
|
if (userRole == 'staff') {
|
||||||
context.go(AppRoutes.enquiryForStaff);
|
context.go(AppRoutes.enquiryForStaff);
|
||||||
} else {
|
} else {
|
||||||
context.go(AppRoutes.dashboard);
|
context.go(AppRoutes.dashboard);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ToastHelper.showErrorToast(context, data['message'] ?? 'Invalid OTP');
|
ToastHelper.showErrorToast(context, data['message'] ?? 'Invalid OTP');
|
||||||
|
|||||||
37
lib/presentation/screens/payout/FormFieldBox.dart
Normal file
37
lib/presentation/screens/payout/FormFieldBox.dart
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
|
||||||
|
class FormFieldBox extends StatelessWidget {
|
||||||
|
final Widget child;
|
||||||
|
final String label;
|
||||||
|
|
||||||
|
const FormFieldBox({
|
||||||
|
super.key,
|
||||||
|
required this.child,
|
||||||
|
required this.label,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
label,
|
||||||
|
style: GoogleFonts.inter(
|
||||||
|
fontSize: 13,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
color: Color(0xFF2F766E),
|
||||||
|
)
|
||||||
|
),
|
||||||
|
const SizedBox(height: 6),
|
||||||
|
SizedBox(
|
||||||
|
height: 35,
|
||||||
|
child: child,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
623
lib/presentation/screens/payout/invoice_list.dart
Normal file
623
lib/presentation/screens/payout/invoice_list.dart
Normal file
@ -0,0 +1,623 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:nhance_partner/data/utils/toastNotification.dart';
|
||||||
|
|
||||||
|
import '../../../core/routing/routes.dart';
|
||||||
|
import '../../../core/services/api_service.dart';
|
||||||
|
import '../../../data/utils/Pagination.dart';
|
||||||
|
import '../../layouts/main_layout.dart';
|
||||||
|
import '../../layouts/responsive_layout.dart';
|
||||||
|
import '../../providers/manager_provider.dart';
|
||||||
|
import '../../providers/userRoleProvider.dart';
|
||||||
|
import '../../themes/indicators/export_btn.dart';
|
||||||
|
import '../../themes/indicators/search_field_theme.dart';
|
||||||
|
import '../../widgets/custom_Stdate_EnDate_Filter.dart';
|
||||||
|
|
||||||
|
class InvoiceList extends ConsumerStatefulWidget {
|
||||||
|
const InvoiceList({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
ConsumerState<InvoiceList> createState() => _InvoiceListState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _InvoiceListState extends ConsumerState<InvoiceList> {
|
||||||
|
int currentPage = 1;
|
||||||
|
int itemsPerPage = 10;
|
||||||
|
bool isLoading = false;
|
||||||
|
List<Map<String, dynamic>> getInvoiceData = [];
|
||||||
|
List<Map<String, dynamic>> originalData = [];
|
||||||
|
List<Map<String, dynamic>> filteredData = [];
|
||||||
|
dynamic roleId;
|
||||||
|
dynamic userId;
|
||||||
|
late ApiService apiService;
|
||||||
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
Map<String, TextEditingController> controllers = {};
|
||||||
|
List<String> tabHeader = ['startDate', 'endDate'];
|
||||||
|
dynamic SelectedStatus;
|
||||||
|
dynamic SelectedStaffId;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
apiService = ApiService();
|
||||||
|
for (String field in tabHeader) {
|
||||||
|
controllers[field] = TextEditingController();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future.microtask(() {
|
||||||
|
final id = ref.read(managerIdProvider);
|
||||||
|
roleId = ref.read(userRoleProvider);
|
||||||
|
userId = ref.read(userIdProvider);
|
||||||
|
|
||||||
|
print("D49 => r : $roleId | mId: $id | uId: $userId ");
|
||||||
|
getInvoiceList();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get Broker List
|
||||||
|
Future<void> getInvoiceList() async {
|
||||||
|
print('getBroker called');
|
||||||
|
setState(() {
|
||||||
|
isLoading = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
final response = await apiService.getInvoiceList();
|
||||||
|
|
||||||
|
if (response['status'] == 'success') {
|
||||||
|
print('getInvoiceList - ${response['data']}');
|
||||||
|
final data = response['data'];
|
||||||
|
print('D81 => getInvoiceList => ${response['data']}');
|
||||||
|
|
||||||
|
// final fromDate = response['from_date'] ?? '';
|
||||||
|
// final toDate = response['to_date'] ?? '';
|
||||||
|
//
|
||||||
|
// print('FromDate : $fromDate');
|
||||||
|
// print('ToDate : $toDate');
|
||||||
|
setState(() {
|
||||||
|
// controllers['startDate']?.text = fromDate;
|
||||||
|
// controllers['endDate']?.text = toDate;
|
||||||
|
if (data is List) {
|
||||||
|
// Already a list of maps
|
||||||
|
getInvoiceData = List<Map<String, dynamic>>.from(data);
|
||||||
|
} else if (data is Map) {
|
||||||
|
// Single object, wrap in a list
|
||||||
|
getInvoiceData = [Map<String, dynamic>.from(data)];
|
||||||
|
} else {
|
||||||
|
getInvoiceData = [];
|
||||||
|
}
|
||||||
|
originalData = getInvoiceData;
|
||||||
|
filteredData = List.from(originalData);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
originalData = [];
|
||||||
|
filteredData = [];
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
print('Exception occurred: $e');
|
||||||
|
} finally {
|
||||||
|
setState(() {
|
||||||
|
isLoading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete Invoice List
|
||||||
|
Future<void> deleteInvoice(ID) async {
|
||||||
|
setState(() {
|
||||||
|
isLoading = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
final response = await apiService.deleteInvoice(ID);
|
||||||
|
|
||||||
|
if (response['status'] == 'success') {
|
||||||
|
ToastHelper.showSuccessToast(context, response['data']);
|
||||||
|
getInvoiceList();
|
||||||
|
} else {
|
||||||
|
ToastHelper.showSuccessToast(context, response['data']);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
print('Exception occurred: $e');
|
||||||
|
} finally {
|
||||||
|
setState(() {
|
||||||
|
isLoading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<dynamic> get _paginatedData {
|
||||||
|
// Sort descending by id first
|
||||||
|
final sortedData = [...filteredData]
|
||||||
|
..sort((a, b) => int.parse(b['id']) - int.parse(a['id']));
|
||||||
|
|
||||||
|
if (sortedData.isEmpty) return [];
|
||||||
|
|
||||||
|
// Ensure currentPage is valid
|
||||||
|
final maxPage = (sortedData.length / itemsPerPage).ceil();
|
||||||
|
final safePage = currentPage.clamp(1, maxPage);
|
||||||
|
|
||||||
|
final startIndex = (safePage - 1) * itemsPerPage;
|
||||||
|
final endIndex = (startIndex + itemsPerPage).clamp(0, sortedData.length);
|
||||||
|
|
||||||
|
return sortedData.sublist(startIndex, endIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
void filterDateRange() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void refrshfilterDateRange() {
|
||||||
|
setState(() {
|
||||||
|
// SelectedStaffId = null;
|
||||||
|
controllers['startDate']!.clear();
|
||||||
|
controllers['endDate']!.clear();
|
||||||
|
|
||||||
|
controllers['startDate']?.text = '';
|
||||||
|
controllers['endDate']?.text = '';
|
||||||
|
// Reset the FormField validation
|
||||||
|
_formKey.currentState?.reset();
|
||||||
|
});
|
||||||
|
getInvoiceList();
|
||||||
|
}
|
||||||
|
|
||||||
|
void filterData(String query) {
|
||||||
|
print("FilterDAta - $query");
|
||||||
|
setState(() {
|
||||||
|
filteredData = getInvoiceData.where((item) {
|
||||||
|
// final isActiveStatus = item['is_active'] == "1" ? "active" : "inactive";
|
||||||
|
|
||||||
|
return (_formatDate(item['updated_at']) ?? '-').toLowerCase().contains(
|
||||||
|
query.toLowerCase(),
|
||||||
|
) ||
|
||||||
|
(_formatDate(item['invoice_date']) ?? '-').toLowerCase().contains(
|
||||||
|
query.toLowerCase(),
|
||||||
|
) ||
|
||||||
|
(item['invoice_no'] ?? '-').toLowerCase().contains(
|
||||||
|
query.toLowerCase(),
|
||||||
|
) ||
|
||||||
|
(item['invoice_amount'] ?? '-').toLowerCase().contains(
|
||||||
|
query.toLowerCase(),
|
||||||
|
) ||
|
||||||
|
(item['broker_name'] ?? '-').toLowerCase().contains(
|
||||||
|
query.toLowerCase(),
|
||||||
|
) ||
|
||||||
|
(item['agent_name'] ?? '-').toLowerCase().contains(
|
||||||
|
query.toLowerCase(),
|
||||||
|
)
|
||||||
|
// ||
|
||||||
|
// (item['status'] ?? '-').toLowerCase().contains(query.toLowerCase());
|
||||||
|
;
|
||||||
|
}).toList();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
final TextEditingController _searchStaffController = TextEditingController();
|
||||||
|
|
||||||
|
String _formatDate(String rawDate) {
|
||||||
|
try {
|
||||||
|
final dateTime = DateTime.parse(rawDate);
|
||||||
|
return DateFormat('dd-MM-yyyy HH:mm').format(dateTime); // 24-hour format
|
||||||
|
} catch (e) {
|
||||||
|
return rawDate; // fallback if parsing fails
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return MainLayout(
|
||||||
|
title: "Pay Out",
|
||||||
|
body: Container(
|
||||||
|
// color: Colors.yellow.shade50,
|
||||||
|
width: MediaQuery.of(context).size.width,
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
height: 30,
|
||||||
|
width: MediaQuery.of(context).size.width,
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
context.go(AppRoutes.dashboard);
|
||||||
|
},
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Tooltip(
|
||||||
|
message: 'Back',
|
||||||
|
child: IconButton(
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.arrow_left_sharp,
|
||||||
|
size: 25,
|
||||||
|
color: Color(0xFF425B5B),
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
context.go(AppRoutes.dashboard);
|
||||||
|
},
|
||||||
|
splashRadius: 18,
|
||||||
|
hoverColor: Colors.black12,
|
||||||
|
padding: const EdgeInsets.all(4),
|
||||||
|
constraints: const BoxConstraints(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 5), // spacing between icon and text
|
||||||
|
Text(
|
||||||
|
"Invoice",
|
||||||
|
style: GoogleFonts.inter(
|
||||||
|
fontSize: 18,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
SizedBox(height: 5),
|
||||||
|
|
||||||
|
Expanded(
|
||||||
|
child: Container(
|
||||||
|
width: MediaQuery.of(context).size.width,
|
||||||
|
padding: EdgeInsets.all(8.0),
|
||||||
|
child: _buildContent(context),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
Container(
|
||||||
|
// height: 20,
|
||||||
|
width: MediaQuery.of(context).size.width,
|
||||||
|
// color: Colors.green.shade50,
|
||||||
|
child: PaginationControls(
|
||||||
|
currentPage: currentPage,
|
||||||
|
itemsPerPage: itemsPerPage,
|
||||||
|
// totalItems: dataVal.length,
|
||||||
|
totalItems: filteredData.length,
|
||||||
|
// activeColor: layoutColor, // your theme color
|
||||||
|
onPageChanged: (page) {
|
||||||
|
setState(() {
|
||||||
|
currentPage = page;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onItemsPerPageChanged: (items) {
|
||||||
|
setState(() {
|
||||||
|
itemsPerPage = items;
|
||||||
|
currentPage = 1;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildContent(BuildContext context) {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
// height: 40,
|
||||||
|
// color: Colors.pink,
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
// if (!ResponsiveLayout.isMobile(context)) ...[
|
||||||
|
// DateFilterRow(
|
||||||
|
// dataFrom: 'Policy',
|
||||||
|
// role: roleId,
|
||||||
|
// id: userId,
|
||||||
|
// onFilterStaff: (val) {
|
||||||
|
// print('Selected Filterd STAFF Id - $val');
|
||||||
|
// SelectedStaffId = val;
|
||||||
|
// },
|
||||||
|
// selectedStaffId: SelectedStaffId,
|
||||||
|
// startController: controllers['startDate']!,
|
||||||
|
// endController: controllers['endDate']!,
|
||||||
|
// onStatusChanged: (val) {
|
||||||
|
// SelectedStatus = val; // update parent
|
||||||
|
// },
|
||||||
|
// formKey: _formKey,
|
||||||
|
// isMobile: ResponsiveLayout.isMobile(context),
|
||||||
|
// onFilter: () {
|
||||||
|
// // call your filter logic
|
||||||
|
// filterDateRange();
|
||||||
|
// },
|
||||||
|
// onRefresh: () {
|
||||||
|
// // call your refresh logic
|
||||||
|
// refrshfilterDateRange();
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
//
|
||||||
|
// // Form(
|
||||||
|
// // key: _formKey,
|
||||||
|
// // child: Row(
|
||||||
|
// // mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
// // crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
// // children: [
|
||||||
|
// // buildStartDate(context),
|
||||||
|
// // SizedBox(width: 10),
|
||||||
|
// // buildEndDate(context),
|
||||||
|
// // SizedBox(width: 10),
|
||||||
|
// //
|
||||||
|
// // Padding(
|
||||||
|
// // padding: const EdgeInsets.symmetric(
|
||||||
|
// // vertical: 8.0,
|
||||||
|
// // ),
|
||||||
|
// // child: GestureDetector(
|
||||||
|
// // // onTap: filterDateRange,
|
||||||
|
// // onTap: () {
|
||||||
|
// // if (_formKey.currentState!.validate()) {
|
||||||
|
// // filterDateRange(); // only runs if valid
|
||||||
|
// // }
|
||||||
|
// // },
|
||||||
|
// // child: Icon(Icons.filter_alt_outlined),
|
||||||
|
// // ),
|
||||||
|
// // ),
|
||||||
|
// //
|
||||||
|
// // Padding(
|
||||||
|
// // padding: const EdgeInsets.all(8.0),
|
||||||
|
// // child: GestureDetector(
|
||||||
|
// // onTap: refrshfilterDateRange,
|
||||||
|
// // child: Icon(Icons.refresh),
|
||||||
|
// // ),
|
||||||
|
// // ),
|
||||||
|
// // ],
|
||||||
|
// // ),
|
||||||
|
// // ),
|
||||||
|
// Spacer(),
|
||||||
|
// ],
|
||||||
|
|
||||||
|
ThemedSearchField(
|
||||||
|
hintText: 'Search',
|
||||||
|
backgroundColor: Color(0xFFF6F8F8),
|
||||||
|
onChanged: filterData,
|
||||||
|
controller: _searchStaffController,
|
||||||
|
txtwidth: MediaQuery.of(context).size.width * 0.2,
|
||||||
|
),
|
||||||
|
SizedBox(width: 10),
|
||||||
|
Tooltip(
|
||||||
|
message: 'Export File',
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () async {
|
||||||
|
context.go(AppRoutes.payout);
|
||||||
|
},
|
||||||
|
// onTap: () {
|
||||||
|
// print('TAV ExcelExporter');
|
||||||
|
//
|
||||||
|
// ExcelExporter.exportToExcel(
|
||||||
|
// sheetName: sheetName,
|
||||||
|
// data: data,
|
||||||
|
// headers: headers,
|
||||||
|
// fileName: fileName,
|
||||||
|
// keys: keys!,
|
||||||
|
// );
|
||||||
|
// },
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: const Color(0xFF2E7D6E),
|
||||||
|
// color: const Color(0xFF425B5B),
|
||||||
|
borderRadius: BorderRadius.circular(8.0),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
// Image.asset(
|
||||||
|
// "assets/miscellaneous/export.png",
|
||||||
|
// height: 25,
|
||||||
|
// width: 25,
|
||||||
|
// ),
|
||||||
|
Icon(Icons.add, color: Colors.white, size: 25),
|
||||||
|
// Image.asset("assets/miscellaneous/export", height: 15, width: 15),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(width: 10),
|
||||||
|
ExportBtn(
|
||||||
|
sheetName: "Invoice",
|
||||||
|
fileName: "Invoice_List",
|
||||||
|
data: filteredData,
|
||||||
|
txt: true,
|
||||||
|
displayHeaders: [
|
||||||
|
"Updated Date",
|
||||||
|
"Invoice Date",
|
||||||
|
"Invoice No",
|
||||||
|
"Invoice Amount",
|
||||||
|
"Broker Name",
|
||||||
|
"Partner Name",
|
||||||
|
],
|
||||||
|
keys: [
|
||||||
|
"updated_at",
|
||||||
|
"invoice_date",
|
||||||
|
"invoice_no",
|
||||||
|
"invoice_amount",
|
||||||
|
"broker_name",
|
||||||
|
"agent_name",
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(height: 5),
|
||||||
|
Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Color(0xFFEDF6F5),
|
||||||
|
borderRadius: BorderRadius.circular(6),
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(flex: 3, child: Text('Invoice No', style: _headerStyle)),
|
||||||
|
Expanded(
|
||||||
|
flex: 3,
|
||||||
|
child: Text('Invoice Date', style: _headerStyle),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
flex: 3,
|
||||||
|
child: Text('Invoice Amount', style: _headerStyle),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
flex: 3,
|
||||||
|
child: Text('Broker Name', style: _headerStyle),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
flex: 3,
|
||||||
|
child: Text('Partner Name', style: _headerStyle),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
flex: 3,
|
||||||
|
child: Text('Updated Date', style: _headerStyle),
|
||||||
|
),
|
||||||
|
Expanded(flex: 3, child: Text('Action', style: _headerStyle)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
Expanded(child: _buildDataTable(context)),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildDataTable(BuildContext context) {
|
||||||
|
if (filteredData.isEmpty) {
|
||||||
|
return const SizedBox(
|
||||||
|
height: 50,
|
||||||
|
child: Center(child: Text('No available data')),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
final sortedData = [..._paginatedData];
|
||||||
|
|
||||||
|
// Desktop: keep ListView.builder
|
||||||
|
return ListView.builder(
|
||||||
|
itemCount: sortedData.length + 1,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
if (index == 0) return _buildHeader();
|
||||||
|
final startIndex = (currentPage - 1) * itemsPerPage;
|
||||||
|
final item = sortedData[index - 1];
|
||||||
|
final sno = startIndex + index;
|
||||||
|
return _buildDataRow(item, sno);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildHeader() {
|
||||||
|
return SizedBox.shrink();
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildDataRow(Map<String, dynamic> item, sno) {
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 16),
|
||||||
|
// margin: const EdgeInsets.only(top: 10),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
// color: Color(0xFFE0F7F9),
|
||||||
|
border: const Border(
|
||||||
|
bottom: BorderSide(color: Color(0xFFEAEAEA), width: 1),
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
flex: 3,
|
||||||
|
child: Text(item['invoice_no'] ?? '-', style: _dataBold),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
flex: 3,
|
||||||
|
child: Text(
|
||||||
|
item['invoice_date'] ?? '-',
|
||||||
|
style: _dataBold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
flex: 3,
|
||||||
|
child: Text(
|
||||||
|
item['invoice_amount'] ?? '-',
|
||||||
|
style: _dataBold,
|
||||||
|
softWrap: true,
|
||||||
|
maxLines: 3,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
flex: 3,
|
||||||
|
child: Text(
|
||||||
|
item['broker_name'] ?? '-',
|
||||||
|
style: _dataBold,
|
||||||
|
softWrap: true,
|
||||||
|
maxLines: 3,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
flex: 3,
|
||||||
|
child: Text(
|
||||||
|
item['agent_name'] ?? '-',
|
||||||
|
style: _dataBold,
|
||||||
|
softWrap: true,
|
||||||
|
maxLines: 3,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
flex: 3,
|
||||||
|
child: Text(
|
||||||
|
_formatDate(item['updated_at']) ?? '-',
|
||||||
|
style: _dataBold,
|
||||||
|
softWrap: true,
|
||||||
|
maxLines: 3,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
// ACTION ICONS (Edit + Delete)
|
||||||
|
Expanded(
|
||||||
|
flex: 2,
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
// EDIT ICON
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.edit, color: Colors.blue, size: 20),
|
||||||
|
onPressed: () {
|
||||||
|
// TODO: handle edit
|
||||||
|
context.go(AppRoutes.payout, extra: item);
|
||||||
|
print("Edit clicked for ${item['invoice_no']}");
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(width: 6),
|
||||||
|
|
||||||
|
// DELETE ICON
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.delete, color: Colors.red, size: 20),
|
||||||
|
onPressed: () {
|
||||||
|
// TODO: handle delete
|
||||||
|
deleteInvoice(item['id']);
|
||||||
|
print("Delete clicked for ${item['invoice_no']}");
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static final _dataBold = GoogleFonts.inter(
|
||||||
|
fontSize: 14,
|
||||||
|
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
color: Color(0xFF000000),
|
||||||
|
);
|
||||||
|
|
||||||
|
static final _headerStyle = GoogleFonts.inter(
|
||||||
|
color: Colors.black,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
);
|
||||||
|
}
|
||||||
1089
lib/presentation/screens/payout/payout_screen.dart
Normal file
1089
lib/presentation/screens/payout/payout_screen.dart
Normal file
File diff suppressed because it is too large
Load Diff
@ -94,8 +94,8 @@ class ExportBtn extends HookWidget {
|
|||||||
// ?txt! ? SizedBox(width: 15) : null,
|
// ?txt! ? SizedBox(width: 15) : null,
|
||||||
Image.asset(
|
Image.asset(
|
||||||
"assets/miscellaneous/export.png",
|
"assets/miscellaneous/export.png",
|
||||||
height: 15,
|
height: 25,
|
||||||
width: 15,
|
width: 25,
|
||||||
),
|
),
|
||||||
// Icon(Icons.input_sharp, color: Colors.white),
|
// Icon(Icons.input_sharp, color: Colors.white),
|
||||||
// Image.asset("assets/miscellaneous/export", height: 15, width: 15),
|
// Image.asset("assets/miscellaneous/export", height: 15, width: 15),
|
||||||
|
|||||||
20
pubspec.lock
20
pubspec.lock
@ -700,26 +700,26 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: leak_tracker
|
name: leak_tracker
|
||||||
sha256: "6bb818ecbdffe216e81182c2f0714a2e62b593f4a4f13098713ff1685dfb6ab0"
|
sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "10.0.9"
|
version: "11.0.2"
|
||||||
leak_tracker_flutter_testing:
|
leak_tracker_flutter_testing:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: leak_tracker_flutter_testing
|
name: leak_tracker_flutter_testing
|
||||||
sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573
|
sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.0.9"
|
version: "3.0.10"
|
||||||
leak_tracker_testing:
|
leak_tracker_testing:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: leak_tracker_testing
|
name: leak_tracker_testing
|
||||||
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
|
sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.0.1"
|
version: "3.0.2"
|
||||||
lints:
|
lints:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -1225,10 +1225,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: test_api
|
name: test_api
|
||||||
sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd
|
sha256: "522f00f556e73044315fa4585ec3270f1808a4b186c936e612cab0b565ff1e00"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.7.4"
|
version: "0.7.6"
|
||||||
toastification:
|
toastification:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -1345,10 +1345,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: vector_math
|
name: vector_math
|
||||||
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
|
sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.4"
|
version: "2.2.0"
|
||||||
vm_service:
|
vm_service:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user