Commit e54f0aeb authored by Sai Srinivas's avatar Sai Srinivas
Browse files

17-05-2025 By Sai Srinivas

Common Module
parent f7b0d1aa
import 'package:dropdown_button2/dropdown_button2.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:generp/Models/financeModels/addReceiptPaymentResponse.dart';
import 'package:provider/provider.dart';
import '../../Notifiers/financeProvider/paymentReceiptsProvider.dart';
import '../../Utils/app_colors.dart';
import '../../Utils/commonWidgets.dart';
class Addpaymentreceiptlist extends StatefulWidget {
final pageTitleName;
const Addpaymentreceiptlist({super.key, this.pageTitleName});
@override
State<Addpaymentreceiptlist> createState() => _AddpaymentreceiptlistState();
}
class _AddpaymentreceiptlistState extends State<Addpaymentreceiptlist> {
@override
void initState() {
// TODO: implement initState
super.initState();
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
var provider = Provider.of<Paymentreceiptsprovider>(
context,
listen: false,
);
provider.addReceiptPaymentRequestionViewAPI(context);
});
}
@override
void dispose() {
super.dispose();
}
Future<bool> _onBackPressed(BuildContext context) async {
Navigator.pop(context, true);
return true;
}
@override
Widget build(BuildContext context) {
return Consumer<Paymentreceiptsprovider>(
builder: (context, provider, child) {
return WillPopScope(
child: Scaffold(
backgroundColor: AppColors.white,
appBar: appbar(context, "${widget.pageTitleName}"),
body: Container(
padding: EdgeInsets.symmetric(horizontal: 10),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(20),
),
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextWidget(context, "Account"),
DropdownButtonHideUnderline(
child: Row(
children: [
Expanded(
child: DropdownButton2<Accounts>(
isExpanded: true,
hint: Text(
'Select Account Type',
style: TextStyle(fontSize: 14),
overflow: TextOverflow.ellipsis,
),
items:
provider.receiptAccounts
.map(
(accs) =>
DropdownMenuItem<Accounts>(
value: accs,
child: Text(
accs.name ?? '',
style: const TextStyle(
fontSize: 14,
),
overflow: TextOverflow.ellipsis,
),
),
)
.toList(),
value: provider.selectreceiptAccounts,
onChanged: (Accounts? value) {
if (value != null) {
if (provider.receiptAccounts.isNotEmpty) {
provider.selectreceiptAccounts = value;
print(
"Selected Complaint Type: ${value.name}, ID: ${value.id}",
);
provider.receiptAccountId = value.id!;
provider.receiptAccountValue = value.name!;
print(
"hfjkshfg" +
provider.receiptAccountId.toString(),
);
}
}
},
buttonStyleData: ButtonStyleData(
height: 50,
width: 160,
padding: const EdgeInsets.only(
left: 14,
right: 14,
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(14),
color: AppColors.text_field_color,
),
),
iconStyleData: const IconStyleData(
icon: Icon(Icons.keyboard_arrow_down),
iconSize: 12,
iconEnabledColor: Color(0xFF2D2D2D),
iconDisabledColor: Colors.grey,
),
dropdownStyleData: DropdownStyleData(
maxHeight: 200,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(14),
color: AppColors.text_field_color,
),
scrollbarTheme: ScrollbarThemeData(
radius: const Radius.circular(15),
thickness: MaterialStateProperty.all<double>(
6,
),
thumbVisibility:
MaterialStateProperty.all<bool>(true),
),
),
menuItemStyleData: const MenuItemStyleData(
height: 40,
padding: EdgeInsets.only(left: 14, right: 14),
),
),
),
],
),
),
TextWidget(context, "Payment Account"),
DropdownButtonHideUnderline(
child: Row(
children: [
Expanded(
child: DropdownButton2<ReceiptAccounts>(
isExpanded: true,
hint: Text(
'Select Account Type',
style: TextStyle(fontSize: 14),
overflow: TextOverflow.ellipsis,
),
items:
provider.receiptPaymentAccounts
.map(
(accs) => DropdownMenuItem<
ReceiptAccounts
>(
value: accs,
child: Text(
accs.name ?? '',
style: const TextStyle(
fontSize: 14,
),
overflow: TextOverflow.ellipsis,
),
),
)
.toList(),
value: provider.selectreceiptPaymentAccounts,
onChanged: (ReceiptAccounts? value) {
if (value != null) {
if (provider
.receiptPaymentAccounts
.isNotEmpty) {
provider.selectreceiptPaymentAccounts =
value;
print(
"Selected Complaint Type: ${value.name}, ID: ${value.id}",
);
provider.receiptPaymentAccountsID =
value.id!;
provider.receiptPaymentAccountsValue =
value.name!;
print(
"hfjkshfg" +
provider.receiptPaymentAccountsID
.toString(),
);
}
}
},
buttonStyleData: ButtonStyleData(
height: 50,
width: 160,
padding: const EdgeInsets.only(
left: 14,
right: 14,
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(14),
color: AppColors.text_field_color,
),
),
iconStyleData: const IconStyleData(
icon: Icon(Icons.keyboard_arrow_down),
iconSize: 12,
iconEnabledColor: Color(0xFF2D2D2D),
iconDisabledColor: Colors.grey,
),
dropdownStyleData: DropdownStyleData(
maxHeight: 200,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(14),
color: AppColors.text_field_color,
),
scrollbarTheme: ScrollbarThemeData(
radius: const Radius.circular(15),
thickness: MaterialStateProperty.all<double>(
6,
),
thumbVisibility:
MaterialStateProperty.all<bool>(true),
),
),
menuItemStyleData: const MenuItemStyleData(
height: 40,
padding: EdgeInsets.only(left: 14, right: 14),
),
),
),
],
),
),
textControllerWidget(
context,
provider.amountController,
"Enter Amount",
provider.updateAmount,
),
///payment date toBE
TextWidget(context, "Receipt Date"),
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: InkResponse(
onTap: () async {
provider.showDatePickerDialog(context);
},
child: Container(
padding: EdgeInsets.only(left: 10),
height:48,
alignment: Alignment.centerLeft,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(14),
color: AppColors.text_field_color
),
child: Text(
'${provider.formattedDate ?? 'Select Date'}',
style: TextStyle(
fontSize: 14,
fontFamily:
"JakartaMedium",
color: AppColors.semi_black,
),
),
),
),
),
],
),
TextWidget(context, "Select Payment Mode"),
DropdownButtonHideUnderline(
child: Row(
children: [
Expanded(
child: DropdownButton2<PaymentModes>(
isExpanded: true,
hint: Text(
'Select Payment mode',
style: TextStyle(fontSize: 14),
overflow: TextOverflow.ellipsis,
),
items:
provider.receiptPaymentModes
.map(
(paymenents) => DropdownMenuItem<
PaymentModes
>(
value: paymenents,
child: Text(
paymenents.name ?? '',
style: const TextStyle(
fontSize: 14,
),
overflow: TextOverflow.ellipsis,
),
),
)
.toList(),
value: provider.selectreceiptPaymentModes,
onChanged: (PaymentModes? value) {
if (value != null) {
if (provider.receiptPaymentModes.isNotEmpty) {
provider.selectreceiptPaymentModes = value;
print(
"Selected Complaint Type: ${value.name}, ID: ${value.id}",
);
provider.receiptPaymentModesID = value.id!;
provider.receiptPaymentModesValues =
value.name!;
print(
"hfjkshfg" +
provider.receiptPaymentModesID
.toString(),
);
}
}
},
buttonStyleData: ButtonStyleData(
height: 50,
width: 160,
padding: const EdgeInsets.only(
left: 14,
right: 14,
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(14),
color: AppColors.text_field_color,
),
),
iconStyleData: const IconStyleData(
icon: Icon(Icons.keyboard_arrow_down),
iconSize: 12,
iconEnabledColor: Color(0xFF2D2D2D),
iconDisabledColor: Colors.grey,
),
dropdownStyleData: DropdownStyleData(
maxHeight: 200,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(14),
color: AppColors.text_field_color,
),
scrollbarTheme: ScrollbarThemeData(
radius: const Radius.circular(15),
thickness: MaterialStateProperty.all<double>(
6,
),
thumbVisibility:
MaterialStateProperty.all<bool>(true),
),
),
menuItemStyleData: const MenuItemStyleData(
height: 40,
padding: EdgeInsets.only(left: 14, right: 14),
),
),
),
],
),
),
if ([
"Cheque",
"RTGS",
"IMPS",
"NEFT",
].contains(provider.paymentModeValue)) ...
[
textControllerWidget(
context,
provider.bankNameController,
"Enter Bank Name",
provider.updateBankName,
),
textControllerWidget(
context,
provider.bankBranchController,
"Enter Bank Branch",
provider.updateBankBranch,
),
textControllerWidget(
context,
provider.bankAccNumberController,
"Enter Account Number",
provider.updateNumber,
),
textControllerWidget(
context,
provider.bankIfscController,
"Enter Bank IFSC",
provider.updateIFSC,
),
textControllerWidget(
context,
provider.bankAcHolderController,
"Enter Bank Account Holder Name",
provider.updateHolder,
),
] else if (provider.paymentModeValue == "UPI") ...
[
textControllerWidget(
context,
provider.amountController,
"Enter UPI ID",
provider.updateUPI,
),
],
textControllerWidget(
context,
provider.paymentReferenceController,
"Enter Payment Reference Number",
provider.updateDescription,
),
textControllerWidget(
context,
provider.descController,
"Enter Description",
provider.updateDescription,
),
InkResponse(
onTap: () {
_showAttachmentSheet(context);
},
child: Container(
margin: EdgeInsets.symmetric(vertical: 10),
height: 45,
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
color: Color(0xFFE6F6FF),
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: AppColors.app_blue,
width: 0.5,
),
),
child: Center(
child: Text(
"File Attachment",
style: TextStyle(
fontFamily: "JakartaMedium",
color: AppColors.app_blue,
),
),
),
),
),
],
),
),
),
floatingActionButtonLocation:
FloatingActionButtonLocation.centerFloat,
bottomNavigationBar: InkResponse(
onTap: () {
// provider.submitClicked = true;
provider.addReceiptPaymentRequestionSubmitAPI(context, provider.formattedDate);
},
child: Container(
height: 45,
alignment: Alignment.center,
margin: EdgeInsets.symmetric(horizontal: 10),
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 5),
decoration: BoxDecoration(
color: AppColors.app_blue,
borderRadius: BorderRadius.circular(15),
),
child: Text(
"Submit",
style: TextStyle(
fontSize: 15,
fontFamily: "JakartaMedium",
color: Colors.white,
),
),
),
),
),
onWillPop: () {
provider.resetForm();
return onBackPressed(context);
},
);
},
);
}
void _showDialog(Widget child) {
showCupertinoModalPopup<void>(
context: context,
builder: (BuildContext context) => Container(
height: 216,
padding: const EdgeInsets.only(top: 6.0),
// The Bottom margin is provided to align the popup above the system
// navigation bar.
margin: EdgeInsets.only(
bottom: MediaQuery.of(context).viewInsets.bottom,
),
// Provide a background color for the popup.
color: CupertinoColors.systemBackground.resolveFrom(context),
// Use a SafeArea widget to avoid system overlaps.
child: SafeArea(
top: false,
child: Column(
children: [
Expanded(
flex: 1,
child: SizedBox(
height: 40,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
// Add a Cancel button (optional)
CupertinoButton(
child: Text(
'Cancel',
style: TextStyle(fontFamily: "JakartaMedium"),
),
onPressed: () {
Navigator.pop(context);
},
),
// Add a Done button
CupertinoButton(
child: Text('Done',
style: TextStyle(fontFamily: "JakartaMedium")),
onPressed: () {
Navigator.pop(context); // Dismiss the dialog
},
),
],
),
),
),
Expanded(flex: 3, child: child),
],
),
),
),
);
}
Widget TextWidget(context, text) {
return Padding(
padding: const EdgeInsets.only(bottom: 5.0, top: 8.0),
child: Text(text),
);
}
Widget ErrorWidget(context, text) {
if (text != null)
return Text(text!, style: TextStyle(color: Colors.red, fontSize: 12));
else
return SizedBox(height: 10);
}
Widget textControllerWidget(
context,
controller,
hintText,
Function(String)? onChanged,
) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(bottom: 5.0, top: 8.0),
child: Text(hintText),
),
Container(
height: hintText == "Enter Description" ? 150 : 50,
alignment: Alignment.center,
decoration: BoxDecoration(
color: AppColors.text_field_color,
borderRadius: BorderRadius.circular(14),
),
child: Padding(
padding: const EdgeInsets.fromLTRB(10.0, 0.0, 10, 0),
child: TextFormField(
controller: controller,
keyboardType: TextInputType.text,
maxLines: hintText == "Enter Description" ? 60 : 1,
onChanged: onChanged,
decoration: InputDecoration(
hintText: hintText,
hintStyle: TextStyle(
fontWeight: FontWeight.w400,
color: Color(0xFFB4BEC0),
fontSize: 14,
),
enabledBorder: InputBorder.none,
focusedBorder: InputBorder.none,
),
),
),
),
],
);
}
Future<void> _showAttachmentSheet(BuildContext context) {
return showModalBottomSheet(
useSafeArea: true,
isDismissible: true,
isScrollControlled: true,
showDragHandle: true,
backgroundColor: Colors.white,
enableDrag: true,
context: context,
builder: (context) {
return StatefulBuilder(
builder: (context, setState) {
return SafeArea(
child: Consumer<Paymentreceiptsprovider>(
builder: (context, provider, child) {
return Padding(
padding: EdgeInsets.only(
bottom:
MediaQuery.of(
context,
).viewInsets.bottom, // This handles keyboard
),
child: Container(
margin: EdgeInsets.only(
bottom: 15,
left: 15,
right: 15,
top: 10,
),
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Align(
alignment: Alignment.center,
child: Text(
"Select Source",
style: TextStyle(
color: AppColors.app_blue,
fontFamily: "JakrtaMedium",
fontSize: 16,
),
),
),
SizedBox(height: 15),
InkWell(
onTap: () {
Navigator.of(context).pop(false);
provider.imgFromGallery(context);
},
child: Container(
height: 35,
child: Text("Select photo from gallery"),
),
),
SizedBox(height: 10),
InkWell(
onTap: () {
Navigator.of(context).pop(false);
provider.imgFromCamera(context);
},
child: Container(
height: 35,
child: Text("Capture photo from camera"),
),
),
],
),
),
),
);
},
),
);
},
);
},
);
}
}
......@@ -4,6 +4,7 @@ import 'package:generp/Notifiers/financeProvider/DashboardProvider.dart';
import 'package:generp/Utils/app_colors.dart';
import 'package:generp/Utils/commonWidgets.dart';
import 'package:generp/screens/finance/AllPaymentRequesitionListsByModes.dart';
import 'package:generp/screens/finance/addPaymentReceiptList.dart';
import 'package:generp/screens/finance/directPaymentRequesitionList.dart';
import 'package:generp/screens/finance/paymentListPaymentRequisition.dart';
import 'package:generp/screens/finance/paymentreceiptList.dart';
......@@ -238,6 +239,24 @@ class _FinancedashboardState extends State<Financedashboard> {
),
),
);
}else if (provider
.accessiblePagesList2[index]
.pageName ==
"Add Payment Receipt") {
res = await Navigator.push(
context,
MaterialPageRoute(
builder:
(
context,
) => Addpaymentreceiptlist(
pageTitleName:
provider
.accessiblePagesList2[index]
.pageName!,
),
),
);
} else {
res = await Navigator.push(
context,
......
......@@ -7,6 +7,7 @@ import 'package:provider/provider.dart';
import '../../Notifiers/financeProvider/paymentRequisitionPaymentsListProvider.dart';
import '../../Utils/app_colors.dart';
import '../../Utils/commonWidgets.dart';
import '../commonDateRangeFilter.dart';
import 'FileViewer.dart';
class Paymentlistpaymentrequisition extends StatefulWidget {
......@@ -28,7 +29,7 @@ class _PaymentlistpaymentrequisitionState extends State<Paymentlistpaymentrequis
context,
listen: false,
);
provider.paymentsListAPI(context);
provider.paymentsListAPI(context,'','');
});
}
......@@ -53,6 +54,34 @@ class _PaymentlistpaymentrequisitionState extends State<Paymentlistpaymentrequis
},
child: Icon(CupertinoIcons.down_arrow),
),
InkResponse(
onTap: () async {
var cf = Commondaterangefilter();
var result = await cf.showFilterBottomSheet(context);
if (result != null) {
var dateRange = result['dateRange'] as DateTimeRange?;
print("dateRange: $dateRange");
var formatted = result['formatted'] as List<String>;
print("formatted: $formatted");
if (formatted.isNotEmpty) {
var fromDate = formatted[0]; // From date
var toDate = formatted[1]; // To date
print("from_date: $fromDate");
print("to_date: $toDate");
provider.paymentsListAPI(context,fromDate,toDate);
// You can now use fromDate and toDate as needed
// For example, store them or pass to another function
} else {
print("No valid date range selected");
}
} else {
print("Bottom sheet closed without selection");
}
},
child: Icon(CupertinoIcons.color_filter),
),
],
),
),
......
......@@ -9,6 +9,7 @@ import '../../Notifiers/financeProvider/paymentReceiptsProvider.dart';
import '../../Notifiers/financeProvider/paymentRequisitionPaymentsListProvider.dart';
import '../../Utils/app_colors.dart';
import '../../Utils/commonWidgets.dart';
import '../commonDateRangeFilter.dart';
import 'FileViewer.dart';
class Paymentreceiptlist extends StatefulWidget {
......@@ -30,7 +31,7 @@ class _PaymentreceiptlistState extends State<Paymentreceiptlist> {
context,
listen: false,
);
provider.paymentsListAPI(context);
provider.paymentsListAPI(context,'','');
});
}
......@@ -55,6 +56,34 @@ class _PaymentreceiptlistState extends State<Paymentreceiptlist> {
},
child: Icon(CupertinoIcons.down_arrow),
),
InkResponse(
onTap: () async {
var cf = Commondaterangefilter();
var result = await cf.showFilterBottomSheet(context);
if (result != null) {
var dateRange = result['dateRange'] as DateTimeRange?;
print("dateRange: $dateRange");
var formatted = result['formatted'] as List<String>;
print("formatted: $formatted");
if (formatted.isNotEmpty) {
var fromDate = formatted[0]; // From date
var toDate = formatted[1]; // To date
print("from_date: $fromDate");
print("to_date: $toDate");
provider.paymentsListAPI(context,fromDate,toDate);
// You can now use fromDate and toDate as needed
// For example, store them or pass to another function
} else {
print("No valid date range selected");
}
} else {
print("Bottom sheet closed without selection");
}
},
child: Icon(CupertinoIcons.color_filter),
),
],
),
),
......
import 'dart:io';
import 'dart:async';
import 'dart:ui' as ui;
import 'package:intl/intl.dart';
import 'package:flutter_svg/svg.dart';
import 'package:flutter/material.dart';
import 'package:dropdown_button2/dropdown_button2.dart';
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:cached_network_image/cached_network_image.dart';
class Affiliatedashboard extends StatefulWidget {
const Affiliatedashboard({super.key});
@override
State<Affiliatedashboard> createState() => _AffiliatedashboardState();
}
class _AffiliatedashboardState extends State<Affiliatedashboard>
with TickerProviderStateMixin {
late final AnimationController _controller = AnimationController(
duration: const Duration(milliseconds: 100),
animationBehavior: AnimationBehavior.normal,
vsync: this,
)..repeat(reverse: true);
late Animation<double> _fadeInFadeOut;
bool isLoading = true;
var totalClicks;
var totalEarned;
var totalOrders;
var totalordersShipped;
var customers_list_filter = "";
var customer_filter_from_date = "";
var customer_filter_to_date = "";
var earnings_filter = "";
var earnings_filter_from_date = "";
var earnings_filter_to_date = "";
int _currentIndex = 0;
final List<String> Filteritems = [
'Today',
'This Month',
'Past 7 days',
'Last Month',
'Custom',
];
final List<String> Filteritems2 = [
'Today',
'This Month',
'Past 7 days',
'Last Month',
'Custom',
];
String? selectedValue;
String? selectedValue2;
DateTimeRange? selectedDateRange;
DateTimeRange? getDateRange(String filter) {
DateTime now = DateTime.now();
switch (filter) {
case 'Today':
return DateTimeRange(
start: DateTime(now.year, now.month, now.day),
end: DateTime(now.year, now.month, now.day),
);
case 'Yesterday':
DateTime yesterday = now.subtract(Duration(days: 1));
return DateTimeRange(
start: DateTime(yesterday.year, yesterday.month, yesterday.day),
end: DateTime(yesterday.year, yesterday.month, yesterday.day),
);
case 'This Month':
return DateTimeRange(
start: DateTime(now.year, now.month, 1),
end: DateTime(now.year, now.month + 1, 0),
);
case 'Last Month':
DateTime firstDayLastMonth = DateTime(now.year, now.month - 1, 1);
DateTime lastDayLastMonth = DateTime(now.year, now.month, 0);
return DateTimeRange(start: firstDayLastMonth, end: lastDayLastMonth);
case 'Past 7 days':
DateTime startOfPast7Days = now.subtract(Duration(days: 6));
return DateTimeRange(
start: DateTime(startOfPast7Days.year, startOfPast7Days.month,
startOfPast7Days.day),
end: DateTime(now.year, now.month, now.day),
);
case 'Custom':
return null; // Handle this separately
default:
return null;
}
}
// Function to show custom date range picker
Future<DateTimeRange?> showCustomDateRangePicker(BuildContext context) async {
return await showDateRangePicker(
context: context,
firstDate: DateTime(2020),
lastDate: DateTime(2100),
);
}
// Function to format date for display as YYYY-MM-DD
String formatDate(DateTime date) {
return "${date.year}-${date.month.toString().padLeft(2, '0')}-${date.day.toString().padLeft(2, '0')}";
}
// Example usage for displaying the selected date range
String getFormattedDateRange() {
if (selectedDateRange != null) {
return '${formatDate(selectedDateRange!.start)} - ${formatDate(selectedDateRange!.end)}';
}
return 'Select Item';
}
@override
void initState() {
_fadeInFadeOut = Tween<double>(begin: 0.3, end: 1.5).animate(_controller);
super.initState();
}
void _prepareChartData() {
chartData = []
.map((earning) {
// Convert rawDate or date to DateTime
DateTime? dateTime;
if (earning.rawDate != null) {
dateTime = DateTime.tryParse(earning.rawDate!);
} else if (earning.date != null) {
dateTime = DateTime.tryParse(earning.date!);
}
// Convert creditAmount to double
double? credit = double.tryParse(earning.creditAmount ?? '0');
if (dateTime != null && credit != null) {
return _ChartData(dateTime, credit);
} else {
return null;
}
})
.where((data) => data != null) // Remove null values
.cast<_ChartData>()
.toList();
}
@override
void dispose() {
// TODO: implement dispose
_controller.dispose();
super.dispose();
}
List<_ChartData> chartData = [];
@override
Widget build(BuildContext context) {
double screenWidth = MediaQuery.of(context).size.width;
double screenHeight = MediaQuery.of(context).size.height;
return Scaffold(
backgroundColor: Color(0xFFF4F5FA),
body: SingleChildScrollView(
child: Container(
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
child: Column(
children: [
Container(
width: screenWidth,
height: screenHeight * 0.28,
child: GridView.builder(
itemCount: 4,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
// 4 items in a row for tablet
crossAxisSpacing: 10,
mainAxisSpacing: 10,
childAspectRatio: 80 / 138,
),
scrollDirection: Axis.horizontal,
shrinkWrap: true,
itemBuilder: (context, index) {
List<String> labels = [
"Total Earnings",
"Total Orders",
"Pending Remitance Amount",
"Total Orders Shipped",
];
List<String> labelsTexts = [
"${totalEarned}",
"${totalOrders}",
"${totalClicks}",
"${totalordersShipped}",
];
return Container(
padding:
EdgeInsets.symmetric(vertical: 5, horizontal: 10),
decoration: BoxDecoration(
color: (index == 0)
? Color(0xFF382560)
: Color(0xFFD7E0FF),
borderRadius: BorderRadius.circular(14)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.end,
children: [
Text(
"${labelsTexts[index]}",
style: TextStyle(
color: (index == 0)
? Colors.white
: Color(0xFF382560),
fontFamily: "Inter",
fontWeight: FontWeight.w400,
fontSize: 28,
),
),
Text(
"${labels[index]}",
style: TextStyle(
color: (index == 0)
? Colors.white
: Color(0xFF566CB8),
fontFamily: "Inter",
fontWeight: FontWeight.w400,
fontSize: 12,
),
)
],
),
);
},
),
),
if (chartData.length >= 0) ...[
Container(
padding: EdgeInsets.symmetric(vertical: 10),
height: screenHeight * 0.5,
width: screenWidth,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12)),
child: Column(
children: [
Container(
padding:
EdgeInsets.symmetric(vertical: 0, horizontal: 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
child: Text(
'Earnings Overview',
style: TextStyle(
color: Color(0xFF382560),
fontSize: 18,
fontWeight: FontWeight.bold,
),
textAlign: TextAlign.center,
),
),
DropdownButtonHideUnderline(
child: DropdownButton2<String>(
isExpanded: true,
hint: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
SizedBox(width: 4),
Expanded(
child: Text(
selectedValue2 ?? 'Select Item',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w400,
color: Colors.white,
),
overflow: TextOverflow.ellipsis,
),
),
],
),
items: Filteritems2.map(
(String item) => DropdownMenuItem<String>(
value: item,
child: Text(
item,
textAlign: TextAlign.right,
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w400,
color: Colors.white,
),
overflow: TextOverflow.ellipsis,
),
)).toList(),
value: selectedValue2,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w400,
color: Colors.white,
),
alignment: Alignment.center,
onChanged: (value) async {
if (value == 'Custom') {
selectedDateRange =
await showCustomDateRangePicker(
context);
} else {
selectedDateRange = getDateRange(value!);
}
setState(() {
selectedValue2 = value;
// print(selectedDateRange);
// print(selectedValue2);
if (selectedDateRange != null) {
// Extracting the 'from' and 'to' dates directly from DateTimeRange
var fromRange = formatDate(
selectedDateRange!
.start); // Format start date
var toRange = formatDate(
selectedDateRange!
.end); // Format end date
// print('From range: $fromRange'); // Output: From range: 2024-09-21
// print('To range: $toRange'); // Output: To range: 2024-09-21
earnings_filter = "1";
earnings_filter_from_date = fromRange;
earnings_filter_to_date = toRange;
}
});
},
buttonStyleData: ButtonStyleData(
height: 40,
width: 160,
padding: const EdgeInsets.only(
left: 14, right: 14),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(14),
border: Border.all(
color: Colors.black26,
),
color: Color(0xFF382560),
),
elevation: 0,
),
iconStyleData: IconStyleData(
icon: SvgPicture.asset(
"assets/images/dropdown_burron2.svg",
),
iconSize: 14,
),
dropdownStyleData: DropdownStyleData(
direction: DropdownDirection.right,
maxHeight: 200,
width: 160,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(14),
color: Color(0xFFDDE1F2),
),
offset: const Offset(0, 0),
scrollbarTheme: ScrollbarThemeData(
radius: const Radius.circular(40),
thickness: MaterialStateProperty.all(0),
thumbVisibility:
MaterialStateProperty.all(true),
),
),
menuItemStyleData: const MenuItemStyleData(
height: 40,
padding: EdgeInsets.only(left: 14, right: 14),
),
),
)
],
),
),
],
),
),
],
],
),
),
),
);
}
}
class _ChartData {
_ChartData(this.date, this.creditAmount);
final DateTime date;
final double creditAmount;
}
......@@ -2,6 +2,10 @@ import 'dart:convert';
import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:generp/Models/ViewVisitDetailsResponseNew.dart';
import 'package:generp/Models/commonModels/DistrictsResponse.dart';
import 'package:generp/Models/commonModels/SubLocationsResponse.dart';
import 'package:generp/Models/commonModels/commonAccessiblePagesResponse.dart';
import 'package:generp/Models/commonModels/commonAddAccountsViewResponse.dart';
import 'package:generp/Models/financeModels/addDirectPaymentResponse.dart';
import 'package:generp/Models/financeModels/paymentRequisitionPaymentsListResponse.dart';
import 'package:generp/services/api_names.dart';
......@@ -40,6 +44,7 @@ import '../Models/UpdatePasswordResponse.dart';
import '../Models/VersionsResponse.dart';
import '../Models/ViewVisitDetailsResponse.dart';
import '../Models/financeModels/addPaymentRequestionResponse.dart';
import '../Models/financeModels/addReceiptPaymentResponse.dart';
import '../Models/financeModels/paymentRequesitionListsResponse.dart';
import '../Models/financeModels/paymentRequisitionDetailsResponse.dart';
import '../Models/financeModels/paymentRequisitionPaymentsDetailsResponse.dart';
......@@ -1188,7 +1193,6 @@ class ApiCalling {
static Future<addDirectPaymentResponse?> addDirectPaymentRequestionViewAPI(
empId,
session,
) async {
try {
Map<String, String> data = {
......@@ -1209,7 +1213,28 @@ class ApiCalling {
}
}
static Future<addReceiptPaymentResponse?> addReceiptPaymentRequestionViewAPI(
empId,
session,
) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
};
final res = await post(data, addPaymentReceiptViewUrl, {});
if (res != null) {
debugPrint(res.body);
return addReceiptPaymentResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static addPaymentRequestionSubmitAPI(
emp_id,
......@@ -1273,23 +1298,23 @@ class ApiCalling {
}
static addDirectPaymentRequestionSubmitAPI(
emp_id,
session_id,
from_account_id,
to_account_id,
description,
payment_mode_id,
amount,
payment_date,
payment_reference_number,
bank_name,
bank_branch_name,
bank_acc_number,
bank_ifsc_code,
acc_holder_name,
bank_upi_id,
attachment,
) async {
emp_id,
session_id,
from_account_id,
to_account_id,
description,
payment_mode_id,
amount,
payment_date,
payment_reference_number,
bank_name,
bank_branch_name,
bank_acc_number,
bank_ifsc_code,
acc_holder_name,
bank_upi_id,
attachment,
) async {
try {
Map<String, String> data = {
'emp_id': emp_id.toString(),
......@@ -1335,17 +1360,85 @@ class ApiCalling {
}
}
static addReceiptPaymentRequestionSubmitAPI(
emp_id,
session_id,
from_account_id,
to_account_id,
description,
payment_mode_id,
amount,
receipt_date,
payment_reference_number,
bank_name,
bank_branch_name,
bank_acc_number,
bank_ifsc_code,
acc_holder_name,
bank_upi_id,
attachment,
) async {
try {
Map<String, String> data = {
'emp_id': emp_id.toString(),
'session_id': session_id.toString(),
'from_account_id': from_account_id.toString(),
'to_account_id': to_account_id.toString(),
'description': description.toString(),
'payment_mode_id': payment_mode_id.toString(),
'amount': amount.toString(),
'receipt_date': receipt_date.toString(),
'payment_reference_number': payment_reference_number.toString(),
'bank_name': bank_name.toString(),
'bank_branch_name': bank_branch_name.toString(),
'bank_acc_number': bank_acc_number.toString(),
'bank_ifsc_code': bank_ifsc_code.toString(),
'acc_holder_name': acc_holder_name.toString(),
'bank_upi_id': bank_upi_id.toString(),
};
var res;
if (attachment != null) {
res = await postImageNew(
data,
{},
addPaymentReceiptSubmitUrl,
attachment,
"attachment",
);
res = jsonDecode(res);
} else {
res = await post(data, addPaymentReceiptSubmitUrl, {});
res = jsonDecode(res);
}
if (res != null) {
return res;
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static Future<paymentRequesitionListsResponse?> paymentRequestionListsAPI(
empId,
session,
mode,
from_date,
to_date,
) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
'mode': (mode).toString(),
'from': from_date.toString(),
'to': to_date.toString(),
};
print(data);
final res = await post(data, paymentRequestionListUrl, {});
if (res != null) {
debugPrint(res.body);
......@@ -1518,11 +1611,14 @@ class ApiCalling {
}
}
static Future<paymentRequisitionPaymentsListResponse?> paymentRequisitionPaymentListAPI(empId,session,) async {
static Future<paymentRequisitionPaymentsListResponse?>
paymentRequisitionPaymentListAPI(empId, session, from, to) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
'from': (from).toString(),
'to': (to).toString(),
};
final res = await post(data, paymentRequesitionPaymentsListUrl, {});
if (res != null) {
......@@ -1540,13 +1636,20 @@ class ApiCalling {
}
}
static Future<paymentRequisitionPaymentsReceiptsListResponse?> paymentRequisitionPaymentReceiptListAPI(empId,session,) async {
static Future<paymentRequisitionPaymentsReceiptsListResponse?>
paymentRequisitionPaymentReceiptListAPI(empId, session, from, to) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
'from': (from).toString(),
'to': (to).toString(),
};
final res = await post(data, paymentRequesitionPaymentsReceiptsListUrl, {});
final res = await post(
data,
paymentRequesitionPaymentsReceiptsListUrl,
{},
);
if (res != null) {
debugPrint(res.body);
return paymentRequisitionPaymentsReceiptsListResponse.fromJson(
......@@ -1562,7 +1665,8 @@ class ApiCalling {
}
}
static Future<paymentRequisitionPaymentsDetailsResponse?> paymentRequisitionPaymentDetailsAPI(empId,session,payment_id) async {
static Future<paymentRequisitionPaymentsDetailsResponse?>
paymentRequisitionPaymentDetailsAPI(empId, session, payment_id) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
......@@ -1585,14 +1689,19 @@ class ApiCalling {
}
}
static Future<paymentRequisitionPaymentsReceiptsDetailsResponse?> paymentRequisitionPaymentReceiptDetailsAPI(empId,session,payment_id) async {
static Future<paymentRequisitionPaymentsReceiptsDetailsResponse?>
paymentRequisitionPaymentReceiptDetailsAPI(empId, session, payment_id) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
'payment_receipt_id': (payment_id).toString(),
};
final res = await post(data, paymentRequesitionPaymentsReceiptsDetailsUrl, {});
final res = await post(
data,
paymentRequesitionPaymentsReceiptsDetailsUrl,
{},
);
if (res != null) {
debugPrint(res.body);
return paymentRequisitionPaymentsReceiptsDetailsResponse.fromJson(
......@@ -1607,4 +1716,182 @@ class ApiCalling {
return null;
}
}
///common Module
static Future<commonAccessiblePagesResponse?> commonDashboardPagesAPI(
empId,
session,
) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
};
final res = await post(data, commonAccessiblePagesUrl, {});
if (res != null) {
debugPrint(res.body);
return commonAccessiblePagesResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static Future<commonAddAccountsViewResponse?> commonAddAccountViewAPI(
empId,
session,
) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
};
final res = await post(data, commonAddAccountViewUrl, {});
if (res != null) {
debugPrint(res.body);
return commonAddAccountsViewResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static Future<DistrictsResponse?> commonAddAccountViewDistrictAPI(
empId,
session,
state_id,
) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
'state_id': state_id.toString(),
};
final res = await post(data, commonAddAccountViewgetDistrictUrl, {});
if (res != null) {
debugPrint(res.body);
return DistrictsResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static Future<SubLocationsResponse?>
commonAddAccountViewSubLocationAPI(empId, session, district_id) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
'district_id': district_id.toString(),
};
final res = await post(data, commonAddAccountViewgetSubLocationUrl, {});
if (res != null) {
debugPrint(res.body);
return SubLocationsResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static Future<commonAddAccountsViewResponse?> commonAddAccountCheckInputsAPI(
empId,
session,
type,
type_value,
) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
'type': (type).toString(),
'type_value': (type_value).toString(),
};
final res = await post(data, commonAddAccountCheckInputsUrl, {});
if (res != null) {
debugPrint(res.body);
return commonAddAccountsViewResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static Future<commonAddAccountsViewResponse?> commonAddAccountSubmitAPI(
empId,
session,
type,
name,
mob1,
mob2,
tel,
email,
designation,
address,
state,
district,
sub_locality,
bank_name,
bank_branch_name,
bank_ifsc_code,
bank_account_holder_name,
bank_account_number,
bank_upi_id,
) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
'type':type.toString(),
'name':name.toString(),
'mob1':mob1.toString(),
'mob2':mob2.toString(),
'tel':tel.toString(),
'email':email.toString(),
'designation':designation.toString(),
'address':address.toString(),
'state':state.toString(),
'district':district.toString(),
'sub_locality':sub_locality.toString(),
'bank_name':bank_name.toString(),
'bank_branch_name':bank_branch_name.toString(),
'bank_ifsc_code':bank_ifsc_code.toString(),
'bank_account_holder_name':bank_account_holder_name.toString(),
'bank_account_number':bank_account_number.toString(),
'bank_upi_id':bank_upi_id.toString(),
};
final res = await post(data, commonAddAccountSubmit, {});
if (res != null) {
debugPrint(res.body);
return commonAddAccountsViewResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
}
......@@ -69,3 +69,16 @@ const paymentRequesitionPaymentsListUrl = "${baseUrl_test}payment_requistion_pay
const paymentRequesitionPaymentsDetailsUrl = "${baseUrl_test}payment_requisition_payment_details";
const paymentRequesitionPaymentsReceiptsListUrl = "${baseUrl_test}payment_receipts_list";
const paymentRequesitionPaymentsReceiptsDetailsUrl = "${baseUrl_test}payment_receipt_details";
///common Module
const commonAccessiblePagesUrl = "${baseUrl_test}common_accessible_pages";
const commonAddAccountViewUrl = "${baseUrl_test}common_add_account_view";
const commonAddAccountViewgetDistrictUrl = "${baseUrl_test}get_district_on_state";
const commonAddAccountViewgetSubLocationUrl = "${baseUrl_test}get_sublocation_on_district";
const commonAddAccountCheckInputsUrl = "${baseUrl_test}check_common_add_account_fields";
const commonAddAccountSubmit = "${baseUrl_test}common_add_account_submit";
const commonAccountLedgerDropDownUrl = "${baseUrl_test}common_account_ledger_list_view";
const commonAccountLedgerListWithFilterUrl = "${baseUrl_test}common_account_ledger_list_submit_filter";
const commonAccountLedgerAccountDetails = "${baseUrl_test}common_account_details";
\ No newline at end of file
......@@ -37,10 +37,10 @@ packages:
dependency: transitive
description:
name: async
sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb"
sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63
url: "https://pub.dev"
source: hosted
version: "2.13.0"
version: "2.12.0"
barcode:
dependency: transitive
description:
......@@ -285,10 +285,10 @@ packages:
dependency: transitive
description:
name: fake_async
sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44"
sha256: "6a95e56b2449df2273fd8c45a662d6947ce1ebb7aafe80e550a3f68297f3cacc"
url: "https://pub.dev"
source: hosted
version: "1.3.3"
version: "1.3.2"
ffi:
dependency: transitive
description:
......@@ -924,26 +924,26 @@ packages:
dependency: transitive
description:
name: leak_tracker
sha256: "8dcda04c3fc16c14f48a7bb586d4be1f0d1572731b6d81d51772ef47c02081e0"
sha256: c35baad643ba394b40aac41080300150a4f08fd0fd6a10378f8f7c6bc161acec
url: "https://pub.dev"
source: hosted
version: "11.0.1"
version: "10.0.8"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1"
sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573
url: "https://pub.dev"
source: hosted
version: "3.0.10"
version: "3.0.9"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1"
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
url: "https://pub.dev"
source: hosted
version: "3.0.2"
version: "3.0.1"
lints:
dependency: transitive
description:
......@@ -1641,10 +1641,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: ddfa8d30d89985b96407efce8acbdd124701f96741f2d981ca860662f1c0dc02
sha256: "0968250880a6c5fe7edc067ed0a13d4bae1577fe2771dcf3010d52c4a9d3ca14"
url: "https://pub.dev"
source: hosted
version: "15.0.0"
version: "14.3.1"
web:
dependency: transitive
description:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment