Commit 7210793a authored by Sai Srinivas's avatar Sai Srinivas
Browse files

17-09

parent 185e0896
...@@ -6,8 +6,7 @@ import 'package:generp/Notifiers/HomeScreenNotifier.dart'; ...@@ -6,8 +6,7 @@ import 'package:generp/Notifiers/HomeScreenNotifier.dart';
import 'package:generp/services/api_calling.dart'; import 'package:generp/services/api_calling.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
class Accountledgerprovider extends ChangeNotifier{ class Accountledgerprovider extends ChangeNotifier {
TextEditingController searchAccountController = TextEditingController(); TextEditingController searchAccountController = TextEditingController();
List<Accounts> _accounts = []; List<Accounts> _accounts = [];
...@@ -29,30 +28,33 @@ class Accountledgerprovider extends ChangeNotifier{ ...@@ -29,30 +28,33 @@ class Accountledgerprovider extends ChangeNotifier{
String get selectedAcId => _selectedAcID; String get selectedAcId => _selectedAcID;
String get selectedAcVal => _selectedAcVal; String get selectedAcVal => _selectedAcVal;
set showMoreDetails(bool value){ set showMoreDetails(bool value) {
_showMoreDetails = value; _showMoreDetails = value;
notifyListeners(); notifyListeners();
} }
set accounts(List<Accounts> value){
set accounts(List<Accounts> value) {
_accounts = value; _accounts = value;
notifyListeners(); notifyListeners();
} }
set selectedAccount(Accounts? value){
set selectedAccount(Accounts? value) {
_selectedAccount = value; _selectedAccount = value;
_selectedAcID = value!.id!; _selectedAcID = value!.id!;
_selectedAcVal = value!.name!; _selectedAcVal = value.name!;
notifyListeners(); notifyListeners();
} }
set selectedAcId(String value){ set selectedAcId(String value) {
_selectedAcID = value; _selectedAcID = value;
notifyListeners(); notifyListeners();
} }
set selectedAcVal(String value){ set selectedAcVal(String value) {
_selectedAcVal = value; _selectedAcVal = value;
notifyListeners(); notifyListeners();
} }
// Reset all values // Reset all values
void resetAll() { void resetAll() {
_selectedAccount = null; _selectedAccount = null;
...@@ -63,8 +65,9 @@ class Accountledgerprovider extends ChangeNotifier{ ...@@ -63,8 +65,9 @@ class Accountledgerprovider extends ChangeNotifier{
checkDropdownReset(); checkDropdownReset();
notifyListeners(); // Notify UI to update notifyListeners(); // Notify UI to update
} }
void checkDropdownReset(){
if(!_accounts.contains(_selectedAccount)&&_selectedAccount!=null){ void checkDropdownReset() {
if (!_accounts.contains(_selectedAccount) && _selectedAccount != null) {
_selectedAcID = ""; _selectedAcID = "";
_selectedAcVal = ""; _selectedAcVal = "";
} }
...@@ -72,50 +75,53 @@ class Accountledgerprovider extends ChangeNotifier{ ...@@ -72,50 +75,53 @@ class Accountledgerprovider extends ChangeNotifier{
} }
Future<void> dropDownAPI(context) async { Future<void> dropDownAPI(context) async {
try{ try {
var prov = Provider.of<HomescreenNotifier>(context,listen: false); var prov = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.commonAccountLedgerDropDownAPI(prov.empId,prov.session); final data = await ApiCalling.commonAccountLedgerDropDownAPI(
if(data!=null){ prov.empId,
if(data.error=="0"){ prov.session,
);
if (data != null) {
if (data.error == "0") {
checkDropdownReset(); checkDropdownReset();
_accounts = data.accounts!; _accounts = data.accounts!;
notifyListeners(); notifyListeners();
} }
} }
}catch (e,s){ } catch (e) {}
}
} }
Future<void> ledgerlistAPI(context) async { Future<void> ledgerlistAPI(context) async {
try{ try {
var prov = Provider.of<HomescreenNotifier>(context,listen: false); var prov = Provider.of<HomescreenNotifier>(context, listen: false);
_ledgerList.clear(); _ledgerList.clear();
_isLoading = true; _isLoading = true;
notifyListeners(); notifyListeners();
final data = await ApiCalling.commonAccountLedgerListAPI(prov.empId,prov.session,selectedAcId); final data = await ApiCalling.commonAccountLedgerListAPI(
if(data!=null){ prov.empId,
if(data.error=="0"){ prov.session,
selectedAcId,
);
if (data != null) {
if (data.error == "0") {
_isLoading = false; _isLoading = false;
_ledgerList= data.ledgerList!; _ledgerList = data.ledgerList!;
_balanceDetails = data.balanceDetails!; _balanceDetails = data.balanceDetails!;
_accountDetails= data.accountDetails!; _accountDetails = data.accountDetails!;
if (_selectedAccount != null && if (_selectedAccount != null &&
!_accounts.contains(_selectedAccount)) { !_accounts.contains(_selectedAccount)) {
_selectedAccount = null; _selectedAccount = null;
_selectedAcID = ""; _selectedAcID = "";
} }
notifyListeners(); notifyListeners();
} else if(data.error=="1"){ } else if (data.error == "1") {
_isLoading = false; _isLoading = false;
notifyListeners(); notifyListeners();
} }
} }
}catch (e,s){ } catch (e) {}
}
} }
Map<String, List<LedgerList>> groupByDate(List<LedgerList> list) { Map<String, List<LedgerList>> groupByDate(List<LedgerList> list) {
Map<String, List<LedgerList>> grouped = {}; Map<String, List<LedgerList>> grouped = {};
...@@ -129,4 +135,4 @@ class Accountledgerprovider extends ChangeNotifier{ ...@@ -129,4 +135,4 @@ class Accountledgerprovider extends ChangeNotifier{
return grouped; return grouped;
} }
} }
\ No newline at end of file
...@@ -141,7 +141,7 @@ class Accountslistprovider extends ChangeNotifier { ...@@ -141,7 +141,7 @@ class Accountslistprovider extends ChangeNotifier {
set selectedState(States? value) { set selectedState(States? value) {
_selectedState = value; _selectedState = value;
_selectedStateID = value!.id; _selectedStateID = value!.id;
_selectedStateValue = value!.name; _selectedStateValue = value.name;
stateError = null; stateError = null;
notifyListeners(); notifyListeners();
} }
...@@ -149,7 +149,7 @@ class Accountslistprovider extends ChangeNotifier { ...@@ -149,7 +149,7 @@ class Accountslistprovider extends ChangeNotifier {
set selectedDistricts(Districts? value) { set selectedDistricts(Districts? value) {
_selectedDistricts = value; _selectedDistricts = value;
_selectedDistrictID = value!.id; _selectedDistrictID = value!.id;
_selectedDistrictValue = value!.district; _selectedDistrictValue = value.district;
districtError = null; districtError = null;
notifyListeners(); notifyListeners();
} }
...@@ -157,7 +157,7 @@ class Accountslistprovider extends ChangeNotifier { ...@@ -157,7 +157,7 @@ class Accountslistprovider extends ChangeNotifier {
set selectedSubLocations(SubLocations? value) { set selectedSubLocations(SubLocations? value) {
_selectedSubLocations = value; _selectedSubLocations = value;
_selectedSubLocID = value!.id; _selectedSubLocID = value!.id;
_selectedSubLocValue = value!.subLocality!; _selectedSubLocValue = value.subLocality!;
localityError = null; localityError = null;
notifyListeners(); notifyListeners();
} }
...@@ -210,7 +210,7 @@ class Accountslistprovider extends ChangeNotifier { ...@@ -210,7 +210,7 @@ class Accountslistprovider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
} }
} catch (e, s) {} } catch (e) {}
} }
Future<void> getDistrictAPI(context, stateID) async { Future<void> getDistrictAPI(context, stateID) async {
...@@ -229,7 +229,7 @@ class Accountslistprovider extends ChangeNotifier { ...@@ -229,7 +229,7 @@ class Accountslistprovider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
} }
} catch (e, s) {} } catch (e) {}
} }
Future<void> getSubLocationAPI(context, districtID) async { Future<void> getSubLocationAPI(context, districtID) async {
...@@ -248,7 +248,7 @@ class Accountslistprovider extends ChangeNotifier { ...@@ -248,7 +248,7 @@ class Accountslistprovider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
} }
} catch (e, s) {} } catch (e) {}
} }
Future<void> checkInputsAPI(context, type, value) async { Future<void> checkInputsAPI(context, type, value) async {
...@@ -275,7 +275,7 @@ class Accountslistprovider extends ChangeNotifier { ...@@ -275,7 +275,7 @@ class Accountslistprovider extends ChangeNotifier {
// toast(context, data.message); // toast(context, data.message);
} }
} }
} catch (e, s) {} } catch (e) {}
} }
bool hasFilledAdditionalDetails = false; bool hasFilledAdditionalDetails = false;
...@@ -354,14 +354,13 @@ class Accountslistprovider extends ChangeNotifier { ...@@ -354,14 +354,13 @@ class Accountslistprovider extends ChangeNotifier {
_submitClicked = false; _submitClicked = false;
notifyListeners(); notifyListeners();
} }
} catch (e, s) { } catch (e) {
_submitClicked = false; _submitClicked = false;
notifyListeners(); notifyListeners();
} }
} }
bool validateStep1() {
bool validateStep1(){
accountError = null; accountError = null;
nameError = null; nameError = null;
mobileError = null; mobileError = null;
...@@ -375,7 +374,8 @@ class Accountslistprovider extends ChangeNotifier { ...@@ -375,7 +374,8 @@ class Accountslistprovider extends ChangeNotifier {
nameError = "Please Enter a Name"; nameError = "Please Enter a Name";
isValid = false; isValid = false;
} }
if(mobileController.text.trim().isNotEmpty&&mobileController.text.length<10){ if (mobileController.text.trim().isNotEmpty &&
mobileController.text.length < 10) {
mobileError = "Mobile Number should be 10 digits"; mobileError = "Mobile Number should be 10 digits";
isValid = false; isValid = false;
} }
...@@ -391,33 +391,35 @@ class Accountslistprovider extends ChangeNotifier { ...@@ -391,33 +391,35 @@ class Accountslistprovider extends ChangeNotifier {
notifyListeners(); notifyListeners();
return isValid; return isValid;
} }
bool validateStep2(){
bool validateStep2() {
stateError = null; stateError = null;
districtError = null; districtError = null;
localityError = null; localityError = null;
addressError = null; addressError = null;
bool isValid = true; bool isValid = true;
// if (_selectedState == null || _selectedStateID!.isEmpty) { // if (_selectedState == null || _selectedStateID!.isEmpty) {
// stateError = "Please select a State"; // stateError = "Please select a State";
// isValid = false; // isValid = false;
// } // }
// if (_selectedDistricts == null || _selectedDistrictID!.isEmpty) { // if (_selectedDistricts == null || _selectedDistrictID!.isEmpty) {
// districtError = "Please select a District"; // districtError = "Please select a District";
// isValid = false; // isValid = false;
// } // }
// if (_selectedSubLocations == null || _selectedSubLocID!.isEmpty) { // if (_selectedSubLocations == null || _selectedSubLocID!.isEmpty) {
// localityError = "Please select a Locality"; // localityError = "Please select a Locality";
// isValid = false; // isValid = false;
// } // }
// if (addressController.text.trim().isEmpty) { // if (addressController.text.trim().isEmpty) {
// addressError = "Please Enter an Address"; // addressError = "Please Enter an Address";
// isValid = false; // isValid = false;
// } // }
_submitClicked = false; _submitClicked = false;
notifyListeners(); notifyListeners();
return isValid; return isValid;
} }
bool validateStep3(){
bool validateStep3() {
banknameError = null; banknameError = null;
bankBranchError = null; bankBranchError = null;
bankIFSCError = null; bankIFSCError = null;
...@@ -425,48 +427,49 @@ class Accountslistprovider extends ChangeNotifier { ...@@ -425,48 +427,49 @@ class Accountslistprovider extends ChangeNotifier {
bankAcNumberError = null; bankAcNumberError = null;
upiError = null; upiError = null;
bool isValid = true; bool isValid = true;
// if (bankNameController.text // if (bankNameController.text
// .trim() // .trim()
// .isEmpty) { // .isEmpty) {
// banknameError = "Please Enter a Bank Name"; // banknameError = "Please Enter a Bank Name";
// isValid = false; // isValid = false;
// } // }
// //
// if (branchNameController.text // if (branchNameController.text
// .trim() // .trim()
// .isEmpty) { // .isEmpty) {
// bankBranchError = "Please Enter Branch Name"; // bankBranchError = "Please Enter Branch Name";
// isValid = false; // isValid = false;
// } // }
// if (bankIfscCotroller.text // if (bankIfscCotroller.text
// .trim() // .trim()
// .isEmpty) { // .isEmpty) {
// bankIFSCError = "Please Enter Bank IFSC"; // bankIFSCError = "Please Enter Bank IFSC";
// isValid = false; // isValid = false;
// } // }
// if (bankHolderNameController.text // if (bankHolderNameController.text
// .trim() // .trim()
// .isEmpty) { // .isEmpty) {
// bankHolderNameError = "Please Enter Account Holder Name"; // bankHolderNameError = "Please Enter Account Holder Name";
// isValid = false; // isValid = false;
// } // }
// if (bankAcNumberController.text // if (bankAcNumberController.text
// .trim() // .trim()
// .isEmpty) { // .isEmpty) {
// bankAcNumberError = "Please Enter Bank Account Number"; // bankAcNumberError = "Please Enter Bank Account Number";
// isValid = false; // isValid = false;
// } // }
// if (bankUpiController.text // if (bankUpiController.text
// .trim() // .trim()
// .isEmpty) { // .isEmpty) {
// upiError = "Please Enter UPI ID"; // upiError = "Please Enter UPI ID";
// isValid = false; // isValid = false;
// } // }
_submitClicked = false; _submitClicked = false;
notifyListeners(); notifyListeners();
return isValid; return isValid;
} }
bool validateStep4(){
bool validateStep4() {
bool isValid = true; bool isValid = true;
// if (contectPersonDesignationController.text // if (contectPersonDesignationController.text
// .trim() // .trim()
...@@ -706,26 +709,22 @@ class Accountslistprovider extends ChangeNotifier { ...@@ -706,26 +709,22 @@ class Accountslistprovider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
void onChangedMobileNum(value) {
void onChangedMobileNum(value){
notifyListeners(); notifyListeners();
} }
void onChangedCompanyName(value){ void onChangedCompanyName(value) {
notifyListeners(); notifyListeners();
} }
String? _errorMessage; String? _errorMessage;
String? get errorMessage => _errorMessage; String? get errorMessage => _errorMessage;
// Common Account list provider // Common Account list provider
Future<void> commonAccountListAPIFunction( Future<void> commonAccountListAPIFunction(
BuildContext context, { BuildContext context, {
bool append = false, bool append = false,
}) async { }) async {
try { try {
var prov = Provider.of<HomescreenNotifier>(context, listen: false); var prov = Provider.of<HomescreenNotifier>(context, listen: false);
...@@ -748,16 +747,19 @@ class Accountslistprovider extends ChangeNotifier { ...@@ -748,16 +747,19 @@ class Accountslistprovider extends ChangeNotifier {
companyNameController.text, companyNameController.text,
mobileNumberController.text, mobileNumberController.text,
); );
debugPrint('empId: ${prov.empId}, session: ${prov.session}, pageNumber: $_pageNum'); debugPrint(
'empId: ${prov.empId}, session: ${prov.session}, pageNumber: $_pageNum',
);
if (data != null && data.error == "0") { if (data != null && data.error == "0") {
if (data.accountList != null) { if (data.accountList != null) {
if (append) { if (append) {
// Append with deduplication // Append with deduplication
final existingIds = _accountsList.map((e) => e.id).toSet(); final existingIds = _accountsList.map((e) => e.id).toSet();
final newItems = data.accountList! final newItems =
.where((item) => !existingIds.contains(item.id)) data.accountList!
.toList(); .where((item) => !existingIds.contains(item.id))
.toList();
_accountsList.addAll(newItems); _accountsList.addAll(newItems);
} else { } else {
_accountsList = data.accountList!; _accountsList = data.accountList!;
...@@ -768,7 +770,7 @@ class Accountslistprovider extends ChangeNotifier { ...@@ -768,7 +770,7 @@ class Accountslistprovider extends ChangeNotifier {
if (_hasMoreData) _pageNum++; if (_hasMoreData) _pageNum++;
} }
} }
} catch (e, s) { } catch (e) {
debugPrint("Error in commonAccountListAPIFunction: $e"); debugPrint("Error in commonAccountListAPIFunction: $e");
} finally { } finally {
_isLoading = false; _isLoading = false;
...@@ -776,10 +778,6 @@ class Accountslistprovider extends ChangeNotifier { ...@@ -776,10 +778,6 @@ class Accountslistprovider extends ChangeNotifier {
} }
} }
resetValues() { resetValues() {
print("rv"); print("rv");
_selectedAccountType = null; _selectedAccountType = null;
......
...@@ -5,25 +5,23 @@ import 'package:provider/provider.dart'; ...@@ -5,25 +5,23 @@ import 'package:provider/provider.dart';
import '../../Models/commonModels/commonAccessiblePagesResponse.dart'; import '../../Models/commonModels/commonAccessiblePagesResponse.dart';
class Commonpagesprovider extends ChangeNotifier{ class Commonpagesprovider extends ChangeNotifier {
List<PagesAccessible> _accessPages = []; List<PagesAccessible> _accessPages = [];
List<PagesAccessible> get accessPages => _accessPages; List<PagesAccessible> get accessPages => _accessPages;
Future<void> commonAccessPagesAPIFunction(context) async { Future<void> commonAccessPagesAPIFunction(context) async {
try{ try {
var HomeProv = Provider.of<HomescreenNotifier>(context,listen: false); var HomeProv = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.commonDashboardPagesAPI(HomeProv.empId, HomeProv.session); final data = await ApiCalling.commonDashboardPagesAPI(
if(data!=null){ HomeProv.empId,
if(data.error=="0"){ HomeProv.session,
);
if (data != null) {
if (data.error == "0") {
_accessPages = data.pagesAccessible!; _accessPages = data.pagesAccessible!;
notifyListeners(); notifyListeners();
} }
} }
} catch (e) {}
}catch (e,s){
}
} }
}
}
\ No newline at end of file
...@@ -796,7 +796,9 @@ class Leadlistprovider extends ChangeNotifier { ...@@ -796,7 +796,9 @@ class Leadlistprovider extends ChangeNotifier {
_selectedSources = value; _selectedSources = value;
_selectedSourceId = value?.id; _selectedSourceId = value?.id;
_selectedSourceValue = value?.name; _selectedSourceValue = value?.name;
print('Setting selectedSource: $value, id: ${_selectedSourceId}, name: ${_selectedSourceValue}'); print(
'Setting selectedSource: $value, id: $_selectedSourceId, name: $_selectedSourceValue',
);
notifyListeners(); notifyListeners();
} }
...@@ -965,7 +967,9 @@ class Leadlistprovider extends ChangeNotifier { ...@@ -965,7 +967,9 @@ class Leadlistprovider extends ChangeNotifier {
mode, mode,
); );
if (data != null) { if (data != null) {
print('crmLeadListViewAPI error: ${data.error}, sources: ${data.sources}'); print(
'crmLeadListViewAPI error: ${data.error}, sources: ${data.sources}',
);
if (data.error == "0") { if (data.error == "0") {
_leadStatusList = [ _leadStatusList = [
"all", "all",
...@@ -975,12 +979,33 @@ class Leadlistprovider extends ChangeNotifier { ...@@ -975,12 +979,33 @@ class Leadlistprovider extends ChangeNotifier {
"Order Gain", "Order Gain",
"Order Lost", "Order Lost",
]; ];
_alphabetList = List.generate(26, (index) => String.fromCharCode(index + 65)); _alphabetList = List.generate(
26,
(index) => String.fromCharCode(index + 65),
);
_openStatusList = ["open", "Closed", "All"]; _openStatusList = ["open", "Closed", "All"];
_sourcesList = data.sources?.where((source) => source != null && source.id != null && source.name != null).toList() ?? []; _sourcesList =
_teamsList = data.teams?.where((team) => team != null && team.id != null && team.name != null).toList() ?? []; data.sources
_statesList = data.states?.where((state) => state != null && state.id != null && state.name != null).toList() ?? []; ?.where((source) => source.id != null && source.name != null)
_employeesList = data.employees?.where((employee) => employee != null && employee.id != null && employee.name != null).toList() ?? []; .toList() ??
[];
_teamsList =
data.teams
?.where((team) => team.id != null && team.name != null)
.toList() ??
[];
_statesList =
data.states
?.where((state) => state.id != null && state.name != null)
.toList() ??
[];
_employeesList =
data.employees
?.where(
(employee) => employee.id != null && employee.name != null,
)
.toList() ??
[];
checkDropDownValues(); checkDropDownValues();
notifyListeners(); notifyListeners();
} }
...@@ -991,10 +1016,10 @@ class Leadlistprovider extends ChangeNotifier { ...@@ -991,10 +1016,10 @@ class Leadlistprovider extends ChangeNotifier {
} }
Future<void> crmLeadListSourceOnReferenceAPIFunction( Future<void> crmLeadListSourceOnReferenceAPIFunction(
context, context,
mode, mode,
String? sourceID, String? sourceID,
) async { ) async {
try { try {
var prov = Provider.of<HomescreenNotifier>(context, listen: false); var prov = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.crmLeadListSourceOnReferenceAPI( final data = await ApiCalling.crmLeadListSourceOnReferenceAPI(
...@@ -1004,7 +1029,11 @@ class Leadlistprovider extends ChangeNotifier { ...@@ -1004,7 +1029,11 @@ class Leadlistprovider extends ChangeNotifier {
); );
if (data != null) { if (data != null) {
if (data.error == "0") { if (data.error == "0") {
_referencesList = data.references?.where((ref) => ref != null && ref.id != null && ref.name != null).toList() ?? []; _referencesList =
data.references
?.where((ref) => ref.id != null && ref.name != null)
.toList() ??
[];
notifyListeners(); notifyListeners();
} else { } else {
_referencesList.clear(); _referencesList.clear();
...@@ -1017,10 +1046,10 @@ class Leadlistprovider extends ChangeNotifier { ...@@ -1017,10 +1046,10 @@ class Leadlistprovider extends ChangeNotifier {
} }
Future<void> crmLeadListSegmentOnTeamAPIFunction( Future<void> crmLeadListSegmentOnTeamAPIFunction(
context, context,
mode, mode,
String? teamID, String? teamID,
) async { ) async {
try { try {
var prov = Provider.of<HomescreenNotifier>(context, listen: false); var prov = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.crmLeadListSegmentOnTeamAPI( final data = await ApiCalling.crmLeadListSegmentOnTeamAPI(
...@@ -1030,7 +1059,13 @@ class Leadlistprovider extends ChangeNotifier { ...@@ -1030,7 +1059,13 @@ class Leadlistprovider extends ChangeNotifier {
); );
if (data != null) { if (data != null) {
if (data.error == "0") { if (data.error == "0") {
_segmentsList = data.segments?.where((segment) => segment != null && segment.id != null && segment.name != null).toList() ?? []; _segmentsList =
data.segments
?.where(
(segment) => segment.id != null && segment.name != null,
)
.toList() ??
[];
notifyListeners(); notifyListeners();
} else { } else {
_segmentsList.clear(); _segmentsList.clear();
...@@ -1043,10 +1078,10 @@ class Leadlistprovider extends ChangeNotifier { ...@@ -1043,10 +1078,10 @@ class Leadlistprovider extends ChangeNotifier {
} }
Future<void> crmLeadListDistrictsOnStateAPIFunction( Future<void> crmLeadListDistrictsOnStateAPIFunction(
context, context,
mode, mode,
String? stateID, String? stateID,
) async { ) async {
try { try {
var prov = Provider.of<HomescreenNotifier>(context, listen: false); var prov = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.crmDistrictsOnStateAPI( final data = await ApiCalling.crmDistrictsOnStateAPI(
...@@ -1056,7 +1091,14 @@ class Leadlistprovider extends ChangeNotifier { ...@@ -1056,7 +1091,14 @@ class Leadlistprovider extends ChangeNotifier {
); );
if (data != null) { if (data != null) {
if (data.error == "0") { if (data.error == "0") {
_districtsList = data.districts?.where((district) => district != null && district.id != null && district.district != null).toList() ?? []; _districtsList =
data.districts
?.where(
(district) =>
district.id != null && district.district != null,
)
.toList() ??
[];
notifyListeners(); notifyListeners();
} else { } else {
_districtsList.clear(); _districtsList.clear();
...@@ -1069,10 +1111,10 @@ class Leadlistprovider extends ChangeNotifier { ...@@ -1069,10 +1111,10 @@ class Leadlistprovider extends ChangeNotifier {
} }
Future<void> crmLeadListSubLocOnDistrictAPIFunction( Future<void> crmLeadListSubLocOnDistrictAPIFunction(
context, context,
mode, mode,
String? districtID, String? districtID,
) async { ) async {
try { try {
var prov = Provider.of<HomescreenNotifier>(context, listen: false); var prov = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.crmSubLocOnDistrictAPI( final data = await ApiCalling.crmSubLocOnDistrictAPI(
...@@ -1082,7 +1124,13 @@ class Leadlistprovider extends ChangeNotifier { ...@@ -1082,7 +1124,13 @@ class Leadlistprovider extends ChangeNotifier {
); );
if (data != null) { if (data != null) {
if (data.error == "0") { if (data.error == "0") {
_subLocationsList = data.subLocations?.where((subLoc) => subLoc != null && subLoc.id != null && subLoc.subLocality != null).toList() ?? []; _subLocationsList =
data.subLocations
?.where(
(subLoc) => subLoc.id != null && subLoc.subLocality != null,
)
.toList() ??
[];
notifyListeners(); notifyListeners();
} else { } else {
_subLocationsList.clear(); _subLocationsList.clear();
...@@ -1095,10 +1143,10 @@ class Leadlistprovider extends ChangeNotifier { ...@@ -1095,10 +1143,10 @@ class Leadlistprovider extends ChangeNotifier {
} }
Future<void> crmLeadListContactPopUpAPIFunction( Future<void> crmLeadListContactPopUpAPIFunction(
context, context,
mode, mode,
String? accountID, String? accountID,
) async { ) async {
try { try {
var prov = Provider.of<HomescreenNotifier>(context, listen: false); var prov = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.crmLeadListContactPopUpAPI( final data = await ApiCalling.crmLeadListContactPopUpAPI(
...@@ -1108,7 +1156,13 @@ class Leadlistprovider extends ChangeNotifier { ...@@ -1108,7 +1156,13 @@ class Leadlistprovider extends ChangeNotifier {
); );
if (data != null) { if (data != null) {
if (data.error == "0") { if (data.error == "0") {
_contactsList = data.contacts?.where((contact) => contact != null && contact.id != null && contact.name != null).toList() ?? []; _contactsList =
data.contacts
?.where(
(contact) => contact.id != null && contact.name != null,
)
.toList() ??
[];
notifyListeners(); notifyListeners();
} else { } else {
_contactsList.clear(); _contactsList.clear();
...@@ -1139,17 +1193,17 @@ class Leadlistprovider extends ChangeNotifier { ...@@ -1139,17 +1193,17 @@ class Leadlistprovider extends ChangeNotifier {
} }
Future<void> crmLeadListAPIFunction( Future<void> crmLeadListAPIFunction(
BuildContext context, BuildContext context,
String? mode, String? mode,
String? leadStatus, String? leadStatus,
String? openStatus, String? openStatus,
String? sourceID, String? sourceID,
String? referenceID, String? referenceID,
String? teamID, String? teamID,
String? segmentID, String? segmentID,
String? alphabet, { String? alphabet, {
bool append = false, bool append = false,
}) async { }) async {
try { try {
var HomeProv = Provider.of<HomescreenNotifier>(context, listen: false); var HomeProv = Provider.of<HomescreenNotifier>(context, listen: false);
...@@ -1177,7 +1231,9 @@ class Leadlistprovider extends ChangeNotifier { ...@@ -1177,7 +1231,9 @@ class Leadlistprovider extends ChangeNotifier {
alphabet, alphabet,
_currentPage.toString(), // _currentPage.toString(), //
); );
debugPrint('empId: ${HomeProv.empId}, session: ${HomeProv.session}, pageNumber: $_currentPage'); debugPrint(
'empId: ${HomeProv.empId}, session: ${HomeProv.session}, pageNumber: $_currentPage',
);
if (data != null && data.error == "0") { if (data != null && data.error == "0") {
if (append) { if (append) {
...@@ -1193,7 +1249,7 @@ class Leadlistprovider extends ChangeNotifier { ...@@ -1193,7 +1249,7 @@ class Leadlistprovider extends ChangeNotifier {
if (!append) _errorMessage = "No leads found!"; if (!append) _errorMessage = "No leads found!";
_hasMoreData = false; _hasMoreData = false;
} }
} catch (e, s) { } catch (e) {
_errorMessage = "Error: $e"; _errorMessage = "Error: $e";
} }
...@@ -1204,16 +1260,16 @@ class Leadlistprovider extends ChangeNotifier { ...@@ -1204,16 +1260,16 @@ class Leadlistprovider extends ChangeNotifier {
/// Load next page /// Load next page
Future<void> loadMore( Future<void> loadMore(
BuildContext context, BuildContext context,
String? mode, String? mode,
String? leadStatus, String? leadStatus,
String? openStatus, String? openStatus,
String? sourceID, String? sourceID,
String? referenceID, String? referenceID,
String? teamID, String? teamID,
String? segmentID, String? segmentID,
String? alphabet, String? alphabet,
) async { ) async {
if (_isLoadingMore || !_hasMoreData) return; if (_isLoadingMore || !_hasMoreData) return;
_currentPage++; _currentPage++;
await crmLeadListAPIFunction( await crmLeadListAPIFunction(
...@@ -1280,7 +1336,8 @@ class Leadlistprovider extends ChangeNotifier { ...@@ -1280,7 +1336,8 @@ class Leadlistprovider extends ChangeNotifier {
} }
void checkDropDownValues() { void checkDropDownValues() {
if (_selectedEmployees != null && !_employeesList.contains(_selectedEmployees)) { if (_selectedEmployees != null &&
!_employeesList.contains(_selectedEmployees)) {
_selectedEmployees = null; _selectedEmployees = null;
_selectedEmployeeId = null; _selectedEmployeeId = null;
_selectedEmployeeValue = null; _selectedEmployeeValue = null;
...@@ -1290,12 +1347,14 @@ class Leadlistprovider extends ChangeNotifier { ...@@ -1290,12 +1347,14 @@ class Leadlistprovider extends ChangeNotifier {
_selectedSourceId = null; _selectedSourceId = null;
_selectedSourceValue = null; _selectedSourceValue = null;
} }
if (_selectedReferences != null && !_referencesList.contains(_selectedReferences)) { if (_selectedReferences != null &&
!_referencesList.contains(_selectedReferences)) {
_selectedReferences = null; _selectedReferences = null;
_selectedReferenceId = null; _selectedReferenceId = null;
_selectedReferenceValue = null; _selectedReferenceValue = null;
} }
if (_selectedSegments != null && !_segmentsList.contains(_selectedSegments)) { if (_selectedSegments != null &&
!_segmentsList.contains(_selectedSegments)) {
_selectedSegments = null; _selectedSegments = null;
_selectedSegmentId = null; _selectedSegmentId = null;
_selectedSegmentValue = null; _selectedSegmentValue = null;
...@@ -1305,7 +1364,8 @@ class Leadlistprovider extends ChangeNotifier { ...@@ -1305,7 +1364,8 @@ class Leadlistprovider extends ChangeNotifier {
_selectedTeamId = null; _selectedTeamId = null;
_selectedTeamValue = null; _selectedTeamValue = null;
} }
if (_selectedDistricts != null && !_districtsList.contains(_selectedDistricts)) { if (_selectedDistricts != null &&
!_districtsList.contains(_selectedDistricts)) {
_selectedDistricts = null; _selectedDistricts = null;
_selectedDistrictId = null; _selectedDistrictId = null;
_selectedDistrictValue = null; _selectedDistrictValue = null;
...@@ -1315,11 +1375,12 @@ class Leadlistprovider extends ChangeNotifier { ...@@ -1315,11 +1375,12 @@ class Leadlistprovider extends ChangeNotifier {
_selectedStateId = null; _selectedStateId = null;
_selectedStateValue = null; _selectedStateValue = null;
} }
if (_selectedSubLocations != null && !_subLocationsList.contains(_selectedSubLocations)) { if (_selectedSubLocations != null &&
!_subLocationsList.contains(_selectedSubLocations)) {
_selectedSubLocations = null; _selectedSubLocations = null;
_selectedSubLocationId = null; _selectedSubLocationId = null;
_selectedSubLocationValue = null; _selectedSubLocationValue = null;
} }
notifyListeners(); notifyListeners();
} }
} }
\ No newline at end of file
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
...@@ -7,7 +6,6 @@ import '../../Models/crmModels/SubmitProspectListFilterResponse.dart'; ...@@ -7,7 +6,6 @@ import '../../Models/crmModels/SubmitProspectListFilterResponse.dart';
import '../../services/api_calling.dart'; import '../../services/api_calling.dart';
import '../HomeScreenNotifier.dart'; import '../HomeScreenNotifier.dart';
class ProspectListProvider extends ChangeNotifier { class ProspectListProvider extends ChangeNotifier {
TextEditingController searchController = TextEditingController(); TextEditingController searchController = TextEditingController();
TextEditingController mobileNumberController = TextEditingController(); TextEditingController mobileNumberController = TextEditingController();
...@@ -17,43 +15,30 @@ class ProspectListProvider extends ChangeNotifier { ...@@ -17,43 +15,30 @@ class ProspectListProvider extends ChangeNotifier {
bool _isLoading = true; bool _isLoading = true;
List<Employees> _employeesList = []; List<Employees> _employeesList = [];
List<AccountsList> _accountList = []; List<AccountsList> _accountList = [];
Employees? _selectedEmployees; Employees? _selectedEmployees;
String? _selectedEmployeeId; String? _selectedEmployeeId;
String? _selectedEmployeeValue; String? _selectedEmployeeValue;
bool get isLoading => _isLoading; bool get isLoading => _isLoading;
List<Employees> get employeesList => _employeesList; List<Employees> get employeesList => _employeesList;
List<AccountsList> get accountList => _accountList; List<AccountsList> get accountList => _accountList;
Employees? get selectedEmployees => _selectedEmployees; Employees? get selectedEmployees => _selectedEmployees;
String? get selectedEmployeeId => _selectedEmployeeId; String? get selectedEmployeeId => _selectedEmployeeId;
String? get selectedEmployeeValue => _selectedEmployeeValue; String? get selectedEmployeeValue => _selectedEmployeeValue;
set isLoading(bool value) { set isLoading(bool value) {
_isLoading = value; _isLoading = value;
notifyListeners(); notifyListeners();
} }
set selectedEmployees(Employees? value) { set selectedEmployees(Employees? value) {
_selectedEmployees = value; _selectedEmployees = value;
_selectedEmployeeId = value!.id!; _selectedEmployeeId = value!.id!;
...@@ -71,8 +56,6 @@ class ProspectListProvider extends ChangeNotifier { ...@@ -71,8 +56,6 @@ class ProspectListProvider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
Future<void> crmProspectListViewAPIFunction(context, mode) async { Future<void> crmProspectListViewAPIFunction(context, mode) async {
try { try {
var HomeProv = Provider.of<HomescreenNotifier>(context, listen: false); var HomeProv = Provider.of<HomescreenNotifier>(context, listen: false);
...@@ -90,15 +73,10 @@ class ProspectListProvider extends ChangeNotifier { ...@@ -90,15 +73,10 @@ class ProspectListProvider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
} }
} catch (e, s) {} } catch (e) {}
} }
Future<void> crmProspectListAPIFunction(context, mode, employeeID) async {
Future<void> crmProspectListAPIFunction(
context,
mode,
employeeID,
) async {
try { try {
_accountList.clear(); _accountList.clear();
notifyListeners(); notifyListeners();
...@@ -110,7 +88,7 @@ class ProspectListProvider extends ChangeNotifier { ...@@ -110,7 +88,7 @@ class ProspectListProvider extends ChangeNotifier {
employeeID, employeeID,
mobileNumberController.text, mobileNumberController.text,
companyNameController.text, companyNameController.text,
"1" "1",
); );
if (data != null) { if (data != null) {
_isLoading = true; _isLoading = true;
...@@ -128,7 +106,7 @@ class ProspectListProvider extends ChangeNotifier { ...@@ -128,7 +106,7 @@ class ProspectListProvider extends ChangeNotifier {
_isLoading = false; _isLoading = false;
notifyListeners(); notifyListeners();
} }
} catch (e, s) { } catch (e) {
_isLoading = false; _isLoading = false;
notifyListeners(); notifyListeners();
} }
...@@ -156,7 +134,6 @@ class ProspectListProvider extends ChangeNotifier { ...@@ -156,7 +134,6 @@ class ProspectListProvider extends ChangeNotifier {
_selectedEmployeeId = null; _selectedEmployeeId = null;
_selectedEmployeeValue = null; _selectedEmployeeValue = null;
checkDropDownValues(); checkDropDownValues();
......
...@@ -58,7 +58,6 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier { ...@@ -58,7 +58,6 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier {
List<Map<String, dynamic>> _productRows = []; // For backend List<Map<String, dynamic>> _productRows = []; // For backend
List<Map<String, dynamic>> get productRows => _productRows; List<Map<String, dynamic>> get productRows => _productRows;
ProductsData? _selectedProductsDeatilsData; ProductsData? _selectedProductsDeatilsData;
List<Employees> _employeesList = []; List<Employees> _employeesList = [];
List<Sources> _sourcesList = []; List<Sources> _sourcesList = [];
...@@ -102,8 +101,6 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier { ...@@ -102,8 +101,6 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier {
String? _selectedSegmentValue; String? _selectedSegmentValue;
String? _selectedLeadStatus; String? _selectedLeadStatus;
ProductsData? get selectedProductsDetailsData => _selectedProductsDeatilsData; ProductsData? get selectedProductsDetailsData => _selectedProductsDeatilsData;
String? get selectedLeadStatus => _selectedLeadStatus; String? get selectedLeadStatus => _selectedLeadStatus;
...@@ -193,7 +190,7 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier { ...@@ -193,7 +190,7 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier {
set selectedEmployees(Employees? value) { set selectedEmployees(Employees? value) {
_selectedEmployees = value; _selectedEmployees = value;
_selectedEmployeesId = value!.id; _selectedEmployeesId = value!.id;
_selectedEmployeesValue = value!.name; _selectedEmployeesValue = value.name;
notifyListeners(); notifyListeners();
} }
...@@ -210,7 +207,7 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier { ...@@ -210,7 +207,7 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier {
set selectedSources(Sources? value) { set selectedSources(Sources? value) {
_selectedSources = value; _selectedSources = value;
_selectedSourcesId = value!.id; _selectedSourcesId = value!.id;
_selectedSourcesValue = value!.name; _selectedSourcesValue = value.name;
sourceError = null; sourceError = null;
notifyListeners(); notifyListeners();
} }
...@@ -228,7 +225,7 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier { ...@@ -228,7 +225,7 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier {
set selectedTeams(Teams? value) { set selectedTeams(Teams? value) {
_selectedTeams = value; _selectedTeams = value;
_selectedTeamsId = value!.id; _selectedTeamsId = value!.id;
_selectedTeamsValue = value!.name; _selectedTeamsValue = value.name;
teamsError = null; teamsError = null;
notifyListeners(); notifyListeners();
} }
...@@ -246,7 +243,7 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier { ...@@ -246,7 +243,7 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier {
set selectedStates(States? value) { set selectedStates(States? value) {
_selectedStates = value; _selectedStates = value;
_selectedStatesId = value!.id; _selectedStatesId = value!.id;
_selectedStatesValue = value!.name; _selectedStatesValue = value.name;
statesError = null; statesError = null;
notifyListeners(); notifyListeners();
} }
...@@ -263,9 +260,9 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier { ...@@ -263,9 +260,9 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier {
set selectedProducts(Products? value) { set selectedProducts(Products? value) {
_selectedProducts = value; _selectedProducts = value;
if(value!=null){ if (value != null) {
_selectedProductsId = value!.id; _selectedProductsId = value.id;
_selectedProductsValue = value!.name; _selectedProductsValue = value.name;
} }
notifyListeners(); notifyListeners();
...@@ -392,7 +389,7 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier { ...@@ -392,7 +389,7 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier {
String? subLocError = ""; String? subLocError = "";
String? leadStatusError = ""; String? leadStatusError = "";
bool _isLoading = true; final bool _isLoading = true;
bool _submitLoading = false; bool _submitLoading = false;
bool get isLoading => _isLoading; bool get isLoading => _isLoading;
...@@ -403,17 +400,19 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier { ...@@ -403,17 +400,19 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier {
_submitLoading = value; _submitLoading = value;
notifyListeners(); notifyListeners();
} }
// New method to update an existing product // New method to update an existing product
void updateProduct(int index, Map<String, dynamic> updatedProduct) { void updateProduct(int index, Map<String, dynamic> updatedProduct) {
productRows[index] = updatedProduct; productRows[index] = updatedProduct;
notifyListeners(); notifyListeners();
} }
// provider.productRows.add({
// "product_id": provider.selectedProductsId!, // provider.productRows.add({
// "price": provider.addProductPriceController.text, // "product_id": provider.selectedProductsId!,
// "qty": provider.addQuantityController.text, // "price": provider.addProductPriceController.text,
// "net_price": provider.addTotalAmountController.text, // "qty": provider.addQuantityController.text,
// }); // "net_price": provider.addTotalAmountController.text,
// });
// Existing method to add a new product // Existing method to add a new product
void addProduct(Map<String, dynamic> product) { void addProduct(Map<String, dynamic> product) {
productRows.add(product); productRows.add(product);
...@@ -423,7 +422,7 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier { ...@@ -423,7 +422,7 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier {
void prefillProductForEdit(int index) { void prefillProductForEdit(int index) {
final product = productRows[index]; final product = productRows[index];
selectedProducts = productsList.firstWhere( selectedProducts = productsList.firstWhere(
(p) => p.id == product['product_id'], (p) => p.id == product['product_id'],
orElse: () => Products(id: '', name: 'Unknown'), orElse: () => Products(id: '', name: 'Unknown'),
); );
selectedProductsId = product['product_id']; selectedProductsId = product['product_id'];
...@@ -461,7 +460,7 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier { ...@@ -461,7 +460,7 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier {
prov.session, prov.session,
); );
if (data != null) { if (data != null) {
if(data.sessionExists==1){ if (data.sessionExists == 1) {
if (data.error == "0") { if (data.error == "0") {
_employeesList = data.employees!; _employeesList = data.employees!;
_sourcesList = data.sources!; _sourcesList = data.sources!;
...@@ -472,11 +471,10 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier { ...@@ -472,11 +471,10 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} else {} } else {}
} else {} } else {}
}else{ } else {
sessionDoesNotExist(context); sessionDoesNotExist(context);
} }
} catch (e) {}
} catch (e, s) {}
} }
Future<void> crmLeadListDistrictsOnStateAPIFunction( Future<void> crmLeadListDistrictsOnStateAPIFunction(
...@@ -497,7 +495,7 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier { ...@@ -497,7 +495,7 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
} }
} catch (e, s) {} } catch (e) {}
} }
Future<void> crmLeadListSubLocOnDistrictAPIFunction( Future<void> crmLeadListSubLocOnDistrictAPIFunction(
...@@ -519,7 +517,7 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier { ...@@ -519,7 +517,7 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
} }
} catch (e, s) {} } catch (e) {}
} }
Future<void> crmLeadListSourceOnReferenceAPIFunction( Future<void> crmLeadListSourceOnReferenceAPIFunction(
...@@ -540,7 +538,7 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier { ...@@ -540,7 +538,7 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
} }
} catch (e, s) {} } catch (e) {}
} }
Future<void> crmLeadListSegmentOnTeamAPIFunction( Future<void> crmLeadListSegmentOnTeamAPIFunction(
...@@ -561,22 +559,22 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier { ...@@ -561,22 +559,22 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
} }
} catch (e, s) {} } catch (e) {}
} }
Future<void> crmAddNewLeadsAndProspectsAPIFunction( Future<void> crmAddNewLeadsAndProspectsAPIFunction(
BuildContext context, BuildContext context,
mode, mode,
acc_manager_id, accManagerId,
salutation_name, salutationName,
district, district,
state, state,
segment, segment,
source, source,
reference, reference,
team, team,
sub_locality, subLocality,
lead_status, leadStatus,
products, products,
) async { ) async {
try { try {
...@@ -585,8 +583,8 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier { ...@@ -585,8 +583,8 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier {
prov.session, prov.session,
prov.empId, prov.empId,
mode, mode,
acc_manager_id, accManagerId,
salutation_name, salutationName,
companyNameController.text, companyNameController.text,
contactPersonNameController.text, contactPersonNameController.text,
district, district,
...@@ -596,13 +594,13 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier { ...@@ -596,13 +594,13 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier {
source, source,
reference, reference,
team, team,
sub_locality, subLocality,
mobileController.text, mobileController.text,
alternateMobileController.text, alternateMobileController.text,
telephoneController.text, telephoneController.text,
customerMailIdController.text, customerMailIdController.text,
designationController.text, designationController.text,
lead_status, leadStatus,
products, products,
); );
if (data != null) { if (data != null) {
...@@ -610,12 +608,15 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier { ...@@ -610,12 +608,15 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier {
Navigator.pushAndRemoveUntil( Navigator.pushAndRemoveUntil(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => LeadDetailsByMode(mode: "executive", pageTitleName: "Lead Details", leadId: data.leadId??"-",), builder:
settings: RouteSettings( (context) => LeadDetailsByMode(
name: "LeadDetailsByMode" mode: "executive",
) pageTitleName: "Lead Details",
leadId: data.leadId ?? "-",
),
settings: RouteSettings(name: "LeadDetailsByMode"),
), ),
(Route<dynamic> route) { (Route<dynamic> route) {
return route.settings.name == 'CrmdashboardScreen'; return route.settings.name == 'CrmdashboardScreen';
}, },
); );
...@@ -630,9 +631,9 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier { ...@@ -630,9 +631,9 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier {
} }
Future<void> crmSelectedProductDetailsApiFunction( Future<void> crmSelectedProductDetailsApiFunction(
BuildContext context, BuildContext context,
String productId, String productId,
) async { ) async {
try { try {
final prov = Provider.of<HomescreenNotifier>(context, listen: false); final prov = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.crmSelectedProductDetailsApi( final data = await ApiCalling.crmSelectedProductDetailsApi(
...@@ -643,7 +644,7 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier { ...@@ -643,7 +644,7 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier {
if (data != null && data.error == "0") { if (data != null && data.error == "0") {
_selectedProductsDeatilsData = data.productsData!; _selectedProductsDeatilsData = data.productsData!;
addProductPriceController.text= data.productsData!.price!; addProductPriceController.text = data.productsData!.price!;
notifyListeners(); notifyListeners();
} }
} catch (e, s) { } catch (e, s) {
...@@ -738,35 +739,35 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier { ...@@ -738,35 +739,35 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier {
taxesController.clear(); taxesController.clear();
_productRows = []; _productRows = [];
_selectedProductsDeatilsData = null; _selectedProductsDeatilsData = null;
_selectedEmployees = null; _selectedEmployees = null;
_selectedEmployeesId = null; _selectedEmployeesId = null;
_selectedEmployeesValue = null; _selectedEmployeesValue = null;
_selectedSources = null; _selectedSources = null;
_selectedSourcesId = null; _selectedSourcesId = null;
_selectedSourcesValue = null; _selectedSourcesValue = null;
_selectedTeams = null; _selectedTeams = null;
_selectedTeamsId = null; _selectedTeamsId = null;
_selectedTeamsValue = null; _selectedTeamsValue = null;
_selectedStates = null; _selectedStates = null;
_selectedStatesId = null; _selectedStatesId = null;
_selectedStatesValue = null; _selectedStatesValue = null;
_selectedProducts = null; _selectedProducts = null;
_selectedProductsId = null; _selectedProductsId = null;
_selectedProductsValue = null; _selectedProductsValue = null;
_selectedSalutation = null; _selectedSalutation = null;
_selectedDistricts = null; _selectedDistricts = null;
_selectedSubLocations = null; _selectedSubLocations = null;
_selectedReferences = null; _selectedReferences = null;
_selectedSegments = null; _selectedSegments = null;
_selectedDistrictId = null; _selectedDistrictId = null;
_selectedDistrictValue = null; _selectedDistrictValue = null;
_selectedSubLocationId = null; _selectedSubLocationId = null;
_selectedSubLocationValue = null; _selectedSubLocationValue = null;
_selectedReferenceId = null; _selectedReferenceId = null;
_selectedReferenceValue = null; _selectedReferenceValue = null;
_selectedSegmentId = null; _selectedSegmentId = null;
_selectedSegmentValue = null; _selectedSegmentValue = null;
_selectedLeadStatus = null; _selectedLeadStatus = null;
mailIdError = ""; mailIdError = "";
companynameError = ""; companynameError = "";
salutationError = ""; salutationError = "";
...@@ -838,31 +839,32 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier { ...@@ -838,31 +839,32 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
bool validateStep1(){ bool validateStep1() {
bool isValid = true; bool isValid = true;
if(_selectedSalutation==null||_selectedSalutation==''){ if (_selectedSalutation == null || _selectedSalutation == '') {
isValid = false; isValid = false;
salutationError = "Please Select Salutation"; salutationError = "Please Select Salutation";
} }
if(companyNameController.text.trim().isEmpty){ if (companyNameController.text.trim().isEmpty) {
companynameError = "Please Enter Company Name"; companynameError = "Please Enter Company Name";
isValid = false; isValid = false;
} }
if(contactPersonNameController.text.trim().isEmpty){ if (contactPersonNameController.text.trim().isEmpty) {
nameError = "Please Enter Name"; nameError = "Please Enter Name";
isValid = false; isValid = false;
} }
if(customerMailIdController.text.trim().isNotEmpty && !RegExp(r'\S+@\S+\.\S+').hasMatch(customerMailIdController.text)){ if (customerMailIdController.text.trim().isNotEmpty &&
!RegExp(r'\S+@\S+\.\S+').hasMatch(customerMailIdController.text)) {
mailIdError = "Please enter a proper Email ID"; mailIdError = "Please enter a proper Email ID";
isValid = false; isValid = false;
} }
if(mobileController.text.trim().isEmpty){ if (mobileController.text.trim().isEmpty) {
mobileError = "Please enter Mobile Number"; mobileError = "Please enter Mobile Number";
isValid = false; isValid = false;
}else{ } else {
if(mobileController.text.length<10){ if (mobileController.text.length < 10) {
mobileError = "Please enter 10 digits"; mobileError = "Please enter 10 digits";
isValid = false; isValid = false;
} }
...@@ -873,36 +875,35 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier { ...@@ -873,36 +875,35 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier {
// isValid = false; // isValid = false;
// } // }
notifyListeners(); notifyListeners();
return isValid; return isValid;
} }
bool validateStep2(){ bool validateStep2() {
bool isValid = true; bool isValid = true;
if(alternateMobileController.text.trim().isNotEmpty && alternateMobileController.text.length<10){ if (alternateMobileController.text.trim().isNotEmpty &&
alternateMobileController.text.length < 10) {
AlternatemobileError = "Please enter 10 digits"; AlternatemobileError = "Please enter 10 digits";
isValid = false; isValid = false;
} }
// if(telephoneController.text.trim().isEmpty){ // if(telephoneController.text.trim().isEmpty){
// isValid = false; // isValid = false;
// //
// } // }
if(_selectedSources==null||_selectedSourcesId!.isEmpty){ if (_selectedSources == null || _selectedSourcesId!.isEmpty) {
sourceError = "Please Select Source"; sourceError = "Please Select Source";
isValid = false; isValid = false;
} }
if(_selectedReferences==null||_selectedReferenceId!.isEmpty){ if (_selectedReferences == null || _selectedReferenceId!.isEmpty) {
referenceError = "Please Select Reference"; referenceError = "Please Select Reference";
isValid = false; isValid = false;
} }
if(_selectedTeams==null||_selectedTeamsId!.isEmpty){ if (_selectedTeams == null || _selectedTeamsId!.isEmpty) {
teamsError = "Please Select Team"; teamsError = "Please Select Team";
isValid = false; isValid = false;
} }
if(_selectedSegments==null||_selectedSegmentId!.isEmpty){ if (_selectedSegments == null || _selectedSegmentId!.isEmpty) {
segmentsError = "Please Select Segement"; segmentsError = "Please Select Segement";
isValid = false; isValid = false;
} }
...@@ -911,13 +912,13 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier { ...@@ -911,13 +912,13 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier {
return isValid; return isValid;
} }
bool validateStep3(){ bool validateStep3() {
bool isValid = true; bool isValid = true;
if(_selectedStates==null||_selectedStatesId!.isEmpty){ if (_selectedStates == null || _selectedStatesId!.isEmpty) {
statesError = "Please Select State"; statesError = "Please Select State";
isValid = false; isValid = false;
} }
if(_selectedDistricts==null||_selectedDistrictId!.isEmpty){ if (_selectedDistricts == null || _selectedDistrictId!.isEmpty) {
districtsError = "Please Select District"; districtsError = "Please Select District";
isValid = false; isValid = false;
} }
...@@ -925,15 +926,15 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier { ...@@ -925,15 +926,15 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier {
// subLocError = "Please Select Sub Location"; // subLocError = "Please Select Sub Location";
// isValid = false; // isValid = false;
// } // }
if(_selectedLeadStatus==null||_selectedLeadStatus!.isEmpty){ if (_selectedLeadStatus == null || _selectedLeadStatus!.isEmpty) {
leadStatusError = "Please Select Lead Status"; leadStatusError = "Please Select Lead Status";
isValid = false; isValid = false;
} }
if(addressController.text.trim().isEmpty){ if (addressController.text.trim().isEmpty) {
addressError = "Please Enter address"; addressError = "Please Enter address";
isValid = false; isValid = false;
} }
if(productRows.isEmpty || _productRows.isEmpty){ if (productRows.isEmpty || _productRows.isEmpty) {
productsEmptyError = "Please Add min. one Product"; productsEmptyError = "Please Add min. one Product";
isValid = false; isValid = false;
} }
......
...@@ -36,8 +36,8 @@ class Addprospectleadsprovider extends ChangeNotifier { ...@@ -36,8 +36,8 @@ class Addprospectleadsprovider extends ChangeNotifier {
List<TextEditingController> editProductPriceControllers = []; List<TextEditingController> editProductPriceControllers = [];
List<TextEditingController> editQuantityControllers = []; List<TextEditingController> editQuantityControllers = [];
List<TextEditingController> editTotalAmountControllers = []; List<TextEditingController> editTotalAmountControllers = [];
List<String?> _selectedProductIds = []; final List<String?> _selectedProductIds = [];
List<String?> _selectedValues = []; final List<String?> _selectedValues = [];
bool _submitLoading = false; bool _submitLoading = false;
ProductsData? get selectedProductsDetailsData => _selectedProductsDeatilsData; ProductsData? get selectedProductsDetailsData => _selectedProductsDeatilsData;
...@@ -70,7 +70,7 @@ class Addprospectleadsprovider extends ChangeNotifier { ...@@ -70,7 +70,7 @@ class Addprospectleadsprovider extends ChangeNotifier {
set selectedEmployee(LeadEmployees? value) { set selectedEmployee(LeadEmployees? value) {
_selectedEmployees = value; _selectedEmployees = value;
_selectedEmployeeId = value!.id!; _selectedEmployeeId = value!.id!;
_selectedEmployeeValue = value!.name!; _selectedEmployeeValue = value.name!;
notifyListeners(); notifyListeners();
} }
...@@ -129,9 +129,9 @@ class Addprospectleadsprovider extends ChangeNotifier { ...@@ -129,9 +129,9 @@ class Addprospectleadsprovider extends ChangeNotifier {
} }
Future<void> crmSelectedProductDetailsApiFunction( Future<void> crmSelectedProductDetailsApiFunction(
BuildContext context, BuildContext context,
String productId, String productId,
) async { ) async {
try { try {
final prov = Provider.of<HomescreenNotifier>(context, listen: false); final prov = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.crmSelectedProductDetailsApi( final data = await ApiCalling.crmSelectedProductDetailsApi(
...@@ -142,7 +142,7 @@ class Addprospectleadsprovider extends ChangeNotifier { ...@@ -142,7 +142,7 @@ class Addprospectleadsprovider extends ChangeNotifier {
if (data != null && data.error == "0") { if (data != null && data.error == "0") {
_selectedProductsDeatilsData = data.productsData!; _selectedProductsDeatilsData = data.productsData!;
addLeadProductPriceController.text= data.productsData!.price!; addLeadProductPriceController.text = data.productsData!.price!;
notifyListeners(); notifyListeners();
} }
} catch (e, s) { } catch (e, s) {
...@@ -225,10 +225,10 @@ class Addprospectleadsprovider extends ChangeNotifier { ...@@ -225,10 +225,10 @@ class Addprospectleadsprovider extends ChangeNotifier {
Future<void> crmProspectDetailsAddLeadsSubmitAPIFunction( Future<void> crmProspectDetailsAddLeadsSubmitAPIFunction(
BuildContext context, BuildContext context,
mode, mode,
account_id, accountId,
acc_manager_id, accManagerId,
products, products,
lead_status, leadStatus,
) async { ) async {
try { try {
_submitLoading = true; _submitLoading = true;
...@@ -238,10 +238,10 @@ class Addprospectleadsprovider extends ChangeNotifier { ...@@ -238,10 +238,10 @@ class Addprospectleadsprovider extends ChangeNotifier {
prov.empId, prov.empId,
prov.session, prov.session,
mode, mode,
account_id, accountId,
acc_manager_id, accManagerId,
products, products,
lead_status, leadStatus,
); );
if (data != null && data.error == "0") { if (data != null && data.error == "0") {
_submitLoading = false; _submitLoading = false;
...@@ -259,9 +259,9 @@ class Addprospectleadsprovider extends ChangeNotifier { ...@@ -259,9 +259,9 @@ class Addprospectleadsprovider extends ChangeNotifier {
BuildContext context, BuildContext context,
mode, mode,
leadId, leadId,
account_id, accountId,
productId, productId,
lead_status, leadStatus,
) async { ) async {
try { try {
if (!validateform(context)) { if (!validateform(context)) {
...@@ -277,11 +277,11 @@ class Addprospectleadsprovider extends ChangeNotifier { ...@@ -277,11 +277,11 @@ class Addprospectleadsprovider extends ChangeNotifier {
final data = await ApiCalling.crmProspectDetailsAddLeadAPI( final data = await ApiCalling.crmProspectDetailsAddLeadAPI(
prov.empId, prov.empId,
prov.session, prov.session,
account_id, accountId,
productId, productId,
addLeadProductQtyController.text, addLeadProductQtyController.text,
addLeadProductPriceController.text, addLeadProductPriceController.text,
lead_status, leadStatus,
); );
if (data != null) { if (data != null) {
if (data.error == "0") { if (data.error == "0") {
......
...@@ -6,8 +6,7 @@ import 'package:provider/provider.dart'; ...@@ -6,8 +6,7 @@ import 'package:provider/provider.dart';
import '../../services/api_calling.dart'; import '../../services/api_calling.dart';
import '../HomeScreenNotifier.dart'; import '../HomeScreenNotifier.dart';
class Appointmentcalendarprovider extends ChangeNotifier{ class Appointmentcalendarprovider extends ChangeNotifier {
bool _isLoading = false; bool _isLoading = false;
List<Appointments> _appointmentsList = []; List<Appointments> _appointmentsList = [];
DateTime? _selectedDate; DateTime? _selectedDate;
...@@ -17,26 +16,29 @@ class Appointmentcalendarprovider extends ChangeNotifier{ ...@@ -17,26 +16,29 @@ class Appointmentcalendarprovider extends ChangeNotifier{
String? get selectedFollowUpType => _selectedFollowUpType; String? get selectedFollowUpType => _selectedFollowUpType;
List<Appointments> get appointmentList => _appointmentsList; List<Appointments> get appointmentList => _appointmentsList;
DateTime? get selectedDate => _selectedDate; DateTime? get selectedDate => _selectedDate;
set selectedFollowUpType(String? value){ set selectedFollowUpType(String? value) {
_selectedFollowUpType = value; _selectedFollowUpType = value;
notifyListeners(); notifyListeners();
} }
set isLoading(bool value){
set isLoading(bool value) {
_isLoading = value; _isLoading = value;
notifyListeners(); notifyListeners();
} }
void setSelectedDate(DateTime date) { void setSelectedDate(DateTime date) {
_selectedDate = date; _selectedDate = date;
notifyListeners(); notifyListeners();
} }
Future<void> crmAppointmentCalendarAPIFunction(context, date,type) async {
Future<void> crmAppointmentCalendarAPIFunction(context, date, type) async {
try { try {
var HomeProv = Provider.of<HomescreenNotifier>(context, listen: false); var HomeProv = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.crmAppointmentCalendarAPI( final data = await ApiCalling.crmAppointmentCalendarAPI(
HomeProv.empId, HomeProv.empId,
HomeProv.session, HomeProv.session,
date, date,
type type,
); );
_isLoading = true; _isLoading = true;
notifyListeners(); notifyListeners();
...@@ -45,19 +47,18 @@ class Appointmentcalendarprovider extends ChangeNotifier{ ...@@ -45,19 +47,18 @@ class Appointmentcalendarprovider extends ChangeNotifier{
_isLoading = false; _isLoading = false;
_appointmentsList = data.appointments!; _appointmentsList = data.appointments!;
notifyListeners(); notifyListeners();
}else{ } else {
toast(context, data.message); toast(context, data.message);
_isLoading = false; _isLoading = false;
notifyListeners(); notifyListeners();
} }
}else{ } else {
_isLoading = false; _isLoading = false;
notifyListeners(); notifyListeners();
} }
} catch (e, s) { } catch (e) {
_isLoading = false; _isLoading = false;
notifyListeners(); notifyListeners();
} }
} }
} }
...@@ -19,7 +19,7 @@ import '../../services/api_calling.dart'; ...@@ -19,7 +19,7 @@ import '../../services/api_calling.dart';
import '../HomeScreenNotifier.dart'; import '../HomeScreenNotifier.dart';
class Crmdashboardprovider extends ChangeNotifier { class Crmdashboardprovider extends ChangeNotifier {
String _googleApikey = "AIzaSyBGzvgMMKwPBAANTwaoRsAnrCpiWCj8wVs"; final String _googleApikey = "AIzaSyBGzvgMMKwPBAANTwaoRsAnrCpiWCj8wVs";
TextEditingController searchController = TextEditingController(); TextEditingController searchController = TextEditingController();
List<PagesAccessible> _accessPages = []; List<PagesAccessible> _accessPages = [];
...@@ -31,11 +31,10 @@ class Crmdashboardprovider extends ChangeNotifier { ...@@ -31,11 +31,10 @@ class Crmdashboardprovider extends ChangeNotifier {
List<Leads> _leadsList = []; List<Leads> _leadsList = [];
List<Enquires> _enquiresList = []; List<Enquires> _enquiresList = [];
List<FollowupLists> _dashboardFollowUps = []; List<FollowupLists> _dashboardFollowUps = [];
List<QuotationLists> _dashboardQuotations = []; List<QuotationLists> _dashboardQuotations = [];
List<FollowupLists> get dashboardFollowUps => _dashboardFollowUps; List<FollowupLists> get dashboardFollowUps => _dashboardFollowUps;
List<QuotationLists> get dashboardQuotations => _dashboardQuotations; List<QuotationLists> get dashboardQuotations => _dashboardQuotations;
LatLng? currentLocationLatLng; LatLng? currentLocationLatLng;
...@@ -103,8 +102,6 @@ class Crmdashboardprovider extends ChangeNotifier { ...@@ -103,8 +102,6 @@ class Crmdashboardprovider extends ChangeNotifier {
List<Hotleads> get allLeads => _allLeads; List<Hotleads> get allLeads => _allLeads;
Future<void> accessPagesAPIFunction(context) async { Future<void> accessPagesAPIFunction(context) async {
try { try {
var HomeProv = Provider.of<HomescreenNotifier>(context, listen: false); var HomeProv = Provider.of<HomescreenNotifier>(context, listen: false);
...@@ -121,7 +118,7 @@ class Crmdashboardprovider extends ChangeNotifier { ...@@ -121,7 +118,7 @@ class Crmdashboardprovider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
} }
} catch (e, s) {} } catch (e) {}
} }
Future<void> getCurrentLocation(context) async { Future<void> getCurrentLocation(context) async {
...@@ -130,9 +127,9 @@ class Crmdashboardprovider extends ChangeNotifier { ...@@ -130,9 +127,9 @@ class Crmdashboardprovider extends ChangeNotifier {
desiredAccuracy: geo_location.LocationAccuracy.high, desiredAccuracy: geo_location.LocationAccuracy.high,
); );
currentLocationLatLng = LatLng(position.latitude, position.longitude); currentLocationLatLng = LatLng(position.latitude, position.longitude);
print("Current Loc: ${currentLocationLatLng}"); print("Current Loc: $currentLocationLatLng");
latlongs = '${position.latitude},${position.longitude}'; latlongs = '${position.latitude},${position.longitude}';
print("latlongs : ${latlongs}"); print("latlongs : $latlongs");
notifyListeners(); notifyListeners();
crmDashboardAPIFunction(context); crmDashboardAPIFunction(context);
} catch (e) { } catch (e) {
...@@ -176,7 +173,7 @@ class Crmdashboardprovider extends ChangeNotifier { ...@@ -176,7 +173,7 @@ class Crmdashboardprovider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
} }
} catch (e, s) {} } catch (e) {}
} }
String getStaticMapUrl(double lat, double lng) { String getStaticMapUrl(double lat, double lng) {
...@@ -213,7 +210,7 @@ class Crmdashboardprovider extends ChangeNotifier { ...@@ -213,7 +210,7 @@ class Crmdashboardprovider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
} }
} catch (e, s) {} } catch (e) {}
} }
Future<void> crmUniversalSearchFunction(context) async { Future<void> crmUniversalSearchFunction(context) async {
...@@ -232,30 +229,30 @@ class Crmdashboardprovider extends ChangeNotifier { ...@@ -232,30 +229,30 @@ class Crmdashboardprovider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
} }
} catch (e, s) {} } catch (e) {}
} }
Future<void> crmDashboardFollowUpAPIFunction(context,type) async { Future<void> crmDashboardFollowUpAPIFunction(context, type) async {
try { try {
var HomeProv = Provider.of<HomescreenNotifier>(context, listen: false); var HomeProv = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.crmDashboardFollowUpAPI( final data = await ApiCalling.crmDashboardFollowUpAPI(
HomeProv.empId, HomeProv.empId,
HomeProv.session, HomeProv.session,
type type,
); );
if (data != null) { if (data != null) {
if(data.sessionExists==1){ if (data.sessionExists == 1) {
if (data.error == "0") { if (data.error == "0") {
_dashboardFollowUps = data.followupLists!; _dashboardFollowUps = data.followupLists!;
notifyListeners(); notifyListeners();
} }
}else{ } else {
sessionDoesNotExist(context); sessionDoesNotExist(context);
} }
} }
} catch (e, s) {} } catch (e) {}
} }
Future<void> crmDashboardQuotationsAPIFunction(context) async { Future<void> crmDashboardQuotationsAPIFunction(context) async {
try { try {
var HomeProv = Provider.of<HomescreenNotifier>(context, listen: false); var HomeProv = Provider.of<HomescreenNotifier>(context, listen: false);
...@@ -264,17 +261,15 @@ class Crmdashboardprovider extends ChangeNotifier { ...@@ -264,17 +261,15 @@ class Crmdashboardprovider extends ChangeNotifier {
HomeProv.session, HomeProv.session,
); );
if (data != null) { if (data != null) {
if(data.sessionExists==1){ if (data.sessionExists == 1) {
if (data.error == "0") { if (data.error == "0") {
_dashboardQuotations = data.quotationLists!; _dashboardQuotations = data.quotationLists!;
notifyListeners(); notifyListeners();
} }
}else{ } else {
sessionDoesNotExist(context); sessionDoesNotExist(context);
} }
} }
} catch (e, s) {} } catch (e) {}
} }
} }
...@@ -17,10 +17,9 @@ class Crmeditprospectaccountprovider extends ChangeNotifier { ...@@ -17,10 +17,9 @@ class Crmeditprospectaccountprovider extends ChangeNotifier {
TextEditingController addressController = TextEditingController(); TextEditingController addressController = TextEditingController();
TextEditingController searchController = TextEditingController(); TextEditingController searchController = TextEditingController();
String? salutationError; String? salutationError;
String? companyNameError; String? companyNameError;
String? pincodeError; String? pincodeError;
...@@ -88,7 +87,6 @@ class Crmeditprospectaccountprovider extends ChangeNotifier { ...@@ -88,7 +87,6 @@ class Crmeditprospectaccountprovider extends ChangeNotifier {
String? get selectedSubLocationValue => _selectedSubLocationValue; String? get selectedSubLocationValue => _selectedSubLocationValue;
set isLoading(bool value) { set isLoading(bool value) {
_isLoading = value; _isLoading = value;
notifyListeners(); notifyListeners();
...@@ -182,7 +180,7 @@ class Crmeditprospectaccountprovider extends ChangeNotifier { ...@@ -182,7 +180,7 @@ class Crmeditprospectaccountprovider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
} }
} catch (e, s) {} } catch (e) {}
} }
Future<void> crmProspectDetailsEditAccountViewAPIFunction( Future<void> crmProspectDetailsEditAccountViewAPIFunction(
...@@ -201,8 +199,8 @@ class Crmeditprospectaccountprovider extends ChangeNotifier { ...@@ -201,8 +199,8 @@ class Crmeditprospectaccountprovider extends ChangeNotifier {
if (data != null) { if (data != null) {
if (data.error == "0") { if (data.error == "0") {
_accountDetails = data.accountDetails!; _accountDetails = data.accountDetails!;
_statesList = data.states??[]; _statesList = data.states ?? [];
_salutationsList = data.salutations??[]; _salutationsList = data.salutations ?? [];
_isLoading = false; _isLoading = false;
notifyListeners(); notifyListeners();
} else { } else {
...@@ -213,7 +211,7 @@ class Crmeditprospectaccountprovider extends ChangeNotifier { ...@@ -213,7 +211,7 @@ class Crmeditprospectaccountprovider extends ChangeNotifier {
_isLoading = false; _isLoading = false;
notifyListeners(); notifyListeners();
} }
} catch (e, s) { } catch (e) {
_isLoading = false; _isLoading = false;
notifyListeners(); notifyListeners();
} }
...@@ -223,7 +221,7 @@ class Crmeditprospectaccountprovider extends ChangeNotifier { ...@@ -223,7 +221,7 @@ class Crmeditprospectaccountprovider extends ChangeNotifier {
context, context,
accID, accID,
salutation, salutation,
stateID, stateID,
districtID, districtID,
subLocalityID, subLocalityID,
...@@ -260,17 +258,17 @@ class Crmeditprospectaccountprovider extends ChangeNotifier { ...@@ -260,17 +258,17 @@ class Crmeditprospectaccountprovider extends ChangeNotifier {
_isLoading = false; _isLoading = false;
notifyListeners(); notifyListeners();
} }
} catch (e, s) { } catch (e) {
_isLoading = false; _isLoading = false;
notifyListeners(); notifyListeners();
} }
} }
Future<void> crmLeadListDistrictsOnStateAPIFunction( Future<void> crmLeadListDistrictsOnStateAPIFunction(
context, context,
mode, mode,
stateID, stateID,
) async { ) async {
try { try {
var prov = Provider.of<HomescreenNotifier>(context, listen: false); var prov = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.crmDistrictsOnStateAPI( final data = await ApiCalling.crmDistrictsOnStateAPI(
...@@ -284,14 +282,14 @@ class Crmeditprospectaccountprovider extends ChangeNotifier { ...@@ -284,14 +282,14 @@ class Crmeditprospectaccountprovider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
} }
} catch (e, s) {} } catch (e) {}
} }
Future<void> crmLeadListSubLocOnDistrictAPIFunction( Future<void> crmLeadListSubLocOnDistrictAPIFunction(
context, context,
mode, mode,
districtID, districtID,
) async { ) async {
try { try {
var prov = Provider.of<HomescreenNotifier>(context, listen: false); var prov = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.crmSubLocOnDistrictAPI( final data = await ApiCalling.crmSubLocOnDistrictAPI(
...@@ -305,14 +303,13 @@ class Crmeditprospectaccountprovider extends ChangeNotifier { ...@@ -305,14 +303,13 @@ class Crmeditprospectaccountprovider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
} }
} catch (e, s) {} } catch (e) {}
} }
Future<void> crmProspectDetailsTransferAccountAPIFunction( Future<void> crmProspectDetailsTransferAccountAPIFunction(
context, context,
accID, accID,
transferEmpID, transferEmpID,
) async { ) async {
try { try {
var prov = Provider.of<HomescreenNotifier>(context, listen: false); var prov = Provider.of<HomescreenNotifier>(context, listen: false);
...@@ -340,30 +337,32 @@ class Crmeditprospectaccountprovider extends ChangeNotifier { ...@@ -340,30 +337,32 @@ class Crmeditprospectaccountprovider extends ChangeNotifier {
_isLoading = false; _isLoading = false;
notifyListeners(); notifyListeners();
} }
} catch (e, s) { } catch (e) {
_isLoading = false; _isLoading = false;
notifyListeners(); notifyListeners();
} }
} }
void onChangeSalutation(value){ void onChangeSalutation(value) {
salutationError = ""; salutationError = "";
notifyListeners(); notifyListeners();
} }
void onChangeCompanyName(value){
void onChangeCompanyName(value) {
companyNameError = ""; companyNameError = "";
notifyListeners(); notifyListeners();
} }
void onChangePincode(value){
void onChangePincode(value) {
pincodeError = ""; pincodeError = "";
notifyListeners(); notifyListeners();
} }
void onChangeAddress(value){
void onChangeAddress(value) {
addressError = ""; addressError = "";
notifyListeners(); notifyListeners();
} }
void resetAll() { void resetAll() {
editCompanyNameController.clear(); editCompanyNameController.clear();
editSalutationNameController.clear(); editSalutationNameController.clear();
...@@ -378,7 +377,8 @@ class Crmeditprospectaccountprovider extends ChangeNotifier { ...@@ -378,7 +377,8 @@ class Crmeditprospectaccountprovider extends ChangeNotifier {
addressError = null; addressError = null;
notifyListeners(); notifyListeners();
_selectedEmployees = null; _selectedEmployeeId = null; _selectedEmployees = null;
_selectedEmployeeId = null;
_selectedEmployeeValue = null; _selectedEmployeeValue = null;
_selectedStates = null; _selectedStates = null;
_selectedDistricts = null; _selectedDistricts = null;
...@@ -393,6 +393,7 @@ class Crmeditprospectaccountprovider extends ChangeNotifier { ...@@ -393,6 +393,7 @@ class Crmeditprospectaccountprovider extends ChangeNotifier {
checkDropDownValues(); checkDropDownValues();
notifyListeners(); notifyListeners();
} }
void checkDropDownValues() { void checkDropDownValues() {
if (!_salutationsList.contains(_selectedSalutation) && if (!_salutationsList.contains(_selectedSalutation) &&
_selectedSalutation != null) { _selectedSalutation != null) {
......
...@@ -45,7 +45,7 @@ class Crmgeneratequotationprovider extends ChangeNotifier { ...@@ -45,7 +45,7 @@ class Crmgeneratequotationprovider extends ChangeNotifier {
bool get buttonsLoading => _buttonsLoading; bool get buttonsLoading => _buttonsLoading;
set buttonsLoading(bool value){ set buttonsLoading(bool value) {
_buttonsLoading = value; _buttonsLoading = value;
notifyListeners(); notifyListeners();
} }
...@@ -87,8 +87,8 @@ class Crmgeneratequotationprovider extends ChangeNotifier { ...@@ -87,8 +87,8 @@ class Crmgeneratequotationprovider extends ChangeNotifier {
String? get selectedTaxes => _selectedTaxes; String? get selectedTaxes => _selectedTaxes;
List<String?> _selectedProductIds = []; final List<String?> _selectedProductIds = [];
List<String?> _selectedValues = []; final List<String?> _selectedValues = [];
bool _submitLoading = false; bool _submitLoading = false;
String? get quotationFilePath => _quotationFilePath; String? get quotationFilePath => _quotationFilePath;
...@@ -108,7 +108,7 @@ class Crmgeneratequotationprovider extends ChangeNotifier { ...@@ -108,7 +108,7 @@ class Crmgeneratequotationprovider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
set selectedTaxes(String? value){ set selectedTaxes(String? value) {
_selectedTaxes = value; _selectedTaxes = value;
taxesError = ""; taxesError = "";
notifyListeners(); notifyListeners();
...@@ -140,20 +140,20 @@ class Crmgeneratequotationprovider extends ChangeNotifier { ...@@ -140,20 +140,20 @@ class Crmgeneratequotationprovider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
set selectedProducts(Products? value){ set selectedProducts(Products? value) {
_selectedProducts = value; _selectedProducts = value;
_selectedAddEditProductId = value!.id!; _selectedAddEditProductId = value!.id!;
_selectedAddEditProductName = value!.name; _selectedAddEditProductName = value.name;
notifyListeners(); notifyListeners();
} }
set selectedAddEditProductId(String? value){ set selectedAddEditProductId(String? value) {
_selectedAddEditProductId = value; _selectedAddEditProductId = value;
notifyListeners(); notifyListeners();
} }
set selectedAddEditProductName(String? value){ set selectedAddEditProductName(String? value) {
_selectedAddEditProductName= value; _selectedAddEditProductName = value;
notifyListeners(); notifyListeners();
} }
...@@ -203,10 +203,10 @@ class Crmgeneratequotationprovider extends ChangeNotifier { ...@@ -203,10 +203,10 @@ class Crmgeneratequotationprovider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
void preFillFormForEdit(LeadProducts product,int index) { void preFillFormForEdit(LeadProducts product, int index) {
final newprod = product; final newprod = product;
selectedProducts = productsList.firstWhere( selectedProducts = productsList.firstWhere(
(p) => p.id == newprod.productId, (p) => p.id == newprod.productId,
orElse: () => Products(id: '', name: 'Unknown'), orElse: () => Products(id: '', name: 'Unknown'),
); );
// selectedLeadProducts = product; // selectedLeadProducts = product;
...@@ -214,7 +214,6 @@ class Crmgeneratequotationprovider extends ChangeNotifier { ...@@ -214,7 +214,6 @@ class Crmgeneratequotationprovider extends ChangeNotifier {
selectedAddEditProductId = product.productId; selectedAddEditProductId = product.productId;
selectedAddEditProductName = product.productName; selectedAddEditProductName = product.productName;
addEditProductPriceController.text = product.price?.toString() ?? ''; addEditProductPriceController.text = product.price?.toString() ?? '';
addEditQuantityController.text = product.qty?.toString() ?? ''; addEditQuantityController.text = product.qty?.toString() ?? '';
addEditTotalAmountController.text = addEditTotalAmountController.text =
...@@ -257,10 +256,11 @@ class Crmgeneratequotationprovider extends ChangeNotifier { ...@@ -257,10 +256,11 @@ class Crmgeneratequotationprovider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
Future<void> crmSelectedProductDetailsApiFunction( Future<void> crmSelectedProductDetailsApiFunction(
BuildContext context, BuildContext context,
String productId, String productId,
) async { ) async {
try { try {
final prov = Provider.of<HomescreenNotifier>(context, listen: false); final prov = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.crmSelectedProductDetailsApi( final data = await ApiCalling.crmSelectedProductDetailsApi(
...@@ -271,13 +271,14 @@ class Crmgeneratequotationprovider extends ChangeNotifier { ...@@ -271,13 +271,14 @@ class Crmgeneratequotationprovider extends ChangeNotifier {
if (data != null && data.error == "0") { if (data != null && data.error == "0") {
_selectedProductsDeatilsData = data.productsData!; _selectedProductsDeatilsData = data.productsData!;
addEditProductPriceController.text= data.productsData!.price!; addEditProductPriceController.text = data.productsData!.price!;
notifyListeners(); notifyListeners();
} }
} catch (e, s) { } catch (e, s) {
print("Error: $e, Stack: $s"); print("Error: $e, Stack: $s");
} }
} }
void editAddNewRow() { void editAddNewRow() {
editProductPriceControllers.add(TextEditingController()); editProductPriceControllers.add(TextEditingController());
editQuantityControllers.add(TextEditingController()); editQuantityControllers.add(TextEditingController());
...@@ -370,14 +371,14 @@ class Crmgeneratequotationprovider extends ChangeNotifier { ...@@ -370,14 +371,14 @@ class Crmgeneratequotationprovider extends ChangeNotifier {
data.quoteDetails!.paymentTerms ?? "-"; data.quoteDetails!.paymentTerms ?? "-";
for (var product in data.leadProducts!) { for (var product in data.leadProducts!) {
_productRows.add({ _productRows.add({
"product_id": product.productId!, "product_id": product.productId!,
"price": product.price, "price": product.price,
"qty": product.qty, "qty": product.qty,
"net_price": product.prodTotalPrice, "net_price": product.prodTotalPrice,
}); });
} }
print("_productRows : ${_productRows}"); print("_productRows : $_productRows");
notifyListeners(); notifyListeners();
} else { } else {
_isLoading = false; _isLoading = false;
...@@ -398,11 +399,11 @@ class Crmgeneratequotationprovider extends ChangeNotifier { ...@@ -398,11 +399,11 @@ class Crmgeneratequotationprovider extends ChangeNotifier {
Future<void> crmLeadDetailsGenerateQuoteSubmitAPIFunction( Future<void> crmLeadDetailsGenerateQuoteSubmitAPIFunction(
BuildContext context, BuildContext context,
String leadID, String leadID,
quote_products, quoteProducts,
quotation_type, quotationType,
) async { ) async {
try { try {
if(!validateform()){ if (!validateform()) {
return; return;
} }
_buttonsLoading = true; _buttonsLoading = true;
...@@ -419,14 +420,14 @@ class Crmgeneratequotationprovider extends ChangeNotifier { ...@@ -419,14 +420,14 @@ class Crmgeneratequotationprovider extends ChangeNotifier {
forController.text, forController.text,
paymentTermsController.text, paymentTermsController.text,
mailIdController.text, mailIdController.text,
quote_products, quoteProducts,
quotation_type, quotationType,
); );
if (data != null) { if (data != null) {
if (data.error == "0") { if (data.error == "0") {
_buttonsLoading = false; _buttonsLoading = false;
_quotationFilePath = data.quoteFilepath!; _quotationFilePath = data.quoteFilepath!;
if (quotation_type == "genquotedown") { if (quotationType == "genquotedown") {
String suggestedFilename = getUniqueFilename('quotation', 'pdf'); String suggestedFilename = getUniqueFilename('quotation', 'pdf');
String contentDisposition = String contentDisposition =
'attachment; filename="$suggestedFilename"'; 'attachment; filename="$suggestedFilename"';
...@@ -438,7 +439,7 @@ class Crmgeneratequotationprovider extends ChangeNotifier { ...@@ -438,7 +439,7 @@ class Crmgeneratequotationprovider extends ChangeNotifier {
'application/octet-stream', 'application/octet-stream',
'', '',
); );
} else if (quotation_type == "genquotewhatsappbymynum") { } else if (quotationType == "genquotewhatsappbymynum") {
openWhatsApp(data.quoteFilepath!); openWhatsApp(data.quoteFilepath!);
} }
Navigator.pop(context, true); Navigator.pop(context, true);
...@@ -655,42 +656,42 @@ class Crmgeneratequotationprovider extends ChangeNotifier { ...@@ -655,42 +656,42 @@ class Crmgeneratequotationprovider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
bool validateform(){ bool validateform() {
bool isValid = true; bool isValid = true;
if(mailIdController.text.trim().isEmpty){ if (mailIdController.text.trim().isEmpty) {
mailIdError = "Please Enter Email ID"; mailIdError = "Please Enter Email ID";
isValid = false; isValid = false;
} }
if(mobileController.text.trim().isEmpty){ if (mobileController.text.trim().isEmpty) {
mobileError = "Please Enter Mobile Number"; mobileError = "Please Enter Mobile Number";
isValid = false; isValid = false;
}else{ } else {
if(mobileController.text.length<10){ if (mobileController.text.length < 10) {
mobileError = "Mobile Number should be 10 digits"; mobileError = "Mobile Number should be 10 digits";
isValid = false; isValid = false;
} }
} }
if(subjectsController.text.isEmpty){ if (subjectsController.text.isEmpty) {
subjectsError = "Please Enter Subject"; subjectsError = "Please Enter Subject";
isValid = false; isValid = false;
} }
if(productRows.isEmpty||_productRows.isEmpty){ if (productRows.isEmpty || _productRows.isEmpty) {
productRowsError = "Please Add Min. 1 Product"; productRowsError = "Please Add Min. 1 Product";
isValid = false; isValid = false;
} }
if(_selectedTaxes==null||_selectedTaxes==""){ if (_selectedTaxes == null || _selectedTaxes == "") {
taxesError = "Please select a value"; taxesError = "Please select a value";
isValid = false; isValid = false;
} }
if(SpecialNoteController.text.trim().isEmpty){ if (SpecialNoteController.text.trim().isEmpty) {
SpecialNoteError = "Please Enter a Note"; SpecialNoteError = "Please Enter a Note";
isValid = false; isValid = false;
} }
if(forController.text.trim().isEmpty){ if (forController.text.trim().isEmpty) {
forError = "Please Enter FOR"; forError = "Please Enter FOR";
isValid = false; isValid = false;
} }
if(paymentTermsController.text.trim().isEmpty){ if (paymentTermsController.text.trim().isEmpty) {
paymentTermsError = "Please Enter Terms"; paymentTermsError = "Please Enter Terms";
isValid = false; isValid = false;
} }
......
...@@ -19,9 +19,10 @@ import '../../Utils/app_colors.dart'; ...@@ -19,9 +19,10 @@ import '../../Utils/app_colors.dart';
import '../../services/api_calling.dart'; import '../../services/api_calling.dart';
import '../HomeScreenNotifier.dart'; import '../HomeScreenNotifier.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
class crmLeadDetailsProvider extends ChangeNotifier { class crmLeadDetailsProvider extends ChangeNotifier {
final FlutterLocalNotificationsPlugin _notificationsPlugin = final FlutterLocalNotificationsPlugin _notificationsPlugin =
FlutterLocalNotificationsPlugin(); FlutterLocalNotificationsPlugin();
static const platform = MethodChannel('in.webgrid.generp/download'); static const platform = MethodChannel('in.webgrid.generp/download');
final GlobalKey webViewKey = GlobalKey(); final GlobalKey webViewKey = GlobalKey();
...@@ -63,8 +64,6 @@ class crmLeadDetailsProvider extends ChangeNotifier { ...@@ -63,8 +64,6 @@ class crmLeadDetailsProvider extends ChangeNotifier {
String? _editTeleError; String? _editTeleError;
String? _editEmailError; String? _editEmailError;
String? _dateError; String? _dateError;
LeadDetails _leadDetails = LeadDetails(); LeadDetails _leadDetails = LeadDetails();
...@@ -76,14 +75,13 @@ class crmLeadDetailsProvider extends ChangeNotifier { ...@@ -76,14 +75,13 @@ class crmLeadDetailsProvider extends ChangeNotifier {
List<QuotationsDetails> _quotationsDetails = []; List<QuotationsDetails> _quotationsDetails = [];
List<String> _visitTypes = []; List<String> _visitTypes = [];
String? _selectedVisitType; String? _selectedVisitType;
List<String> _headings = []; final List<String> _headings = [];
List<String> _subHeadings = []; final List<String> _subHeadings = [];
DateTime? _date; DateTime? _date;
String? _formattedDate; String? _formattedDate;
String? _formattedDateToSend; String? _formattedDateToSend;
String? _visitTypeError = ""; String? _visitTypeError = "";
String? get formattedDateToSend => _formattedDateToSend; String? get formattedDateToSend => _formattedDateToSend;
get showEditButton => _showEditButton; get showEditButton => _showEditButton;
...@@ -223,7 +221,7 @@ class crmLeadDetailsProvider extends ChangeNotifier { ...@@ -223,7 +221,7 @@ class crmLeadDetailsProvider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
set leadDetailsLoading(bool value){ set leadDetailsLoading(bool value) {
_leadDetailsLoading = value; _leadDetailsLoading = value;
notifyListeners(); notifyListeners();
} }
...@@ -291,7 +289,7 @@ class crmLeadDetailsProvider extends ChangeNotifier { ...@@ -291,7 +289,7 @@ class crmLeadDetailsProvider extends ChangeNotifier {
_leadDetailsLoading = false; _leadDetailsLoading = false;
notifyListeners(); notifyListeners();
} }
} catch (e, s) { } catch (e) {
_leadDetailsLoading = false; _leadDetailsLoading = false;
notifyListeners(); notifyListeners();
} }
...@@ -299,7 +297,7 @@ class crmLeadDetailsProvider extends ChangeNotifier { ...@@ -299,7 +297,7 @@ class crmLeadDetailsProvider extends ChangeNotifier {
Future<void> crmLeadDetailsAddContactAPIFunction(context, accID) async { Future<void> crmLeadDetailsAddContactAPIFunction(context, accID) async {
try { try {
if(!AddContactValidation()){ if (!AddContactValidation()) {
return; return;
} }
_isLoading = true; _isLoading = true;
...@@ -337,17 +335,15 @@ class crmLeadDetailsProvider extends ChangeNotifier { ...@@ -337,17 +335,15 @@ class crmLeadDetailsProvider extends ChangeNotifier {
_isLoading = false; _isLoading = false;
notifyListeners(); notifyListeners();
} }
} catch (e, s) { } catch (e) {
_isLoading = false; _isLoading = false;
notifyListeners(); notifyListeners();
} }
} }
Future<void> crmLeadDetailsEditContactAPIFunction(context, contactID) async { Future<void> crmLeadDetailsEditContactAPIFunction(context, contactID) async {
try { try {
if(!editContactValidation()){ if (!editContactValidation()) {
return; return;
} }
_isLoading = true; _isLoading = true;
...@@ -384,7 +380,7 @@ class crmLeadDetailsProvider extends ChangeNotifier { ...@@ -384,7 +380,7 @@ class crmLeadDetailsProvider extends ChangeNotifier {
_isLoading = false; _isLoading = false;
notifyListeners(); notifyListeners();
} }
} catch (e, s) { } catch (e) {
_isLoading = false; _isLoading = false;
notifyListeners(); notifyListeners();
} }
...@@ -430,7 +426,7 @@ class crmLeadDetailsProvider extends ChangeNotifier { ...@@ -430,7 +426,7 @@ class crmLeadDetailsProvider extends ChangeNotifier {
} else { } else {
notifyListeners(); notifyListeners();
} }
} catch (e, s) { } catch (e) {
_isLoading = false; _isLoading = false;
notifyListeners(); notifyListeners();
} }
...@@ -465,7 +461,7 @@ class crmLeadDetailsProvider extends ChangeNotifier { ...@@ -465,7 +461,7 @@ class crmLeadDetailsProvider extends ChangeNotifier {
} else { } else {
notifyListeners(); notifyListeners();
} }
} catch (e, s) { } catch (e) {
notifyListeners(); notifyListeners();
} }
} }
...@@ -477,7 +473,7 @@ class crmLeadDetailsProvider extends ChangeNotifier { ...@@ -477,7 +473,7 @@ class crmLeadDetailsProvider extends ChangeNotifier {
appointmentType, appointmentType,
note, note,
) async { ) async {
if(!validAppointment()){ if (!validAppointment()) {
return; return;
} }
_isLoading = true; _isLoading = true;
...@@ -513,7 +509,7 @@ class crmLeadDetailsProvider extends ChangeNotifier { ...@@ -513,7 +509,7 @@ class crmLeadDetailsProvider extends ChangeNotifier {
_isLoading = false; _isLoading = false;
notifyListeners(); notifyListeners();
} }
} catch (e, s) { } catch (e) {
_isLoading = false; _isLoading = false;
notifyListeners(); notifyListeners();
} }
...@@ -575,7 +571,11 @@ class crmLeadDetailsProvider extends ChangeNotifier { ...@@ -575,7 +571,11 @@ class crmLeadDetailsProvider extends ChangeNotifier {
child: CupertinoDatePicker( child: CupertinoDatePicker(
dateOrder: DatePickerDateOrder.dmy, dateOrder: DatePickerDateOrder.dmy,
initialDateTime: _date ?? DateTime.now(), initialDateTime: _date ?? DateTime.now(),
minimumDate: DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day), minimumDate: DateTime(
DateTime.now().year,
DateTime.now().month,
DateTime.now().day,
),
mode: CupertinoDatePickerMode.date, mode: CupertinoDatePickerMode.date,
use24hFormat: true, use24hFormat: true,
showDayOfWeek: true, showDayOfWeek: true,
...@@ -620,12 +620,6 @@ class crmLeadDetailsProvider extends ChangeNotifier { ...@@ -620,12 +620,6 @@ class crmLeadDetailsProvider extends ChangeNotifier {
void copyToClipboard(BuildContext context) async { void copyToClipboard(BuildContext context) async {
try { try {
if (leadDetails == null) {
ScaffoldMessenger.of(
context,
).showSnackBar(SnackBar(content: Text("No data to copy")));
return;
}
final data = prepareExportData(); final data = prepareExportData();
// if (data.isEmpty || data[1].every((element) => element == "-")) { // if (data.isEmpty || data[1].every((element) => element == "-")) {
// ScaffoldMessenger.of(context).showSnackBar( // ScaffoldMessenger.of(context).showSnackBar(
...@@ -647,14 +641,13 @@ class crmLeadDetailsProvider extends ChangeNotifier { ...@@ -647,14 +641,13 @@ class crmLeadDetailsProvider extends ChangeNotifier {
} }
} }
Future<void> _handleDownload( Future<void> _handleDownload(
context, context,
String url, String url,
String contentDisposition, String contentDisposition,
String mimeType, String mimeType,
String suggestedFilename, String suggestedFilename,
) async { ) async {
// Request notification permission for Android 13+ // Request notification permission for Android 13+
if (Platform.isIOS) { if (Platform.isIOS) {
_handleIOSDownload(context, url, suggestedFilename); _handleIOSDownload(context, url, suggestedFilename);
...@@ -690,10 +683,10 @@ class crmLeadDetailsProvider extends ChangeNotifier { ...@@ -690,10 +683,10 @@ class crmLeadDetailsProvider extends ChangeNotifier {
} }
Future<void> _handleIOSDownload( Future<void> _handleIOSDownload(
context, context,
String url, String url,
String suggestedFilename, String suggestedFilename,
) async { ) async {
try { try {
// Show initial download notification // Show initial download notification
await _showDownloadNotification(0, suggestedFilename, isComplete: false); await _showDownloadNotification(0, suggestedFilename, isComplete: false);
...@@ -701,9 +694,9 @@ class crmLeadDetailsProvider extends ChangeNotifier { ...@@ -701,9 +694,9 @@ class crmLeadDetailsProvider extends ChangeNotifier {
// Get the temporary directory for iOS // Get the temporary directory for iOS
final tempDir = await getTemporaryDirectory(); final tempDir = await getTemporaryDirectory();
final fileName = final fileName =
suggestedFilename.isNotEmpty suggestedFilename.isNotEmpty
? suggestedFilename ? suggestedFilename
: url.split('/').last; : url.split('/').last;
final filePath = '${tempDir.path}/$fileName'; final filePath = '${tempDir.path}/$fileName';
// Download the file using http // Download the file using http
...@@ -732,6 +725,7 @@ class crmLeadDetailsProvider extends ChangeNotifier { ...@@ -732,6 +725,7 @@ class crmLeadDetailsProvider extends ChangeNotifier {
toast(context, "Failed to download file: $e"); toast(context, "Failed to download file: $e");
} }
} }
String getUniqueFilename(String baseName, [String ext = 'pdf']) { String getUniqueFilename(String baseName, [String ext = 'pdf']) {
final now = DateTime.now(); final now = DateTime.now();
final formattedDate = DateFormat('yyyyMMdd_HHmmss').format(now); final formattedDate = DateFormat('yyyyMMdd_HHmmss').format(now);
...@@ -739,11 +733,11 @@ class crmLeadDetailsProvider extends ChangeNotifier { ...@@ -739,11 +733,11 @@ class crmLeadDetailsProvider extends ChangeNotifier {
} }
Future<void> _showDownloadNotification( Future<void> _showDownloadNotification(
int progress, int progress,
String fileName, { String fileName, {
bool isComplete = false, bool isComplete = false,
bool isError = false, bool isError = false,
}) async { }) async {
final androidDetails = AndroidNotificationDetails( final androidDetails = AndroidNotificationDetails(
'download_channel', 'download_channel',
'Downloads', 'Downloads',
...@@ -769,11 +763,11 @@ class crmLeadDetailsProvider extends ChangeNotifier { ...@@ -769,11 +763,11 @@ class crmLeadDetailsProvider extends ChangeNotifier {
presentBadge: true, presentBadge: true,
presentSound: isComplete || isError, presentSound: isComplete || isError,
subtitle: subtitle:
isError isError
? 'Download failed' ? 'Download failed'
: isComplete : isComplete
? 'Download complete' ? 'Download complete'
: 'Downloading...', : 'Downloading...',
threadIdentifier: 'download_thread', threadIdentifier: 'download_thread',
); );
...@@ -814,10 +808,11 @@ class crmLeadDetailsProvider extends ChangeNotifier { ...@@ -814,10 +808,11 @@ class crmLeadDetailsProvider extends ChangeNotifier {
} }
void onChangeAltMobile(value) { void onChangeAltMobile(value) {
if (mobileNumberController.text.trim() ==
if(mobileNumberController.text.trim() == alternativeMobileController.text.trim()){ alternativeMobileController.text.trim()) {
_altMobError = "Mobile Number and Alternate Mobile Number Should not be same"; _altMobError =
}else{ "Mobile Number and Alternate Mobile Number Should not be same";
} else {
_altMobError = ""; _altMobError = "";
} }
notifyListeners(); notifyListeners();
...@@ -849,9 +844,11 @@ class crmLeadDetailsProvider extends ChangeNotifier { ...@@ -849,9 +844,11 @@ class crmLeadDetailsProvider extends ChangeNotifier {
} }
void onChangeEditAltMobile(value) { void onChangeEditAltMobile(value) {
if(editMobileNumberController.text.trim() == editAlternativeMobileController.text.trim()){ if (editMobileNumberController.text.trim() ==
_editAltMobError = "Mobile Number and Alternate Mobile Number Should not be same"; editAlternativeMobileController.text.trim()) {
}else{ _editAltMobError =
"Mobile Number and Alternate Mobile Number Should not be same";
} else {
_editAltMobError = ""; _editAltMobError = "";
} }
notifyListeners(); notifyListeners();
...@@ -872,8 +869,8 @@ class crmLeadDetailsProvider extends ChangeNotifier { ...@@ -872,8 +869,8 @@ class crmLeadDetailsProvider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
bool AddContactValidation(){ bool AddContactValidation() {
bool isValid = true; bool isValid = true;
_nameError = null; _nameError = null;
_designationError = null; _designationError = null;
_mobileNumError = null; _mobileNumError = null;
...@@ -881,31 +878,34 @@ class crmLeadDetailsProvider extends ChangeNotifier { ...@@ -881,31 +878,34 @@ class crmLeadDetailsProvider extends ChangeNotifier {
_teleError = null; _teleError = null;
_emailError = null; _emailError = null;
_noteError = null; _noteError = null;
if(nameController.text.trim().isEmpty){ if (nameController.text.trim().isEmpty) {
_nameError = "Please Enter Name"; _nameError = "Please Enter Name";
isValid = false; isValid = false;
} }
if(mobileNumberController.text.trim().isEmpty || mobileNumberController.text.length<10){ if (mobileNumberController.text.trim().isEmpty ||
mobileNumberController.text.length < 10) {
_mobileNumError = "Please Enter Mobile Number 10 Digits"; _mobileNumError = "Please Enter Mobile Number 10 Digits";
isValid = false; isValid = false;
} }
if(alternativeMobileController.text.trim().isNotEmpty){ if (alternativeMobileController.text.trim().isNotEmpty) {
if(alternativeMobileController.text.length<10){ if (alternativeMobileController.text.length < 10) {
_altMobError = "Please Enter Mobile Number 10 Digits"; _altMobError = "Please Enter Mobile Number 10 Digits";
isValid = false; isValid = false;
} }
} }
if(mobileNumberController.text.trim() == alternativeMobileController.text.trim()){ if (mobileNumberController.text.trim() ==
_altMobError = "Mobile Number and Alternate Mobile Number Should not be same"; alternativeMobileController.text.trim()) {
_altMobError =
"Mobile Number and Alternate Mobile Number Should not be same";
isValid = false; isValid = false;
} }
if(emailController.text.isNotEmpty){ if (emailController.text.isNotEmpty) {
final RegExp emailRegex = RegExp( final RegExp emailRegex = RegExp(
r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$', r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$',
); );
isValid = emailRegex.hasMatch(emailController.text.trim()); isValid = emailRegex.hasMatch(emailController.text.trim());
if(!isValid){ if (!isValid) {
_emailError = "Please Enter Proper Email ID"; _emailError = "Please Enter Proper Email ID";
} }
} }
...@@ -915,8 +915,8 @@ class crmLeadDetailsProvider extends ChangeNotifier { ...@@ -915,8 +915,8 @@ class crmLeadDetailsProvider extends ChangeNotifier {
return isValid; return isValid;
} }
bool editContactValidation(){ bool editContactValidation() {
bool isValid = true; bool isValid = true;
_editNameError = null; _editNameError = null;
_editDesignationError = null; _editDesignationError = null;
_editMobileNumError = null; _editMobileNumError = null;
...@@ -924,31 +924,34 @@ class crmLeadDetailsProvider extends ChangeNotifier { ...@@ -924,31 +924,34 @@ class crmLeadDetailsProvider extends ChangeNotifier {
_editTeleError = null; _editTeleError = null;
_editEmailError = null; _editEmailError = null;
_noteError = null; _noteError = null;
if(editNameController.text.trim().isEmpty){ if (editNameController.text.trim().isEmpty) {
_editNameError = "Please Enter Name"; _editNameError = "Please Enter Name";
isValid = false; isValid = false;
} }
if(editMobileNumberController.text.trim().isEmpty || editMobileNumberController.text.length<10){ if (editMobileNumberController.text.trim().isEmpty ||
editMobileNumberController.text.length < 10) {
_editMobileNumError = "Please Enter Mobile Number 10 Digits"; _editMobileNumError = "Please Enter Mobile Number 10 Digits";
isValid = false; isValid = false;
} }
if(editAlternativeMobileController.text.trim().isNotEmpty){ if (editAlternativeMobileController.text.trim().isNotEmpty) {
if(editAlternativeMobileController.text.length<10){ if (editAlternativeMobileController.text.length < 10) {
_editAltMobError = "Please Enter Mobile Number 10 Digits"; _editAltMobError = "Please Enter Mobile Number 10 Digits";
isValid = false; isValid = false;
} }
} }
if(editMobileNumberController.text.trim() == editAlternativeMobileController.text.trim()){ if (editMobileNumberController.text.trim() ==
_editAltMobError = "Mobile Number and Alternate Mobile Number Should not be same"; editAlternativeMobileController.text.trim()) {
_editAltMobError =
"Mobile Number and Alternate Mobile Number Should not be same";
isValid = false; isValid = false;
} }
if(editEmailController.text.isNotEmpty){ if (editEmailController.text.isNotEmpty) {
final RegExp emailRegex = RegExp( final RegExp emailRegex = RegExp(
r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$', r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$',
); );
isValid = emailRegex.hasMatch(editEmailController.text.trim()); isValid = emailRegex.hasMatch(editEmailController.text.trim());
if(!isValid){ if (!isValid) {
_editEmailError = "Please Enter Proper Email ID"; _editEmailError = "Please Enter Proper Email ID";
} }
} }
...@@ -958,24 +961,24 @@ class crmLeadDetailsProvider extends ChangeNotifier { ...@@ -958,24 +961,24 @@ class crmLeadDetailsProvider extends ChangeNotifier {
return isValid; return isValid;
} }
bool validAppointment(){ bool validAppointment() {
bool isValid = true; bool isValid = true;
_dateError = null; _dateError = null;
_visitTypeError = null; _visitTypeError = null;
_noteError = null; _noteError = null;
if(dateController.text.trim().isEmpty){ if (dateController.text.trim().isEmpty) {
_dateError = "Please Enter Name"; _dateError = "Please Enter Name";
isValid = false; isValid = false;
} }
if(_selectedVisitType==null || _selectedVisitType == ""){ if (_selectedVisitType == null || _selectedVisitType == "") {
_visitTypeError = "Please Select Appointment Type"; _visitTypeError = "Please Select Appointment Type";
isValid = false; isValid = false;
} }
if(noteController.text.trim().isEmpty){ if (noteController.text.trim().isEmpty) {
_noteError = "Please Enter Note"; _noteError = "Please Enter Note";
isValid = false; isValid = false;
} }
...@@ -986,8 +989,6 @@ class crmLeadDetailsProvider extends ChangeNotifier { ...@@ -986,8 +989,6 @@ class crmLeadDetailsProvider extends ChangeNotifier {
return isValid; return isValid;
} }
void resetAll() { void resetAll() {
_formattedDateToSend = null; _formattedDateToSend = null;
_formattedDate = null; _formattedDate = null;
......
...@@ -352,11 +352,14 @@ import '../../Utils/commonServices.dart'; ...@@ -352,11 +352,14 @@ import '../../Utils/commonServices.dart';
class crmNearbyOpenLeadsProvider extends ChangeNotifier { class crmNearbyOpenLeadsProvider extends ChangeNotifier {
List<LeadList> _leadslist = []; List<LeadList> _leadslist = [];
TextEditingController _locationController = TextEditingController(); final TextEditingController _locationController = TextEditingController();
String _googleApikey = "AIzaSyBGzvgMMKwPBAANTwaoRsAnrCpiWCj8wVs"; final String _googleApikey = "AIzaSyBGzvgMMKwPBAANTwaoRsAnrCpiWCj8wVs";
GoogleMapController? _mapController; GoogleMapController? _mapController;
CameraPosition? _cameraPosition; CameraPosition? _cameraPosition;
LatLng _startLocation = const LatLng(17.439112226708446, 78.43292499146135); final LatLng _startLocation = const LatLng(
17.439112226708446,
78.43292499146135,
);
String _latlongs = ""; String _latlongs = "";
List<Marker> _markers = []; List<Marker> _markers = [];
List<String> _addresses = []; List<String> _addresses = [];
...@@ -434,7 +437,7 @@ class crmNearbyOpenLeadsProvider extends ChangeNotifier { ...@@ -434,7 +437,7 @@ class crmNearbyOpenLeadsProvider extends ChangeNotifier {
LocationPermission permission = await Geolocator.checkPermission(); LocationPermission permission = await Geolocator.checkPermission();
_hasLocationPermission = _hasLocationPermission =
permission == LocationPermission.always || permission == LocationPermission.always ||
permission == LocationPermission.whileInUse; permission == LocationPermission.whileInUse;
final Location.Location location = Location.Location(); final Location.Location location = Location.Location();
bool serviceEnabled; bool serviceEnabled;
...@@ -462,11 +465,13 @@ class crmNearbyOpenLeadsProvider extends ChangeNotifier { ...@@ -462,11 +465,13 @@ class crmNearbyOpenLeadsProvider extends ChangeNotifier {
_currentLocation = locData; _currentLocation = locData;
if (_currentLocation != null && _mapCenter == null) { if (_currentLocation != null && _mapCenter == null) {
_mapCenter = LatLng(_currentLocation!.latitude!, _currentLocation!.longitude!); _mapCenter = LatLng(
_latlongs = '${_currentLocation!.latitude},${_currentLocation!.longitude}'; _currentLocation!.latitude!,
_mapController?.animateCamera( _currentLocation!.longitude!,
CameraUpdate.newLatLng(_mapCenter!),
); );
_latlongs =
'${_currentLocation!.latitude},${_currentLocation!.longitude}';
_mapController?.animateCamera(CameraUpdate.newLatLng(_mapCenter!));
await LoadNearbyOpenLeadsAPI(context, _currentValue); await LoadNearbyOpenLeadsAPI(context, _currentValue);
} }
notifyListeners(); notifyListeners();
...@@ -494,7 +499,10 @@ class crmNearbyOpenLeadsProvider extends ChangeNotifier { ...@@ -494,7 +499,10 @@ class crmNearbyOpenLeadsProvider extends ChangeNotifier {
await LoadNearbyOpenLeadsAPI(context, radius); await LoadNearbyOpenLeadsAPI(context, radius);
} }
Future<void> LoadNearbyOpenLeadsAPI(BuildContext context, double radius) async { Future<void> LoadNearbyOpenLeadsAPI(
BuildContext context,
double radius,
) async {
if (_latlongs.isEmpty || radius <= 0) { if (_latlongs.isEmpty || radius <= 0) {
print("Invalid parameters: latlongs=$_latlongs, radius=$radius"); print("Invalid parameters: latlongs=$_latlongs, radius=$radius");
toast(context, 'Invalid location or radius.'); toast(context, 'Invalid location or radius.');
...@@ -514,7 +522,8 @@ class crmNearbyOpenLeadsProvider extends ChangeNotifier { ...@@ -514,7 +522,8 @@ class crmNearbyOpenLeadsProvider extends ChangeNotifier {
if (data != null) { if (data != null) {
if (data.error == 0) { if (data.error == 0) {
_isLoading = false; _isLoading = false;
_leadslist = data.leadList?.where((lead) => lead != null).toList() ?? []; _leadslist =
data.leadList?.where((lead) => lead != null).toList() ?? [];
await updateMarkersFromApiResponse(context, _leadslist); await updateMarkersFromApiResponse(context, _leadslist);
if (_leadslist.isEmpty) { if (_leadslist.isEmpty) {
toast(context, 'No leads found within the selected radius.'); toast(context, 'No leads found within the selected radius.');
...@@ -538,9 +547,9 @@ class crmNearbyOpenLeadsProvider extends ChangeNotifier { ...@@ -538,9 +547,9 @@ class crmNearbyOpenLeadsProvider extends ChangeNotifier {
} }
Future<void> updateMarkersFromApiResponse( Future<void> updateMarkersFromApiResponse(
BuildContext context, BuildContext context,
List<LeadList> leadsList, List<LeadList> leadsList,
) async { ) async {
_markers = await createMarkersFromApiResponse(context, leadsList); _markers = await createMarkersFromApiResponse(context, leadsList);
_addresses.clear(); _addresses.clear();
await Future.forEach(leadsList, (store) async { await Future.forEach(leadsList, (store) async {
...@@ -551,24 +560,27 @@ class crmNearbyOpenLeadsProvider extends ChangeNotifier { ...@@ -551,24 +560,27 @@ class crmNearbyOpenLeadsProvider extends ChangeNotifier {
} }
Future<List<Marker>> createMarkersFromApiResponse( Future<List<Marker>> createMarkersFromApiResponse(
BuildContext context, BuildContext context,
List<LeadList> leadsList, List<LeadList> leadsList,
) async { ) async {
List<Marker> markers = []; List<Marker> markers = [];
ByteData data = await rootBundle.load("assets/images/maps_ic.png"); ByteData data = await rootBundle.load("assets/images/maps_ic.png");
Uint8List bytes = data.buffer.asUint8List(); Uint8List bytes = data.buffer.asUint8List();
await Future.forEach(leadsList, (leads) async { await Future.forEach(leadsList, (leads) async {
if (leads.loc == null || leads.id == null || leads.name == null) { if (leads.loc == null || leads.id == null || leads.name == null) {
print('Skipping invalid lead: id=${leads.id}, name=${leads.name}, loc=${leads.loc}'); print(
'Skipping invalid lead: id=${leads.id}, name=${leads.name}, loc=${leads.loc}',
);
return; return;
} }
ui.Codec codec = await ui.instantiateImageCodec(bytes); ui.Codec codec = await ui.instantiateImageCodec(bytes);
ui.FrameInfo fi = await codec.getNextFrame(); ui.FrameInfo fi = await codec.getNextFrame();
Uint8List resizedBytes = (await fi.image.toByteData( Uint8List resizedBytes =
format: ui.ImageByteFormat.png, (await fi.image.toByteData(
))!.buffer.asUint8List(); format: ui.ImageByteFormat.png,
))!.buffer.asUint8List();
markers.add( markers.add(
Marker( Marker(
...@@ -582,11 +594,12 @@ class crmNearbyOpenLeadsProvider extends ChangeNotifier { ...@@ -582,11 +594,12 @@ class crmNearbyOpenLeadsProvider extends ChangeNotifier {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => LeadDetailsByMode( builder:
mode: "", (context) => LeadDetailsByMode(
pageTitleName: "Lead Details", mode: "",
leadId: leads.id, pageTitleName: "Lead Details",
), leadId: leads.id,
),
), ),
); );
}, },
...@@ -607,11 +620,12 @@ class crmNearbyOpenLeadsProvider extends ChangeNotifier { ...@@ -607,11 +620,12 @@ class crmNearbyOpenLeadsProvider extends ChangeNotifier {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => LeadDetailsByMode( builder:
mode: "", (context) => LeadDetailsByMode(
pageTitleName: "Lead Details", mode: "",
leadId: leadID, pageTitleName: "Lead Details",
), leadId: leadID,
),
), ),
); );
notifyListeners(); notifyListeners();
...@@ -640,8 +654,8 @@ class crmNearbyOpenLeadsProvider extends ChangeNotifier { ...@@ -640,8 +654,8 @@ class crmNearbyOpenLeadsProvider extends ChangeNotifier {
double lng = double.tryParse(parts[1]) ?? 0.0; double lng = double.tryParse(parts[1]) ?? 0.0;
if (lat != 0.0 && lng != 0.0) { if (lat != 0.0 && lng != 0.0) {
try { try {
List<geocoding.Placemark> placemarks = List<geocoding.Placemark> placemarks = await geocoding
await geocoding.placemarkFromCoordinates(lat, lng); .placemarkFromCoordinates(lat, lng);
if (placemarks.isNotEmpty) { if (placemarks.isNotEmpty) {
final placemark = placemarks.first; final placemark = placemarks.first;
String address = String address =
...@@ -663,4 +677,4 @@ class crmNearbyOpenLeadsProvider extends ChangeNotifier { ...@@ -663,4 +677,4 @@ class crmNearbyOpenLeadsProvider extends ChangeNotifier {
} }
return "Address not found"; return "Address not found";
} }
} }
\ No newline at end of file
...@@ -24,7 +24,7 @@ class crmProspectDetailsProvider extends ChangeNotifier { ...@@ -24,7 +24,7 @@ class crmProspectDetailsProvider extends ChangeNotifier {
bool get addContactSelected => _addContactSelected; bool get addContactSelected => _addContactSelected;
set addContactSelected(bool value){ set addContactSelected(bool value) {
_addContactSelected = value; _addContactSelected = value;
notifyListeners(); notifyListeners();
} }
...@@ -281,7 +281,7 @@ class crmProspectDetailsProvider extends ChangeNotifier { ...@@ -281,7 +281,7 @@ class crmProspectDetailsProvider extends ChangeNotifier {
_isLoading = false; _isLoading = false;
notifyListeners(); notifyListeners();
} }
} catch (e, s) { } catch (e) {
_isLoading = false; _isLoading = false;
notifyListeners(); notifyListeners();
} }
...@@ -316,7 +316,7 @@ class crmProspectDetailsProvider extends ChangeNotifier { ...@@ -316,7 +316,7 @@ class crmProspectDetailsProvider extends ChangeNotifier {
} else { } else {
notifyListeners(); notifyListeners();
} }
} catch (e, s) { } catch (e) {
notifyListeners(); notifyListeners();
} }
} }
...@@ -356,7 +356,7 @@ class crmProspectDetailsProvider extends ChangeNotifier { ...@@ -356,7 +356,7 @@ class crmProspectDetailsProvider extends ChangeNotifier {
_isLoading = false; _isLoading = false;
notifyListeners(); notifyListeners();
} }
} catch (e, s) { } catch (e) {
_isLoading = false; _isLoading = false;
notifyListeners(); notifyListeners();
} }
...@@ -403,7 +403,7 @@ class crmProspectDetailsProvider extends ChangeNotifier { ...@@ -403,7 +403,7 @@ class crmProspectDetailsProvider extends ChangeNotifier {
_isLoading = false; _isLoading = false;
notifyListeners(); notifyListeners();
} }
} catch (e, s) { } catch (e) {
_isLoading = false; _isLoading = false;
notifyListeners(); notifyListeners();
} }
...@@ -465,7 +465,11 @@ class crmProspectDetailsProvider extends ChangeNotifier { ...@@ -465,7 +465,11 @@ class crmProspectDetailsProvider extends ChangeNotifier {
child: CupertinoDatePicker( child: CupertinoDatePicker(
dateOrder: DatePickerDateOrder.dmy, dateOrder: DatePickerDateOrder.dmy,
initialDateTime: _date ?? DateTime.now(), initialDateTime: _date ?? DateTime.now(),
minimumDate: DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day), minimumDate: DateTime(
DateTime.now().year,
DateTime.now().month,
DateTime.now().day,
),
mode: CupertinoDatePickerMode.date, mode: CupertinoDatePickerMode.date,
use24hFormat: true, use24hFormat: true,
showDayOfWeek: true, showDayOfWeek: true,
......
...@@ -55,10 +55,12 @@ class Editcrmaccountdetailsprovider extends ChangeNotifier { ...@@ -55,10 +55,12 @@ class Editcrmaccountdetailsprovider extends ChangeNotifier {
_companyNameError = value; _companyNameError = value;
notifyListeners(); notifyListeners();
} }
set selectedTeamError(String? value) { set selectedTeamError(String? value) {
_selectedTeamError = value; _selectedTeamError = value;
notifyListeners(); notifyListeners();
} }
set selectedSegmentError(String? value) { set selectedSegmentError(String? value) {
_selectedSegmentError = value; _selectedSegmentError = value;
notifyListeners(); notifyListeners();
...@@ -70,12 +72,14 @@ class Editcrmaccountdetailsprovider extends ChangeNotifier { ...@@ -70,12 +72,14 @@ class Editcrmaccountdetailsprovider extends ChangeNotifier {
_selectedTeamValue = value.name; _selectedTeamValue = value.name;
notifyListeners(); notifyListeners();
} }
set selectedSegments(Segments? value) { set selectedSegments(Segments? value) {
_selectedSegments = value; _selectedSegments = value;
_selectedSegmentId = value!.id!; _selectedSegmentId = value!.id!;
_selectedSegmentValue = value.name; _selectedSegmentValue = value.name;
notifyListeners(); notifyListeners();
} }
set selectedTeamId(String? value) { set selectedTeamId(String? value) {
_selectedTeamId = value; _selectedTeamId = value;
notifyListeners(); notifyListeners();
...@@ -85,6 +89,7 @@ class Editcrmaccountdetailsprovider extends ChangeNotifier { ...@@ -85,6 +89,7 @@ class Editcrmaccountdetailsprovider extends ChangeNotifier {
_selectedTeamValue = value; _selectedTeamValue = value;
notifyListeners(); notifyListeners();
} }
set selectedSegmentId(String? value) { set selectedSegmentId(String? value) {
_selectedSegmentId = value; _selectedSegmentId = value;
notifyListeners(); notifyListeners();
...@@ -124,17 +129,17 @@ class Editcrmaccountdetailsprovider extends ChangeNotifier { ...@@ -124,17 +129,17 @@ class Editcrmaccountdetailsprovider extends ChangeNotifier {
_isLoading = false; _isLoading = false;
notifyListeners(); notifyListeners();
} }
} catch (e, s) { } catch (e) {
_isLoading = false; _isLoading = false;
notifyListeners(); notifyListeners();
} }
} }
Future<void> crmLeadListSegmentOnTeamAPIFunction( Future<void> crmLeadListSegmentOnTeamAPIFunction(
context, context,
mode, mode,
teamID, teamID,
) async { ) async {
try { try {
var prov = Provider.of<HomescreenNotifier>(context, listen: false); var prov = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.crmLeadListSegmentOnTeamAPI( final data = await ApiCalling.crmLeadListSegmentOnTeamAPI(
...@@ -148,7 +153,7 @@ class Editcrmaccountdetailsprovider extends ChangeNotifier { ...@@ -148,7 +153,7 @@ class Editcrmaccountdetailsprovider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
} }
} catch (e, s) {} } catch (e) {}
} }
Future<void> crmLeadDetailsEditAccountSubmitAPIFunction( Future<void> crmLeadDetailsEditAccountSubmitAPIFunction(
...@@ -158,7 +163,7 @@ class Editcrmaccountdetailsprovider extends ChangeNotifier { ...@@ -158,7 +163,7 @@ class Editcrmaccountdetailsprovider extends ChangeNotifier {
teamId, teamId,
) async { ) async {
try { try {
if(!validateForm(context)){ if (!validateForm(context)) {
return; return;
} }
var HomeProv = Provider.of<HomescreenNotifier>(context, listen: false); var HomeProv = Provider.of<HomescreenNotifier>(context, listen: false);
...@@ -186,16 +191,16 @@ class Editcrmaccountdetailsprovider extends ChangeNotifier { ...@@ -186,16 +191,16 @@ class Editcrmaccountdetailsprovider extends ChangeNotifier {
_isLoading = false; _isLoading = false;
notifyListeners(); notifyListeners();
} }
} catch (e, s) { } catch (e) {
_isLoading = false; _isLoading = false;
notifyListeners(); notifyListeners();
} }
} }
bool validateForm(BuildContext context) { bool validateForm(BuildContext context) {
// Reset all errors // Reset all errors
_companyNameError = null; _companyNameError = null;
bool isValid = true; bool isValid = true;
if (_selectedTeams == null || _selectedTeamId!.isEmpty) { if (_selectedTeams == null || _selectedTeamId!.isEmpty) {
...@@ -208,7 +213,6 @@ class Editcrmaccountdetailsprovider extends ChangeNotifier { ...@@ -208,7 +213,6 @@ class Editcrmaccountdetailsprovider extends ChangeNotifier {
isValid = false; isValid = false;
} }
if (editCompanyNameController.text.trim().isEmpty) { if (editCompanyNameController.text.trim().isEmpty) {
_companyNameError = "Please enter Company name"; _companyNameError = "Please enter Company name";
isValid = false; isValid = false;
...@@ -234,7 +238,7 @@ class Editcrmaccountdetailsprovider extends ChangeNotifier { ...@@ -234,7 +238,7 @@ class Editcrmaccountdetailsprovider extends ChangeNotifier {
_selectedSegmentValue = null; _selectedSegmentValue = null;
} }
void checkDropDownValues(){ void checkDropDownValues() {
if (!_segmentsList.contains(_selectedSegments) && if (!_segmentsList.contains(_selectedSegments) &&
_selectedSegments != null) { _selectedSegments != null) {
_selectedTeamId = null; _selectedTeamId = null;
......
...@@ -150,18 +150,16 @@ class Editproductlistprovider extends ChangeNotifier { ...@@ -150,18 +150,16 @@ class Editproductlistprovider extends ChangeNotifier {
List<TextEditingController> editProductPriceControllers = []; List<TextEditingController> editProductPriceControllers = [];
List<TextEditingController> editQuantityControllers = []; List<TextEditingController> editQuantityControllers = [];
List<TextEditingController> editTotalAmountControllers = []; List<TextEditingController> editTotalAmountControllers = [];
List<String?> _selectedProductIds = []; final List<String?> _selectedProductIds = [];
List<String?> _selectedValues = []; final List<String?> _selectedValues = [];
bool _submitLoading = false; bool _submitLoading = false;
String? qtyError; String? qtyError;
String? priceError; String? priceError;
String? productError; String? productError;
bool get editProductDetailsClicked => _editProductDetailsClicked; bool get editProductDetailsClicked => _editProductDetailsClicked;
bool get editContactDetailsClicked => _editContactDetailsClicked; bool get editContactDetailsClicked => _editContactDetailsClicked;
bool get followupDetailsClicked => _followupDetailsClicked; bool get followupDetailsClicked => _followupDetailsClicked;
bool get appointmentDetailsClicked => _appointmentDetailsClicked; bool get appointmentDetailsClicked => _appointmentDetailsClicked;
bool get quotationDetailsClicked => _quotationDetailsClicked; bool get quotationDetailsClicked => _quotationDetailsClicked;
...@@ -183,26 +181,27 @@ class Editproductlistprovider extends ChangeNotifier { ...@@ -183,26 +181,27 @@ class Editproductlistprovider extends ChangeNotifier {
bool get submitLoading => _submitLoading; bool get submitLoading => _submitLoading;
set editProductDetailsClicked(bool value){ set editProductDetailsClicked(bool value) {
_editProductDetailsClicked = value; _editProductDetailsClicked = value;
notifyListeners(); notifyListeners();
} }
set editContactDetailsClicked(bool value){
set editContactDetailsClicked(bool value) {
_editContactDetailsClicked = value; _editContactDetailsClicked = value;
notifyListeners(); notifyListeners();
} }
set followupDetailsClicked(bool value) {
set followupDetailsClicked(bool value){
_followupDetailsClicked = value; _followupDetailsClicked = value;
notifyListeners(); notifyListeners();
} }
set appointmentDetailsClicked(bool value){
set appointmentDetailsClicked(bool value) {
_appointmentDetailsClicked = value; _appointmentDetailsClicked = value;
notifyListeners(); notifyListeners();
} }
set quotationDetailsClicked(bool value){
set quotationDetailsClicked(bool value) {
_quotationDetailsClicked = value; _quotationDetailsClicked = value;
notifyListeners(); notifyListeners();
} }
...@@ -334,19 +333,17 @@ class Editproductlistprovider extends ChangeNotifier { ...@@ -334,19 +333,17 @@ class Editproductlistprovider extends ChangeNotifier {
leadID, leadID,
); );
if (data != null){ if (data != null) {
if(data.sessionExists==1){ if (data.sessionExists == 1) {
if( data.error == "0") { if (data.error == "0") {
_leadProductsList = data.leadProducts ?? []; _leadProductsList = data.leadProducts ?? [];
_productsList = data.products ?? []; _productsList = data.products ?? [];
notifyListeners(); notifyListeners();
} }
}else{ } else {
sessionDoesNotExist(context); sessionDoesNotExist(context);
} }
} }
} catch (e, s) { } catch (e, s) {
print("Error: $e, Stack: $s"); print("Error: $e, Stack: $s");
} }
...@@ -366,7 +363,7 @@ class Editproductlistprovider extends ChangeNotifier { ...@@ -366,7 +363,7 @@ class Editproductlistprovider extends ChangeNotifier {
if (data != null && data.error == "0") { if (data != null && data.error == "0") {
_selectedProductsDeatilsData = data.productsData!; _selectedProductsDeatilsData = data.productsData!;
addEditProductPriceController.text= data.productsData!.price!; addEditProductPriceController.text = data.productsData!.price!;
notifyListeners(); notifyListeners();
} }
} catch (e, s) { } catch (e, s) {
...@@ -374,9 +371,6 @@ class Editproductlistprovider extends ChangeNotifier { ...@@ -374,9 +371,6 @@ class Editproductlistprovider extends ChangeNotifier {
} }
} }
Future<void> crmLeadDetailsEditProductsSubmitAPIFunction( Future<void> crmLeadDetailsEditProductsSubmitAPIFunction(
BuildContext context, BuildContext context,
products, products,
...@@ -402,14 +396,14 @@ class Editproductlistprovider extends ChangeNotifier { ...@@ -402,14 +396,14 @@ class Editproductlistprovider extends ChangeNotifier {
Future<void> crmLeadDetailsAddEditProductsSubmitAPIFunction( Future<void> crmLeadDetailsAddEditProductsSubmitAPIFunction(
BuildContext context, BuildContext context,
mode, mode,
String leadID, String leadID,
type, type,
leadProductId, leadProductId,
productId, productId,
) async { ) async {
try { try {
if(!validateform(context)){ if (!validateform(context)) {
return; return;
} }
_submitLoading = true; _submitLoading = true;
...@@ -432,7 +426,7 @@ class Editproductlistprovider extends ChangeNotifier { ...@@ -432,7 +426,7 @@ class Editproductlistprovider extends ChangeNotifier {
Navigator.pop(context, true); Navigator.pop(context, true);
prov2.crmLeadDetailsAPIFunction(context, leadID, mode); prov2.crmLeadDetailsAPIFunction(context, leadID, mode);
notifyListeners(); notifyListeners();
}else{ } else {
_submitLoading = false; _submitLoading = false;
notifyListeners(); notifyListeners();
} }
...@@ -443,16 +437,16 @@ class Editproductlistprovider extends ChangeNotifier { ...@@ -443,16 +437,16 @@ class Editproductlistprovider extends ChangeNotifier {
} }
} }
bool validateform(context){ bool validateform(context) {
bool isValid = true; bool isValid = true;
qtyError = null; qtyError = null;
priceError = null; priceError = null;
productError = null; productError = null;
if(addEditQuantityController.text.trim().isEmpty){ if (addEditQuantityController.text.trim().isEmpty) {
qtyError = "Please Enter Quantity"; qtyError = "Please Enter Quantity";
isValid = false; isValid = false;
} }
if(addEditTotalAmountController.text.trim().isEmpty){ if (addEditTotalAmountController.text.trim().isEmpty) {
priceError = "Please Enter Price"; priceError = "Please Enter Price";
isValid = false; isValid = false;
} }
...@@ -497,8 +491,9 @@ class Editproductlistprovider extends ChangeNotifier { ...@@ -497,8 +491,9 @@ class Editproductlistprovider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
void checkDropdownReset(){ void checkDropdownReset() {
if(!_productsList.contains(_selectedProducts)&&_selectedProducts!=null){ if (!_productsList.contains(_selectedProducts) &&
_selectedProducts != null) {
_selectedAddEditProductId = null; _selectedAddEditProductId = null;
_selectedAddEditProductName = null; _selectedAddEditProductName = null;
} }
......
...@@ -68,7 +68,7 @@ class followUpUpdateProvider extends ChangeNotifier { ...@@ -68,7 +68,7 @@ class followUpUpdateProvider extends ChangeNotifier {
String? get selectedCompetitor => _selectedCompetitor; String? get selectedCompetitor => _selectedCompetitor;
set submitLoading(bool value){ set submitLoading(bool value) {
_submitLoading = value; _submitLoading = value;
notifyListeners(); notifyListeners();
} }
...@@ -146,9 +146,9 @@ class followUpUpdateProvider extends ChangeNotifier { ...@@ -146,9 +146,9 @@ class followUpUpdateProvider extends ChangeNotifier {
desiredAccuracy: geo_location.LocationAccuracy.high, desiredAccuracy: geo_location.LocationAccuracy.high,
); );
currentLocationLatLng = LatLng(position.latitude, position.longitude); currentLocationLatLng = LatLng(position.latitude, position.longitude);
print("Current Loc: ${currentLocationLatLng}"); print("Current Loc: $currentLocationLatLng");
latlongs = '${position.latitude},${position.longitude}'; latlongs = '${position.latitude},${position.longitude}';
print("latlongs : ${latlongs}"); print("latlongs : $latlongs");
notifyListeners(); notifyListeners();
} catch (e) { } catch (e) {
print("Error getting current location: $e"); print("Error getting current location: $e");
...@@ -159,18 +159,17 @@ class followUpUpdateProvider extends ChangeNotifier { ...@@ -159,18 +159,17 @@ class followUpUpdateProvider extends ChangeNotifier {
BuildContext context, BuildContext context,
fromScreen, fromScreen,
nextAppointmentStatus, nextAppointmentStatus,
orderStatus, orderStatus,
leadID, leadID,
followupType, followupType,
competitor, competitor,
leadStatus, leadStatus,
appointmentType, appointmentType,
sms, sms, [
[mode] mode,
) async { ]) async {
try { try {
if (!valid()) {
if(!valid()){
return; return;
} }
_submitLoading = true; _submitLoading = true;
...@@ -185,7 +184,7 @@ class followUpUpdateProvider extends ChangeNotifier { ...@@ -185,7 +184,7 @@ class followUpUpdateProvider extends ChangeNotifier {
leadID, leadID,
followUpFeedbackController.text, followUpFeedbackController.text,
followupType, followupType,
_selectedTime.hour.toString() + ":" + _selectedTime.minute.toString(), "${_selectedTime.hour}:${_selectedTime.minute}",
latlongs, latlongs,
competitor, competitor,
reasonController.text, reasonController.text,
...@@ -198,24 +197,27 @@ class followUpUpdateProvider extends ChangeNotifier { ...@@ -198,24 +197,27 @@ class followUpUpdateProvider extends ChangeNotifier {
if (data != null && data.error == "0") { if (data != null && data.error == "0") {
_submitLoading = false; _submitLoading = false;
resetForm(); resetForm();
if(fromScreen=="Pending Tasks"){ if (fromScreen == "Pending Tasks") {
Navigator.pushAndRemoveUntil( Navigator.pushAndRemoveUntil(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => LeadDetailsByMode(mode: "executive", pageTitleName: "Lead Details", leadId: leadID??"-",), builder:
settings: RouteSettings( (context) => LeadDetailsByMode(
name: "LeadDetailsByMode" mode: "executive",
) pageTitleName: "Lead Details",
leadId: leadID ?? "-",
),
settings: RouteSettings(name: "LeadDetailsByMode"),
), ),
(Route<dynamic> route) { (Route<dynamic> route) {
return route.settings.name == 'CrmdashboardScreen'; return route.settings.name == 'CrmdashboardScreen';
}, },
); );
}else{ } else {
Navigator.pop(context); Navigator.pop(context);
} }
if(mode.isNotEmpty){ if (mode.isNotEmpty) {
prov2.crmLeadDetailsAPIFunction(context, leadID, mode); prov2.crmLeadDetailsAPIFunction(context, leadID, mode);
} }
...@@ -231,8 +233,7 @@ class followUpUpdateProvider extends ChangeNotifier { ...@@ -231,8 +233,7 @@ class followUpUpdateProvider extends ChangeNotifier {
} }
} }
bool valid() {
bool valid(){
followupError = null; followupError = null;
followupFeedbackError = null; followupFeedbackError = null;
leadStatusError = null; leadStatusError = null;
...@@ -244,60 +245,60 @@ class followUpUpdateProvider extends ChangeNotifier { ...@@ -244,60 +245,60 @@ class followUpUpdateProvider extends ChangeNotifier {
competitorError = null; competitorError = null;
reasonError = null; reasonError = null;
bool isValid = true; bool isValid = true;
if(_selectedFollowupType==null||_selectedFollowupType==""){ if (_selectedFollowupType == null || _selectedFollowupType == "") {
followupError = "Please select Followup Type"; followupError = "Please select Followup Type";
isValid = false; isValid = false;
} }
if(followUpFeedbackController.text.trim().isEmpty){ if (followUpFeedbackController.text.trim().isEmpty) {
followupFeedbackError = "Please enter Feedback"; followupFeedbackError = "Please enter Feedback";
isValid = false; isValid = false;
} }
if(_selectedLeadStatus==null||_selectedLeadStatus==""){ if (_selectedLeadStatus == null || _selectedLeadStatus == "") {
leadStatusError = "Please Select Lead Status"; leadStatusError = "Please Select Lead Status";
isValid = false; isValid = false;
} }
if(_nextAppointmentStatus==null||_nextAppointmentStatus==""){ if (_nextAppointmentStatus == null || _nextAppointmentStatus == "") {
appStatusError = "Please select a value"; appStatusError = "Please select a value";
isValid = false; isValid = false;
} }
if(nextAppointmentStatus=="Next Appointment"){ if (nextAppointmentStatus == "Next Appointment") {
if(nextAppointmentDateController.text.trim().isEmpty){ if (nextAppointmentDateController.text.trim().isEmpty) {
nextAppDateError = "Please Enter Date"; nextAppDateError = "Please Enter Date";
isValid = false; isValid = false;
} }
if(_selectNextAppointmentType==null||_selectNextAppointmentType==""){ if (_selectNextAppointmentType == null ||
_selectNextAppointmentType == "") {
nextAppType = "Please select Appointment Type"; nextAppType = "Please select Appointment Type";
isValid = false; isValid = false;
} }
if (noteController.text.trim().isEmpty) {
if(noteController.text.trim().isEmpty){
noteError = "Enter Note"; noteError = "Enter Note";
isValid = false; isValid = false;
} }
}else if(nextAppointmentStatus=="Update Order Status"){ } else if (nextAppointmentStatus == "Update Order Status") {
if(_selectOrderStatus==null||_selectOrderStatus==""){ if (_selectOrderStatus == null || _selectOrderStatus == "") {
orderStatusError = "Please Select Order Status"; orderStatusError = "Please Select Order Status";
isValid = false; isValid = false;
} }
if(selectOrderStatus=="Order Lost"){ if (selectOrderStatus == "Order Lost") {
if(_selectedCompetitor==null||_selectedCompetitor==""){ if (_selectedCompetitor == null || _selectedCompetitor == "") {
competitorError = "Please Select Competitor"; competitorError = "Please Select Competitor";
isValid = false; isValid = false;
} }
}else if(selectOrderStatus=="No Requirement"){ } else if (selectOrderStatus == "No Requirement") {
if(reasonController.text.trim().isEmpty){ if (reasonController.text.trim().isEmpty) {
reasonError = "Please Enter reason"; reasonError = "Please Enter reason";
isValid = false; isValid = false;
} }
} }
} }
_submitLoading = false; _submitLoading = false;
notifyListeners(); notifyListeners();
return isValid; return isValid;
} }
void setDate(DateTime newDate) { void setDate(DateTime newDate) {
_date = newDate; _date = newDate;
// _formattedDate = DateFormat('yyyy-MM-dd').format(newDate); // _formattedDate = DateFormat('yyyy-MM-dd').format(newDate);
...@@ -314,8 +315,7 @@ class followUpUpdateProvider extends ChangeNotifier { ...@@ -314,8 +315,7 @@ class followUpUpdateProvider extends ChangeNotifier {
initialTime: _selectedTime, initialTime: _selectedTime,
); );
if (picked != null && picked != _selectedTime) _selectedTime = picked; if (picked != null && picked != _selectedTime) _selectedTime = picked;
_formattedTime = _formattedTime = "${_selectedTime.hour}:${_selectedTime.minute}";
_selectedTime.hour.toString() + ":" + _selectedTime.minute.toString();
notifyListeners(); notifyListeners();
} }
...@@ -377,7 +377,7 @@ class followUpUpdateProvider extends ChangeNotifier { ...@@ -377,7 +377,7 @@ class followUpUpdateProvider extends ChangeNotifier {
), ),
), ),
onPressed: () { onPressed: () {
setDate(_date ?? DateTime.now() ); setDate(_date ?? DateTime.now());
Navigator.pop(context); Navigator.pop(context);
}, },
), ),
...@@ -390,7 +390,11 @@ class followUpUpdateProvider extends ChangeNotifier { ...@@ -390,7 +390,11 @@ class followUpUpdateProvider extends ChangeNotifier {
flex: 4, flex: 4,
child: CupertinoDatePicker( child: CupertinoDatePicker(
initialDateTime: _date ?? DateTime.now(), initialDateTime: _date ?? DateTime.now(),
minimumDate: DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day), minimumDate: DateTime(
DateTime.now().year,
DateTime.now().month,
DateTime.now().day,
),
dateOrder: DatePickerDateOrder.dmy, dateOrder: DatePickerDateOrder.dmy,
mode: CupertinoDatePickerMode.date, mode: CupertinoDatePickerMode.date,
use24hFormat: true, use24hFormat: true,
...@@ -408,7 +412,6 @@ class followUpUpdateProvider extends ChangeNotifier { ...@@ -408,7 +412,6 @@ class followUpUpdateProvider extends ChangeNotifier {
} }
onFollowUpChanged(value) { onFollowUpChanged(value) {
followupFeedbackError = null; followupFeedbackError = null;
notifyListeners(); notifyListeners();
} }
...@@ -423,7 +426,7 @@ class followUpUpdateProvider extends ChangeNotifier { ...@@ -423,7 +426,7 @@ class followUpUpdateProvider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
void resetForm(){ void resetForm() {
nextAppointmentDateController.clear(); nextAppointmentDateController.clear();
_formattedDateToSend = null; _formattedDateToSend = null;
_formattedDate = null; _formattedDate = null;
......
...@@ -4,8 +4,7 @@ import 'package:generp/Notifiers/HomeScreenNotifier.dart'; ...@@ -4,8 +4,7 @@ import 'package:generp/Notifiers/HomeScreenNotifier.dart';
import 'package:generp/services/api_calling.dart'; import 'package:generp/services/api_calling.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
class Dashboardprovider extends ChangeNotifier{ class Dashboardprovider extends ChangeNotifier {
List<PagesAccessible> _accessiblePagesList = []; List<PagesAccessible> _accessiblePagesList = [];
List<PagesAccessible> _accessiblePagesList2 = []; List<PagesAccessible> _accessiblePagesList2 = [];
...@@ -13,36 +12,34 @@ class Dashboardprovider extends ChangeNotifier{ ...@@ -13,36 +12,34 @@ class Dashboardprovider extends ChangeNotifier{
List<PagesAccessible> get accessiblePagesList2 => _accessiblePagesList2; List<PagesAccessible> get accessiblePagesList2 => _accessiblePagesList2;
Future<void> DashboardPagesAPIFunction(context) async { Future<void> DashboardPagesAPIFunction(context) async {
try{ try {
var provider = Provider.of<HomescreenNotifier>(context,listen: false); var provider = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.financeDashboardPagesAPI(provider.empId, provider.session); final data = await ApiCalling.financeDashboardPagesAPI(
if(data!=null){ provider.empId,
if(data.error=="0"){ provider.session,
);
if (data != null) {
if (data.error == "0") {
_accessiblePagesList = data.pagesAccessible!; _accessiblePagesList = data.pagesAccessible!;
notifyListeners(); notifyListeners();
}else{ } else {}
}
} }
}catch(e,s){ } catch (e) {}
}
} }
Future<void> addFormfinanceFormAccessPagesAPIFunction(context) async { Future<void> addFormfinanceFormAccessPagesAPIFunction(context) async {
try{ try {
var provider = Provider.of<HomescreenNotifier>(context,listen: false); var provider = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.addFormfinanceFormAccessPagesAPI(provider.empId, provider.session); final data = await ApiCalling.addFormfinanceFormAccessPagesAPI(
if(data!=null){ provider.empId,
if(data.error=="0"){ provider.session,
);
if (data != null) {
if (data.error == "0") {
_accessiblePagesList2 = data.pagesAccessible!; _accessiblePagesList2 = data.pagesAccessible!;
notifyListeners(); notifyListeners();
}else{ } else {}
}
} }
}catch(e,s){ } catch (e) {}
}
} }
} }
\ No newline at end of file
...@@ -14,7 +14,6 @@ import 'package:provider/provider.dart'; ...@@ -14,7 +14,6 @@ import 'package:provider/provider.dart';
import 'approveRejectPaymentRequestResponse.dart'; import 'approveRejectPaymentRequestResponse.dart';
class Requesitionlidtdetailsprovider extends ChangeNotifier { class Requesitionlidtdetailsprovider extends ChangeNotifier {
bool _showMoreDetails = false; bool _showMoreDetails = false;
final numberFormat = NumberFormat.decimalPattern(); final numberFormat = NumberFormat.decimalPattern();
TextEditingController requestedAmount = TextEditingController(); TextEditingController requestedAmount = TextEditingController();
...@@ -34,15 +33,16 @@ class Requesitionlidtdetailsprovider extends ChangeNotifier { ...@@ -34,15 +33,16 @@ class Requesitionlidtdetailsprovider extends ChangeNotifier {
TextEditingController bankIfscCode = TextEditingController(); TextEditingController bankIfscCode = TextEditingController();
TextEditingController bankHolderName = TextEditingController(); TextEditingController bankHolderName = TextEditingController();
TextEditingController paymentAccountSearchController = TextEditingController paymentAccountSearchController =
TextEditingController(); TextEditingController();
TextEditingController editPaymentRequestedAmountController = TextEditingController(); TextEditingController editPaymentRequestedAmountController =
TextEditingController editPaymentRequestedEditableAmountController = TextEditingController(); TextEditingController();
TextEditingController editPaymentRequestedEditableAmountController =
TextEditingController();
bool _editPaymentProcessLoading = false; bool _editPaymentProcessLoading = false;
String? editableAmountError; String? editableAmountError;
String? proposedAmountError; String? proposedAmountError;
PaymentDetails _paymentDetails = PaymentDetails(); PaymentDetails _paymentDetails = PaymentDetails();
RequestDetails _requestDetails = RequestDetails(); RequestDetails _requestDetails = RequestDetails();
PaymentRequestDetails _paymentRequestDetails = PaymentRequestDetails(); PaymentRequestDetails _paymentRequestDetails = PaymentRequestDetails();
...@@ -76,7 +76,7 @@ String? proposedAmountError; ...@@ -76,7 +76,7 @@ String? proposedAmountError;
File? get imageFilePath => _image; File? get imageFilePath => _image;
set editPaymentProcessLoading(bool value){ set editPaymentProcessLoading(bool value) {
_editPaymentProcessLoading = value; _editPaymentProcessLoading = value;
notifyListeners(); notifyListeners();
} }
...@@ -96,7 +96,7 @@ String? proposedAmountError; ...@@ -96,7 +96,7 @@ String? proposedAmountError;
notifyListeners(); notifyListeners();
} }
set showMoreDetails(bool value){ set showMoreDetails(bool value) {
_showMoreDetails = value; _showMoreDetails = value;
notifyListeners(); notifyListeners();
} }
...@@ -129,7 +129,7 @@ String? proposedAmountError; ...@@ -129,7 +129,7 @@ String? proposedAmountError;
set selectedPaymentAccounts(PaymentAccounts? value) { set selectedPaymentAccounts(PaymentAccounts? value) {
_selectedPaymentAccounts = value; _selectedPaymentAccounts = value;
_selectedValue = value!.name!; _selectedValue = value!.name!;
_selectedID = value!.id; _selectedID = value.id;
selectpaymentAccountError = null; selectpaymentAccountError = null;
notifyListeners(); notifyListeners();
} }
...@@ -154,7 +154,7 @@ String? proposedAmountError; ...@@ -154,7 +154,7 @@ String? proposedAmountError;
debugPrint("added"); debugPrint("added");
_image = File(galleryImage!.path); _image = File(galleryImage!.path);
_imageName = File(galleryImage!.name); _imageName = File(galleryImage.name);
_image_picked = 1; _image_picked = 1;
FileError = null; FileError = null;
notifyListeners(); notifyListeners();
...@@ -176,7 +176,7 @@ String? proposedAmountError; ...@@ -176,7 +176,7 @@ String? proposedAmountError;
debugPrint("Jenny: bytes:$bytes, kb:$kb, mb: $mb"); debugPrint("Jenny: bytes:$bytes, kb:$kb, mb: $mb");
_image = File(galleryImage!.path); _image = File(galleryImage!.path);
_imageName = File(galleryImage!.name); _imageName = File(galleryImage.name);
_image_picked = 1; _image_picked = 1;
FileError = null; FileError = null;
notifyListeners(); notifyListeners();
...@@ -186,13 +186,13 @@ String? proposedAmountError; ...@@ -186,13 +186,13 @@ String? proposedAmountError;
} }
} }
Future<void> paymentRequesitionDetails(context, payment_request_id) async { Future<void> paymentRequesitionDetails(context, paymentRequestId) async {
try { try {
var provider = Provider.of<HomescreenNotifier>(context, listen: false); var provider = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.paymentRequestionDetailsAPI( final data = await ApiCalling.paymentRequestionDetailsAPI(
provider.empId, provider.empId,
provider.session, provider.session,
payment_request_id, paymentRequestId,
); );
if (data != null) { if (data != null) {
if (data.error == "0") { if (data.error == "0") {
...@@ -216,64 +216,64 @@ String? proposedAmountError; ...@@ -216,64 +216,64 @@ String? proposedAmountError;
]; ];
_paymentDetails = _paymentDetails =
data.paymentDetails ?? data.paymentDetails ??
PaymentDetails( PaymentDetails(
accountId: "-", accountId: "-",
accountName: "-", accountName: "-",
amount: "-", amount: "-",
attachmentDirFilePath: "-", attachmentDirFilePath: "-",
attachmentViewFileName: "-", attachmentViewFileName: "-",
bankAccountHolderName: "-", bankAccountHolderName: "-",
bankAccountNumber: "-", bankAccountNumber: "-",
bankBranchName: "-", bankBranchName: "-",
bankIfscCode: "-", bankIfscCode: "-",
bankName: "-", bankName: "-",
bankUpiId: "-", bankUpiId: "-",
createdDatetime: "-", createdDatetime: "-",
createdEmployeeId: "-", createdEmployeeId: "-",
description: "-", description: "-",
id: "-", id: "-",
isExists: "-", isExists: "-",
mode: "-", mode: "-",
paymentAccountId: "-", paymentAccountId: "-",
paymentAccountName: "-", paymentAccountName: "-",
paymentDate: "-", paymentDate: "-",
paymentEmployeeName: "-", paymentEmployeeName: "-",
paymentModeId: "-", paymentModeId: "-",
paymentReferenceNumber: "-", paymentReferenceNumber: "-",
paymentRemarks: "-", paymentRemarks: "-",
refId: "-", refId: "-",
refType: "-", refType: "-",
updatedDatetime: "-", updatedDatetime: "-",
); );
_requestDetails = _requestDetails =
data.requestDetails ?? data.requestDetails ??
RequestDetails( RequestDetails(
updatedDatetime: "-", updatedDatetime: "-",
id: "-", id: "-",
description: "-", description: "-",
createdDatetime: "-", createdDatetime: "-",
attachmentViewFileName: "-", attachmentViewFileName: "-",
attachmentDirFilePath: "-", attachmentDirFilePath: "-",
amount: "-", amount: "-",
accountName: "-", accountName: "-",
accountId: "-", accountId: "-",
branch: "-", branch: "-",
createdEmployee: "-", createdEmployee: "-",
date: "-", date: "-",
isProcessedPaymentRequest: "-", isProcessedPaymentRequest: "-",
level1ApprovalRemarks: "-", level1ApprovalRemarks: "-",
level1Employee: "-", level1Employee: "-",
level2ApprovalRemarks: "-", level2ApprovalRemarks: "-",
level2Employee: "-", level2Employee: "-",
proposedAccount: "-", proposedAccount: "-",
proposedAccountId: "-", proposedAccountId: "-",
requestedAmount: "-", requestedAmount: "-",
requestingPurpose: "-", requestingPurpose: "-",
requestMode: "-", requestMode: "-",
status: "-", status: "-",
transDis: "-", transDis: "-",
); );
_subHeadings = [ _subHeadings = [
_requestDetails.accountName ?? "-", _requestDetails.accountName ?? "-",
...@@ -299,7 +299,7 @@ String? proposedAmountError; ...@@ -299,7 +299,7 @@ String? proposedAmountError;
notifyListeners(); notifyListeners();
} }
} }
} catch (e, s) {} } catch (e) {}
} }
preValues() { preValues() {
...@@ -323,14 +323,16 @@ String? proposedAmountError; ...@@ -323,14 +323,16 @@ String? proposedAmountError;
notifyListeners(); notifyListeners();
} }
Future<void> approveRejectPaymentRequestAPIFunction(context, Future<void> approveRejectPaymentRequestAPIFunction(
payment_request_id,) async { context,
paymentRequestId,
) async {
try { try {
var provider = Provider.of<HomescreenNotifier>(context, listen: false); var provider = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.approveRejectPaymentRequestAPI( final data = await ApiCalling.approveRejectPaymentRequestAPI(
provider.empId, provider.empId,
provider.session, provider.session,
payment_request_id, paymentRequestId,
); );
if (data != null) { if (data != null) {
if (data.error == "0") { if (data.error == "0") {
...@@ -340,12 +342,9 @@ String? proposedAmountError; ...@@ -340,12 +342,9 @@ String? proposedAmountError;
notifyListeners(); notifyListeners();
} }
} }
} catch (e, s) {} } catch (e) {}
} }
String? remarksError; String? remarksError;
String? ApprovedAmountError; String? ApprovedAmountError;
String? selectpaymentAccountError; String? selectpaymentAccountError;
...@@ -353,17 +352,19 @@ String? proposedAmountError; ...@@ -353,17 +352,19 @@ String? proposedAmountError;
bool get submitClicked => _submitClicked; bool get submitClicked => _submitClicked;
set submitClicked(bool value){ set submitClicked(bool value) {
_submitClicked = value; _submitClicked = value;
notifyListeners(); notifyListeners();
} }
Future<void> paymentrequisitionRejectSubmitAPIFunction(context, Future<void> paymentrequisitionRejectSubmitAPIFunction(
mode, context,
payment_request_id, mode,
approve_remarks,) async { paymentRequestId,
approveRemarks,
) async {
try { try {
if(approve_remarks.toString().trim().isEmpty) { if (approveRemarks.toString().trim().isEmpty) {
remarksError = "Please Enter Remarks"; remarksError = "Please Enter Remarks";
notifyListeners(); notifyListeners();
// toast(context,"Enter Remarks"); // toast(context,"Enter Remarks");
...@@ -374,30 +375,34 @@ String? proposedAmountError; ...@@ -374,30 +375,34 @@ String? proposedAmountError;
provider.empId, provider.empId,
provider.session, provider.session,
mode, mode,
payment_request_id, paymentRequestId,
approve_remarks, approveRemarks,
); );
if (data != null) { if (data != null) {
if (data.error == "0") { if (data.error == "0") {
paymentRequesitionDetails(context, payment_request_id); paymentRequesitionDetails(context, paymentRequestId);
resetAll(); resetAll();
toast(context, data.message); toast(context, data.message);
Navigator.pop(context); Navigator.pop(context);
} }
} }
} catch (e, s) {} } catch (e) {}
} }
Future<void> paymentrequisitionApproveSubmitAPIFunction(context, Future<void> paymentrequisitionApproveSubmitAPIFunction(
mode, context,
payment_request_id, mode,
approved_amount, paymentRequestId,
approve_remarks, approvedAmount,
proposed_payment_account_id,) async { approveRemarks,
proposedPaymentAccountId,
) async {
try { try {
if(!validateApproval(approved_amount, if (!validateApproval(
approve_remarks, approvedAmount,
proposed_payment_account_id,)){ approveRemarks,
proposedPaymentAccountId,
)) {
return; return;
} }
...@@ -406,42 +411,46 @@ String? proposedAmountError; ...@@ -406,42 +411,46 @@ String? proposedAmountError;
provider.empId, provider.empId,
provider.session, provider.session,
mode, mode,
payment_request_id, paymentRequestId,
approved_amount, approvedAmount,
approve_remarks, approveRemarks,
proposed_payment_account_id, proposedPaymentAccountId,
); );
if (data != null) { if (data != null) {
if (data.error == "0") { if (data.error == "0") {
paymentRequesitionDetails(context, payment_request_id); paymentRequesitionDetails(context, paymentRequestId);
resetAll(); resetAll();
toast(context, data.message); toast(context, data.message);
Navigator.pop(context,true); Navigator.pop(context, true);
notifyListeners(); notifyListeners();
} }
} }
} catch (e, s) {} } catch (e) {}
} }
editPrevalues(){ editPrevalues() {
editPaymentRequestedAmountController.text = _requestDetails.requestedAmount ?? "-"; editPaymentRequestedAmountController.text =
editPaymentRequestedEditableAmountController.text = _requestDetails.requestedAmount ?? "-"; _requestDetails.requestedAmount ?? "-";
editPaymentRequestedEditableAmountController.text =
_requestDetails.requestedAmount ?? "-";
notifyListeners(); notifyListeners();
} }
onChangeEditableAmount(value,context){ onChangeEditableAmount(value, context) {
var provider = Provider.of<HomescreenNotifier>(context, listen: false); var provider = Provider.of<HomescreenNotifier>(context, listen: false);
if(provider.empId=="5" || provider.empId=="130" || provider.empId=="131"||provider.empId =="6"){ if (provider.empId == "5" ||
editableAmountError = provider.empId == "130" ||
""; provider.empId == "131" ||
}else{ provider.empId == "6") {
editableAmountError = "";
} else {
if (numberFormat.parse(editPaymentRequestedAmountController.text) < if (numberFormat.parse(editPaymentRequestedAmountController.text) <
numberFormat.parse(editPaymentRequestedEditableAmountController.text)) { numberFormat.parse(
editPaymentRequestedEditableAmountController.text,
)) {
editableAmountError = editableAmountError =
"Approved Amount should not be greater than amount"; "Approved Amount should not be greater than amount";
} else { } else {
editableAmountError = null; editableAmountError = null;
} }
...@@ -450,23 +459,27 @@ String? proposedAmountError; ...@@ -450,23 +459,27 @@ String? proposedAmountError;
notifyListeners(); notifyListeners();
} }
bool validateEditprocessPayment(context){ bool validateEditprocessPayment(context) {
bool isValid = true; bool isValid = true;
editableAmountError = null; editableAmountError = null;
var provider = Provider.of<HomescreenNotifier>(context, listen: false); var provider = Provider.of<HomescreenNotifier>(context, listen: false);
if(editPaymentRequestedEditableAmountController.text.isNotEmpty){ if (editPaymentRequestedEditableAmountController.text.isNotEmpty) {
if(provider.empId=="5" || provider.empId=="130" || provider.empId=="131" ||provider.empId =="6"){ if (provider.empId == "5" ||
provider.empId == "130" ||
provider.empId == "131" ||
provider.empId == "6") {
editableAmountError = null; editableAmountError = null;
}else{ } else {
if (numberFormat.parse(editPaymentRequestedAmountController.text) < if (numberFormat.parse(editPaymentRequestedAmountController.text) <
numberFormat.parse(editPaymentRequestedEditableAmountController.text)) { numberFormat.parse(
editPaymentRequestedEditableAmountController.text,
)) {
editableAmountError = editableAmountError =
"Approved Amount should not be greater than amount"; "Approved Amount should not be greater than amount";
isValid = false; isValid = false;
} else { } else {
editableAmountError = null; editableAmountError = null;
} }
} }
} }
...@@ -476,108 +489,113 @@ String? proposedAmountError; ...@@ -476,108 +489,113 @@ String? proposedAmountError;
return isValid; return isValid;
} }
Future<void> editProcessedPaymentAmountAPIFunction(context, Future<void> editProcessedPaymentAmountAPIFunction(
payment_request_id,approval_amount) async { context,
paymentRequestId,
approvalAmount,
) async {
try { try {
_editPaymentProcessLoading = true; _editPaymentProcessLoading = true;
notifyListeners(); notifyListeners();
if(!validateEditprocessPayment(context)){ if (!validateEditprocessPayment(context)) {
return; return;
} }
var provider = Provider.of<HomescreenNotifier>(context, listen: false); var provider = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.editProcessedRequestAmountAPI( final data = await ApiCalling.editProcessedRequestAmountAPI(
provider.empId, provider.empId,
provider.session, provider.session,
payment_request_id, paymentRequestId,
approval_amount approvalAmount,
); );
if (data != null) { if (data != null) {
if (data.error == "0") { if (data.error == "0") {
_editPaymentProcessLoading = false; _editPaymentProcessLoading = false;
paymentRequesitionDetails(context, payment_request_id); paymentRequesitionDetails(context, paymentRequestId);
resetAll(); resetAll();
toast(context, data.message); toast(context, data.message);
Navigator.pop(context,true); Navigator.pop(context, true);
notifyListeners(); notifyListeners();
}else{ } else {
_editPaymentProcessLoading = false; _editPaymentProcessLoading = false;
notifyListeners(); notifyListeners();
} }
}else{ } else {
_editPaymentProcessLoading = false; _editPaymentProcessLoading = false;
notifyListeners(); notifyListeners();
} }
} catch (e, s) { } catch (e) {
_editPaymentProcessLoading = false; _editPaymentProcessLoading = false;
notifyListeners(); notifyListeners();
} }
} }
bool validateApproval(approved_amount, bool validateApproval(
approve_remarks, approvedAmount,
proposed_payment_account_id,){ approveRemarks,
proposedPaymentAccountId,
) {
remarksError = null; remarksError = null;
ApprovedAmountError = null; ApprovedAmountError = null;
selectpaymentAccountError = null; selectpaymentAccountError = null;
bool isValid = true; bool isValid = true;
if(approved_amount.toString().trim().isEmpty){ if (approvedAmount.toString().trim().isEmpty) {
ApprovedAmountError = "Enter Amount"; ApprovedAmountError = "Enter Amount";
isValid = false; isValid = false;
} }
if(approve_remarks.toString().trim().isEmpty) { if (approveRemarks.toString().trim().isEmpty) {
remarksError = "Please Enter Remarks"; remarksError = "Please Enter Remarks";
isValid = false; isValid = false;
} }
final numberFormat = NumberFormat.decimalPattern(); final numberFormat = NumberFormat.decimalPattern();
if(numberFormat.parse(approvedAmount.text) > numberFormat.parse(requestedAmount.text)){ if (numberFormat.parse(approvedAmount.text) >
ApprovedAmountError = "Approved Amount should not be greater than requested amount"; numberFormat.parse(requestedAmount.text)) {
ApprovedAmountError =
"Approved Amount should not be greater than requested amount";
isValid = false; isValid = false;
} }
if (_selectedPaymentAccounts == null || _selectedID.isEmpty) { if (_selectedPaymentAccounts == null || _selectedID.isEmpty) {
selectpaymentAccountError = "Please select an account"; selectpaymentAccountError = "Please select an account";
isValid = false; isValid = false;
} }
_submitClicked = false; _submitClicked = false;
notifyListeners(); notifyListeners();
return isValid; return isValid;
} }
checkApprovalDropDown(){ checkApprovalDropDown() {}
} Future<void> paymentrequisitionProcessSubmitAPIFunction(
context,
Future<void> paymentrequisitionProcessSubmitAPIFunction(context, mode,
mode, referenceNum,
reference_num, paymentAmount,
payment_amount, paymentRequestId,
payment_request_id, paymentAccountId,
payment_account_id, processingRemarks,
processing_remarks, attachment,
attachment,) async { ) async {
try { try {
var provider = Provider.of<HomescreenNotifier>(context, listen: false); var provider = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.processApproveRejectPaymentRequestSubmitAPI( final data = await ApiCalling.processApproveRejectPaymentRequestSubmitAPI(
provider.empId, provider.empId,
provider.session, provider.session,
mode, mode,
reference_num, referenceNum,
payment_amount, paymentAmount,
payment_request_id, paymentRequestId,
payment_account_id, paymentAccountId,
processing_remarks, processingRemarks,
attachment, attachment,
); );
if (data != null) { if (data != null) {
if (data.error == "0") { if (data.error == "0") {
paymentRequesitionDetails(context, payment_request_id); paymentRequesitionDetails(context, paymentRequestId);
resetAll(); resetAll();
toast(context, data.message); toast(context, data.message);
Navigator.pop(context); Navigator.pop(context);
} }
} }
} catch (e, s) {} } catch (e) {}
} }
resetAll() { resetAll() {
...@@ -612,16 +630,16 @@ String? proposedAmountError; ...@@ -612,16 +630,16 @@ String? proposedAmountError;
selectpaymentAccountError = null; selectpaymentAccountError = null;
notifyListeners(); notifyListeners();
} }
onChangeApprov(value){ onChangeApprov(value) {
final numberFormat = NumberFormat.decimalPattern(); final numberFormat = NumberFormat.decimalPattern();
if(numberFormat.parse(approvedAmount.text) > numberFormat.parse(requestedAmount.text)){ if (numberFormat.parse(approvedAmount.text) >
ApprovedAmountError = "Approved Amount should not be greater than requested amount"; numberFormat.parse(requestedAmount.text)) {
}else{ ApprovedAmountError =
"Approved Amount should not be greater than requested amount";
} else {
ApprovedAmountError = null; ApprovedAmountError = null;
} }
notifyListeners(); notifyListeners();
} }
...@@ -631,7 +649,7 @@ String? proposedAmountError; ...@@ -631,7 +649,7 @@ String? proposedAmountError;
_selectedPaymentAccounts != null) { _selectedPaymentAccounts != null) {
_selectedPaymentAccounts = null; _selectedPaymentAccounts = null;
_selectedID = null; _selectedID = null;
_selectedValue =""; _selectedValue = "";
} }
notifyListeners(); notifyListeners();
} }
......
...@@ -122,7 +122,7 @@ class Requestionlistprovider extends ChangeNotifier { ...@@ -122,7 +122,7 @@ class Requestionlistprovider extends ChangeNotifier {
set selectedApprovalEmployee(Employees? value) { set selectedApprovalEmployee(Employees? value) {
_selectedApprovalEmployee = value; _selectedApprovalEmployee = value;
_selectedApprovalEmployeeID = value!.id!; _selectedApprovalEmployeeID = value!.id!;
_selectedApprovalEmployeeValue = value!.name!; _selectedApprovalEmployeeValue = value.name!;
notifyListeners(); notifyListeners();
} }
...@@ -154,7 +154,7 @@ class Requestionlistprovider extends ChangeNotifier { ...@@ -154,7 +154,7 @@ class Requestionlistprovider extends ChangeNotifier {
set selectDirectAccounts(DirectAccounts? value) { set selectDirectAccounts(DirectAccounts? value) {
_selectedDirectAccounts = value; _selectedDirectAccounts = value;
_directAccountID = value!.id!; _directAccountID = value!.id!;
_directAccountValue = value!.name!; _directAccountValue = value.name!;
selectDirectAccountError = null; selectDirectAccountError = null;
notifyListeners(); notifyListeners();
} }
...@@ -162,7 +162,7 @@ class Requestionlistprovider extends ChangeNotifier { ...@@ -162,7 +162,7 @@ class Requestionlistprovider extends ChangeNotifier {
set selectDirectPaymentAccounts(DirectPaymentAccounts? value) { set selectDirectPaymentAccounts(DirectPaymentAccounts? value) {
_selectDirectPaymentAccounts = value; _selectDirectPaymentAccounts = value;
_directPaymentAccountsID = value!.id!; _directPaymentAccountsID = value!.id!;
_directPaymentAccountsValue = value!.name!; _directPaymentAccountsValue = value.name!;
selectDirectPaymentAccountError = null; selectDirectPaymentAccountError = null;
notifyListeners(); notifyListeners();
} }
...@@ -170,7 +170,7 @@ class Requestionlistprovider extends ChangeNotifier { ...@@ -170,7 +170,7 @@ class Requestionlistprovider extends ChangeNotifier {
set selectDirectPaymentModes(DirectPaymentModes? value) { set selectDirectPaymentModes(DirectPaymentModes? value) {
_selectDirectPaymentModes = value; _selectDirectPaymentModes = value;
_directPaymentModesID = value!.id!; _directPaymentModesID = value!.id!;
_directPaymentModesValues = value!.name!; _directPaymentModesValues = value.name!;
selectDirectPaymentError = null; selectDirectPaymentError = null;
notifyListeners(); notifyListeners();
} }
...@@ -303,7 +303,7 @@ class Requestionlistprovider extends ChangeNotifier { ...@@ -303,7 +303,7 @@ class Requestionlistprovider extends ChangeNotifier {
set selectedAccount(Accounts? value) { set selectedAccount(Accounts? value) {
_selectedAccounts = value; _selectedAccounts = value;
_accountId = value!.id!; _accountId = value!.id!;
_accountValue = value!.name!; _accountValue = value.name!;
selectAccountError = null; selectAccountError = null;
notifyListeners(); notifyListeners();
...@@ -312,7 +312,7 @@ class Requestionlistprovider extends ChangeNotifier { ...@@ -312,7 +312,7 @@ class Requestionlistprovider extends ChangeNotifier {
set selectedPayment(PaymentModes? value) { set selectedPayment(PaymentModes? value) {
_selectedPayment = value; _selectedPayment = value;
_paymentModeId = value!.id!; _paymentModeId = value!.id!;
_paymentModeValue = value!.name!; _paymentModeValue = value.name!;
selectPaymentError = null; selectPaymentError = null;
notifyListeners(); notifyListeners();
...@@ -360,7 +360,7 @@ class Requestionlistprovider extends ChangeNotifier { ...@@ -360,7 +360,7 @@ class Requestionlistprovider extends ChangeNotifier {
debugPrint("added"); debugPrint("added");
_image = File(galleryImage!.path); _image = File(galleryImage!.path);
_imageName = File(galleryImage!.name); _imageName = File(galleryImage.name);
_image_picked = 1; _image_picked = 1;
FileError = null; FileError = null;
notifyListeners(); notifyListeners();
...@@ -382,7 +382,7 @@ class Requestionlistprovider extends ChangeNotifier { ...@@ -382,7 +382,7 @@ class Requestionlistprovider extends ChangeNotifier {
debugPrint("Jenny: bytes:$bytes, kb:$kb, mb: $mb"); debugPrint("Jenny: bytes:$bytes, kb:$kb, mb: $mb");
_image = File(galleryImage!.path); _image = File(galleryImage!.path);
_imageName = File(galleryImage!.name); _imageName = File(galleryImage.name);
_image_picked = 1; _image_picked = 1;
FileError = null; FileError = null;
notifyListeners(); notifyListeners();
...@@ -440,12 +440,12 @@ class Requestionlistprovider extends ChangeNotifier { ...@@ -440,12 +440,12 @@ class Requestionlistprovider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} else {} } else {}
} }
} catch (e, s) {} } catch (e) {}
} }
Future<void> paymentRequestionBankDetailsAPIFunction( Future<void> paymentRequestionBankDetailsAPIFunction(
context, context,
account_id, accountId,
) async { ) async {
try { try {
var homeProvider = Provider.of<HomescreenNotifier>( var homeProvider = Provider.of<HomescreenNotifier>(
...@@ -455,7 +455,7 @@ class Requestionlistprovider extends ChangeNotifier { ...@@ -455,7 +455,7 @@ class Requestionlistprovider extends ChangeNotifier {
final data = await ApiCalling.paymentRequestionBankDetailsAPI( final data = await ApiCalling.paymentRequestionBankDetailsAPI(
homeProvider.empId, homeProvider.empId,
homeProvider.session, homeProvider.session,
account_id, accountId,
); );
notifyListeners(); notifyListeners();
...@@ -474,7 +474,7 @@ class Requestionlistprovider extends ChangeNotifier { ...@@ -474,7 +474,7 @@ class Requestionlistprovider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} else {} } else {}
} }
} catch (e, s) {} } catch (e) {}
} }
Future<void> addPaymentRequestionSubmitAPI( Future<void> addPaymentRequestionSubmitAPI(
...@@ -530,7 +530,7 @@ class Requestionlistprovider extends ChangeNotifier { ...@@ -530,7 +530,7 @@ class Requestionlistprovider extends ChangeNotifier {
_submitClicked = false; _submitClicked = false;
notifyListeners(); notifyListeners();
} }
} catch (e, s) { } catch (e) {
_submitClicked = false; _submitClicked = false;
notifyListeners(); notifyListeners();
} }
...@@ -568,15 +568,11 @@ class Requestionlistprovider extends ChangeNotifier { ...@@ -568,15 +568,11 @@ class Requestionlistprovider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} else {} } else {}
} }
} catch (e, s) {} } catch (e) {}
} }
Future<void> addDirectPaymentRequestionSubmitAPI( Future<void> addDirectPaymentRequestionSubmitAPI(context, paymentDate) async {
context,
payment_date,
) async {
try { try {
if (!validateDirectForm(context)) { if (!validateDirectForm(context)) {
return; return;
} }
...@@ -594,7 +590,7 @@ class Requestionlistprovider extends ChangeNotifier { ...@@ -594,7 +590,7 @@ class Requestionlistprovider extends ChangeNotifier {
descController.text, descController.text,
_directPaymentModesID, _directPaymentModesID,
amountController.text, amountController.text,
payment_date, paymentDate,
paymentReferenceController.text, paymentReferenceController.text,
bankNameController.text, bankNameController.text,
bankBranchController.text, bankBranchController.text,
...@@ -619,7 +615,7 @@ class Requestionlistprovider extends ChangeNotifier { ...@@ -619,7 +615,7 @@ class Requestionlistprovider extends ChangeNotifier {
_submitClicked = false; _submitClicked = false;
notifyListeners(); notifyListeners();
} }
} catch (e, s) { } catch (e) {
_submitClicked = false; _submitClicked = false;
notifyListeners(); notifyListeners();
} }
...@@ -644,12 +640,12 @@ class Requestionlistprovider extends ChangeNotifier { ...@@ -644,12 +640,12 @@ class Requestionlistprovider extends ChangeNotifier {
} }
Future<void> paymentRequestionListsAPIFunction( Future<void> paymentRequestionListsAPIFunction(
BuildContext context, BuildContext context,
String mode, String mode,
String from, String from,
String to, { String to, {
bool append = false, bool append = false,
}) async { }) async {
try { try {
var homeProvider = Provider.of<HomescreenNotifier>( var homeProvider = Provider.of<HomescreenNotifier>(
context, context,
...@@ -675,14 +671,17 @@ class Requestionlistprovider extends ChangeNotifier { ...@@ -675,14 +671,17 @@ class Requestionlistprovider extends ChangeNotifier {
to, to,
_pageNum.toString(), _pageNum.toString(),
); );
debugPrint('empId: ${homeProvider.empId}, session: ${homeProvider.session}, pageNumber: $_pageNum'); debugPrint(
'empId: ${homeProvider.empId}, session: ${homeProvider.session}, pageNumber: $_pageNum',
);
if (data != null && data.error == "0") { if (data != null && data.error == "0") {
if (append) { if (append) {
final existingIds = _requisitionList.map((e) => e.id).toSet(); final existingIds = _requisitionList.map((e) => e.id).toSet();
final newItems = data.requistionList! final newItems =
.where((item) => !existingIds.contains(item.id)) data.requistionList!
.toList(); .where((item) => !existingIds.contains(item.id))
.toList();
_requisitionList.addAll(newItems); _requisitionList.addAll(newItems);
} else { } else {
_requisitionList = data.requistionList ?? []; _requisitionList = data.requistionList ?? [];
...@@ -706,7 +705,6 @@ class Requestionlistprovider extends ChangeNotifier { ...@@ -706,7 +705,6 @@ class Requestionlistprovider extends ChangeNotifier {
} }
} }
void showDatePickerDialog(BuildContext context) { void showDatePickerDialog(BuildContext context) {
showCupertinoModalPopup<void>( showCupertinoModalPopup<void>(
context: context, context: context,
...@@ -750,7 +748,7 @@ class Requestionlistprovider extends ChangeNotifier { ...@@ -750,7 +748,7 @@ class Requestionlistprovider extends ChangeNotifier {
), ),
), ),
onPressed: () { onPressed: () {
setDate(_date ?? DateTime.now() ); setDate(_date ?? DateTime.now());
Navigator.pop(context); Navigator.pop(context);
}, },
), ),
...@@ -838,10 +836,8 @@ class Requestionlistprovider extends ChangeNotifier { ...@@ -838,10 +836,8 @@ class Requestionlistprovider extends ChangeNotifier {
if (await Permission.storage.request().isGranted || if (await Permission.storage.request().isGranted ||
await Permission.manageExternalStorage.request().isGranted) { await Permission.manageExternalStorage.request().isGranted) {
final dir = await getApplicationDocumentsDirectory(); final dir = await getApplicationDocumentsDirectory();
if (dir != null) { print('Using Downloads directory: ${dir.path}');
print('Using Downloads directory: ${dir.path}'); return dir.path;
return dir.path;
}
} }
} }
} catch (e) { } catch (e) {
...@@ -1180,9 +1176,7 @@ class Requestionlistprovider extends ChangeNotifier { ...@@ -1180,9 +1176,7 @@ class Requestionlistprovider extends ChangeNotifier {
_submitClicked = false; _submitClicked = false;
} }
if (["Cheque", "RTGS", "IMPS", "NEFT"].contains(_paymentModeValue)) { if (["Cheque", "RTGS", "IMPS", "NEFT"].contains(_paymentModeValue)) {
if (bankNameController.text.trim().isEmpty) { if (bankNameController.text.trim().isEmpty) {
bankNameError = "Please enter bank name"; bankNameError = "Please enter bank name";
isValid = false; isValid = false;
...@@ -1212,13 +1206,14 @@ class Requestionlistprovider extends ChangeNotifier { ...@@ -1212,13 +1206,14 @@ class Requestionlistprovider extends ChangeNotifier {
} }
if (_paymentModeValue == "UPI") { if (_paymentModeValue == "UPI") {
if (bankUpiController.text.trim().isEmpty) { if (bankUpiController.text.trim().isEmpty) {
UPIError = "Please enter UPI ID"; UPIError = "Please enter UPI ID";
isValid = false; isValid = false;
_submitClicked = false; _submitClicked = false;
} }
if(!RegExp(r"^[a-zA-Z0-9.-]{2,256}@[a-zA-Z][a-zA-Z]{2,64}$").hasMatch(bankUpiController.text)){ if (!RegExp(
r"^[a-zA-Z0-9.-]{2,256}@[a-zA-Z][a-zA-Z]{2,64}$",
).hasMatch(bankUpiController.text)) {
UPIError = "Please enter UPI ID correctly."; UPIError = "Please enter UPI ID correctly.";
isValid = false; isValid = false;
_submitClicked = false; _submitClicked = false;
......
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