Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sai Srinivas
GEN_ERP_2025
Commits
e54f0aeb
Commit
e54f0aeb
authored
May 19, 2025
by
Sai Srinivas
Browse files
17-05-2025 By Sai Srinivas
Common Module
parent
f7b0d1aa
Changes
28
Expand all
Hide whitespace changes
Inline
Side-by-side
lib/Models/commonModels/DistrictsResponse.dart
0 → 100644
View file @
e54f0aeb
class
DistrictsResponse
{
List
<
Districts
>?
districts
;
String
?
error
;
String
?
message
;
DistrictsResponse
({
this
.
districts
,
this
.
error
,
this
.
message
});
DistrictsResponse
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
if
(
json
[
'districts'
]
!=
null
)
{
districts
=
<
Districts
>[];
json
[
'districts'
].
forEach
((
v
)
{
districts
!.
add
(
new
Districts
.
fromJson
(
v
));
});
}
error
=
json
[
'error'
];
message
=
json
[
'message'
];
}
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
if
(
this
.
districts
!=
null
)
{
data
[
'districts'
]
=
this
.
districts
!.
map
((
v
)
=>
v
.
toJson
()).
toList
();
}
data
[
'error'
]
=
this
.
error
;
data
[
'message'
]
=
this
.
message
;
return
data
;
}
}
class
Districts
{
String
?
id
;
String
?
state
;
String
?
district
;
String
?
date
;
String
?
isExists
;
String
?
createdDatetime
;
String
?
updatedDatetime
;
Districts
({
this
.
id
,
this
.
state
,
this
.
district
,
this
.
date
,
this
.
isExists
,
this
.
createdDatetime
,
this
.
updatedDatetime
,
});
Districts
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
id
=
json
[
'id'
];
state
=
json
[
'state'
];
district
=
json
[
'district'
];
date
=
json
[
'date'
];
isExists
=
json
[
'is_exists'
];
createdDatetime
=
json
[
'created_datetime'
];
updatedDatetime
=
json
[
'updated_datetime'
];
}
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
data
[
'id'
]
=
this
.
id
;
data
[
'state'
]
=
this
.
state
;
data
[
'district'
]
=
this
.
district
;
data
[
'date'
]
=
this
.
date
;
data
[
'is_exists'
]
=
this
.
isExists
;
data
[
'created_datetime'
]
=
this
.
createdDatetime
;
data
[
'updated_datetime'
]
=
this
.
updatedDatetime
;
return
data
;
}
}
lib/Models/commonModels/SubLocationsResponse.dart
0 → 100644
View file @
e54f0aeb
class
SubLocationsResponse
{
List
<
SubLocations
>?
subLocations
;
String
?
error
;
String
?
message
;
SubLocationsResponse
({
this
.
subLocations
,
this
.
error
,
this
.
message
,
});
SubLocationsResponse
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
if
(
json
[
'sub_locations'
]
!=
null
)
{
subLocations
=
<
SubLocations
>[];
json
[
'sub_locations'
].
forEach
((
v
)
{
subLocations
!.
add
(
new
SubLocations
.
fromJson
(
v
));
});
}
error
=
json
[
'error'
];
message
=
json
[
'message'
];
}
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
if
(
this
.
subLocations
!=
null
)
{
data
[
'sub_locations'
]
=
this
.
subLocations
!.
map
((
v
)
=>
v
.
toJson
()).
toList
();
}
data
[
'error'
]
=
this
.
error
;
data
[
'message'
]
=
this
.
message
;
return
data
;
}
}
class
SubLocations
{
String
?
id
;
String
?
districtId
;
String
?
subLocality
;
String
?
date
;
String
?
isExists
;
String
?
createdDatetime
;
String
?
updatedDatetime
;
SubLocations
({
this
.
id
,
this
.
districtId
,
this
.
subLocality
,
this
.
date
,
this
.
isExists
,
this
.
createdDatetime
,
this
.
updatedDatetime
,
});
SubLocations
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
id
=
json
[
'id'
];
districtId
=
json
[
'district_id'
];
subLocality
=
json
[
'sub_locality'
];
date
=
json
[
'date'
];
isExists
=
json
[
'is_exists'
];
createdDatetime
=
json
[
'created_datetime'
];
updatedDatetime
=
json
[
'updated_datetime'
];
}
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
data
[
'id'
]
=
this
.
id
;
data
[
'district_id'
]
=
this
.
districtId
;
data
[
'sub_locality'
]
=
this
.
subLocality
;
data
[
'date'
]
=
this
.
date
;
data
[
'is_exists'
]
=
this
.
isExists
;
data
[
'created_datetime'
]
=
this
.
createdDatetime
;
data
[
'updated_datetime'
]
=
this
.
updatedDatetime
;
return
data
;
}
}
lib/Models/commonModels/commonAccessiblePagesResponse.dart
0 → 100644
View file @
e54f0aeb
class
commonAccessiblePagesResponse
{
String
?
error
;
List
<
PagesAccessible
>?
pagesAccessible
;
String
?
message
;
commonAccessiblePagesResponse
(
{
this
.
error
,
this
.
pagesAccessible
,
this
.
message
});
commonAccessiblePagesResponse
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
error
=
json
[
'error'
];
if
(
json
[
'pages_accessible'
]
!=
null
)
{
pagesAccessible
=
<
PagesAccessible
>[];
json
[
'pages_accessible'
].
forEach
((
v
)
{
pagesAccessible
!.
add
(
new
PagesAccessible
.
fromJson
(
v
));
});
}
message
=
json
[
'message'
];
}
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
data
[
'error'
]
=
this
.
error
;
if
(
this
.
pagesAccessible
!=
null
)
{
data
[
'pages_accessible'
]
=
this
.
pagesAccessible
!.
map
((
v
)
=>
v
.
toJson
()).
toList
();
}
data
[
'message'
]
=
this
.
message
;
return
data
;
}
}
class
PagesAccessible
{
int
?
id
;
String
?
pageName
;
String
?
mode
;
PagesAccessible
({
this
.
id
,
this
.
pageName
,
this
.
mode
});
PagesAccessible
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
id
=
json
[
'id'
];
pageName
=
json
[
'page_name'
];
mode
=
json
[
'mode'
];
}
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
data
[
'id'
]
=
this
.
id
;
data
[
'page_name'
]
=
this
.
pageName
;
data
[
'mode'
]
=
this
.
mode
;
return
data
;
}
}
lib/Models/commonModels/commonAddAccountsViewResponse.dart
0 → 100644
View file @
e54f0aeb
class
commonAddAccountsViewResponse
{
List
<
States
>?
states
;
List
<
String
>?
accountTypes
;
String
?
error
;
String
?
message
;
commonAddAccountsViewResponse
({
this
.
states
,
this
.
accountTypes
,
this
.
error
,
this
.
message
,
});
commonAddAccountsViewResponse
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
if
(
json
[
'states'
]
!=
null
)
{
states
=
<
States
>[];
json
[
'states'
].
forEach
((
v
)
{
states
!.
add
(
new
States
.
fromJson
(
v
));
});
}
if
(
json
[
'account_types'
]!=
null
){
accountTypes
=
json
[
'account_types'
].
cast
<
String
>();
}
error
=
json
[
'error'
];
message
=
json
[
'message'
];
}
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
if
(
this
.
states
!=
null
)
{
data
[
'states'
]
=
this
.
states
!.
map
((
v
)
=>
v
.
toJson
()).
toList
();
}
if
(
this
.
accountTypes
!=
null
){
data
[
'account_types'
]
=
this
.
accountTypes
;
}
data
[
'error'
]
=
this
.
error
;
data
[
'message'
]
=
this
.
message
;
return
data
;
}
}
class
States
{
String
?
id
;
String
?
name
;
States
({
this
.
id
,
this
.
name
});
States
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
id
=
json
[
'id'
];
name
=
json
[
'name'
];
}
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
data
[
'id'
]
=
this
.
id
;
data
[
'name'
]
=
this
.
name
;
return
data
;
}
}
lib/Models/financeModels/addReceiptPaymentResponse.dart
0 → 100644
View file @
e54f0aeb
class
addReceiptPaymentResponse
{
List
<
Accounts
>?
accounts
;
List
<
ReceiptAccounts
>?
receiptAccounts
;
List
<
PaymentModes
>?
paymentModes
;
String
?
error
;
String
?
message
;
addReceiptPaymentResponse
(
{
this
.
accounts
,
this
.
receiptAccounts
,
this
.
paymentModes
,
this
.
error
,
this
.
message
});
addReceiptPaymentResponse
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
if
(
json
[
'accounts'
]
!=
null
)
{
accounts
=
<
Accounts
>[];
json
[
'accounts'
].
forEach
((
v
)
{
accounts
!.
add
(
new
Accounts
.
fromJson
(
v
));
});
}
if
(
json
[
'receipt_accounts'
]
!=
null
)
{
receiptAccounts
=
<
ReceiptAccounts
>[];
json
[
'receipt_accounts'
].
forEach
((
v
)
{
receiptAccounts
!.
add
(
new
ReceiptAccounts
.
fromJson
(
v
));
});
}
if
(
json
[
'payment_modes'
]
!=
null
)
{
paymentModes
=
<
PaymentModes
>[];
json
[
'payment_modes'
].
forEach
((
v
)
{
paymentModes
!.
add
(
new
PaymentModes
.
fromJson
(
v
));
});
}
error
=
json
[
'error'
];
message
=
json
[
'message'
];
}
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
if
(
this
.
accounts
!=
null
)
{
data
[
'accounts'
]
=
this
.
accounts
!.
map
((
v
)
=>
v
.
toJson
()).
toList
();
}
if
(
this
.
receiptAccounts
!=
null
)
{
data
[
'receipt_accounts'
]
=
this
.
receiptAccounts
!.
map
((
v
)
=>
v
.
toJson
()).
toList
();
}
if
(
this
.
paymentModes
!=
null
)
{
data
[
'payment_modes'
]
=
this
.
paymentModes
!.
map
((
v
)
=>
v
.
toJson
()).
toList
();
}
data
[
'error'
]
=
this
.
error
;
data
[
'message'
]
=
this
.
message
;
return
data
;
}
}
class
Accounts
{
String
?
id
;
String
?
name
;
Accounts
({
this
.
id
,
this
.
name
});
Accounts
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
id
=
json
[
'id'
];
name
=
json
[
'name'
];
}
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
data
[
'id'
]
=
this
.
id
;
data
[
'name'
]
=
this
.
name
;
return
data
;
}
}
class
ReceiptAccounts
{
String
?
id
;
String
?
name
;
ReceiptAccounts
({
this
.
id
,
this
.
name
});
ReceiptAccounts
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
id
=
json
[
'id'
];
name
=
json
[
'name'
];
}
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
data
[
'id'
]
=
this
.
id
;
data
[
'name'
]
=
this
.
name
;
return
data
;
}
}
class
PaymentModes
{
String
?
id
;
String
?
name
;
PaymentModes
({
this
.
id
,
this
.
name
});
PaymentModes
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
id
=
json
[
'id'
];
name
=
json
[
'name'
];
}
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
data
[
'id'
]
=
this
.
id
;
data
[
'name'
]
=
this
.
name
;
return
data
;
}
}
\ No newline at end of file
lib/Notifiers/commonProvider/accountsListProvider.dart
0 → 100644
View file @
e54f0aeb
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:generp/Notifiers/HomeScreenNotifier.dart'
;
import
'package:generp/Utils/commonServices.dart'
;
import
'package:generp/services/api_calling.dart'
;
import
'package:provider/provider.dart'
;
import
'../../Models/commonModels/DistrictsResponse.dart'
;
import
'../../Models/commonModels/SubLocationsResponse.dart'
;
import
'../../Models/commonModels/commonAddAccountsViewResponse.dart'
;
class
Accountslistprovider
extends
ChangeNotifier
{
TextEditingController
nameController
=
TextEditingController
();
TextEditingController
mobileController
=
TextEditingController
();
TextEditingController
addressController
=
TextEditingController
();
TextEditingController
bankNameController
=
TextEditingController
();
TextEditingController
branchNameController
=
TextEditingController
();
TextEditingController
bankIfscCotroller
=
TextEditingController
();
TextEditingController
bankHolderNameController
=
TextEditingController
();
TextEditingController
bankAcNameController
=
TextEditingController
();
TextEditingController
bankUpiController
=
TextEditingController
();
TextEditingController
contactPersonController
=
TextEditingController
();
TextEditingController
contectPersonDesignationController
=
TextEditingController
();
TextEditingController
contectPersonAltMobController
=
TextEditingController
();
TextEditingController
contectPersonTeleController
=
TextEditingController
();
TextEditingController
contectPersonMailController
=
TextEditingController
();
List
<
States
>
_states
=
[];
List
<
Districts
>
_districts
=
[];
List
<
SubLocations
>
_subLocations
=
[];
List
<
String
>
_accountTypes
=
[];
List
<
States
>
get
states
=>
_states
;
List
<
Districts
>
get
districts
=>
_districts
;
List
<
SubLocations
>
get
subLocations
=>
_subLocations
;
List
<
String
>
get
accountTypes
=>
_accountTypes
;
States
?
_selectedState
;
Districts
?
_selectedDistricts
;
SubLocations
?
_selectedSubLocations
;
String
?
_selectedAccountType
;
String
?
_selectedDistrictID
;
String
?
_selectedDistrictValue
;
String
?
_selectedStateID
;
String
?
_selectedStateValue
;
String
?
_selectedSubLocID
;
String
?
_selectedSubLocValue
;
States
?
get
selectedState
=>
_selectedState
;
String
?
get
selectedStateID
=>
_selectedStateID
;
String
?
get
selectedStateValue
=>
_selectedStateValue
;
Districts
?
get
selectedDistricts
=>
_selectedDistricts
;
String
?
get
selectedDistrictId
=>
_selectedDistrictID
;
String
?
get
selectedDistrictValue
=>
_selectedDistrictValue
;
SubLocations
?
get
selectedSubLocations
=>
_selectedSubLocations
;
String
?
get
selectedSubLocID
=>
_selectedSubLocID
;
String
?
get
selectedSubLocValue
=>
_selectedSubLocValue
;
String
?
get
selectedAccountType
=>
_selectedAccountType
;
set
selectedAccountType
(
String
?
value
)
{
_selectedAccountType
=
value
;
notifyListeners
();
}
set
selectedState
(
States
?
value
)
{
_selectedState
=
value
;
_selectedStateID
=
value
!.
id
;
_selectedStateValue
=
value
!.
name
;
notifyListeners
();
}
set
selectedDistricts
(
Districts
?
value
)
{
_selectedDistricts
=
value
;
_selectedDistrictID
=
value
!.
id
;
_selectedDistrictValue
=
value
!.
district
;
notifyListeners
();
}
set
selectedSubLocations
(
SubLocations
?
value
)
{
_selectedSubLocations
=
value
;
_selectedSubLocID
=
value
!.
id
;
_selectedSubLocValue
=
value
!.
subLocality
!;
notifyListeners
();
}
set
selectedStateID
(
value
){
_selectedStateID
=
value
;
notifyListeners
();
}
set
selectedStateValue
(
value
){
_selectedStateID
=
value
;
notifyListeners
();
}
set
selectedDistrictId
(
value
){
_selectedDistrictID
=
value
;
notifyListeners
();
}
set
selectedDistrictValue
(
value
){
_selectedDistrictValue
=
value
;
notifyListeners
();
}
set
selectedSubLocID
(
value
){
_selectedSubLocID
=
value
;
notifyListeners
();
}
set
selectedSubLocValue
(
value
){
_selectedSubLocValue
=
value
;
notifyListeners
();
}
Future
<
void
>
addCommonAccountViewAPI
(
context
)
async
{
try
{
var
homeProv
=
Provider
.
of
<
HomescreenNotifier
>(
context
,
listen:
false
);
final
data
=
await
ApiCalling
.
commonAddAccountViewAPI
(
homeProv
.
empId
,
homeProv
.
session
,
);
_accountTypes
.
clear
();
_states
.
clear
();
notifyListeners
();
if
(
data
!=
null
)
{
if
(
data
.
error
==
"0"
)
{
_accountTypes
=
data
.
accountTypes
!;
_states
=
data
.
states
!;
notifyListeners
();
}
}
}
catch
(
e
,
s
)
{}
}
Future
<
void
>
getDistrictAPI
(
context
,
stateID
)
async
{
try
{
var
homeProv
=
Provider
.
of
<
HomescreenNotifier
>(
context
,
listen:
false
);
_districts
.
clear
();
notifyListeners
();
final
data
=
await
ApiCalling
.
commonAddAccountViewDistrictAPI
(
homeProv
.
empId
,
homeProv
.
session
,
stateID
,
);
if
(
data
!=
null
)
{
if
(
data
.
error
==
"0"
)
{
_districts
=
data
.
districts
!;
notifyListeners
();
}
}
}
catch
(
e
,
s
)
{}
}
Future
<
void
>
getSubLocationAPI
(
context
,
districtID
)
async
{
try
{
var
homeProv
=
Provider
.
of
<
HomescreenNotifier
>(
context
,
listen:
false
);
_subLocations
.
clear
();
notifyListeners
();
final
data
=
await
ApiCalling
.
commonAddAccountViewSubLocationAPI
(
homeProv
.
empId
,
homeProv
.
session
,
districtID
,
);
if
(
data
!=
null
)
{
if
(
data
.
error
==
"0"
)
{
_subLocations
=
data
.
subLocations
!;
notifyListeners
();
}
}
}
catch
(
e
,
s
)
{}
}
Future
<
void
>
checkInputsAPI
(
context
,
type
,
value
)
async
{
try
{
var
homeProv
=
Provider
.
of
<
HomescreenNotifier
>(
context
,
listen:
false
);
final
data
=
await
ApiCalling
.
commonAddAccountCheckInputsAPI
(
homeProv
.
empId
,
homeProv
.
session
,
type
,
value
,
);
if
(
data
!=
null
)
{
if
(
data
.
error
==
"0"
)
{
}
else
if
(
data
.
error
==
"1"
)
{
toast
(
context
,
data
.
message
);
}
}
}
catch
(
e
,
s
)
{}
}
Future
<
void
>
submitCommonAccountsAPI
(
context
,
)
async
{
try
{
var
homeProv
=
Provider
.
of
<
HomescreenNotifier
>(
context
,
listen:
false
);
final
data
=
await
ApiCalling
.
commonAddAccountSubmitAPI
(
homeProv
.
empId
,
homeProv
.
session
,
_selectedAccountType
,
nameController
.
text
,
mobileController
.
text
,
contectPersonAltMobController
.
text
,
contectPersonTeleController
.
text
,
contectPersonMailController
.
text
,
contectPersonDesignationController
.
text
,
addressController
.
text
,
_selectedStateID
,
_selectedDistrictID
,
_selectedSubLocID
,
bankNameController
.
text
,
branchNameController
.
text
,
bankIfscCotroller
.
text
,
bankHolderNameController
.
text
,
bankAcNameController
.
text
,
bankUpiController
.
text
,
);
if
(
data
!=
null
)
{
if
(
data
.
error
==
"0"
)
{
Navigator
.
pop
(
context
);
resetValues
();
toast
(
context
,
data
.
message
);
}
else
if
(
data
.
error
==
"1"
)
{
toast
(
context
,
data
.
message
);
}
else
{}
}
}
catch
(
e
,
s
)
{}
}
resetValues
(){
_selectedAccountType
=
null
;
_selectedStateID
=
null
;
_selectedDistrictID
=
null
;
_selectedSubLocID
=
null
;
nameController
.
clear
();
mobileController
.
clear
();
contectPersonAltMobController
.
clear
();
contectPersonTeleController
.
clear
();
contectPersonMailController
.
clear
();
contectPersonDesignationController
.
clear
();
addressController
.
clear
();
bankNameController
.
clear
();
branchNameController
.
clear
();
bankIfscCotroller
.
clear
();
bankHolderNameController
.
clear
();
bankAcNameController
.
clear
();
bankUpiController
.
clear
();
}
}
lib/Notifiers/commonProvider/commonPagesProvider.dart
0 → 100644
View file @
e54f0aeb
import
'package:flutter/foundation.dart'
;
import
'package:generp/Notifiers/HomeScreenNotifier.dart'
;
import
'package:generp/services/api_calling.dart'
;
import
'package:provider/provider.dart'
;
import
'../../Models/commonModels/commonAccessiblePagesResponse.dart'
;
class
Commonpagesprovider
extends
ChangeNotifier
{
List
<
PagesAccessible
>
_accessPages
=
[];
List
<
PagesAccessible
>
get
accessPages
=>
_accessPages
;
Future
<
void
>
commonAccessPagesAPIFunction
(
context
)
async
{
try
{
var
HomeProv
=
Provider
.
of
<
HomescreenNotifier
>(
context
,
listen:
false
);
final
data
=
await
ApiCalling
.
commonDashboardPagesAPI
(
HomeProv
.
empId
,
HomeProv
.
session
);
if
(
data
!=
null
){
if
(
data
.
error
==
"0"
){
_accessPages
=
data
.
pagesAccessible
!;
notifyListeners
();
}
}
}
catch
(
e
,
s
){
}
}
}
\ No newline at end of file
lib/Notifiers/financeProvider/RequestionListProvider.dart
View file @
e54f0aeb
...
@@ -8,6 +8,7 @@ import 'package:flutter/services.dart';
...
@@ -8,6 +8,7 @@ import 'package:flutter/services.dart';
import
'package:flutter_image_compress/flutter_image_compress.dart'
;
import
'package:flutter_image_compress/flutter_image_compress.dart'
;
import
'package:generp/Models/financeModels/addDirectPaymentResponse.dart'
;
import
'package:generp/Models/financeModels/addDirectPaymentResponse.dart'
;
import
'package:generp/Notifiers/HomeScreenNotifier.dart'
;
import
'package:generp/Notifiers/HomeScreenNotifier.dart'
;
import
'package:generp/Notifiers/HomeScreenNotifier.dart'
;
import
'package:generp/Utils/commonServices.dart'
;
import
'package:generp/Utils/commonServices.dart'
;
import
'package:generp/services/api_calling.dart'
;
import
'package:generp/services/api_calling.dart'
;
import
'package:image_picker/image_picker.dart'
;
import
'package:image_picker/image_picker.dart'
;
...
@@ -168,6 +169,7 @@ class Requestionlistprovider extends ChangeNotifier {
...
@@ -168,6 +169,7 @@ class Requestionlistprovider extends ChangeNotifier {
String
?
FileError
;
String
?
FileError
;
bool
buttonEnabled
=
false
;
bool
buttonEnabled
=
false
;
bool
_isLoading
=
true
;
// bool _submitClicked = false;
// bool _submitClicked = false;
...
@@ -176,6 +178,7 @@ class Requestionlistprovider extends ChangeNotifier {
...
@@ -176,6 +178,7 @@ class Requestionlistprovider extends ChangeNotifier {
File
?
_image
;
File
?
_image
;
bool
get
isLoading
=>
_isLoading
;
String
get
paymentModeId
=>
_paymentModeId
;
String
get
paymentModeId
=>
_paymentModeId
;
String
get
paymentModeValue
=>
_paymentModeValue
;
String
get
paymentModeValue
=>
_paymentModeValue
;
...
@@ -453,22 +456,31 @@ class Requestionlistprovider extends ChangeNotifier {
...
@@ -453,22 +456,31 @@ class Requestionlistprovider extends ChangeNotifier {
}
catch
(
e
,
s
)
{}
}
catch
(
e
,
s
)
{}
}
}
Future
<
void
>
paymentRequestionListsAPIFunction
(
context
,
mode
)
async
{
Future
<
void
>
paymentRequestionListsAPIFunction
(
context
,
mode
,
from
,
to
)
async
{
try
{
try
{
var
homeProvider
=
Provider
.
of
<
HomescreenNotifier
>(
var
homeProvider
=
Provider
.
of
<
HomescreenNotifier
>(
context
,
context
,
listen:
false
,
listen:
false
,
);
);
_requisitionList
.
clear
();
_isLoading
=
true
;
notifyListeners
();
final
data
=
await
ApiCalling
.
paymentRequestionListsAPI
(
final
data
=
await
ApiCalling
.
paymentRequestionListsAPI
(
homeProvider
.
empId
,
homeProvider
.
empId
,
homeProvider
.
session
,
homeProvider
.
session
,
mode
,
mode
,
from
,
to
);
);
if
(
data
!=
null
)
{
if
(
data
!=
null
)
{
if
(
data
.
error
==
"0"
)
{
if
(
data
.
error
==
"0"
)
{
_isLoading
=
false
;
_requisitionList
=
data
.
requistionList
!;
_requisitionList
=
data
.
requistionList
!;
notifyListeners
();
}
else
{}
}
else
if
(
data
.
error
==
"1"
){
_isLoading
=
false
;
}
notifyListeners
();
}
}
}
catch
(
e
,
s
)
{}
}
catch
(
e
,
s
)
{}
}
}
...
...
lib/Notifiers/financeProvider/paymentReceiptsProvider.dart
View file @
e54f0aeb
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/foundation.dart'
;
import
'dart:io'
;
import
'dart:io'
;
...
@@ -8,6 +9,8 @@ import 'package:flutter/material.dart';
...
@@ -8,6 +9,8 @@ import 'package:flutter/material.dart';
import
'package:flutter/services.dart'
;
import
'package:flutter/services.dart'
;
import
'package:generp/Notifiers/HomeScreenNotifier.dart'
;
import
'package:generp/Notifiers/HomeScreenNotifier.dart'
;
import
'package:generp/services/api_calling.dart'
;
import
'package:generp/services/api_calling.dart'
;
import
'package:image_picker/image_picker.dart'
;
import
'package:intl/intl.dart'
;
import
'package:path_provider/path_provider.dart'
;
import
'package:path_provider/path_provider.dart'
;
import
'package:pdf/pdf.dart'
;
import
'package:pdf/pdf.dart'
;
import
'package:pdf/widgets.dart'
as
pw
;
import
'package:pdf/widgets.dart'
as
pw
;
...
@@ -15,10 +18,15 @@ import 'package:permission_handler/permission_handler.dart';
...
@@ -15,10 +18,15 @@ import 'package:permission_handler/permission_handler.dart';
import
'package:printing/printing.dart'
;
import
'package:printing/printing.dart'
;
import
'package:provider/provider.dart'
;
import
'package:provider/provider.dart'
;
import
'../../Models/financeModels/addReceiptPaymentResponse.dart'
;
import
'../../Models/financeModels/paymentRequisitionPaymentsReceiptsDetailsResponse.dart'
;
import
'../../Models/financeModels/paymentRequisitionPaymentsReceiptsDetailsResponse.dart'
;
import
'../../Models/financeModels/paymentRequisitionPaymentsReceiptsListResponse.dart'
;
import
'../../Models/financeModels/paymentRequisitionPaymentsReceiptsListResponse.dart'
;
import
'../../Utils/commonServices.dart'
;
import
'../../Utils/commonServices.dart'
;
import
'package:share_plus/share_plus.dart'
;
import
'package:printing/printing.dart'
;
class
Paymentreceiptsprovider
extends
ChangeNotifier
{
class
Paymentreceiptsprovider
extends
ChangeNotifier
{
List
<
ReceiptsList
>
_receiptsList
=
[];
List
<
ReceiptsList
>
_receiptsList
=
[];
ReceiptDetails
_receiptDetails
=
ReceiptDetails
();
ReceiptDetails
_receiptDetails
=
ReceiptDetails
();
...
@@ -30,10 +38,277 @@ class Paymentreceiptsprovider extends ChangeNotifier{
...
@@ -30,10 +38,277 @@ class Paymentreceiptsprovider extends ChangeNotifier{
List
<
String
>
get
Headings
=>
_headings
;
List
<
String
>
get
Headings
=>
_headings
;
List
<
String
>
get
subHeadings
=>
_subHeadings
;
List
<
String
>
get
subHeadings
=>
_subHeadings
;
Future
<
void
>
paymentsListAPI
(
context
)
async
{
TextEditingController
reqPurposeController
=
TextEditingController
();
TextEditingController
descController
=
TextEditingController
();
TextEditingController
amountController
=
TextEditingController
();
TextEditingController
bankNameController
=
TextEditingController
();
TextEditingController
bankBranchController
=
TextEditingController
();
TextEditingController
bankAccNumberController
=
TextEditingController
();
TextEditingController
bankIfscController
=
TextEditingController
();
TextEditingController
bankAcHolderController
=
TextEditingController
();
TextEditingController
bankUpiController
=
TextEditingController
();
TextEditingController
paymentReferenceController
=
TextEditingController
();
// Date picker state
DateTime
?
_date
;
String
?
_formattedDate
;
List
<
Accounts
>
_accounts
=
[];
List
<
PaymentModes
>
_paymentModes
=
[];
List
<
String
>
_requestingPurposes
=
[];
List
<
Accounts
>
_receiptAccounts
=
[];
List
<
ReceiptAccounts
>
_receiptPaymentAccounts
=
[];
List
<
PaymentModes
>
_receiptPaymentModes
=
[];
Accounts
?
_selectedreceiptAccounts
;
ReceiptAccounts
?
_selectreceiptPaymentAccounts
;
PaymentModes
?
_selectreceiptPaymentModes
;
String
_receiptAccountID
=
""
;
String
_receiptAccountValue
=
""
;
String
_receiptPaymentAccountsID
=
""
;
String
_receiptPaymentAccountsValue
=
""
;
String
_receiptPaymentModesID
=
""
;
String
_receiptPaymentModesValues
=
""
;
List
<
Accounts
>
get
receiptAccounts
=>
_receiptAccounts
;
List
<
ReceiptAccounts
>
get
receiptPaymentAccounts
=>
_receiptPaymentAccounts
;
List
<
PaymentModes
>
get
receiptPaymentModes
=>
_receiptPaymentModes
;
Accounts
?
get
selectreceiptAccounts
=>
_selectedreceiptAccounts
;
ReceiptAccounts
?
get
selectreceiptPaymentAccounts
=>
_selectreceiptPaymentAccounts
;
PaymentModes
?
get
selectreceiptPaymentModes
=>
_selectreceiptPaymentModes
;
String
get
receiptAccountId
=>
_receiptAccountID
;
String
get
receiptAccountValue
=>
_receiptAccountValue
;
String
get
receiptPaymentAccountsID
=>
_receiptPaymentAccountsID
;
String
get
receiptPaymentAccountsValue
=>
_receiptPaymentAccountsValue
;
String
get
receiptPaymentModesID
=>
_receiptPaymentModesID
;
String
get
receiptPaymentModesValues
=>
_receiptPaymentModesValues
;
// Date picker methods
void
setDate
(
DateTime
newDate
)
{
_date
=
newDate
;
_formattedDate
=
DateFormat
(
'yyyy-MM-dd'
).
format
(
newDate
);
notifyListeners
();
}
set
selectreceiptAccounts
(
Accounts
?
value
)
{
_selectedreceiptAccounts
=
value
;
_receiptAccountID
=
value
!.
id
!;
_receiptAccountValue
=
value
!.
name
!;
notifyListeners
();
}
set
selectreceiptPaymentAccounts
(
ReceiptAccounts
?
value
)
{
_selectreceiptPaymentAccounts
=
value
;
_receiptPaymentAccountsID
=
value
!.
id
!;
_receiptPaymentAccountsValue
=
value
!.
name
!;
notifyListeners
();
}
set
selectreceiptPaymentModes
(
PaymentModes
?
value
)
{
_selectreceiptPaymentModes
=
value
;
_receiptPaymentModesID
=
value
!.
id
!;
_receiptPaymentModesValues
=
value
!.
name
!;
notifyListeners
();
}
set
receiptAccountId
(
String
value
)
{
_receiptAccountID
=
value
;
notifyListeners
();
}
set
receiptAccountValue
(
String
value
)
{
_receiptAccountValue
=
value
;
notifyListeners
();
}
set
receiptPaymentAccountsID
(
String
value
)
{
_receiptPaymentAccountsID
=
value
;
notifyListeners
();
}
set
receiptPaymentAccountsValue
(
String
value
)
{
_receiptPaymentAccountsValue
=
value
;
notifyListeners
();
}
set
receiptPaymentModesID
(
String
value
)
{
_receiptPaymentModesID
=
value
;
notifyListeners
();
}
set
receiptPaymentModesValues
(
String
value
)
{
_receiptPaymentModesValues
=
value
;
notifyListeners
();
}
Accounts
?
_selectedAccounts
;
PaymentModes
?
_selectedPayment
;
String
?
_selectReqPurpose
;
String
_paymentModeId
=
""
;
String
_paymentModeValue
=
""
;
String
_accountId
=
""
;
String
_reqPurpose
=
""
;
String
?
selectAccountError
;
String
?
reqPurposeError
;
String
?
descriptionError
;
String
?
amountError
;
String
?
selectPaymentError
;
String
?
bankNameError
;
String
?
bankBranchError
;
String
?
bankNumberError
;
String
?
bankIFSCError
;
String
?
bankHolderError
;
String
?
UPIError
;
String
?
FileError
;
bool
buttonEnabled
=
false
;
bool
_isLoading
=
true
;
// bool _submitClicked = false;
var
_image_picked
=
0
;
final
ImagePicker
_picker
=
ImagePicker
();
File
?
_image
;
bool
get
isLoading
=>
_isLoading
;
String
get
paymentModeId
=>
_paymentModeId
;
String
get
paymentModeValue
=>
_paymentModeValue
;
get
image_picked
=>
_image_picked
;
File
?
get
imagePath
=>
_image
;
String
get
accountId
=>
_accountId
;
String
get
reqPurpose
=>
_reqPurpose
;
String
?
get
selectReqPurpose
=>
_selectReqPurpose
;
Accounts
?
get
selectedAccount
=>
_selectedAccounts
;
PaymentModes
?
get
selectedPayment
=>
_selectedPayment
;
List
<
Accounts
>
get
accounts
=>
_accounts
;
List
<
PaymentModes
>
get
paymentModes
=>
_paymentModes
;
List
<
String
>
get
requestingPurposes
=>
_requestingPurposes
;
String
?
get
formattedDate
=>
_formattedDate
;
// bool get submitClicked => _submitClicked;
// set submitClicked(bool value){
// _submitClicked = value;
// notifyListeners();
// }
set
selectedAccount
(
Accounts
?
value
)
{
_selectedAccounts
=
value
;
_accountId
=
value
!.
id
!;
selectAccountError
=
null
;
notifyListeners
();
}
set
selectedPayment
(
PaymentModes
?
value
)
{
_selectedPayment
=
value
;
_paymentModeId
=
value
!.
id
!;
_paymentModeValue
=
value
!.
name
!;
selectPaymentError
=
null
;
notifyListeners
();
}
set
selectReqPurpose
(
String
?
value
)
{
_selectReqPurpose
=
value
;
reqPurposeError
=
null
;
notifyListeners
();
}
set
paymentModeId
(
String
value
)
{
_paymentModeId
=
value
;
notifyListeners
();
}
set
paymentModeValue
(
String
value
)
{
_paymentModeValue
=
value
;
notifyListeners
();
}
set
accountId
(
String
value
)
{
_accountId
=
value
;
notifyListeners
();
}
set
reqPurposeId
(
String
value
)
{
_reqPurpose
=
value
;
notifyListeners
();
}
imgFromCamera
(
context
)
async
{
// Capture a photo
try
{
final
XFile
?
galleryImage
=
await
_picker
.
pickImage
(
source
:
ImageSource
.
camera
,
imageQuality:
50
,
);
debugPrint
(
"added"
);
_image
=
File
(
galleryImage
!.
path
);
_image_picked
=
1
;
FileError
=
null
;
notifyListeners
();
}
catch
(
e
)
{
debugPrint
(
"mmmm:
${e.toString()}
"
);
}
}
imgFromGallery
(
context
)
async
{
// Pick an image
try
{
final
XFile
?
galleryImage
=
await
_picker
.
pickImage
(
source
:
ImageSource
.
gallery
,
);
final
bytes
=
(
await
galleryImage
?.
readAsBytes
())?.
lengthInBytes
;
final
kb
=
bytes
!
/
1024
;
final
mb
=
kb
/
1024
;
debugPrint
(
"Jenny: bytes:
$bytes
, kb:
$kb
, mb:
$mb
"
);
_image
=
File
(
galleryImage
!.
path
);
_image_picked
=
1
;
FileError
=
null
;
notifyListeners
();
// var file = FlutterImageCompress.compressWithFile(galleryImage!.path);
}
catch
(
e
)
{
debugPrint
(
"mmmm:
${e.toString()}
"
);
}
}
Future
<
void
>
paymentsListAPI
(
context
,
from
,
to
)
async
{
try
{
try
{
var
prov
=
Provider
.
of
<
HomescreenNotifier
>(
context
,
listen:
false
);
var
prov
=
Provider
.
of
<
HomescreenNotifier
>(
context
,
listen:
false
);
final
data
=
await
ApiCalling
.
paymentRequisitionPaymentReceiptListAPI
(
prov
.
empId
,
prov
.
session
);
final
data
=
await
ApiCalling
.
paymentRequisitionPaymentReceiptListAPI
(
prov
.
empId
,
prov
.
session
,
from
,
to
);
if
(
data
!=
null
){
if
(
data
!=
null
){
if
(
data
.
error
==
"0"
){
if
(
data
.
error
==
"0"
){
_receiptsList
=
data
.
receiptsList
!;
_receiptsList
=
data
.
receiptsList
!;
...
@@ -92,6 +367,92 @@ class Paymentreceiptsprovider extends ChangeNotifier{
...
@@ -92,6 +367,92 @@ class Paymentreceiptsprovider extends ChangeNotifier{
}
}
}
}
Future
<
void
>
addReceiptPaymentRequestionViewAPI
(
context
)
async
{
try
{
var
homeProvider
=
Provider
.
of
<
HomescreenNotifier
>(
context
,
listen:
false
,
);
final
data
=
await
ApiCalling
.
addReceiptPaymentRequestionViewAPI
(
homeProvider
.
empId
,
homeProvider
.
session
,
);
if
(
data
!=
null
)
{
if
(
data
.
error
==
"0"
)
{
_receiptPaymentAccounts
=
data
.
receiptAccounts
!;
_receiptPaymentModes
=
data
.
paymentModes
!;
_receiptAccounts
=
data
.
accounts
!;
if
(
_selectedreceiptAccounts
!=
null
&&
!
_receiptAccounts
.
contains
(
_selectedreceiptAccounts
))
{
_selectedreceiptAccounts
=
null
;
_receiptAccountID
=
""
;
_receiptAccountValue
=
""
;
}
if
(
_selectreceiptPaymentModes
!=
null
&&
!
_receiptPaymentModes
.
contains
(
_selectreceiptPaymentModes
))
{
_selectreceiptPaymentModes
=
null
;
_receiptPaymentModesID
=
""
;
_receiptPaymentModesValues
=
""
;
}
if
(
_selectreceiptPaymentAccounts
!=
null
&&
!
_receiptPaymentAccounts
.
contains
(
_selectreceiptPaymentAccounts
))
{
_selectreceiptPaymentAccounts
=
null
;
_receiptPaymentAccountsID
=
""
;
_receiptPaymentAccountsValue
=
""
;
}
notifyListeners
();
}
else
{}
}
}
catch
(
e
,
s
)
{}
}
Future
<
void
>
addReceiptPaymentRequestionSubmitAPI
(
context
,
receipt_date
)
async
{
try
{
// _submitClicked = true;
if
(!
validatereceiptForm
(
context
))
{
// _submitClicked = false;
return
;
}
var
homeProvider
=
Provider
.
of
<
HomescreenNotifier
>(
context
,
listen:
false
,
);
final
data
=
await
ApiCalling
.
addReceiptPaymentRequestionSubmitAPI
(
homeProvider
.
empId
,
homeProvider
.
session
,
_receiptAccountID
,
_receiptPaymentAccountsID
,
descController
.
text
,
_receiptPaymentModesID
,
amountController
.
text
,
receipt_date
,
paymentReferenceController
.
text
,
bankNameController
.
text
,
bankBranchController
.
text
,
bankAccNumberController
.
text
,
bankIfscController
.
text
,
bankAcHolderController
.
text
,
bankUpiController
.
text
,
_image
);
if
(
data
!=
null
)
{
if
(
data
[
'error'
]
==
"0"
)
{
print
(
data
[
'error'
]
==
"0"
);
toast
(
context
,
"Added Successfully"
);
resetForm
();
Navigator
.
pop
(
context
,
true
);
notifyListeners
();
}
else
{}
}
}
catch
(
e
,
s
)
{}
}
List
<
List
<
String
>>
prepareExportData
()
{
List
<
List
<
String
>>
prepareExportData
()
{
final
headers
=
[
final
headers
=
[
'ID'
,
'ID'
,
...
@@ -147,8 +508,8 @@ class Paymentreceiptsprovider extends ChangeNotifier{
...
@@ -147,8 +508,8 @@ class Paymentreceiptsprovider extends ChangeNotifier{
}
}
}
}
Future
<
String
>
getSave
Di
rectory
()
async
{
Future
<
String
>
getSaverec
eip
tory
()
async
{
// Try Downloads
di
rectory first
// Try Downloads rec
eip
tory first
try
{
try
{
if
(
Platform
.
isAndroid
)
{
if
(
Platform
.
isAndroid
)
{
// Request storage permission for Android
// Request storage permission for Android
...
@@ -160,16 +521,16 @@ class Paymentreceiptsprovider extends ChangeNotifier{
...
@@ -160,16 +521,16 @@ class Paymentreceiptsprovider extends ChangeNotifier{
.
isGranted
)
{
.
isGranted
)
{
final
dir
=
await
getApplicationDocumentsDirectory
();
final
dir
=
await
getApplicationDocumentsDirectory
();
if
(
dir
!=
null
)
{
if
(
dir
!=
null
)
{
print
(
'Using Downloads
di
rectory:
${dir.path}
'
);
print
(
'Using Downloads rec
eip
tory:
${dir.path}
'
);
return
dir
.
path
;
return
dir
.
path
;
}
}
}
}
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
print
(
'Error accessing Downloads
di
rectory:
$e
'
);
print
(
'Error accessing Downloads rec
eip
tory:
$e
'
);
}
}
// Fallback to shared Documents
di
rectory
// Fallback to shared Documents rec
eip
tory
try
{
try
{
final
dir
=
await
getDownloadsDirectory
();
final
dir
=
await
getDownloadsDirectory
();
if
(
dir
!=
null
)
{
if
(
dir
!=
null
)
{
...
@@ -177,16 +538,16 @@ class Paymentreceiptsprovider extends ChangeNotifier{
...
@@ -177,16 +538,16 @@ class Paymentreceiptsprovider extends ChangeNotifier{
if
(!
await
customDir
.
exists
())
{
if
(!
await
customDir
.
exists
())
{
await
customDir
.
create
(
recursive:
true
);
await
customDir
.
create
(
recursive:
true
);
}
}
print
(
'Using custom Documents
di
rectory:
${customDir.path}
'
);
print
(
'Using custom Documents rec
eip
tory:
${customDir.path}
'
);
return
customDir
.
path
;
return
customDir
.
path
;
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
print
(
'Error accessing Documents
di
rectory:
$e
'
);
print
(
'Error accessing Documents rec
eip
tory:
$e
'
);
}
}
// Final fallback to app's Documents
di
rectory
// Final fallback to app's Documents rec
eip
tory
final
dir
=
await
getApplicationDocumentsDirectory
();
final
dir
=
await
getApplicationDocumentsDirectory
();
print
(
'Using app Documents
di
rectory:
${dir.path}
'
);
print
(
'Using app Documents rec
eip
tory:
${dir.path}
'
);
return
dir
.
path
;
return
dir
.
path
;
}
}
...
@@ -200,7 +561,7 @@ class Paymentreceiptsprovider extends ChangeNotifier{
...
@@ -200,7 +561,7 @@ class Paymentreceiptsprovider extends ChangeNotifier{
}
}
final
data
=
prepareExportData
();
final
data
=
prepareExportData
();
final
csvData
=
const
ListToCsvConverter
().
convert
(
data
);
final
csvData
=
const
ListToCsvConverter
().
convert
(
data
);
final
dirPath
=
await
getSave
Di
rectory
();
final
dirPath
=
await
getSaverec
eip
tory
();
final
file
=
File
(
'
$dirPath
/requisition_data.csv'
);
final
file
=
File
(
'
$dirPath
/requisition_data.csv'
);
await
file
.
writeAsString
(
csvData
);
await
file
.
writeAsString
(
csvData
);
print
(
'CSV saved at:
${file.path}
'
);
print
(
'CSV saved at:
${file.path}
'
);
...
@@ -226,7 +587,7 @@ class Paymentreceiptsprovider extends ChangeNotifier{
...
@@ -226,7 +587,7 @@ class Paymentreceiptsprovider extends ChangeNotifier{
for
(
var
row
in
data
)
{
for
(
var
row
in
data
)
{
sheet
.
appendRow
(
row
.
map
((
cell
)
=>
TextCellValue
(
cell
)).
toList
());
sheet
.
appendRow
(
row
.
map
((
cell
)
=>
TextCellValue
(
cell
)).
toList
());
}
}
final
dirPath
=
await
getSave
Di
rectory
();
final
dirPath
=
await
getSaverec
eip
tory
();
final
file
=
File
(
'
$dirPath
/requisition_data.xlsx'
);
final
file
=
File
(
'
$dirPath
/requisition_data.xlsx'
);
final
bytes
=
excel
.
encode
();
final
bytes
=
excel
.
encode
();
if
(
bytes
==
null
)
throw
Exception
(
"Excel encoding failed"
);
if
(
bytes
==
null
)
throw
Exception
(
"Excel encoding failed"
);
...
@@ -253,7 +614,7 @@ class Paymentreceiptsprovider extends ChangeNotifier{
...
@@ -253,7 +614,7 @@ class Paymentreceiptsprovider extends ChangeNotifier{
pdf
.
addPage
(
pdf
.
addPage
(
pw
.
Page
(
build:
(
context
)
=>
pw
.
Table
.
fromTextArray
(
data:
data
)),
pw
.
Page
(
build:
(
context
)
=>
pw
.
Table
.
fromTextArray
(
data:
data
)),
);
);
final
dirPath
=
await
getSave
Di
rectory
();
final
dirPath
=
await
getSaverec
eip
tory
();
final
file
=
File
(
'
$dirPath
/requisition_data.pdf'
);
final
file
=
File
(
'
$dirPath
/requisition_data.pdf'
);
await
file
.
writeAsBytes
(
await
pdf
.
save
());
await
file
.
writeAsBytes
(
await
pdf
.
save
());
print
(
'PDF saved at:
${file.path}
'
);
print
(
'PDF saved at:
${file.path}
'
);
...
@@ -285,4 +646,162 @@ class Paymentreceiptsprovider extends ChangeNotifier{
...
@@ -285,4 +646,162 @@ class Paymentreceiptsprovider extends ChangeNotifier{
print
(
'Error printing data:
$e
'
);
print
(
'Error printing data:
$e
'
);
}
}
}
}
void
resetForm
()
{
reqPurposeController
.
clear
();
descController
.
clear
();
amountController
.
clear
();
bankNameController
.
clear
();
bankBranchController
.
clear
();
bankAccNumberController
.
clear
();
bankIfscController
.
clear
();
bankAcHolderController
.
clear
();
bankUpiController
.
clear
();
_selectedAccounts
=
null
;
_selectedPayment
=
null
;
_selectReqPurpose
=
null
;
_paymentModeId
=
""
;
_paymentModeValue
=
""
;
_accountId
=
""
;
_reqPurpose
=
""
;
_image
=
null
;
_image_picked
=
0
;
// _submitClicked = false;
// Clear validation errors
selectAccountError
=
null
;
reqPurposeError
=
null
;
descriptionError
=
null
;
amountError
=
null
;
selectPaymentError
=
null
;
bankNameError
=
null
;
bankBranchError
=
null
;
bankNumberError
=
null
;
bankIFSCError
=
null
;
bankHolderError
=
null
;
UPIError
=
null
;
FileError
=
null
;
buttonEnabled
=
false
;
notifyListeners
();
}
bool
validatereceiptForm
(
BuildContext
context
)
{
bool
isValid
=
true
;
notifyListeners
();
return
isValid
;
}
void
updateReqPupose
(
String
value
)
{
reqPurposeError
=
null
;
notifyListeners
();
}
void
updateDescription
(
String
value
)
{
descriptionError
=
null
;
notifyListeners
();
}
void
updateAmount
(
String
value
)
{
amountError
=
null
;
notifyListeners
();
}
void
updateBankName
(
String
value
)
{
bankNameError
=
null
;
notifyListeners
();
}
void
updateBankBranch
(
String
value
)
{
bankBranchError
=
null
;
notifyListeners
();
}
void
updateNumber
(
String
value
)
{
bankNumberError
=
null
;
notifyListeners
();
}
void
updateIFSC
(
String
value
)
{
bankIFSCError
=
null
;
notifyListeners
();
}
void
updateHolder
(
String
value
)
{
bankHolderError
=
null
;
notifyListeners
();
}
void
updateUPI
(
String
value
)
{
UPIError
=
null
;
notifyListeners
();
}
void
showDatePickerDialog
(
BuildContext
context
)
{
showCupertinoModalPopup
<
void
>(
context:
context
,
builder:
(
BuildContext
context
)
=>
Container
(
height:
216
,
padding:
const
EdgeInsets
.
only
(
top:
6.0
),
margin:
EdgeInsets
.
only
(
bottom:
MediaQuery
.
of
(
context
).
viewInsets
.
bottom
,
),
color:
CupertinoColors
.
systemBackground
.
resolveFrom
(
context
),
child:
SafeArea
(
top:
false
,
child:
Column
(
children:
[
Expanded
(
flex:
1
,
child:
SizedBox
(
height:
40
,
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
[
CupertinoButton
(
child:
Text
(
'Cancel'
,
style:
TextStyle
(
fontFamily:
"JakartaMedium"
),
),
onPressed:
()
{
Navigator
.
pop
(
context
);
},
),
CupertinoButton
(
child:
Text
(
'Done'
,
style:
TextStyle
(
fontFamily:
"JakartaMedium"
),
),
onPressed:
()
{
Navigator
.
pop
(
context
);
},
),
],
),
),
),
Expanded
(
flex:
3
,
child:
CupertinoDatePicker
(
minimumDate:
_date
??
DateTime
.
now
(),
initialDateTime:
_date
??
DateTime
.
now
(),
mode:
CupertinoDatePickerMode
.
date
,
use24hFormat:
true
,
showDayOfWeek:
true
,
onDateTimeChanged:
(
DateTime
newDate
)
{
setDate
(
newDate
);
},
),
),
],
),
),
),
);
}
}
}
\ No newline at end of file
lib/Notifiers/financeProvider/paymentRequisitionPaymentsListProvider.dart
View file @
e54f0aeb
...
@@ -29,10 +29,10 @@ class Paymentrequisitionpaymentslistprovider extends ChangeNotifier{
...
@@ -29,10 +29,10 @@ class Paymentrequisitionpaymentslistprovider extends ChangeNotifier{
List
<
String
>
get
Headings
=>
_headings
;
List
<
String
>
get
Headings
=>
_headings
;
List
<
String
>
get
subHeadings
=>
_subHeadings
;
List
<
String
>
get
subHeadings
=>
_subHeadings
;
Future
<
void
>
paymentsListAPI
(
context
)
async
{
Future
<
void
>
paymentsListAPI
(
context
,
from
,
to
)
async
{
try
{
try
{
var
prov
=
Provider
.
of
<
HomescreenNotifier
>(
context
,
listen:
false
);
var
prov
=
Provider
.
of
<
HomescreenNotifier
>(
context
,
listen:
false
);
final
data
=
await
ApiCalling
.
paymentRequisitionPaymentListAPI
(
prov
.
empId
,
prov
.
session
);
final
data
=
await
ApiCalling
.
paymentRequisitionPaymentListAPI
(
prov
.
empId
,
prov
.
session
,
from
,
to
);
if
(
data
!=
null
){
if
(
data
!=
null
){
if
(
data
.
error
==
"0"
){
if
(
data
.
error
==
"0"
){
_paymentsList
=
data
.
paymentsList
!;
_paymentsList
=
data
.
paymentsList
!;
...
...
lib/main.dart
View file @
e54f0aeb
...
@@ -23,6 +23,8 @@ import 'package:generp/Notifiers/ServiceEngineerDashboardProvider.dart';
...
@@ -23,6 +23,8 @@ import 'package:generp/Notifiers/ServiceEngineerDashboardProvider.dart';
import
'package:generp/Notifiers/TodayMontlyVisitsProvider.dart'
;
import
'package:generp/Notifiers/TodayMontlyVisitsProvider.dart'
;
import
'package:generp/Notifiers/UpdatePasswordProvider.dart'
;
import
'package:generp/Notifiers/UpdatePasswordProvider.dart'
;
import
'package:generp/Notifiers/VisitDetailsProvider.dart'
;
import
'package:generp/Notifiers/VisitDetailsProvider.dart'
;
import
'package:generp/Notifiers/commonProvider/accountsListProvider.dart'
;
import
'package:generp/Notifiers/commonProvider/commonPagesProvider.dart'
;
import
'package:generp/Notifiers/financeProvider/DashboardProvider.dart'
;
import
'package:generp/Notifiers/financeProvider/DashboardProvider.dart'
;
import
'package:generp/Notifiers/financeProvider/RequestionListProvider.dart'
;
import
'package:generp/Notifiers/financeProvider/RequestionListProvider.dart'
;
import
'package:generp/Notifiers/financeProvider/paymentReceiptsProvider.dart'
;
import
'package:generp/Notifiers/financeProvider/paymentReceiptsProvider.dart'
;
...
@@ -216,6 +218,8 @@ class MyApp extends StatelessWidget {
...
@@ -216,6 +218,8 @@ class MyApp extends StatelessWidget {
ChangeNotifierProvider
(
create:
(
_
)
=>
Requesitionlidtdetailsprovider
(),),
ChangeNotifierProvider
(
create:
(
_
)
=>
Requesitionlidtdetailsprovider
(),),
ChangeNotifierProvider
(
create:
(
_
)
=>
Paymentrequisitionpaymentslistprovider
(),),
ChangeNotifierProvider
(
create:
(
_
)
=>
Paymentrequisitionpaymentslistprovider
(),),
ChangeNotifierProvider
(
create:
(
_
)
=>
Paymentreceiptsprovider
(),),
ChangeNotifierProvider
(
create:
(
_
)
=>
Paymentreceiptsprovider
(),),
ChangeNotifierProvider
(
create:
(
_
)
=>
Commonpagesprovider
(),),
ChangeNotifierProvider
(
create:
(
_
)
=>
Accountslistprovider
(),),
],
],
child:
Builder
(
child:
Builder
(
builder:
(
BuildContext
context
)
{
builder:
(
BuildContext
context
)
{
...
...
lib/screens/HomeScreen.dart
View file @
e54f0aeb
...
@@ -14,6 +14,7 @@ import 'package:generp/screens/ScannerLogin.dart';
...
@@ -14,6 +14,7 @@ import 'package:generp/screens/ScannerLogin.dart';
import
'package:generp/screens/WebERPIOS.dart'
;
import
'package:generp/screens/WebERPIOS.dart'
;
import
'package:generp/screens/WebERPScreen.dart'
;
import
'package:generp/screens/WebERPScreen.dart'
;
import
'package:generp/screens/WebWhizzdomScreen.dart'
;
import
'package:generp/screens/WebWhizzdomScreen.dart'
;
import
'package:generp/screens/commom/commonDashboard.dart'
;
import
'package:generp/screens/finance/financeDashboard.dart'
;
import
'package:generp/screens/finance/financeDashboard.dart'
;
import
'package:generp/screens/genTracker/GenTrackerDashboard.dart'
;
import
'package:generp/screens/genTracker/GenTrackerDashboard.dart'
;
import
'package:generp/screens/serviceEngineer/NearbyGenerators.dart'
;
import
'package:generp/screens/serviceEngineer/NearbyGenerators.dart'
;
...
@@ -129,8 +130,8 @@ class _MyHomePageState extends State<MyHomePage> {
...
@@ -129,8 +130,8 @@ class _MyHomePageState extends State<MyHomePage> {
"Nearby"
,
"Nearby"
,
"Inventory"
,
"Inventory"
,
"Whizzdom"
,
"Whizzdom"
,
// "CRM
",
"Common
"
,
//
"Finance",
"Finance"
,
];
];
final
icons
=
[
final
icons
=
[
"assets/svg/home_icons_1.svg"
,
"assets/svg/home_icons_1.svg"
,
...
@@ -140,8 +141,8 @@ class _MyHomePageState extends State<MyHomePage> {
...
@@ -140,8 +141,8 @@ class _MyHomePageState extends State<MyHomePage> {
"assets/svg/home_icons_5.svg"
,
"assets/svg/home_icons_5.svg"
,
"assets/svg/home_icons_6.svg"
,
"assets/svg/home_icons_6.svg"
,
"assets/svg/home_icons_81.svg"
,
"assets/svg/home_icons_81.svg"
,
//
"assets/svg/home_icons_8.svg",
"assets/svg/home_icons_8.svg"
,
//
"assets/svg/home_icons_8.svg",
"assets/svg/home_icons_8.svg"
,
];
];
final
requiredRoles
=
[
final
requiredRoles
=
[
"430"
,
"430"
,
...
@@ -151,8 +152,8 @@ class _MyHomePageState extends State<MyHomePage> {
...
@@ -151,8 +152,8 @@ class _MyHomePageState extends State<MyHomePage> {
"433"
,
"433"
,
"432"
,
"432"
,
"431"
,
"431"
,
//
"43
1
",
"43
0
"
,
//
"43
1
",
"43
0
"
,
];
];
final
filteredItems
=
<
Map
<
String
,
String
>>[];
final
filteredItems
=
<
Map
<
String
,
String
>>[];
...
@@ -456,17 +457,22 @@ class _MyHomePageState extends State<MyHomePage> {
...
@@ -456,17 +457,22 @@ class _MyHomePageState extends State<MyHomePage> {
requestGpsPermission
();
requestGpsPermission
();
}
}
break
;
break
;
case
"CRM"
:
case
"Common"
:
//res = await Navigator.push(context, MaterialPageRoute(builder: (context)=>CRMScreen()));
res
=
await
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
context
)
=>
Commondashboard
(),
),
);
break
;
break
;
case
"Finance"
:
case
"Finance"
:
//
res = await Navigator.push(
res
=
await
Navigator
.
push
(
//
context,
context
,
//
MaterialPageRoute(
MaterialPageRoute
(
//
builder:
builder:
//
(context) => Financedashboard(),
(
context
)
=>
Financedashboard
(),
//
),
),
//
);
);
break
;
break
;
default
:
default
:
print
(
"111"
);
print
(
"111"
);
...
...
lib/screens/commom/accountLedger.dart
0 → 100644
View file @
e54f0aeb
import
'package:flutter/material.dart'
;
class
Accountledger
extends
StatefulWidget
{
const
Accountledger
({
super
.
key
});
@override
State
<
Accountledger
>
createState
()
=>
_AccountledgerState
();
}
class
_AccountledgerState
extends
State
<
Accountledger
>
{
@override
Widget
build
(
BuildContext
context
)
{
return
const
Placeholder
();
}
}
lib/screens/commom/accountsList.dart
0 → 100644
View file @
e54f0aeb
import
'package:flutter/material.dart'
;
import
'package:generp/Utils/app_colors.dart'
;
import
'package:generp/Utils/commonWidgets.dart'
;
import
'package:provider/provider.dart'
;
class
Accountslist
extends
StatefulWidget
{
const
Accountslist
({
super
.
key
});
@override
State
<
Accountslist
>
createState
()
=>
_AccountslistState
();
}
class
_AccountslistState
extends
State
<
Accountslist
>
{
@override
Widget
build
(
BuildContext
context
)
{
return
Consumer
(
builder:
(
context
,
provider
,
child
)
{
return
WillPopScope
(
child:
Scaffold
(
appBar:
appbar
(
context
,
"Account List"
),
backgroundColor:
AppColors
.
scaffold_bg_color
,
body:
Container
(
child:
SingleChildScrollView
(
child:
Column
(
children:
[
],
),
),
),
),
onWillPop:
()
=>
onBackPressed
(
context
));
});
}
}
lib/screens/commom/accountsListDetails.dart
0 → 100644
View file @
e54f0aeb
import
'package:flutter/material.dart'
;
class
Accountslistdetails
extends
StatefulWidget
{
const
Accountslistdetails
({
super
.
key
});
@override
State
<
Accountslistdetails
>
createState
()
=>
_AccountslistdetailsState
();
}
class
_AccountslistdetailsState
extends
State
<
Accountslistdetails
>
{
@override
Widget
build
(
BuildContext
context
)
{
return
const
Placeholder
();
}
}
lib/screens/commom/addCommonPayment.dart
0 → 100644
View file @
e54f0aeb
This diff is collapsed.
Click to expand it.
lib/screens/commom/commonDashboard.dart
0 → 100644
View file @
e54f0aeb
import
'package:flutter/material.dart'
;
import
'package:flutter_svg/svg.dart'
;
import
'package:generp/Notifiers/commonProvider/commonPagesProvider.dart'
;
import
'package:generp/screens/commom/accountLedger.dart'
;
import
'package:generp/screens/commom/accountsList.dart'
;
import
'package:generp/screens/commom/addCommonPayment.dart'
;
import
'package:provider/provider.dart'
;
import
'../../Utils/app_colors.dart'
;
import
'../../Utils/commonWidgets.dart'
;
class
Commondashboard
extends
StatefulWidget
{
const
Commondashboard
({
super
.
key
});
@override
State
<
Commondashboard
>
createState
()
=>
_CommondashboardState
();
}
class
_CommondashboardState
extends
State
<
Commondashboard
>
{
@override
void
initState
()
{
// TODO: implement initState
super
.
initState
();
WidgetsBinding
.
instance
.
addPostFrameCallback
((
timeStamp
)
{
var
prov
=
Provider
.
of
<
Commonpagesprovider
>(
context
,
listen:
false
);
prov
.
commonAccessPagesAPIFunction
(
context
);
},);
}
@override
Widget
build
(
BuildContext
context
)
{
return
Consumer
<
Commonpagesprovider
>(
builder:
(
context
,
provider
,
child
)
{
final
gridPages
=
provider
.
accessPages
.
where
((
page
)
=>
page
.
id
!=
292
)
.
toList
();
return
WillPopScope
(
onWillPop:
()
=>
onBackPressed
(
context
),
child:
Scaffold
(
resizeToAvoidBottomInset:
true
,
backgroundColor:
AppColors
.
scaffold_bg_color
,
appBar:
appbar
(
context
,
"Common"
),
body:
GridView
.
builder
(
padding:
EdgeInsets
.
symmetric
(
vertical:
10
,
horizontal:
10
),
itemCount:
gridPages
.
length
,
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount
(
crossAxisCount:
2
,
crossAxisSpacing:
10
,
mainAxisSpacing:
10
,
),
itemBuilder:
(
context
,
index
)
{
final
icons
=
[
"gent_gen_det"
,
"gent_reg_comp"
];
return
InkResponse
(
onTap:
()
{
switch
(
gridPages
[
index
].
pageName
!)
{
case
"Account List"
:
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
context
)
=>
Accountslist
()),
);
break
;
case
"Account Ledger"
:
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
context
)
=>
Accountledger
()),
);
break
;
default
:
print
(
"111"
);
break
;
}
},
child:
Container
(
decoration:
BoxDecoration
(
color:
Colors
.
white
,
borderRadius:
BorderRadius
.
circular
(
30
),
),
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
center
,
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
SvgPicture
.
asset
(
"assets/svg/
${icons[index]}
.svg"
),
SizedBox
(
height:
10
),
Text
(
gridPages
[
index
].
pageName
!),
],
),
),
);
},
),
floatingActionButtonLocation:
FloatingActionButtonLocation
.
centerFloat
,
floatingActionButton:
provider
.
accessPages
.
any
((
page
)
=>
page
.
id
==
292
)?
InkResponse
(
onTap:
()
{
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
context
)
=>
Addcommonpayment
()),
);
},
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
(
"Add Common Account"
,
style:
TextStyle
(
fontSize:
15
,
fontFamily:
"JakartaMedium"
,
color:
Colors
.
white
,
),
),
),
):
SizedBox
(
height:
0
,),
),
);
}
);
}
}
lib/screens/commom/transactionDetails.dart
0 → 100644
View file @
e54f0aeb
import
'package:flutter/material.dart'
;
class
Transactiondetails
extends
StatefulWidget
{
const
Transactiondetails
({
super
.
key
});
@override
State
<
Transactiondetails
>
createState
()
=>
_TransactiondetailsState
();
}
class
_TransactiondetailsState
extends
State
<
Transactiondetails
>
{
@override
Widget
build
(
BuildContext
context
)
{
return
const
Placeholder
();
}
}
lib/screens/commonDateRangeFilter.dart
0 → 100644
View file @
e54f0aeb
import
'package:dropdown_button2/dropdown_button2.dart'
;
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/material.dart'
;
class
Commondaterangefilter
{
final
List
<
String
>
filterItems
=
[
'Today'
,
'Yesterday'
,
'This Month'
,
'Past 7 days'
,
'Last Month'
,
'Custom'
,
];
String
?
selectedValue
;
DateTimeRange
?
selectedDateRange
;
// Get DateTimeRange based on filter selection
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
'Past 7 days'
:
return
DateTimeRange
(
start:
now
.
subtract
(
Duration
(
days:
6
)),
end:
DateTime
(
now
.
year
,
now
.
month
,
now
.
day
),
);
case
'Last Month'
:
return
DateTimeRange
(
start:
DateTime
(
now
.
year
,
now
.
month
-
1
,
1
),
end:
DateTime
(
now
.
year
,
now
.
month
,
0
),
);
case
'Custom'
:
return
null
;
// Custom handled in bottom sheet
default
:
return
null
;
}
}
// Format a single DateTime to string
String
formatDate
(
DateTime
date
)
{
return
"
${date.year}
-
${date.month.toString().padLeft(2, '0')}
-
${date.day.toString().padLeft(2, '0')}
"
;
}
// Get formatted date range as a list of strings
List
<
String
>
getFormattedDateRange
(
DateTimeRange
?
dateRange
)
{
if
(
dateRange
!=
null
)
{
return
[
formatDate
(
dateRange
.
start
),
formatDate
(
dateRange
.
end
),
];
}
return
[];
}
// Show bottom sheet with dropdown and custom calendar for Custom
Future
<
Map
<
String
,
dynamic
>?>
showFilterBottomSheet
(
BuildContext
context
)
async
{
String
?
tempSelectedValue
=
selectedValue
;
DateTimeRange
?
tempSelectedDateRange
=
selectedDateRange
;
DateTime
?
tempStartDate
;
DateTime
?
tempEndDate
;
DateTime
displayedMonth
=
DateTime
.
now
();
return
await
showModalBottomSheet
<
Map
<
String
,
dynamic
>>(
context:
context
,
isScrollControlled:
true
,
shape:
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
vertical
(
top:
Radius
.
circular
(
20
)),
),
builder:
(
BuildContext
context
)
{
return
StatefulBuilder
(
builder:
(
BuildContext
context
,
StateSetter
setState
)
{
// Custom calendar widget
Widget
buildCalendar
()
{
final
firstDayOfMonth
=
DateTime
(
displayedMonth
.
year
,
displayedMonth
.
month
,
1
);
final
lastDayOfMonth
=
DateTime
(
displayedMonth
.
year
,
displayedMonth
.
month
+
1
,
0
);
final
firstDayOfWeek
=
firstDayOfMonth
.
weekday
;
final
daysInMonth
=
lastDayOfMonth
.
day
;
final
daysBefore
=
(
firstDayOfWeek
-
1
)
%
7
;
List
<
Widget
>
dayWidgets
=
[];
// Weekday headers
final
weekdays
=
[
'Mon'
,
'Tue'
,
'Wed'
,
'Thu'
,
'Fri'
,
'Sat'
,
'Sun'
];
dayWidgets
.
addAll
(
weekdays
.
map
((
day
)
=>
Center
(
child:
Text
(
day
,
style:
TextStyle
(
fontSize:
14
,
fontWeight:
FontWeight
.
w600
,
color:
Colors
.
grey
[
700
],
),
),
)));
// Empty cells before the first day
for
(
int
i
=
0
;
i
<
daysBefore
;
i
++)
{
dayWidgets
.
add
(
Container
());
}
// Days of the month
for
(
int
day
=
1
;
day
<=
daysInMonth
;
day
++)
{
final
currentDate
=
DateTime
(
displayedMonth
.
year
,
displayedMonth
.
month
,
day
);
bool
isSelected
=
false
;
bool
isInRange
=
false
;
bool
isOutsideRange
=
currentDate
.
isBefore
(
DateTime
(
2020
))
||
currentDate
.
isAfter
(
DateTime
(
2100
));
if
(
tempStartDate
!=
null
&&
tempEndDate
!=
null
)
{
isSelected
=
currentDate
.
isAtSameMomentAs
(
tempStartDate
!)
||
currentDate
.
isAtSameMomentAs
(
tempEndDate
!);
isInRange
=
currentDate
.
isAfter
(
tempStartDate
!)
&&
currentDate
.
isBefore
(
tempEndDate
!)
&&
!
isSelected
;
}
dayWidgets
.
add
(
GestureDetector
(
onTap:
isOutsideRange
?
null
:
()
{
setState
(()
{
if
(
tempStartDate
==
null
)
{
tempStartDate
=
currentDate
;
}
else
if
(
tempEndDate
==
null
)
{
if
(
currentDate
.
isBefore
(
tempStartDate
!))
{
tempEndDate
=
tempStartDate
;
tempStartDate
=
currentDate
;
}
else
{
tempEndDate
=
currentDate
;
}
tempSelectedDateRange
=
DateTimeRange
(
start:
tempStartDate
!,
end:
tempEndDate
!,
);
}
else
{
tempStartDate
=
currentDate
;
tempEndDate
=
null
;
tempSelectedDateRange
=
null
;
}
});
},
child:
Container
(
margin:
EdgeInsets
.
all
(
2
),
decoration:
BoxDecoration
(
color:
isSelected
?
Colors
.
blue
[
600
]
:
isInRange
?
Colors
.
blue
[
100
]
:
null
,
shape:
BoxShape
.
circle
,
),
child:
Center
(
child:
Text
(
'
$day
'
,
style:
TextStyle
(
color:
isOutsideRange
?
Colors
.
grey
[
400
]
:
isSelected
?
Colors
.
white
:
Colors
.
black
,
fontWeight:
isSelected
?
FontWeight
.
bold
:
FontWeight
.
normal
,
),
),
),
),
),
);
}
return
Column
(
children:
[
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
[
IconButton
(
icon:
Icon
(
Icons
.
chevron_left
,
color:
Colors
.
blue
[
600
]),
onPressed:
displayedMonth
.
isAfter
(
DateTime
(
2020
))
?
()
{
setState
(()
{
displayedMonth
=
DateTime
(
displayedMonth
.
year
,
displayedMonth
.
month
-
1
);
});
}
:
null
,
),
Text
(
'
${_monthName(displayedMonth.month)}
${displayedMonth.year}
'
,
style:
TextStyle
(
fontSize:
16
,
fontWeight:
FontWeight
.
w600
),
),
IconButton
(
icon:
Icon
(
Icons
.
chevron_right
,
color:
Colors
.
blue
[
600
]),
onPressed:
displayedMonth
.
isBefore
(
DateTime
(
2100
))
?
()
{
setState
(()
{
displayedMonth
=
DateTime
(
displayedMonth
.
year
,
displayedMonth
.
month
+
1
);
});
}
:
null
,
),
],
),
Container
(
height:
280
,
child:
GridView
.
count
(
crossAxisCount:
7
,
childAspectRatio:
1
,
children:
dayWidgets
,
physics:
NeverScrollableScrollPhysics
(),
),
),
],
);
}
return
Padding
(
padding:
EdgeInsets
.
all
(
16.0
),
child:
SingleChildScrollView
(
child:
Column
(
mainAxisSize:
MainAxisSize
.
min
,
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
Text
(
'Select Date Range'
,
style:
TextStyle
(
fontSize:
18
,
fontWeight:
FontWeight
.
bold
),
),
SizedBox
(
height:
16
),
DropdownButtonHideUnderline
(
child:
DropdownButton2
<
String
>(
isExpanded:
true
,
hint:
Text
(
tempSelectedValue
??
'Select Item'
,
style:
TextStyle
(
fontSize:
14
,
fontWeight:
FontWeight
.
w400
,
color:
Colors
.
black
,
),
),
items:
filterItems
.
map
((
String
item
)
{
return
DropdownMenuItem
<
String
>(
value:
item
,
child:
Text
(
item
,
style:
TextStyle
(
fontSize:
14
,
fontWeight:
FontWeight
.
w400
,
color:
Colors
.
black
,
),
),
);
}).
toList
(),
value:
tempSelectedValue
,
onChanged:
(
String
?
value
)
{
if
(
value
==
null
)
return
;
setState
(()
{
tempSelectedValue
=
value
;
if
(
value
!=
'Custom'
)
{
tempSelectedDateRange
=
getDateRange
(
value
);
tempStartDate
=
null
;
tempEndDate
=
null
;
}
else
{
tempSelectedDateRange
=
null
;
tempStartDate
=
null
;
tempEndDate
=
null
;
}
});
},
buttonStyleData:
ButtonStyleData
(
height:
40
,
width:
double
.
infinity
,
padding:
EdgeInsets
.
symmetric
(
horizontal:
14
),
decoration:
BoxDecoration
(
border:
Border
.
all
(
color:
Colors
.
grey
),
borderRadius:
BorderRadius
.
circular
(
8
),
),
),
dropdownStyleData:
DropdownStyleData
(
maxHeight:
200
,
width:
MediaQuery
.
of
(
context
).
size
.
width
-
32
,
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
14
),
color:
Colors
.
white
,
),
),
),
),
if
(
tempSelectedValue
==
'Custom'
)
...[
SizedBox
(
height:
16
),
Container
(
decoration:
BoxDecoration
(
border:
Border
.
all
(
color:
Colors
.
grey
[
300
]!),
borderRadius:
BorderRadius
.
circular
(
12
),
),
padding:
EdgeInsets
.
all
(
12
),
child:
buildCalendar
(),
),
if
(
tempSelectedDateRange
!=
null
)
Padding
(
padding:
const
EdgeInsets
.
only
(
top:
12.0
),
child:
Text
(
'Selected:
${formatDate(tempSelectedDateRange!.start)}
to
${formatDate(tempSelectedDateRange!.end)}
'
,
style:
TextStyle
(
fontSize:
14
,
color:
Colors
.
grey
[
600
]),
),
),
],
SizedBox
(
height:
16
),
Row
(
mainAxisAlignment:
MainAxisAlignment
.
end
,
children:
[
TextButton
(
onPressed:
()
=>
Navigator
.
pop
(
context
),
child:
Text
(
'Cancel'
,
style:
TextStyle
(
color:
Colors
.
grey
[
600
]),
),
),
SizedBox
(
width:
8
),
ElevatedButton
(
onPressed:
tempSelectedDateRange
!=
null
&&
tempSelectedValue
!=
null
?
()
{
selectedValue
=
tempSelectedValue
;
selectedDateRange
=
tempSelectedDateRange
;
Navigator
.
pop
(
context
,
{
'selectedValue'
:
tempSelectedValue
,
'dateRange'
:
tempSelectedDateRange
,
'formatted'
:
getFormattedDateRange
(
tempSelectedDateRange
),
});
}
:
null
,
style:
ElevatedButton
.
styleFrom
(
backgroundColor:
Colors
.
blue
[
600
],
foregroundColor:
Colors
.
white
,
shape:
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
circular
(
8
),
),
),
child:
Text
(
'Apply'
),
),
],
),
SizedBox
(
height:
MediaQuery
.
of
(
context
).
viewInsets
.
bottom
),
],
),
),
);
},
);
},
);
}
// Helper to get month name
String
_monthName
(
int
month
)
{
const
months
=
[
'January'
,
'February'
,
'March'
,
'April'
,
'May'
,
'June'
,
'July'
,
'August'
,
'September'
,
'October'
,
'November'
,
'December'
];
return
months
[
month
-
1
];
}
}
// Widget to demonstrate usage
class
MyWidget
extends
StatelessWidget
{
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
body:
Center
(
child:
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
"
);
}
else
{
print
(
"No valid date range selected"
);
}
}
else
{
print
(
"Bottom sheet closed without selection"
);
}
},
child:
Icon
(
CupertinoIcons
.
color_filter
),
),
),
);
}
}
\ No newline at end of file
lib/screens/finance/AllPaymentRequesitionListsByModes.dart
View file @
e54f0aeb
This diff is collapsed.
Click to expand it.
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment