Code Merged
This commit is contained in:
parent
7e1b5c1022
commit
1fefb22f46
File diff suppressed because one or more lines are too long
@ -1718,6 +1718,28 @@ class ApiService {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> fetchAgentUnusedCommissionList(id,broker_id) async {
|
||||||
|
print('fetchAGENTNameDropDown');
|
||||||
|
if (_token == null) {
|
||||||
|
await _initializeToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
dynamic url;
|
||||||
|
print('fetchAGENTNameDropDown 1');
|
||||||
|
url = Uri.parse(
|
||||||
|
'${Env.apiUrl}invoice/getAgentUnusedCommissionList?manager_id=$id&broker_id=$broker_id',
|
||||||
|
);
|
||||||
|
print('fetchAGENTNameDropDown 2');
|
||||||
|
final headers = {
|
||||||
|
'Authorization': 'Bearer $_token' ?? '',
|
||||||
|
'app-signature': Env.App_Signature,
|
||||||
|
};
|
||||||
|
print('fetchAGENTNameDropDown 3');
|
||||||
|
final response = await _makeGetRequest(url, headers);
|
||||||
|
print('fetchAGENTNameDropDown 4 - $response');
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
static late String _baseUrl;
|
static late String _baseUrl;
|
||||||
|
|
||||||
static void initialize(String baseUrl) {
|
static void initialize(String baseUrl) {
|
||||||
@ -2093,7 +2115,7 @@ class ApiService {
|
|||||||
|
|
||||||
Future<void> generatePolicyExcel(managerId, fromDate, toDate, searchValue) async {
|
Future<void> generatePolicyExcel(managerId, fromDate, toDate, searchValue) async {
|
||||||
final url = Uri.parse(
|
final url = Uri.parse(
|
||||||
'${Env.apiUrl}reports/policy-excel?manager_id=$managerId&from_date=${fromDate ?? ''}&to_date=${toDate ?? ''}',
|
'${Env.apiUrl}reports/policy-excel?manager_id=$managerId&from_date=${fromDate ?? ''}&to_date=${toDate ?? ''}&search=${searchValue ?? ''}',
|
||||||
);
|
);
|
||||||
|
|
||||||
// final url = Uri.parse( 'http://localhost/nhance_partner_be/reports/policy-excel?manager_id=$managerId&from_date=${fromDate ?? ''}&to_date=${toDate ?? ''}&search=${searchValue ?? ''}', );
|
// final url = Uri.parse( 'http://localhost/nhance_partner_be/reports/policy-excel?manager_id=$managerId&from_date=${fromDate ?? ''}&to_date=${toDate ?? ''}&search=${searchValue ?? ''}', );
|
||||||
|
|||||||
@ -93,9 +93,10 @@ class _DateFilterRowState extends ConsumerState<DateFilterRowPayout> {
|
|||||||
// getPartnerDetails(userID);
|
// getPartnerDetails(userID);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (managerId != null) {
|
if (managerId != null && widget.selectedBroker != null) {
|
||||||
print('managerId - $managerId');
|
print('managerId - $managerId');
|
||||||
getAgentList(managerId);
|
print('SelectedBroker - $widget.selectedBroker');
|
||||||
|
getAgentList(managerId,widget.selectedBroker);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -133,24 +134,31 @@ class _DateFilterRowState extends ConsumerState<DateFilterRowPayout> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getAgentList(id) async {
|
Future<void> getAgentList(id,broker_id) async {
|
||||||
|
|
||||||
print('getAgentListData called');
|
print('getAgentListData called');
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoadingAgentList = true;
|
isLoadingAgentList = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final response = await apiService.fetchAgentNameDropDown(id);
|
final response = await apiService.fetchAgentUnusedCommissionList(id,broker_id);
|
||||||
print('getAgentListData called response');
|
print('getAgentListData called response');
|
||||||
print('get Agent- ${response['data']}');
|
print('get Agent- ${response['data']}');
|
||||||
if (response['status'] == 'success') {
|
if (response['status'] == 'success') {
|
||||||
print('get Agent- ${response['data']}');
|
print('get Agent- ${response['data']}');
|
||||||
setState(() {
|
setState(() {
|
||||||
getPartnerData = List<Map<String, dynamic>>.from(response['data']);
|
// 1. Convert the response to a list
|
||||||
print('API Data - $getPartnerData');
|
final rawList = List<Map<String, dynamic>>.from(response['data']);
|
||||||
|
print('API Data - rawList');
|
||||||
|
// 2. Filter out items where agent_id is null or empty
|
||||||
|
getPartnerData = rawList.where((item) {
|
||||||
|
final id = item['agent_id'];
|
||||||
|
return id != null && id.toString().isNotEmpty;
|
||||||
|
}).toList();
|
||||||
|
print('Filtered API Data (No Null IDs) - $getPartnerData');
|
||||||
|
// 3. Sync the filtered data to your display list
|
||||||
filteredPartnerData = List.from(getPartnerData);
|
filteredPartnerData = List.from(getPartnerData);
|
||||||
print('originalAgentData - $filteredPartnerData');
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
getPartnerData = [];
|
getPartnerData = [];
|
||||||
@ -499,18 +507,35 @@ class _DateFilterRowState extends ConsumerState<DateFilterRowPayout> {
|
|||||||
},
|
},
|
||||||
// constraints: BoxConstraints(),
|
// constraints: BoxConstraints(),
|
||||||
),
|
),
|
||||||
|
// onChanged: (val) {
|
||||||
|
// if (val != null) {
|
||||||
|
// print("Selected Broker : ${val['name']}");
|
||||||
|
// print("Id: ${val['id']}");
|
||||||
|
// // selectedBroker = val['id'];
|
||||||
|
// widget.onBrokerChanged?.call(val['id'].toString());
|
||||||
|
// // widget.onBrokerChanged?.call(val['id']);
|
||||||
|
// // controllers['agentId']?.text = val['agent_code'];
|
||||||
|
// // agentId = agent['id'];
|
||||||
|
// }
|
||||||
|
// },
|
||||||
onChanged: (val) {
|
onChanged: (val) {
|
||||||
if (val != null) {
|
if (val != null) {
|
||||||
print("Selected Broker : ${val['name']}");
|
String selectedId = val['id'].toString();
|
||||||
print("Id: ${val['id']}");
|
|
||||||
// selectedBroker = val['id'];
|
// 1. Notify parent of the change
|
||||||
widget.onBrokerChanged?.call(val['id'].toString());
|
widget.onBrokerChanged?.call(selectedId);
|
||||||
// widget.onBrokerChanged?.call(val['id']);
|
|
||||||
// controllers['agentId']?.text = val['agent_code'];
|
// 2. Clear current partner list so user doesn't see old data
|
||||||
// agentId = agent['id'];
|
setState(() {
|
||||||
|
filteredPartnerData = [];
|
||||||
|
});
|
||||||
|
|
||||||
|
// 3. Fetch new agents based on this broker
|
||||||
|
getAgentList(managerId!, selectedId);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -523,7 +548,7 @@ class _DateFilterRowState extends ConsumerState<DateFilterRowPayout> {
|
|||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text("Referer *", style: _textStyle),
|
Text("Referer", style: _textStyle),
|
||||||
SizedBox(height: 5),
|
SizedBox(height: 5),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 35,
|
height: 35,
|
||||||
@ -536,7 +561,7 @@ class _DateFilterRowState extends ConsumerState<DateFilterRowPayout> {
|
|||||||
// : null,
|
// : null,
|
||||||
selectedItems: filteredPartnerData
|
selectedItems: filteredPartnerData
|
||||||
.where(
|
.where(
|
||||||
(item) => (widget.selectedParnter ?? []).contains(item['id']),
|
(item) => (widget.selectedParnter ?? []).contains(item['agent_id']),
|
||||||
)
|
)
|
||||||
.toList(),
|
.toList(),
|
||||||
|
|
||||||
@ -549,26 +574,27 @@ class _DateFilterRowState extends ConsumerState<DateFilterRowPayout> {
|
|||||||
return filteredPartnerData;
|
return filteredPartnerData;
|
||||||
},
|
},
|
||||||
|
|
||||||
itemAsString: (val) => val['name'].toString(), // what to show
|
itemAsString: (val) => // what to show
|
||||||
|
"${val['agent_name']} | ${val['unused_commission_amount']} (${val['total_policies']})",
|
||||||
compareFn: (item, selectedItem) =>
|
compareFn: (item, selectedItem) =>
|
||||||
item['id'] == selectedItem['id'], // ✅ compare by id
|
item['agent_id'] == selectedItem['agent_id'], // ✅ compare by id
|
||||||
// validator: (val) {
|
// validator: (val) {
|
||||||
// if (val == null) {
|
// if (val == null) {
|
||||||
// return "Required"; // ✅ error message
|
// return "Required"; // ✅ error message
|
||||||
// }
|
// }
|
||||||
// return null;
|
// return null;
|
||||||
// },
|
// },
|
||||||
validator: (val) {
|
// validator: (val) {
|
||||||
if (val == null || val.isEmpty) {
|
// if (val == null || val.isEmpty) {
|
||||||
return ""; // 👈 triggers error border, no text
|
// return ""; // 👈 triggers error border, no text
|
||||||
}
|
// }
|
||||||
return null;
|
// return null;
|
||||||
|
//
|
||||||
// if (val == null || val.isEmpty) {
|
// // if (val == null || val.isEmpty) {
|
||||||
// return "Required";
|
// // return "Required";
|
||||||
// }
|
// // }
|
||||||
// return null;
|
// // return null;
|
||||||
},
|
// },
|
||||||
|
|
||||||
decoratorProps: DropDownDecoratorProps(
|
decoratorProps: DropDownDecoratorProps(
|
||||||
decoration:
|
decoration:
|
||||||
@ -641,7 +667,7 @@ class _DateFilterRowState extends ConsumerState<DateFilterRowPayout> {
|
|||||||
vertical: 3,
|
vertical: 3,
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
item['name'].toString(),
|
"${item['agent_name']} | ${item['unused_commission_amount']} (${item['total_policies']})",
|
||||||
style: GoogleFonts.inter(fontSize: 12, color: Colors.black),
|
style: GoogleFonts.inter(fontSize: 12, color: Colors.black),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -652,7 +678,7 @@ class _DateFilterRowState extends ConsumerState<DateFilterRowPayout> {
|
|||||||
// selectedPartnerIds = selectedVals
|
// selectedPartnerIds = selectedVals
|
||||||
// .map((v) => v['id'].toString())
|
// .map((v) => v['id'].toString())
|
||||||
// .toList();
|
// .toList();
|
||||||
final ids = selectedVals.map((v) => v['id'].toString()).toList();
|
final ids = selectedVals.map((v) => v['agent_id'].toString()).toList();
|
||||||
print("Selected PArnter IDs: $widget.selectedPartnerIds");
|
print("Selected PArnter IDs: $widget.selectedPartnerIds");
|
||||||
widget.onPartnerChanges?.call(ids);
|
widget.onPartnerChanges?.call(ids);
|
||||||
// widget.onPartnerChanges!(v['id']);
|
// widget.onPartnerChanges!(v['id']);
|
||||||
|
|||||||
@ -138,7 +138,7 @@ class _PayOutScreenState extends ConsumerState<PayOutScreen> {
|
|||||||
|
|
||||||
print('invoiceID $invoiceID');
|
print('invoiceID $invoiceID');
|
||||||
print('brokerID $brokerID');
|
print('brokerID $brokerID');
|
||||||
_loadEditData(invoiceID, brokerID);
|
_loadEditData(invoiceID, brokerID,managerId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,7 +230,7 @@ class _PayOutScreenState extends ConsumerState<PayOutScreen> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void _loadEditData(String invoiceID, brokerID) async {
|
void _loadEditData(String invoiceID, brokerID, managerID) async {
|
||||||
setState(() => isLoadingEditData = true);
|
setState(() => isLoadingEditData = true);
|
||||||
print('_loadEditData');
|
print('_loadEditData');
|
||||||
|
|
||||||
@ -238,6 +238,7 @@ class _PayOutScreenState extends ConsumerState<PayOutScreen> {
|
|||||||
// "id": invoiceID,
|
// "id": invoiceID,
|
||||||
"invoice_id": invoiceID,
|
"invoice_id": invoiceID,
|
||||||
"broker_id": int.tryParse(brokerID ?? ''),
|
"broker_id": int.tryParse(brokerID ?? ''),
|
||||||
|
"manager_id": managerID
|
||||||
|
|
||||||
// "issued_date": formattedTillDate,
|
// "issued_date": formattedTillDate,
|
||||||
};
|
};
|
||||||
@ -442,6 +443,28 @@ class _PayOutScreenState extends ConsumerState<PayOutScreen> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if (dashboardKey == 'f' &&
|
||||||
|
// isDashboardInitialLoad &&
|
||||||
|
// SelectedStatus == "P") {
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// fromDt = "";toDt = "";
|
||||||
|
// isDashboardInitialLoad = false;
|
||||||
|
//
|
||||||
|
// } else if (dashboardKey == 'f' && isDashboardInitialLoad && SelectedStatus != '') {
|
||||||
|
// fromDt = "";toDt = "";
|
||||||
|
// isDashboardInitialLoad = false;
|
||||||
|
// } else if (fromDateVal.isEmpty && toDateVal.isEmpty) {
|
||||||
|
// // Default fallback
|
||||||
|
// final today = DateTime.now();
|
||||||
|
// fromDt = DateFormat('dd-MM-yyyy').format(today.subtract(const Duration(days: 5)));
|
||||||
|
// toDt = DateFormat('dd-MM-yyyy').format(today);
|
||||||
|
// } else {
|
||||||
|
// // ✅ USER SELECTED DATE — ALWAYS RESPECT THIS
|
||||||
|
// fromDt = fromDateVal;
|
||||||
|
// toDt = toDateVal;
|
||||||
|
// }
|
||||||
|
|
||||||
// Load policies (simulate API)
|
// Load policies (simulate API)
|
||||||
Future<void> loadPolicies() async {
|
Future<void> loadPolicies() async {
|
||||||
print('loadPolicies');
|
print('loadPolicies');
|
||||||
@ -454,7 +477,9 @@ class _PayOutScreenState extends ConsumerState<PayOutScreen> {
|
|||||||
"from_date": controllers['startDate']?.text,
|
"from_date": controllers['startDate']?.text,
|
||||||
"to_date": controllers['endDate']?.text,
|
"to_date": controllers['endDate']?.text,
|
||||||
"broker_id": int.tryParse(selectedBrokerID ?? ''),
|
"broker_id": int.tryParse(selectedBrokerID ?? ''),
|
||||||
"agent_id": agentIds,
|
"manager_id": managerId,
|
||||||
|
if (agentIds != null && agentIds.isNotEmpty) "agent_id": agentIds,
|
||||||
|
// "agent_id": agentIds,
|
||||||
// "issued_date": formattedTillDate,
|
// "issued_date": formattedTillDate,
|
||||||
};
|
};
|
||||||
final response = await apiService.getCommissionRateList(jsondata);
|
final response = await apiService.getCommissionRateList(jsondata);
|
||||||
@ -1296,6 +1321,8 @@ class _PayOutScreenState extends ConsumerState<PayOutScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
double _calculateTotalCommission() {
|
double _calculateTotalCommission() {
|
||||||
|
print("ASD");
|
||||||
|
print(filteredPolicies);
|
||||||
double total = 0.0;
|
double total = 0.0;
|
||||||
|
|
||||||
for (var p in filteredPolicies) {
|
for (var p in filteredPolicies) {
|
||||||
|
|||||||
@ -44,12 +44,16 @@ import 'enquiry_inline_SubRow.dart';
|
|||||||
import 'multi_file_list.dart';
|
import 'multi_file_list.dart';
|
||||||
|
|
||||||
class EnquiryListStaffInline extends ConsumerStatefulWidget {
|
class EnquiryListStaffInline extends ConsumerStatefulWidget {
|
||||||
|
|
||||||
const EnquiryListStaffInline({super.key});
|
const EnquiryListStaffInline({super.key});
|
||||||
@override
|
@override
|
||||||
ConsumerState<EnquiryListStaffInline> createState() => EnquiryStaffState();
|
ConsumerState<EnquiryListStaffInline> createState() => EnquiryStaffState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
||||||
|
// bool fromDashboard = false;
|
||||||
|
bool _dashboardInitHandled = false;
|
||||||
|
bool _resetKeyEnable = false;
|
||||||
int currentPage = 1;
|
int currentPage = 1;
|
||||||
int itemsPerPage = 10;
|
int itemsPerPage = 10;
|
||||||
// int itemsPerPage = 5;
|
// int itemsPerPage = 5;
|
||||||
@ -169,9 +173,9 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
Map<String, dynamic> dataDetails() {
|
Map<String, dynamic> dataDetails() {
|
||||||
final data = {
|
final data = {
|
||||||
"agent_id":
|
"agent_id":
|
||||||
((roleId == 'handler') ||
|
((roleId == 'handler') ||
|
||||||
(roleId == 'manager') ||
|
(roleId == 'manager') ||
|
||||||
(roleId == 'staff'))
|
(roleId == 'staff'))
|
||||||
? selectedAgent
|
? selectedAgent
|
||||||
: userId,
|
: userId,
|
||||||
"name": controllers["name"]?.text,
|
"name": controllers["name"]?.text,
|
||||||
@ -198,19 +202,19 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final GlobalKey<DropdownSearchState<Map<String, dynamic>>> dropDownKey =
|
final GlobalKey<DropdownSearchState<Map<String, dynamic>>> dropDownKey =
|
||||||
GlobalKey<DropdownSearchState<Map<String, dynamic>>>();
|
GlobalKey<DropdownSearchState<Map<String, dynamic>>>();
|
||||||
|
|
||||||
final GlobalKey<DropdownSearchState<Map<String, dynamic>>>
|
final GlobalKey<DropdownSearchState<Map<String, dynamic>>>
|
||||||
dropDownSelectPaymentModeKey =
|
dropDownSelectPaymentModeKey =
|
||||||
GlobalKey<DropdownSearchState<Map<String, dynamic>>>();
|
GlobalKey<DropdownSearchState<Map<String, dynamic>>>();
|
||||||
//---------------------- Assign Staff starts -------------------------------- //
|
//---------------------- Assign Staff starts -------------------------------- //
|
||||||
|
|
||||||
final GlobalKey<DropdownSearchState<Map<String, dynamic>>>
|
final GlobalKey<DropdownSearchState<Map<String, dynamic>>>
|
||||||
dropDownKeyInsurerEnqAsgn =
|
dropDownKeyInsurerEnqAsgn =
|
||||||
GlobalKey<DropdownSearchState<Map<String, dynamic>>>();
|
GlobalKey<DropdownSearchState<Map<String, dynamic>>>();
|
||||||
|
|
||||||
final GlobalKey<DropdownSearchState<Map<String, dynamic>>> dropDownKeyBroker =
|
final GlobalKey<DropdownSearchState<Map<String, dynamic>>> dropDownKeyBroker =
|
||||||
GlobalKey<DropdownSearchState<Map<String, dynamic>>>();
|
GlobalKey<DropdownSearchState<Map<String, dynamic>>>();
|
||||||
|
|
||||||
List<Map<String, dynamic>> getStaffDetailsDataEnqAsgn = [];
|
List<Map<String, dynamic>> getStaffDetailsDataEnqAsgn = [];
|
||||||
List<Map<String, dynamic>> filteredStaffDataEnqAsgn = [];
|
List<Map<String, dynamic>> filteredStaffDataEnqAsgn = [];
|
||||||
@ -234,6 +238,26 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
//---------------------- Assign Staff Ends -------------------------------- //
|
//---------------------- Assign Staff Ends -------------------------------- //
|
||||||
//---------------------- Enquiry TAB Initializations Ends -------------------------------- //
|
//---------------------- Enquiry TAB Initializations Ends -------------------------------- //
|
||||||
|
|
||||||
|
// @override
|
||||||
|
// void didChangeDependencies() {
|
||||||
|
// super.didChangeDependencies();
|
||||||
|
|
||||||
|
// if (_dashboardInitHandled) return;
|
||||||
|
// _dashboardInitHandled = true;
|
||||||
|
|
||||||
|
// final extra = GoRouterState.of(context).extra;
|
||||||
|
|
||||||
|
// if (extra is Map<String, dynamic>) {
|
||||||
|
// fromDashboard = extra['fromDashboard'] ?? false;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // 🔥 IMPORTANT: Clear date pickers ONLY when coming from dashboard
|
||||||
|
// if (fromDashboard) {
|
||||||
|
// controllers['startDate']?.clear();
|
||||||
|
// controllers['endDate']?.clear();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@ -298,9 +322,9 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
getPaymentMode();
|
getPaymentMode();
|
||||||
|
|
||||||
refreshSub = ref.listenManual<bool>(enquiryRefreshProvider, (
|
refreshSub = ref.listenManual<bool>(enquiryRefreshProvider, (
|
||||||
previous,
|
previous,
|
||||||
next,
|
next,
|
||||||
) {
|
) {
|
||||||
if (next == true) {
|
if (next == true) {
|
||||||
print('refresh triggered Quick Creation');
|
print('refresh triggered Quick Creation');
|
||||||
autoRefrshfilterDateRange();
|
autoRefrshfilterDateRange();
|
||||||
@ -505,6 +529,9 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> refrshfilterDateRange() async {
|
Future<void> refrshfilterDateRange() async {
|
||||||
|
setState(() {
|
||||||
|
_resetKeyEnable = true;
|
||||||
|
});
|
||||||
print('refrshfilterDateRange');
|
print('refrshfilterDateRange');
|
||||||
// setState(() async {
|
// setState(() async {
|
||||||
final prefs = await SharedPreferences.getInstance();
|
final prefs = await SharedPreferences.getInstance();
|
||||||
@ -603,13 +630,13 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getStaffList(
|
Future<void> getStaffList(
|
||||||
int managerId,
|
int managerId,
|
||||||
role, {
|
role, {
|
||||||
String fromDate = '',
|
String fromDate = '',
|
||||||
String toDate = '',
|
String toDate = '',
|
||||||
String SelectedStatus = '',
|
String SelectedStatus = '',
|
||||||
String SelectedStaffId = '',
|
String SelectedStaffId = '',
|
||||||
}) async {
|
}) async {
|
||||||
print('A613 => Fns called => $managerId | $role');
|
print('A613 => Fns called => $managerId | $role');
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoadingStaffList = true;
|
isLoadingStaffList = true;
|
||||||
@ -624,16 +651,21 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
final dateFormat = DateFormat('dd-MM-yyyy');
|
final dateFormat = DateFormat('dd-MM-yyyy');
|
||||||
|
|
||||||
if (dashboardKey == 'fromDashboard' && SelectedStatus == "PrevPending") {
|
if (dashboardKey == 'fromDashboard' && SelectedStatus == "PrevPending") {
|
||||||
|
setState(() {
|
||||||
|
_dashboardInitHandled = true;
|
||||||
|
});
|
||||||
// For PREV PENDING → set date range until yesterday
|
// For PREV PENDING → set date range until yesterday
|
||||||
final today = DateTime.now();
|
final today = DateTime.now();
|
||||||
print('A813 => Fns called => $managerId | $role');
|
print('A813 => Fns called => $managerId | $role');
|
||||||
// Change to dd-MM-yyyy
|
// Change to dd-MM-yyyy
|
||||||
final dateFormat = DateFormat('dd-MM-yyyy');
|
// final dateFormat = DateFormat('dd-MM-yyyy');
|
||||||
|
//
|
||||||
|
// final yesterday = today.subtract(Duration(days: 1));
|
||||||
|
|
||||||
final yesterday = today.subtract(Duration(days: 1));
|
fromDt = _dashboardInitHandled ? controllers['startDate']?.text : '';
|
||||||
|
toDt = _dashboardInitHandled ? controllers['endDate']?.text : '';
|
||||||
fromDt = dateFormat.format(yesterday.subtract(Duration(days: 15)));
|
// fromDt = dateFormat.format(yesterday.subtract(Duration(days: 15)));
|
||||||
toDt = dateFormat.format(yesterday);
|
// toDt = dateFormat.format(yesterday);
|
||||||
|
|
||||||
print('PrevPending FROM TO - $fromDt - $toDt');
|
print('PrevPending FROM TO - $fromDt - $toDt');
|
||||||
} else if (dashboardKey == 'fromDashboard' &&
|
} else if (dashboardKey == 'fromDashboard' &&
|
||||||
@ -645,8 +677,11 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
// Change to dd-MM-yyyy
|
// Change to dd-MM-yyyy
|
||||||
final dateFormat = DateFormat('dd-MM-yyyy');
|
final dateFormat = DateFormat('dd-MM-yyyy');
|
||||||
|
|
||||||
fromDt = dateFormat.format(today);
|
// fromDt = dateFormat.format(today);
|
||||||
toDt = dateFormat.format(today);
|
// toDt = dateFormat.format(today);
|
||||||
|
|
||||||
|
fromDt = _dashboardInitHandled ? controllers['startDate']?.text : '';
|
||||||
|
toDt = _dashboardInitHandled ? controllers['endDate']?.text : '';
|
||||||
|
|
||||||
print('PrevPending FROM TO - $fromDt - $toDt');
|
print('PrevPending FROM TO - $fromDt - $toDt');
|
||||||
} else if (dashboardKey != 'fromDashboard' &&
|
} else if (dashboardKey != 'fromDashboard' &&
|
||||||
@ -664,8 +699,25 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
} else {
|
} else {
|
||||||
print('A1113 => Fns called => $managerId | $role');
|
print('A1113 => Fns called => $managerId | $role');
|
||||||
print('Enq 1- $fromDt - $toDt');
|
print('Enq 1- $fromDt - $toDt');
|
||||||
fromDt = fromDateVal;
|
|
||||||
toDt = toDateVal;
|
if(_resetKeyEnable = true){
|
||||||
|
final dateFormat = DateFormat('dd-MM-yyyy');
|
||||||
|
final today = DateTime.now();
|
||||||
|
final yesterday = today.subtract(Duration(days: 1));
|
||||||
|
|
||||||
|
fromDt = dateFormat.format(yesterday.subtract(Duration(days: 15)));
|
||||||
|
toDt = dateFormat.format(yesterday);
|
||||||
|
setState(() {
|
||||||
|
controllers['startDate']?.text = fromDt;
|
||||||
|
controllers['endDate']?.text = toDt;
|
||||||
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
fromDt = fromDateVal;
|
||||||
|
toDt = toDateVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
print('Enq 2- $fromDt - $toDt');
|
print('Enq 2- $fromDt - $toDt');
|
||||||
String finalStatus = SelectedStatus;
|
String finalStatus = SelectedStatus;
|
||||||
@ -678,13 +730,13 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
managerId,
|
managerId,
|
||||||
userId,
|
userId,
|
||||||
role,
|
role,
|
||||||
fromDate: fromDt,
|
fromDate: _dashboardInitHandled ? controllers['startDate']?.text : fromDt,
|
||||||
toDate: toDt,
|
toDate: _dashboardInitHandled ? controllers['endDate']?.text : toDt,
|
||||||
// selectedStatus: (finalStatus != '' && finalStatus != 'PrevPending')
|
// selectedStatus: (finalStatus != '' && finalStatus != 'PrevPending')
|
||||||
// ? finalStatus
|
// ? finalStatus
|
||||||
// : '',
|
// : '',
|
||||||
selectedStatus:
|
selectedStatus:
|
||||||
(SelectedStatus != '' && SelectedStatus != 'PrevPending')
|
(SelectedStatus != '' && SelectedStatus != 'PrevPending')
|
||||||
? SelectedStatus
|
? SelectedStatus
|
||||||
: '',
|
: '',
|
||||||
selectedStaffId: SelectedStaffId ?? '',
|
selectedStaffId: SelectedStaffId ?? '',
|
||||||
@ -700,8 +752,13 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
print('A1213 => Fns called => $managerId | $role');
|
print('A1213 => Fns called => $managerId | $role');
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
|
_resetKeyEnable = false;
|
||||||
|
|
||||||
controllers['startDate']?.text = fromDate;
|
controllers['startDate']?.text = fromDate;
|
||||||
controllers['endDate']?.text = toDate;
|
controllers['endDate']?.text = toDate;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (data is List) {
|
if (data is List) {
|
||||||
getStaffData = List<Map<String, dynamic>>.from(data);
|
getStaffData = List<Map<String, dynamic>>.from(data);
|
||||||
|
|
||||||
@ -946,8 +1003,8 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
// Search within the current tab's data
|
// Search within the current tab's data
|
||||||
filteredData = sourceList.where((item) {
|
filteredData = sourceList.where((item) {
|
||||||
return (item['agent_name'] ?? '-').toLowerCase().contains(
|
return (item['agent_name'] ?? '-').toLowerCase().contains(
|
||||||
query.toLowerCase(),
|
query.toLowerCase(),
|
||||||
) ||
|
) ||
|
||||||
(item['agent_code'] ?? '-').toLowerCase().contains(
|
(item['agent_code'] ?? '-').toLowerCase().contains(
|
||||||
query.toLowerCase(),
|
query.toLowerCase(),
|
||||||
) ||
|
) ||
|
||||||
@ -1013,11 +1070,11 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> handleStaff(
|
Future<void> handleStaff(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
dynamic data,
|
dynamic data,
|
||||||
id,
|
id,
|
||||||
regNum,
|
regNum,
|
||||||
) async {
|
) async {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (ctx) => AssignStaffDialog(
|
builder: (ctx) => AssignStaffDialog(
|
||||||
@ -1152,7 +1209,7 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
|
|
||||||
final bool isNewRow =
|
final bool isNewRow =
|
||||||
int.tryParse(id.toString()) != null &&
|
int.tryParse(id.toString()) != null &&
|
||||||
int.parse(id.toString()) > 1000000000000;
|
int.parse(id.toString()) > 1000000000000;
|
||||||
|
|
||||||
print('isNewRow - $isNewRow');
|
print('isNewRow - $isNewRow');
|
||||||
|
|
||||||
@ -1160,20 +1217,20 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
if (isNewRow) {
|
if (isNewRow) {
|
||||||
// Check if this is a new unsaved row
|
// Check if this is a new unsaved row
|
||||||
final row = getStaffData.firstWhere(
|
final row = getStaffData.firstWhere(
|
||||||
(item) => item['id'].toString() == id.toString(),
|
(item) => item['id'].toString() == id.toString(),
|
||||||
orElse: () => {},
|
orElse: () => {},
|
||||||
);
|
);
|
||||||
|
|
||||||
// If policy_number is empty, it's a new row - remove it
|
// If policy_number is empty, it's a new row - remove it
|
||||||
if (row.isNotEmpty) {
|
if (row.isNotEmpty) {
|
||||||
getStaffData.removeWhere(
|
getStaffData.removeWhere(
|
||||||
(item) => item['id'].toString() == id.toString(),
|
(item) => item['id'].toString() == id.toString(),
|
||||||
);
|
);
|
||||||
originalData.removeWhere(
|
originalData.removeWhere(
|
||||||
(item) => item['id'].toString() == id.toString(),
|
(item) => item['id'].toString() == id.toString(),
|
||||||
);
|
);
|
||||||
filteredData.removeWhere(
|
filteredData.removeWhere(
|
||||||
(item) => item['id'].toString() == id.toString(),
|
(item) => item['id'].toString() == id.toString(),
|
||||||
);
|
);
|
||||||
rowControllers.remove(id);
|
rowControllers.remove(id);
|
||||||
}
|
}
|
||||||
@ -1293,10 +1350,10 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
|
|
||||||
Future<void> attachFiles(http.MultipartRequest request) async {
|
Future<void> attachFiles(http.MultipartRequest request) async {
|
||||||
Future<void> addFileOrKeepName(
|
Future<void> addFileOrKeepName(
|
||||||
PlatformFile? file,
|
PlatformFile? file,
|
||||||
String? apiFileName,
|
String? apiFileName,
|
||||||
String fieldName,
|
String fieldName,
|
||||||
) async {
|
) async {
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
// User uploaded a new file → send as multipart
|
// User uploaded a new file → send as multipart
|
||||||
if (file.bytes != null) {
|
if (file.bytes != null) {
|
||||||
@ -1347,8 +1404,8 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
Future<void> createUserData(Map<String, dynamic> userData) async {
|
Future<void> createUserData(Map<String, dynamic> userData) async {
|
||||||
final bool isNewRow =
|
final bool isNewRow =
|
||||||
idPrimary != null &&
|
idPrimary != null &&
|
||||||
int.tryParse(idPrimary.toString()) != null &&
|
int.tryParse(idPrimary.toString()) != null &&
|
||||||
int.parse(idPrimary.toString()) > 1000000000000;
|
int.parse(idPrimary.toString()) > 1000000000000;
|
||||||
|
|
||||||
final bool isUpdating =
|
final bool isUpdating =
|
||||||
idPrimary != null && idPrimary != 'null' && !isNewRow;
|
idPrimary != null && idPrimary != 'null' && !isNewRow;
|
||||||
@ -1577,26 +1634,26 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
// SizedBox(height: 5),
|
// SizedBox(height: 5),
|
||||||
ResponsiveLayout.isMobile(context)
|
ResponsiveLayout.isMobile(context)
|
||||||
? Container(
|
? Container(
|
||||||
height: MediaQuery.of(context).size.height * 0.69,
|
height: MediaQuery.of(context).size.height * 0.69,
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.all(2),
|
padding: EdgeInsets.all(2),
|
||||||
child: _buildContent(context),
|
child: _buildContent(context),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
// Expanded(
|
// Expanded(
|
||||||
// child:
|
// child:
|
||||||
Container(
|
Container(
|
||||||
width: MediaQuery.of(context).size.width,
|
width: MediaQuery.of(context).size.width,
|
||||||
height: MediaQuery.of(context).size.height * 0.69,
|
height: MediaQuery.of(context).size.height * 0.69,
|
||||||
// padding: EdgeInsets.symmetric(
|
// padding: EdgeInsets.symmetric(
|
||||||
// horizontal: 8.0,
|
// horizontal: 8.0,
|
||||||
// vertical: 2.0,
|
// vertical: 2.0,
|
||||||
// ),
|
// ),
|
||||||
child: _buildContent(context),
|
child: _buildContent(context),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -1615,7 +1672,7 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
final result = await showDialog(
|
final result = await showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
barrierDismissible:
|
barrierDismissible:
|
||||||
false, // optional - prevents closing by tapping outside
|
false, // optional - prevents closing by tapping outside
|
||||||
builder: (context) => TabEnquiryStaffList(showKey: val),
|
builder: (context) => TabEnquiryStaffList(showKey: val),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1626,10 +1683,10 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> buildPolicyCreatedStatusActions(
|
Future<void> buildPolicyCreatedStatusActions(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
status,
|
status,
|
||||||
id,
|
id,
|
||||||
) async {
|
) async {
|
||||||
print("Actionsstatus - $status -$id");
|
print("Actionsstatus - $status -$id");
|
||||||
dynamic val;
|
dynamic val;
|
||||||
if (status == 'Awaiting Proposal' || status == 'Proposal Created') {
|
if (status == 'Awaiting Proposal' || status == 'Proposal Created') {
|
||||||
@ -1641,7 +1698,7 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
final result = await showDialog(
|
final result = await showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
barrierDismissible:
|
barrierDismissible:
|
||||||
false, // optional - prevents closing by tapping outside
|
false, // optional - prevents closing by tapping outside
|
||||||
builder: (context) => PolicyStaffEnqList(),
|
builder: (context) => PolicyStaffEnqList(),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1748,7 +1805,7 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
userPreference = newValue; // Save this as the new "normal"
|
userPreference = newValue; // Save this as the new "normal"
|
||||||
});
|
});
|
||||||
final prefs =
|
final prefs =
|
||||||
await SharedPreferences.getInstance();
|
await SharedPreferences.getInstance();
|
||||||
await prefs.setBool(
|
await prefs.setBool(
|
||||||
'isActionable',
|
'isActionable',
|
||||||
newValue,
|
newValue,
|
||||||
@ -1817,7 +1874,7 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
// });
|
// });
|
||||||
},
|
},
|
||||||
child: ThemedSearchField(
|
child: ThemedSearchField(
|
||||||
hintText: 'Search *',
|
hintText: 'Search',
|
||||||
backgroundColor: Color(0xFFFFFFFF),
|
backgroundColor: Color(0xFFFFFFFF),
|
||||||
txtHeight: 30,
|
txtHeight: 30,
|
||||||
controller: _searchStaffController,
|
controller: _searchStaffController,
|
||||||
@ -1851,11 +1908,11 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
txt: !ResponsiveLayout.isMobile(context) ? true : false,
|
txt: !ResponsiveLayout.isMobile(context) ? true : false,
|
||||||
displayHeaders: [
|
displayHeaders: [
|
||||||
"Received Date & Time",
|
"Received Date & Time",
|
||||||
"Partner",
|
|
||||||
"Assigned To",
|
"Assigned To",
|
||||||
|
"Partner",
|
||||||
"Insurer",
|
"Insurer",
|
||||||
"Vehicle.No.",
|
|
||||||
"Insured Name",
|
"Insured Name",
|
||||||
|
"Vehicle.No.",
|
||||||
"Assigned Date & Time",
|
"Assigned Date & Time",
|
||||||
"Premium",
|
"Premium",
|
||||||
"Payment Mode",
|
"Payment Mode",
|
||||||
@ -1864,14 +1921,14 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
],
|
],
|
||||||
keys: [
|
keys: [
|
||||||
"created_on",
|
"created_on",
|
||||||
"agent_name",
|
|
||||||
"assigned_to_name",
|
"assigned_to_name",
|
||||||
|
"agent_name",
|
||||||
"insurer_short_name",
|
"insurer_short_name",
|
||||||
"reg_no",
|
|
||||||
"insured_name",
|
"insured_name",
|
||||||
|
"reg_no",
|
||||||
"updated_on",
|
"updated_on",
|
||||||
"premium_amount",
|
"premium_amount",
|
||||||
"payment_mode",
|
"payment_mode_value",
|
||||||
"policy_number",
|
"policy_number",
|
||||||
"status",
|
"status",
|
||||||
],
|
],
|
||||||
@ -1885,12 +1942,12 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
ResponsiveLayout.isMobile(context)
|
ResponsiveLayout.isMobile(context)
|
||||||
? _buildDataTable(context)
|
? _buildDataTable(context)
|
||||||
: Container(
|
: Container(
|
||||||
height: MediaQuery.of(context).size.height * 0.55,
|
height: MediaQuery.of(context).size.height * 0.55,
|
||||||
// decoration: BoxDecoration(
|
// decoration: BoxDecoration(
|
||||||
// color: Colors.white
|
// color: Colors.white
|
||||||
// ),
|
// ),
|
||||||
child: _buildDataTable(context),
|
child: _buildDataTable(context),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -2036,54 +2093,54 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
// Calculate minimum width based on screen size
|
// Calculate minimum width based on screen size
|
||||||
double minTableWidth = isMobile ? screenWidth * 1.5 : 1300;
|
double minTableWidth = isMobile ? screenWidth * 1.5 : 1300;
|
||||||
return
|
return
|
||||||
// Expanded(
|
// Expanded(
|
||||||
// child:
|
// child:
|
||||||
LayoutBuilder(
|
LayoutBuilder(
|
||||||
builder: (context, constraints) {
|
builder: (context, constraints) {
|
||||||
double tableWidth = constraints.maxWidth > minTableWidth
|
double tableWidth = constraints.maxWidth > minTableWidth
|
||||||
? constraints.maxWidth
|
? constraints.maxWidth
|
||||||
: minTableWidth;
|
: minTableWidth;
|
||||||
|
|
||||||
final isDesktop = !ResponsiveLayout.isMobile(context);
|
final isDesktop = !ResponsiveLayout.isMobile(context);
|
||||||
|
|
||||||
return ScrollConfiguration(
|
return ScrollConfiguration(
|
||||||
behavior: const MaterialScrollBehavior().copyWith(
|
behavior: const MaterialScrollBehavior().copyWith(
|
||||||
dragDevices: {PointerDeviceKind.mouse, PointerDeviceKind.touch},
|
dragDevices: {PointerDeviceKind.mouse, PointerDeviceKind.touch},
|
||||||
),
|
),
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
controller: _horizontalScrollController, // 👈 Shared controller
|
controller: _horizontalScrollController, // 👈 Shared controller
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
// width: minWidth,
|
// width: minWidth,
|
||||||
width: tableWidth,
|
width: tableWidth,
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
// Fixed Header
|
// Fixed Header
|
||||||
Container(
|
Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
// color: Colors.white,
|
// color: Colors.white,
|
||||||
color: Color(0xFFF1F5F9),
|
color: Color(0xFFF1F5F9),
|
||||||
borderRadius: BorderRadius.circular(5),
|
borderRadius: BorderRadius.circular(5),
|
||||||
|
),
|
||||||
|
child: _buildTableHeader(isDesktop),
|
||||||
),
|
),
|
||||||
child: _buildTableHeader(isDesktop),
|
|
||||||
),
|
|
||||||
|
|
||||||
// Scrollable Data Content
|
// Scrollable Data Content
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(color: Colors.white),
|
decoration: BoxDecoration(color: Colors.white),
|
||||||
child: _buildDataTableContent(), // 👈 New method
|
child: _buildDataTableContent(), // 👈 New method
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
_buildPaginationControls(),
|
||||||
_buildPaginationControls(),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
);
|
},
|
||||||
},
|
);
|
||||||
);
|
|
||||||
// );
|
// );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2295,10 +2352,10 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
|
|
||||||
// Helper: Build action buttons
|
// Helper: Build action buttons
|
||||||
Widget _buildActionButtons(
|
Widget _buildActionButtons(
|
||||||
Map<String, dynamic> item,
|
Map<String, dynamic> item,
|
||||||
int id,
|
int id,
|
||||||
String selectId,
|
String selectId,
|
||||||
) {
|
) {
|
||||||
return Row(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
_buildInfoTooltip(item),
|
_buildInfoTooltip(item),
|
||||||
@ -2370,8 +2427,8 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
onTap: () async {
|
onTap: () async {
|
||||||
final button = buttonContext.findRenderObject() as RenderBox;
|
final button = buttonContext.findRenderObject() as RenderBox;
|
||||||
final overlay =
|
final overlay =
|
||||||
Overlay.of(buttonContext).context.findRenderObject()
|
Overlay.of(buttonContext).context.findRenderObject()
|
||||||
as RenderBox;
|
as RenderBox;
|
||||||
final position = button.localToGlobal(
|
final position = button.localToGlobal(
|
||||||
Offset.zero,
|
Offset.zero,
|
||||||
ancestor: overlay,
|
ancestor: overlay,
|
||||||
@ -2417,9 +2474,6 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
String normalizedStatus(dynamic value) {
|
|
||||||
return value?.toString().trim().toLowerCase() ?? '';
|
|
||||||
}
|
|
||||||
// Helper: Status cell with conditional actions
|
// Helper: Status cell with conditional actions
|
||||||
Widget _buildStatusCell(
|
Widget _buildStatusCell(
|
||||||
Map<String, dynamic> item,
|
Map<String, dynamic> item,
|
||||||
@ -2461,11 +2515,11 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
|
|
||||||
// Helper: Status display container
|
// Helper: Status display container
|
||||||
Widget _buildStatusContainer(
|
Widget _buildStatusContainer(
|
||||||
Map<String, dynamic> item,
|
Map<String, dynamic> item,
|
||||||
int id,
|
int id,
|
||||||
Color bgColor,
|
Color bgColor,
|
||||||
Color borderColor,
|
Color borderColor,
|
||||||
) {
|
) {
|
||||||
return Material(
|
return Material(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
@ -2484,13 +2538,7 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
(item['enquiry_status'] ?? '-')
|
item['enquiry_status'] ?? '-',
|
||||||
.toString()
|
|
||||||
.toLowerCase()
|
|
||||||
.split(' ')
|
|
||||||
.where((w) => w.isNotEmpty)
|
|
||||||
.map((w) => w[0].toUpperCase() + w.substring(1))
|
|
||||||
.join(' '),
|
|
||||||
style: GoogleFonts.inter(
|
style: GoogleFonts.inter(
|
||||||
fontSize: 10,
|
fontSize: 10,
|
||||||
color: Color(0XFF1e293b),
|
color: Color(0XFF1e293b),
|
||||||
@ -2645,7 +2693,7 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () => apiService.downloadFile(
|
onTap: () => apiService.downloadFile(
|
||||||
apiUrl:
|
apiUrl:
|
||||||
'api/policy/downloadPolicyFile?policy_id=${item["policy_id"]}&file_type=policy_pdf',
|
'api/policy/downloadPolicyFile?policy_id=${item["policy_id"]}&file_type=policy_pdf',
|
||||||
apiId: item["policy_id"],
|
apiId: item["policy_id"],
|
||||||
localFile: null,
|
localFile: null,
|
||||||
fileName: item['policy_pdf_file_name'],
|
fileName: item['policy_pdf_file_name'],
|
||||||
@ -2685,12 +2733,12 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
|
|
||||||
// Helper: Show policy upload menu
|
// Helper: Show policy upload menu
|
||||||
Future<void> _showPolicyUploadMenu(
|
Future<void> _showPolicyUploadMenu(
|
||||||
BuildContext buttonContext,
|
BuildContext buttonContext,
|
||||||
Map<String, dynamic> item,
|
Map<String, dynamic> item,
|
||||||
) async {
|
) async {
|
||||||
final button = buttonContext.findRenderObject() as RenderBox;
|
final button = buttonContext.findRenderObject() as RenderBox;
|
||||||
final overlay =
|
final overlay =
|
||||||
Overlay.of(buttonContext).context.findRenderObject() as RenderBox;
|
Overlay.of(buttonContext).context.findRenderObject() as RenderBox;
|
||||||
final position = button.localToGlobal(Offset.zero, ancestor: overlay);
|
final position = button.localToGlobal(Offset.zero, ancestor: overlay);
|
||||||
|
|
||||||
await showMenu(
|
await showMenu(
|
||||||
@ -2723,7 +2771,7 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
Widget _buildPolicyUploadField(Map<String, dynamic> item) {
|
Widget _buildPolicyUploadField(Map<String, dynamic> item) {
|
||||||
return ThemedUploadField(
|
return ThemedUploadField(
|
||||||
hintText:
|
hintText:
|
||||||
selectedFileNames ??
|
selectedFileNames ??
|
||||||
item['policy_pdf_file_name'] ??
|
item['policy_pdf_file_name'] ??
|
||||||
"Upload Document",
|
"Upload Document",
|
||||||
padHorizontal: 4,
|
padHorizontal: 4,
|
||||||
@ -2741,10 +2789,10 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
|
|
||||||
// Helper: Handle policy file upload
|
// Helper: Handle policy file upload
|
||||||
Future<void> _handlePolicyFileUpload(
|
Future<void> _handlePolicyFileUpload(
|
||||||
String? fileName,
|
String? fileName,
|
||||||
PlatformFile? file,
|
PlatformFile? file,
|
||||||
Map<String, dynamic> item,
|
Map<String, dynamic> item,
|
||||||
) async {
|
) async {
|
||||||
if (lastPickedFile == fileName) {
|
if (lastPickedFile == fileName) {
|
||||||
ToastHelper.showErrorToast(context, 'Please upload a new file.');
|
ToastHelper.showErrorToast(context, 'Please upload a new file.');
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -2786,7 +2834,7 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
Map<String, dynamic>? _getSelectedPaymentMode(Map<String, dynamic> item) {
|
Map<String, dynamic>? _getSelectedPaymentMode(Map<String, dynamic> item) {
|
||||||
try {
|
try {
|
||||||
return filteredPaymentModeData.firstWhere(
|
return filteredPaymentModeData.firstWhere(
|
||||||
(mode) => mode['id'].toString() == item['payment_mode_id'].toString(),
|
(mode) => mode['id'].toString() == item['payment_mode_id'].toString(),
|
||||||
orElse: () => {},
|
orElse: () => {},
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -2797,8 +2845,8 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
Map<String, dynamic>? _getSelectedInsurancePlan(Map<String, dynamic> item) {
|
Map<String, dynamic>? _getSelectedInsurancePlan(Map<String, dynamic> item) {
|
||||||
try {
|
try {
|
||||||
return filteredInsuranceData.firstWhere(
|
return filteredInsuranceData.firstWhere(
|
||||||
(mode) =>
|
(mode) =>
|
||||||
mode['insurance_plan_type'].toString().trim().toLowerCase() ==
|
mode['insurance_plan_type'].toString().trim().toLowerCase() ==
|
||||||
item['insurance_plan_type'].toString().trim().toLowerCase(),
|
item['insurance_plan_type'].toString().trim().toLowerCase(),
|
||||||
orElse: () => {},
|
orElse: () => {},
|
||||||
);
|
);
|
||||||
@ -2840,8 +2888,8 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
Widget _buildDropdownDisplay(dynamic selectedItem, String key, String hint) {
|
Widget _buildDropdownDisplay(dynamic selectedItem, String key, String hint) {
|
||||||
bool isEmpty =
|
bool isEmpty =
|
||||||
selectedItem == null ||
|
selectedItem == null ||
|
||||||
selectedItem.isEmpty ||
|
selectedItem.isEmpty ||
|
||||||
selectedItem[key] == null;
|
selectedItem[key] == null;
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
@ -3123,7 +3171,7 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
// borderRadius: BorderRadius.circular(6),
|
// borderRadius: BorderRadius.circular(6),
|
||||||
color: isSelected
|
color: isSelected
|
||||||
// ? Color(0xFFF1F5F9)
|
// ? Color(0xFFF1F5F9)
|
||||||
? const Color(0xFF2E7D6E).withOpacity(0.08)
|
? const Color(0xFF2E7D6E).withOpacity(0.08)
|
||||||
: Colors.transparent,
|
: Colors.transparent,
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
@ -3250,9 +3298,9 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
.split(' ')
|
.split(' ')
|
||||||
.map(
|
.map(
|
||||||
(word) => word.isNotEmpty
|
(word) => word.isNotEmpty
|
||||||
? word[0].toUpperCase() + word.substring(1).toLowerCase()
|
? word[0].toUpperCase() + word.substring(1).toLowerCase()
|
||||||
: '',
|
: '',
|
||||||
)
|
)
|
||||||
.join(' ');
|
.join(' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3460,8 +3508,8 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
icon: Icon(Icons.last_page, size: 18),
|
icon: Icon(Icons.last_page, size: 18),
|
||||||
onPressed: completedCurrentPage < totalCompletedPages
|
onPressed: completedCurrentPage < totalCompletedPages
|
||||||
? () => setState(
|
? () => setState(
|
||||||
() => completedCurrentPage = totalCompletedPages,
|
() => completedCurrentPage = totalCompletedPages,
|
||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
color: completedCurrentPage < totalCompletedPages
|
color: completedCurrentPage < totalCompletedPages
|
||||||
? Color(0xFF2E7D6E)
|
? Color(0xFF2E7D6E)
|
||||||
@ -3583,8 +3631,8 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
icon: Icon(Icons.last_page, size: 18),
|
icon: Icon(Icons.last_page, size: 18),
|
||||||
onPressed: completedCurrentPage < totalCompletedPages
|
onPressed: completedCurrentPage < totalCompletedPages
|
||||||
? () => setState(
|
? () => setState(
|
||||||
() => completedCurrentPage = totalCompletedPages,
|
() => completedCurrentPage = totalCompletedPages,
|
||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
color: completedCurrentPage < totalCompletedPages
|
color: completedCurrentPage < totalCompletedPages
|
||||||
? Color(0xFF2E7D6E)
|
? Color(0xFF2E7D6E)
|
||||||
@ -3650,4 +3698,4 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
|
|
||||||
return pageButtons;
|
return pageButtons;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -174,22 +174,23 @@ class ExcelExporter {
|
|||||||
final rowMap = reversedData[i];
|
final rowMap = reversedData[i];
|
||||||
final row = <CellValue?>[];
|
final row = <CellValue?>[];
|
||||||
|
|
||||||
|
// Inside ExcelExporter class -> exportToExcel method
|
||||||
for (var key in keys) {
|
for (var key in keys) {
|
||||||
dynamic value;
|
dynamic value;
|
||||||
if (key == 'sno' ||
|
|
||||||
key.toLowerCase() == 's.no' ||
|
if (key == 'sno' || key.toLowerCase() == 's.no' || key.toLowerCase() == 'sno.') {
|
||||||
key.toLowerCase() == 'sno.') {
|
value = i + 1;
|
||||||
value = i + 1; // serial number (descending)
|
|
||||||
} else if (key.toLowerCase() == 'is_active') {
|
} else if (key.toLowerCase() == 'is_active') {
|
||||||
// ✅ Handle Active/Inactive display
|
|
||||||
final rawVal = rowMap[key];
|
final rawVal = rowMap[key];
|
||||||
value = (rawVal == 1 || rawVal == '1') ? 'Active' : 'Inactive';
|
value = (rawVal == 1 || rawVal == '1') ? 'Active' : 'Inactive';
|
||||||
} else {
|
} else {
|
||||||
|
// FIX: Ensure we extract the value and check if it's "null" as a string
|
||||||
value = rowMap[key];
|
value = rowMap[key];
|
||||||
|
if (value == "null") value = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value == null) {
|
if (value == null || value.toString().trim().isEmpty) {
|
||||||
row.add(TextCellValue('-'));
|
row.add(TextCellValue('-')); // This ensures the column isn't empty
|
||||||
} else if (value is int) {
|
} else if (value is int) {
|
||||||
row.add(IntCellValue(value));
|
row.add(IntCellValue(value));
|
||||||
} else if (value is double) {
|
} else if (value is double) {
|
||||||
@ -198,10 +199,10 @@ class ExcelExporter {
|
|||||||
row.add(TextCellValue(value.toString()));
|
row.add(TextCellValue(value.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sheet.appendRow(row);
|
sheet.appendRow(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
final excelBytes = excel.encode();
|
final excelBytes = excel.encode();
|
||||||
if (excelBytes == null) throw Exception('Failed to encode Excel file');
|
if (excelBytes == null) throw Exception('Failed to encode Excel file');
|
||||||
|
|
||||||
|
|||||||
@ -282,7 +282,7 @@ class _DateFilterRowState extends ConsumerState<DateFilterRow> {
|
|||||||
'dd-MM-yyyy',
|
'dd-MM-yyyy',
|
||||||
).format(date);
|
).format(date);
|
||||||
// controllers['date']?.text = date as String;
|
// controllers['date']?.text = date as String;
|
||||||
Future.microtask(() => widget.onFilter());
|
// Future.microtask(() => widget.onFilter());
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user