Merge code

This commit is contained in:
sanjeev.p 2025-12-29 11:32:57 +05:30
parent a86263ce6b
commit 09dcf56c5b
3 changed files with 72 additions and 7 deletions

File diff suppressed because one or more lines are too long

View File

@ -459,7 +459,7 @@ class ApiService {
} else if (path == 'staff_pending_summary') {
pathVal = 'dashboard/downloadStaffPendingSummaryExcel?manager_id=$managerId';
} else if (path == 'staff_pending_summary_by_id') {
pathVal = 'dashboard/downloadStaffPendingSummaryExcelByID?manager_id=$managerId&staff_id=$id';
pathVal = 'dashboard/downloadStaffPendingSummaryExcelByID?manager_id=$managerId&staff_id=$id&status=$month';
} else {
//NoBusiness
pathVal =

View File

@ -113,8 +113,7 @@ class _DashboardState extends ConsumerState<LiveDashboard> {
Future<void> getExportExcel() async {
final prefmanagerid = ref.read(managerIdProvider);
final path = "staff_level_pending_summary";
final path = "staff_pending_summary";
final id = '';
final month = 'current';
@ -131,6 +130,32 @@ class _DashboardState extends ConsumerState<LiveDashboard> {
}
}
Future<void> getExportExcel2(String status, String staffId) async {
final prefmanagerid = ref.read(managerIdProvider);
// Use the parameters passed from the widget
final path = "staff_pending_summary_by_id";
final id = staffId;
final month = status;
try {
setState(() => isLoading = true);
final response = await apiService.generateChartExcel(
path,
id,
month,
prefmanagerid
);
return response;
} catch (e) {
print('Export Error: $e');
} finally {
if (mounted) setState(() => isLoading = false);
}
}
Future<void> handleEdit(String id) async {
// Navigator.pop(context);
print('EDITStaff');
@ -583,6 +608,7 @@ class _DashboardState extends ConsumerState<LiveDashboard> {
role: role!,
onRefresh: refresh,
onExportExcel: getExportExcel,
onCallExport: getExportExcel2,
),
),
// if (role == 'handler') ...[
@ -1186,6 +1212,7 @@ class othersPendings extends StatelessWidget {
final List<Map<String, dynamic>> data;
final VoidCallback? onRefresh;
VoidCallback? onExportExcel;
final Future<void> Function(String status, String staffId)? onCallExport;
othersPendings({
Key? key,
@ -1195,6 +1222,7 @@ class othersPendings extends StatelessWidget {
required this.stringFlag,
required this.onRefresh,
this.onExportExcel,
this.onCallExport,
}) : super(key: key);
@override
@ -1459,7 +1487,7 @@ class othersPendings extends StatelessWidget {
child: Center(
child: InkWell(
hoverColor: Color(0xFFEAF6F4),
onTap: () {
onTap: () async {
print(
'total_assigned_today : ${row['total_assigned']}',
);
@ -1471,6 +1499,12 @@ class othersPendings extends StatelessWidget {
staffId: row['staff_id'] ?? '',
role: role,
);
if (onCallExport != null) {
await onCallExport!(
"TodayAssigned",
row['staff_id'].toString(),
);
}
},
child: Text(
row['today_assigned'] ?? "",
@ -1489,7 +1523,7 @@ class othersPendings extends StatelessWidget {
child: Center(
child: InkWell(
hoverColor: Color(0xFFEAF6F4),
onTap: () {
onTap: () async {
print(
'total_assigned : ${row['total_assigned']}',
);
@ -1500,6 +1534,12 @@ class othersPendings extends StatelessWidget {
staffId: row['staff_id'] ?? '',
role: role,
);
if (onCallExport != null) {
await onCallExport!(
"Assigned",
row['staff_id'].toString(),
);
}
},
child: Text(
row['today_pending'] ?? "",
@ -1518,7 +1558,7 @@ class othersPendings extends StatelessWidget {
child: Center(
child: InkWell(
// hoverColor: Color(0xFFEAF6F4),
onTap: () {
onTap: () async {
print(
'Awaiting Proposal : ${row['total_in_progress']}',
);
@ -1529,6 +1569,13 @@ class othersPendings extends StatelessWidget {
staffId: row['staff_id'] ?? '',
role: role,
);
if (onCallExport != null) {
await onCallExport!(
'InProgress',
row['staff_id'].toString(),
);
}
},
child: Text(
@ -1558,6 +1605,12 @@ class othersPendings extends StatelessWidget {
staffId: row['staff_id'] ?? '',
role: role,
);
if (onCallExport != null) {
await onCallExport!(
'Completed',
row['staff_id'].toString(),
);
}
},
child: Text(
row['today_completed'] ?? "",
@ -1586,6 +1639,16 @@ class othersPendings extends StatelessWidget {
staffId: row['staff_id'] ?? '',
role: role,
);
// 2. Call the Export function
// We use await here so the 'isLoading' state is respected
// and errors are caught properly.
if (onCallExport != null) {
await onCallExport!(
'PrevPending',
row['staff_id'].toString(),
);
}
},
child: Text(
safePending.toString() ?? "",
@ -2230,6 +2293,8 @@ Future<void> handleDashboardNavigation(
// }
}
final _headerStyle = GoogleFonts.inter(
fontWeight: FontWeight.w600,
fontSize: 11.5,