HR_EXPORT_API_INTEGRATION
This commit is contained in:
parent
85e826e2ce
commit
dd8e9b5755
@ -9,6 +9,7 @@ import 'package:google_fonts/google_fonts.dart';
|
|||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:nhancepolicy/service/api_service.dart';
|
import 'package:nhancepolicy/service/api_service.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import 'package:universal_html/html.dart' as html;
|
import 'package:universal_html/html.dart' as html;
|
||||||
|
|
||||||
import '../../models/environment.dart';
|
import '../../models/environment.dart';
|
||||||
@ -31,9 +32,7 @@ class cdTransactionDetails extends StatefulWidget {
|
|||||||
required this.insurerId,
|
required this.insurerId,
|
||||||
required this.cd_ac_pk,
|
required this.cd_ac_pk,
|
||||||
required this.empClientId,
|
required this.empClientId,
|
||||||
required this.postToken
|
required this.postToken});
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<cdTransactionDetails> createState() => _cdTransactionDetailsState();
|
State<cdTransactionDetails> createState() => _cdTransactionDetailsState();
|
||||||
@ -93,14 +92,15 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
print('10');
|
print('10');
|
||||||
final response = await apiService.getCdTransactionData(
|
final response = await apiService.getCdTransactionData(widget.empClientId,
|
||||||
widget.empClientId, widget.insurerId,widget.cd_ac_pk, widget.postToken);
|
widget.insurerId, widget.cd_ac_pk, widget.postToken);
|
||||||
if (response['status'] == 'success') {
|
if (response['status'] == 'success') {
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
});
|
});
|
||||||
setState(() {
|
setState(() {
|
||||||
getCDTransData = List<Map<String, dynamic>>.from(response['data']['deposit_data']);
|
getCDTransData =
|
||||||
|
List<Map<String, dynamic>>.from(response['data']['deposit_data']);
|
||||||
originalData = getCDTransData;
|
originalData = getCDTransData;
|
||||||
filteredData = List.from(originalData);
|
filteredData = List.from(originalData);
|
||||||
total_deposit = response['data']['total_deposit'];
|
total_deposit = response['data']['total_deposit'];
|
||||||
@ -204,7 +204,19 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
List<List<String>> rows = [];
|
List<List<String>> rows = [];
|
||||||
|
|
||||||
// Header
|
// Header
|
||||||
rows.add(['Date', 'Record Date', 'Unit','Policy','Endorsement No','Sub Type','Credit','Debit','Balance','Description','User']);
|
rows.add([
|
||||||
|
'Date',
|
||||||
|
'Record Date',
|
||||||
|
'Unit',
|
||||||
|
'Policy',
|
||||||
|
'Endorsement No',
|
||||||
|
'Sub Type',
|
||||||
|
'Credit',
|
||||||
|
'Debit',
|
||||||
|
'Balance',
|
||||||
|
'Description',
|
||||||
|
'User'
|
||||||
|
]);
|
||||||
|
|
||||||
// Data rows
|
// Data rows
|
||||||
for (var item in data) {
|
for (var item in data) {
|
||||||
@ -212,8 +224,10 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
item['created_at'] ?? '',
|
item['created_at'] ?? '',
|
||||||
item['record_date'] ?? '',
|
item['record_date'] ?? '',
|
||||||
item['unit'] ?? '',
|
item['unit'] ?? '',
|
||||||
item['policy_type'] != null && item['policy_type'].toString().trim().isNotEmpty &&
|
item['policy_type'] != null &&
|
||||||
item['policy_no'] != null && item['policy_no'].toString().trim().isNotEmpty
|
item['policy_type'].toString().trim().isNotEmpty &&
|
||||||
|
item['policy_no'] != null &&
|
||||||
|
item['policy_no'].toString().trim().isNotEmpty
|
||||||
? '${item['policy_type']} - ${item['policy_no']}'
|
? '${item['policy_type']} - ${item['policy_no']}'
|
||||||
: '-',
|
: '-',
|
||||||
item['endorsement_no'] ?? '',
|
item['endorsement_no'] ?? '',
|
||||||
@ -237,6 +251,35 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
..setAttribute("download", "CD_Policies.csv")
|
..setAttribute("download", "CD_Policies.csv")
|
||||||
..click();
|
..click();
|
||||||
html.Url.revokeObjectUrl(url);
|
html.Url.revokeObjectUrl(url);
|
||||||
|
handleExportAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> handleExportAction() async {
|
||||||
|
print('handleExportAction');
|
||||||
|
|
||||||
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
|
final postId = prefs.getString('empHrId');
|
||||||
|
final preId = prefs.getString('enrollmentEmpPrimaryId');
|
||||||
|
var activity = "export_cdsummary";
|
||||||
|
|
||||||
|
print('postId - $postId');
|
||||||
|
print('preId - $preId');
|
||||||
|
print('activity - $activity');
|
||||||
|
|
||||||
|
try {
|
||||||
|
print('10');
|
||||||
|
final response = await apiService.getPostLogHrActivity(
|
||||||
|
postId!, preId!, widget.postToken, activity);
|
||||||
|
if (response['status'] == 'success') {
|
||||||
|
print('Request success');
|
||||||
|
} else {
|
||||||
|
// ToastHelper.showWarningToast(
|
||||||
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
|
print('Request failed with status: ${response['code']}');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
print('Exception occurred: $e');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String formatDate(String? dateString) {
|
String formatDate(String? dateString) {
|
||||||
@ -263,31 +306,31 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
// TODO: implement build
|
// TODO: implement build
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: CustomAppBar(),
|
appBar: CustomAppBar(),
|
||||||
backgroundColor: Color(0xFFEFF3F6),
|
backgroundColor: Color(0xFFEFF3F6),
|
||||||
body: Stack(
|
body: Stack(children: [
|
||||||
children: [
|
|
||||||
SingleChildScrollView(
|
SingleChildScrollView(
|
||||||
child: Container(
|
child: Container(
|
||||||
padding:
|
padding: EdgeInsets.only(
|
||||||
EdgeInsets.only(top: 30, bottom: 200, left: 50, right: 50),
|
top: 30, bottom: 200, left: 50, right: 50),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
MouseRegion(
|
MouseRegion(
|
||||||
cursor: SystemMouseCursors.click, // 👈 shows pointer on hover
|
cursor: SystemMouseCursors
|
||||||
|
.click, // 👈 shows pointer on hover
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.pop(context); // or your desired action
|
Navigator.pop(context); // or your desired action
|
||||||
},
|
},
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Icon(Icons.arrow_back_ios_new_outlined, color: Color(0xFF707070)),
|
Icon(Icons.arrow_back_ios_new_outlined,
|
||||||
|
color: Color(0xFF707070)),
|
||||||
SizedBox(width: 8),
|
SizedBox(width: 8),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
@ -307,18 +350,22 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
_buildInfoCard('Deposits', '₹$total_deposit', Color(0xFF39D45B), Icons.arrow_upward),
|
_buildInfoCard('Deposits', '₹$total_deposit',
|
||||||
_buildInfoCard('Consumed', '₹$total_consumed', Color(0xFFED1D24), Icons.arrow_downward),
|
Color(0xFF39D45B), Icons.arrow_upward),
|
||||||
_buildInfoCard('Refund', '₹$total_refund', Color(0xFF39D45B), Icons.arrow_upward),
|
_buildInfoCard('Consumed', '₹$total_consumed',
|
||||||
_buildInfoCard('Current Balance', '₹$currect_balance', Colors.black, null),
|
Color(0xFFED1D24), Icons.arrow_downward),
|
||||||
|
_buildInfoCard('Refund', '₹$total_refund',
|
||||||
|
Color(0xFF39D45B), Icons.arrow_upward),
|
||||||
|
_buildInfoCard('Current Balance', '₹$currect_balance',
|
||||||
|
Colors.black, null),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SizedBox(height: 16),
|
SizedBox(height: 16),
|
||||||
Container(
|
Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
borderRadius:
|
borderRadius: BorderRadius.circular(
|
||||||
BorderRadius.circular(10), // 👈 set your desired radius
|
10), // 👈 set your desired radius
|
||||||
),
|
),
|
||||||
// height: 400,
|
// height: 400,
|
||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.all(16.0),
|
||||||
@ -340,7 +387,8 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
child: TextField(
|
child: TextField(
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintText: 'Search',
|
hintText: 'Search',
|
||||||
prefixIcon: Icon(Icons.search, size: 18),
|
prefixIcon:
|
||||||
|
Icon(Icons.search, size: 18),
|
||||||
contentPadding: EdgeInsets.symmetric(
|
contentPadding: EdgeInsets.symmetric(
|
||||||
horizontal: 12, vertical: 8),
|
horizontal: 12, vertical: 8),
|
||||||
border: InputBorder
|
border: InputBorder
|
||||||
@ -348,7 +396,8 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
),
|
),
|
||||||
controller: searchController,
|
controller: searchController,
|
||||||
onChanged: search,
|
onChanged: search,
|
||||||
style: GoogleFonts.poppins(fontSize: 14),
|
style:
|
||||||
|
GoogleFonts.poppins(fontSize: 14),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -368,10 +417,12 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
},
|
},
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: Color(0xFFE26728),
|
backgroundColor: Color(0xFFE26728),
|
||||||
padding: EdgeInsets.all(10), // Internal padding
|
padding: EdgeInsets.all(
|
||||||
|
10), // Internal padding
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius:
|
borderRadius:
|
||||||
BorderRadius.circular(10), // Border radius
|
BorderRadius.circular(
|
||||||
|
10), // Border radius
|
||||||
side: BorderSide(
|
side: BorderSide(
|
||||||
color: Colors
|
color: Colors
|
||||||
.transparent, // Optional border color
|
.transparent, // Optional border color
|
||||||
@ -409,9 +460,7 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
)
|
))),
|
||||||
)
|
|
||||||
),
|
|
||||||
if (isLoading)
|
if (isLoading)
|
||||||
Container(
|
Container(
|
||||||
color: Color(0x98FFFCE5), // Semi-transparent background
|
color: Color(0x98FFFCE5), // Semi-transparent background
|
||||||
@ -430,12 +479,11 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
child: CustomFooter(),
|
child: CustomFooter(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
]
|
]));
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildInfoCard(String label, String value, Color iconColor, IconData? icon) {
|
Widget _buildInfoCard(
|
||||||
|
String label, String value, Color iconColor, IconData? icon) {
|
||||||
return Expanded(
|
return Expanded(
|
||||||
child: Container(
|
child: Container(
|
||||||
margin: EdgeInsets.symmetric(horizontal: 4),
|
margin: EdgeInsets.symmetric(horizontal: 4),
|
||||||
@ -454,17 +502,20 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween, // label left, value right
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.spaceBetween, // label left, value right
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
label,
|
label,
|
||||||
style: GoogleFonts.poppins(color: Color(0xFF737373), fontSize: 14,fontWeight: FontWeight.w400),
|
style: GoogleFonts.poppins(
|
||||||
|
color: Color(0xFF737373),
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.w400),
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
if (icon != null)
|
if (icon != null) Icon(icon, size: 20, color: iconColor),
|
||||||
Icon(icon, size: 20, color: iconColor),
|
|
||||||
if (icon != null) SizedBox(width: 4),
|
if (icon != null) SizedBox(width: 4),
|
||||||
Text(
|
Text(
|
||||||
value,
|
value,
|
||||||
@ -484,7 +535,6 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Widget _buildCDDataTable(BuildContext context) {
|
Widget _buildCDDataTable(BuildContext context) {
|
||||||
if (filteredData.isEmpty) {
|
if (filteredData.isEmpty) {
|
||||||
return const SizedBox(
|
return const SizedBox(
|
||||||
@ -657,8 +707,10 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
flex: 3,
|
flex: 3,
|
||||||
child: Text(
|
child: Text(
|
||||||
// 'Motor - 3001/379707905/00/000',
|
// 'Motor - 3001/379707905/00/000',
|
||||||
item['policy_type'] != null && item['policy_type'].toString().trim().isNotEmpty &&
|
item['policy_type'] != null &&
|
||||||
item['policy_no'] != null && item['policy_no'].toString().trim().isNotEmpty
|
item['policy_type'].toString().trim().isNotEmpty &&
|
||||||
|
item['policy_no'] != null &&
|
||||||
|
item['policy_no'].toString().trim().isNotEmpty
|
||||||
? '${item['policy_type']} - ${item['policy_no']}'
|
? '${item['policy_type']} - ${item['policy_no']}'
|
||||||
: '-',
|
: '-',
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
@ -684,7 +736,9 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
Expanded(
|
Expanded(
|
||||||
flex: 2,
|
flex: 2,
|
||||||
child: Text(
|
child: Text(
|
||||||
item['transaction_type'] == 'Credit' ? '₹${item['amount']}' : '-',
|
item['transaction_type'] == 'Credit'
|
||||||
|
? '₹${item['amount']}'
|
||||||
|
: '-',
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
style: GoogleFonts.poppins(color: Color(0xFF000000)),
|
style: GoogleFonts.poppins(color: Color(0xFF000000)),
|
||||||
),
|
),
|
||||||
@ -692,7 +746,9 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
Expanded(
|
Expanded(
|
||||||
flex: 2,
|
flex: 2,
|
||||||
child: Text(
|
child: Text(
|
||||||
item['transaction_type'] == 'Debit' ? '₹${item['amount']}' : '-',
|
item['transaction_type'] == 'Debit'
|
||||||
|
? '₹${item['amount']}'
|
||||||
|
: '-',
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
style: GoogleFonts.poppins(color: Color(0xFF000000)),
|
style: GoogleFonts.poppins(color: Color(0xFF000000)),
|
||||||
),
|
),
|
||||||
@ -806,8 +862,6 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Sample Data class representing each element in the array
|
// Sample Data class representing each element in the array
|
||||||
class Data {
|
class Data {
|
||||||
final dynamic value;
|
final dynamic value;
|
||||||
|
|||||||
@ -279,6 +279,45 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
..setAttribute("download", "CD_Policies.csv")
|
..setAttribute("download", "CD_Policies.csv")
|
||||||
..click();
|
..click();
|
||||||
html.Url.revokeObjectUrl(url);
|
html.Url.revokeObjectUrl(url);
|
||||||
|
handleExportAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> handleExportAction() async {
|
||||||
|
print('handleExportAction');
|
||||||
|
|
||||||
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
|
final postId = prefs.getString('empHrId');
|
||||||
|
final preId = prefs.getString('enrollmentEmpPrimaryId');
|
||||||
|
var activity = "export_empdata";
|
||||||
|
|
||||||
|
var activityPre = "export_preempdata";
|
||||||
|
dynamic response;
|
||||||
|
|
||||||
|
print('postId - $postId');
|
||||||
|
print('preId - $preId');
|
||||||
|
print('activity - $activity');
|
||||||
|
|
||||||
|
try {
|
||||||
|
print('10');
|
||||||
|
|
||||||
|
if (widget.TokenType == 'pre') {
|
||||||
|
response = await apiService.getPreLogHrActivity(
|
||||||
|
postId!, preId!, widget.Token, activityPre);
|
||||||
|
} else if (widget.TokenType == 'post') {
|
||||||
|
response = await apiService.getPostLogHrActivity(
|
||||||
|
postId!, preId!, widget.Token, activity);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (response['status'] == 'success') {
|
||||||
|
print('Request success');
|
||||||
|
} else {
|
||||||
|
// ToastHelper.showWarningToast(
|
||||||
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
|
print('Request failed with status: ${response['code']}');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
print('Exception occurred: $e');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String _capitalize(String? value) {
|
String _capitalize(String? value) {
|
||||||
@ -359,8 +398,9 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
widget.TokenType == 'pre' ? "${widget.cardPolicy_name} (${widget.cardPolicy_ExpDate})" :
|
widget.TokenType == 'pre'
|
||||||
"${widget.cardInsurer_name} - ${widget.cardPolicy_name} (${widget.cardPolicy_ExpDate})",
|
? "${widget.cardPolicy_name} (${widget.cardPolicy_ExpDate})"
|
||||||
|
: "${widget.cardInsurer_name} - ${widget.cardPolicy_name} (${widget.cardPolicy_ExpDate})",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
color: Colors.grey,
|
color: Colors.grey,
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
|
|||||||
@ -461,6 +461,81 @@ class ApiService {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> getPostLogHrActivity(
|
||||||
|
String? postId, String? preId, String token, String activity) async {
|
||||||
|
print("getCashDepositDetailsToApi1");
|
||||||
|
|
||||||
|
print('postId1 - $postId');
|
||||||
|
print('preId1 - $preId');
|
||||||
|
print('activity1 - $activity');
|
||||||
|
|
||||||
|
// final url = Uri.parse(
|
||||||
|
// '${Environment.apiUrlPost}logHrActivity?user_id=$postId&pre_hr_id=$preId&user_type=hr&activity=$activity');
|
||||||
|
|
||||||
|
final url = Uri.parse('${Environment.apiUrlPost}logHrActivity');
|
||||||
|
|
||||||
|
final headers = {
|
||||||
|
'Authorization': 'Bearer $token' ?? '',
|
||||||
|
};
|
||||||
|
|
||||||
|
final body = {
|
||||||
|
'user_id': postId,
|
||||||
|
'pre_hr_id': preId,
|
||||||
|
'user_type': 'hr',
|
||||||
|
'activity': activity,
|
||||||
|
};
|
||||||
|
|
||||||
|
final response = await http.post(
|
||||||
|
url,
|
||||||
|
headers: headers,
|
||||||
|
body: jsonEncode(body),
|
||||||
|
);
|
||||||
|
|
||||||
|
// final response = await _makeGetRequest(url, headers);
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
return jsonDecode(response.body);
|
||||||
|
} else {
|
||||||
|
throw Exception(
|
||||||
|
'Failed to log HR activity: ${response.statusCode} ${response.body}');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> getPreLogHrActivity(
|
||||||
|
String? postId, String? preId, String token, String activity) async {
|
||||||
|
print("getCashDepositDetailsToApi1");
|
||||||
|
|
||||||
|
print('postId1 - $postId');
|
||||||
|
print('preId1 - $preId');
|
||||||
|
print('activity1 - $activity');
|
||||||
|
|
||||||
|
final url = Uri.parse('${Environment.apiUrl}logHrActivity');
|
||||||
|
|
||||||
|
final headers = {
|
||||||
|
'Authorization': 'Bearer $token' ?? '',
|
||||||
|
};
|
||||||
|
|
||||||
|
final body = {
|
||||||
|
'user_id': postId,
|
||||||
|
'pre_hr_id': preId,
|
||||||
|
'user_type': 'hr',
|
||||||
|
'activity': activity,
|
||||||
|
};
|
||||||
|
|
||||||
|
final response = await http.post(
|
||||||
|
url,
|
||||||
|
headers: headers,
|
||||||
|
body: jsonEncode(body),
|
||||||
|
);
|
||||||
|
|
||||||
|
// final response = await _makeGetRequest(url, headers);
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
return jsonDecode(response.body);
|
||||||
|
} else {
|
||||||
|
throw Exception(
|
||||||
|
'Failed to log HR activity: ${response.statusCode} ${response.body}');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<Map<String, dynamic>> getClaimPoliciesToApi(String token) async {
|
Future<Map<String, dynamic>> getClaimPoliciesToApi(String token) async {
|
||||||
print("getgetClaimPoliciesToApii1");
|
print("getgetClaimPoliciesToApii1");
|
||||||
final url = Uri.parse('${Environment.apiUrlPost}claimsSearch');
|
final url = Uri.parse('${Environment.apiUrlPost}claimsSearch');
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import 'package:universal_html/html.dart' as html;
|
import 'package:universal_html/html.dart' as html;
|
||||||
|
|
||||||
import '../../cdTransactionDetails.dart';
|
import '../../cdTransactionDetails.dart';
|
||||||
@ -182,6 +183,35 @@ class _CdPolicieState extends State<CdPolicies> {
|
|||||||
..setAttribute("download", "CD_Policies.csv")
|
..setAttribute("download", "CD_Policies.csv")
|
||||||
..click();
|
..click();
|
||||||
html.Url.revokeObjectUrl(url);
|
html.Url.revokeObjectUrl(url);
|
||||||
|
handleExportAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> handleExportAction() async {
|
||||||
|
print('handleExportAction');
|
||||||
|
|
||||||
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
|
final postId = prefs.getString('empHrId');
|
||||||
|
final preId = prefs.getString('enrollmentEmpPrimaryId');
|
||||||
|
var activity = "export_cddata";
|
||||||
|
|
||||||
|
print('postId - $postId');
|
||||||
|
print('preId - $preId');
|
||||||
|
print('activity - $activity');
|
||||||
|
|
||||||
|
try {
|
||||||
|
print('10');
|
||||||
|
final response = await apiService.getPostLogHrActivity(
|
||||||
|
postId!, preId!, widget.postToken, activity);
|
||||||
|
if (response['status'] == 'success') {
|
||||||
|
print('Request success');
|
||||||
|
} else {
|
||||||
|
// ToastHelper.showWarningToast(
|
||||||
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
|
print('Request failed with status: ${response['code']}');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
print('Exception occurred: $e');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user