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