"lib/Models/crmModels/crmProspectDetailsAddLeadsResponse.dart" did not exist on "de7401388c36580b84ef8a3cb3632fd36dbced60"
Commit fb928cfe authored by Sai Srinivas's avatar Sai Srinivas
Browse files

23-06-2025 By Sai Srinivas

CRM Module - lead list, lead details, generate quotations, add and edit, Nearby Leads.
parent b9d7c024
class NearbyOpenLeadsResponse {
List<LeadList>? leadList;
int? error;
String? message;
NearbyOpenLeadsResponse({this.leadList, this.error, this.message});
NearbyOpenLeadsResponse.fromJson(Map<String, dynamic> json) {
if (json['lead_list'] != null) {
leadList = <LeadList>[];
json['lead_list'].forEach((v) {
leadList!.add(new LeadList.fromJson(v));
});
}
error = json['error'];
message = json['message'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.leadList != null) {
data['lead_list'] = this.leadList!.map((v) => v.toJson()).toList();
}
data['error'] = this.error;
data['message'] = this.message;
return data;
}
}
class LeadList {
String? id;
String? ownerId;
String? accId;
String? accManagerId;
String? status;
String? openStatus;
String? date;
String? closeDate;
String? closereason;
String? competitor;
String? orderGainId;
String? loc;
String? isExists;
String? createdDatetime;
String? updatedDatetime;
String? followupFunction;
String? name;
String? contName;
String? address;
String? mob1;
String? mob2;
String? tel;
String? email;
String? distance;
LeadList(
{this.id,
this.ownerId,
this.accId,
this.accManagerId,
this.status,
this.openStatus,
this.date,
this.closeDate,
this.closereason,
this.competitor,
this.orderGainId,
this.loc,
this.isExists,
this.createdDatetime,
this.updatedDatetime,
this.followupFunction,
this.name,
this.contName,
this.address,
this.mob1,
this.mob2,
this.tel,
this.email,
this.distance});
LeadList.fromJson(Map<String, dynamic> json) {
id = json['id'];
ownerId = json['owner_id'];
accId = json['acc_id'];
accManagerId = json['acc_manager_id'];
status = json['status'];
openStatus = json['open_status'];
date = json['date'];
closeDate = json['close_date'];
closereason = json['closereason'];
competitor = json['competitor'];
orderGainId = json['order_gain_id'];
loc = json['loc'];
isExists = json['is_exists'];
createdDatetime = json['created_datetime'];
updatedDatetime = json['updated_datetime'];
followupFunction = json['followup_function'];
name = json['name'];
contName = json['cont_name'];
address = json['address'];
mob1 = json['mob1'];
mob2 = json['mob2'];
tel = json['tel'];
email = json['email'];
distance = json['distance'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['owner_id'] = this.ownerId;
data['acc_id'] = this.accId;
data['acc_manager_id'] = this.accManagerId;
data['status'] = this.status;
data['open_status'] = this.openStatus;
data['date'] = this.date;
data['close_date'] = this.closeDate;
data['closereason'] = this.closereason;
data['competitor'] = this.competitor;
data['order_gain_id'] = this.orderGainId;
data['loc'] = this.loc;
data['is_exists'] = this.isExists;
data['created_datetime'] = this.createdDatetime;
data['updated_datetime'] = this.updatedDatetime;
data['followup_function'] = this.followupFunction;
data['name'] = this.name;
data['cont_name'] = this.contName;
data['address'] = this.address;
data['mob1'] = this.mob1;
data['mob2'] = this.mob2;
data['tel'] = this.tel;
data['email'] = this.email;
data['distance'] = this.distance;
return data;
}
}
class crmLeadDetailsEditAccountViewResponse {
List<Teams>? teams;
AccountDetails? accountDetails;
String? error;
String? message;
crmLeadDetailsEditAccountViewResponse(
{this.teams, this.accountDetails, this.error, this.message});
crmLeadDetailsEditAccountViewResponse.fromJson(Map<String, dynamic> json) {
if (json['teams'] != null) {
teams = <Teams>[];
json['teams'].forEach((v) {
teams!.add(new Teams.fromJson(v));
});
}
accountDetails = json['account_details'] != null
? new AccountDetails.fromJson(json['account_details'])
: null;
error = json['error'];
message = json['message'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.teams != null) {
data['teams'] = this.teams!.map((v) => v.toJson()).toList();
}
if (this.accountDetails != null) {
data['account_details'] = this.accountDetails!.toJson();
}
data['error'] = this.error;
data['message'] = this.message;
return data;
}
}
class Teams {
String? id;
String? name;
Teams({this.id, this.name});
Teams.fromJson(Map<String, dynamic> json) {
id = json['id'];
name = json['name'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['name'] = this.name;
return data;
}
}
class AccountDetails {
String? team;
String? segment;
String? name;
AccountDetails({this.team, this.segment, this.name});
AccountDetails.fromJson(Map<String, dynamic> json) {
team = json['team'];
segment = json['segment'];
name = json['name'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['team'] = this.team;
data['segment'] = this.segment;
data['name'] = this.name;
return data;
}
}
class crmLeadDetailsEditProductsViewResponse {
List<Products>? products;
List<LeadProducts>? leadProducts;
String? error;
String? message;
crmLeadDetailsEditProductsViewResponse(
{this.products, this.leadProducts, this.error, this.message});
crmLeadDetailsEditProductsViewResponse.fromJson(Map<String, dynamic> json) {
if (json['products'] != null) {
products = <Products>[];
json['products'].forEach((v) {
products!.add(new Products.fromJson(v));
});
}
if (json['lead_products'] != null) {
leadProducts = <LeadProducts>[];
json['lead_products'].forEach((v) {
leadProducts!.add(new LeadProducts.fromJson(v));
});
}
error = json['error'];
message = json['message'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.products != null) {
data['products'] = this.products!.map((v) => v.toJson()).toList();
}
if (this.leadProducts != null) {
data['lead_products'] =
this.leadProducts!.map((v) => v.toJson()).toList();
}
data['error'] = this.error;
data['message'] = this.message;
return data;
}
}
class Products {
String? id;
String? name;
Products({this.id, this.name});
Products.fromJson(Map<String, dynamic> json) {
id = json['id'];
name = json['name'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['name'] = this.name;
return data;
}
}
class LeadProducts {
String? id;
String? leadId;
String? productId;
String? qty;
String? price;
String? date;
String? isDel;
String? isExists;
String? createdDatetime;
String? updatedDatetime;
String? productName;
LeadProducts(
{this.id,
this.leadId,
this.productId,
this.qty,
this.price,
this.date,
this.isDel,
this.isExists,
this.createdDatetime,
this.updatedDatetime,
this.productName});
LeadProducts.fromJson(Map<String, dynamic> json) {
id = json['id'];
leadId = json['lead_id'];
productId = json['product_id'];
qty = json['qty'];
price = json['price'];
date = json['date'];
isDel = json['is_del'];
isExists = json['is_exists'];
createdDatetime = json['created_datetime'];
updatedDatetime = json['updated_datetime'];
productName = json['product_name'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['lead_id'] = this.leadId;
data['product_id'] = this.productId;
data['qty'] = this.qty;
data['price'] = this.price;
data['date'] = this.date;
data['is_del'] = this.isDel;
data['is_exists'] = this.isExists;
data['created_datetime'] = this.createdDatetime;
data['updated_datetime'] = this.updatedDatetime;
data['product_name'] = this.productName;
return data;
}
}
class crmLeadDetailsGenerateQuotationSubmitResponse {
String? message;
String? error;
String? quoteFilepath;
crmLeadDetailsGenerateQuotationSubmitResponse(
{this.message, this.error, this.quoteFilepath});
crmLeadDetailsGenerateQuotationSubmitResponse.fromJson(
Map<String, dynamic> json) {
message = json['message'];
error = json['error'];
quoteFilepath = json['quote_filepath'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['message'] = this.message;
data['error'] = this.error;
data['quote_filepath'] = this.quoteFilepath;
return data;
}
}
class crmLeadDetailsGenerateQuotationViewResponse {
QuoteDetails? quoteDetails;
List<LeadProducts>? leadProducts;
String? error;
String? message;
crmLeadDetailsGenerateQuotationViewResponse(
{this.quoteDetails, this.leadProducts, this.error, this.message});
crmLeadDetailsGenerateQuotationViewResponse.fromJson(
Map<String, dynamic> json) {
quoteDetails = json['quote_details'] != null
? new QuoteDetails.fromJson(json['quote_details'])
: null;
if (json['lead_products'] != null) {
leadProducts = <LeadProducts>[];
json['lead_products'].forEach((v) {
leadProducts!.add(new LeadProducts.fromJson(v));
});
}
error = json['error'];
message = json['message'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.quoteDetails != null) {
data['quote_details'] = this.quoteDetails!.toJson();
}
if (this.leadProducts != null) {
data['lead_products'] =
this.leadProducts!.map((v) => v.toJson()).toList();
}
data['error'] = this.error;
data['message'] = this.message;
return data;
}
}
class QuoteDetails {
String? accountId;
String? name;
String? email;
String? mobile;
String? subject;
String? forText;
String? paymentTerms;
QuoteDetails(
{this.accountId,
this.name,
this.email,
this.mobile,
this.subject,
this.forText,
this.paymentTerms});
QuoteDetails.fromJson(Map<String, dynamic> json) {
accountId = json['account_id'];
name = json['name'];
email = json['email'];
mobile = json['mobile'];
subject = json['subject'];
forText = json['for_text'];
paymentTerms = json['payment_terms'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['account_id'] = this.accountId;
data['name'] = this.name;
data['email'] = this.email;
data['mobile'] = this.mobile;
data['subject'] = this.subject;
data['for_text'] = this.forText;
data['payment_terms'] = this.paymentTerms;
return data;
}
}
class LeadProducts {
String? id;
String? leadId;
String? productId;
String? qty;
String? price;
String? date;
String? isDel;
String? isExists;
String? createdDatetime;
String? updatedDatetime;
String? productName;
LeadProducts(
{this.id,
this.leadId,
this.productId,
this.qty,
this.price,
this.date,
this.isDel,
this.isExists,
this.createdDatetime,
this.updatedDatetime,
this.productName});
LeadProducts.fromJson(Map<String, dynamic> json) {
id = json['id'];
leadId = json['lead_id'];
productId = json['product_id'];
qty = json['qty'];
price = json['price'];
date = json['date'];
isDel = json['is_del'];
isExists = json['is_exists'];
createdDatetime = json['created_datetime'];
updatedDatetime = json['updated_datetime'];
productName = json['product_name'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['lead_id'] = this.leadId;
data['product_id'] = this.productId;
data['qty'] = this.qty;
data['price'] = this.price;
data['date'] = this.date;
data['is_del'] = this.isDel;
data['is_exists'] = this.isExists;
data['created_datetime'] = this.createdDatetime;
data['updated_datetime'] = this.updatedDatetime;
data['product_name'] = this.productName;
return data;
}
}
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:generp/Models/commonModels/commonAccountLedgerFilterResponse.dart'; import 'package:generp/Models/commonModels/commonAccountLedgerFilterResponse.dart';
import 'package:generp/Models/commonModels/commonAccountLedgerResponse.dart'; import 'package:generp/Models/commonModels/commonAccountLedgerResponse.dart';
...@@ -7,6 +8,8 @@ import 'package:provider/provider.dart'; ...@@ -7,6 +8,8 @@ import 'package:provider/provider.dart';
class Accountledgerprovider extends ChangeNotifier{ class Accountledgerprovider extends ChangeNotifier{
TextEditingController searchAccountController = TextEditingController();
List<Accounts> _accounts = []; List<Accounts> _accounts = [];
List<LedgerList> _ledgerList = []; List<LedgerList> _ledgerList = [];
AccountDetails _accountDetails = AccountDetails(); AccountDetails _accountDetails = AccountDetails();
...@@ -46,10 +49,19 @@ class Accountledgerprovider extends ChangeNotifier{ ...@@ -46,10 +49,19 @@ class Accountledgerprovider extends ChangeNotifier{
void resetAll() { void resetAll() {
_selectedAccount = null; _selectedAccount = null;
_selectedAcID = ""; _selectedAcID = "";
_selectedAcVal = "";
_accounts = []; _accounts = [];
_ledgerList = []; _ledgerList = [];
checkDropdownReset();
notifyListeners(); // Notify UI to update notifyListeners(); // Notify UI to update
} }
void checkDropdownReset(){
if(!_accounts.contains(_selectedAccount)&&_selectedAccount!=null){
_selectedAcID = "";
_selectedAcVal = "";
}
notifyListeners();
}
Future<void> dropDownAPI(context) async { Future<void> dropDownAPI(context) async {
try{ try{
...@@ -57,6 +69,7 @@ class Accountledgerprovider extends ChangeNotifier{ ...@@ -57,6 +69,7 @@ class Accountledgerprovider extends ChangeNotifier{
final data = await ApiCalling.commonAccountLedgerDropDownAPI(prov.empId,prov.session); final data = await ApiCalling.commonAccountLedgerDropDownAPI(prov.empId,prov.session);
if(data!=null){ if(data!=null){
if(data.error=="0"){ if(data.error=="0"){
checkDropdownReset();
_accounts = data.accounts!; _accounts = data.accounts!;
notifyListeners(); notifyListeners();
} }
......
...@@ -28,6 +28,10 @@ class Accountslistprovider extends ChangeNotifier { ...@@ -28,6 +28,10 @@ class Accountslistprovider extends ChangeNotifier {
TextEditingController mobileNumberController = TextEditingController(); TextEditingController mobileNumberController = TextEditingController();
TextEditingController companyNameController = TextEditingController(); TextEditingController companyNameController = TextEditingController();
TextEditingController stateSearchController = TextEditingController();
TextEditingController districtSearchController = TextEditingController();
TextEditingController subLocSearchController = TextEditingController();
String? accountError; String? accountError;
String? nameError; String? nameError;
String? mobileError; String? mobileError;
...@@ -191,6 +195,7 @@ class Accountslistprovider extends ChangeNotifier { ...@@ -191,6 +195,7 @@ class Accountslistprovider extends ChangeNotifier {
notifyListeners(); notifyListeners();
if (data != null) { if (data != null) {
if (data.error == "0") { if (data.error == "0") {
ChechkDropdownValues();
_accountTypes = data.accountTypes!; _accountTypes = data.accountTypes!;
_states = data.states!; _states = data.states!;
notifyListeners(); notifyListeners();
...@@ -230,6 +235,7 @@ class Accountslistprovider extends ChangeNotifier { ...@@ -230,6 +235,7 @@ class Accountslistprovider extends ChangeNotifier {
); );
if (data != null) { if (data != null) {
if (data.error == "0") { if (data.error == "0") {
_subLocations = data.subLocations!; _subLocations = data.subLocations!;
notifyListeners(); notifyListeners();
} }
...@@ -248,19 +254,38 @@ class Accountslistprovider extends ChangeNotifier { ...@@ -248,19 +254,38 @@ class Accountslistprovider extends ChangeNotifier {
); );
if (data != null) { if (data != null) {
if (data.error == "0") { if (data.error == "0") {
nameError = null;
mobileError = null;
notifyListeners();
} else if (data.error == "1") { } else if (data.error == "1") {
toast(context, data.message); if(data.message?.contains("name already exists") ?? false){
nameError = data.message??"";
}else{
mobileError = data.message??"";
}
notifyListeners();
// toast(context, data.message);
} }
} }
} catch (e, s) {} } catch (e, s) {}
} }
bool _submitClicked = false;
bool get submitClickced => _submitClicked;
set submitClickced(bool value){
_submitClicked = value;
notifyListeners();
}
Future<void> submitCommonAccountsAPI(context) async { Future<void> submitCommonAccountsAPI(context) async {
try { try {
if (!validatereceiptForm(context)) { if (!validatereceiptForm(context)) {
// _submitClicked = false; // _submitClicked = false;
return; return;
} }
_submitClicked = true;
notifyListeners();
var homeProv = Provider.of<HomescreenNotifier>(context, listen: false); var homeProv = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.commonAddAccountSubmitAPI( final data = await ApiCalling.commonAddAccountSubmitAPI(
homeProv.empId, homeProv.empId,
...@@ -285,14 +310,27 @@ class Accountslistprovider extends ChangeNotifier { ...@@ -285,14 +310,27 @@ class Accountslistprovider extends ChangeNotifier {
); );
if (data != null) { if (data != null) {
if (data.error == "0") { if (data.error == "0") {
_submitClicked = false;
notifyListeners();
Navigator.pop(context); Navigator.pop(context);
resetValues(); resetValues();
toast(context, data.message); toast(context, data.message);
} else if (data.error == "1") { } else if (data.error == "1") {
_submitClicked = false;
notifyListeners();
toast(context, data.message); toast(context, data.message);
} else {} } else {
_submitClicked = false;
notifyListeners();
}
}else{
_submitClicked = false;
notifyListeners();
} }
} catch (e, s) {} } catch (e, s) {
_submitClicked = false;
notifyListeners();
}
} }
bool validatereceiptForm(BuildContext context) { bool validatereceiptForm(BuildContext context) {
...@@ -381,7 +419,7 @@ class Accountslistprovider extends ChangeNotifier { ...@@ -381,7 +419,7 @@ class Accountslistprovider extends ChangeNotifier {
// if (contectPersonMailController.text.trim().isEmpty) { // if (contectPersonMailController.text.trim().isEmpty) {
// teleError= "Please Enter"; isValid = false; // teleError= "Please Enter"; isValid = false;
// } // }
_submitClicked = false;
notifyListeners(); notifyListeners();
return isValid; return isValid;
} }
...@@ -489,16 +527,22 @@ class Accountslistprovider extends ChangeNotifier { ...@@ -489,16 +527,22 @@ class Accountslistprovider extends ChangeNotifier {
resetValues() { resetValues() {
_selectedAccountType = null; _selectedAccountType = null;
_selectedState = null;
_selectedDistricts = null;
_selectedSubLocations = null;
_selectedStateID = null; _selectedStateID = null;
_selectedStateValue = null;
_selectedDistrictID = null; _selectedDistrictID = null;
_selectedDistrictValue = null;
_selectedSubLocID = null; _selectedSubLocID = null;
_selectedSubLocValue = null;
_isVisible = false;
stateSearchController.clear();
districtSearchController.clear();
subLocSearchController.clear();
nameController.clear(); nameController.clear();
mobileController.clear(); mobileController.clear();
contectPersonAltMobController.clear();
contectPersonTeleController.clear();
contectPersonMailController.clear();
contectPersonDesignationController.clear();
addressController.clear(); addressController.clear();
bankNameController.clear(); bankNameController.clear();
branchNameController.clear(); branchNameController.clear();
...@@ -506,5 +550,52 @@ class Accountslistprovider extends ChangeNotifier { ...@@ -506,5 +550,52 @@ class Accountslistprovider extends ChangeNotifier {
bankHolderNameController.clear(); bankHolderNameController.clear();
bankAcNumberController.clear(); bankAcNumberController.clear();
bankUpiController.clear(); bankUpiController.clear();
contactPersonController.clear();
contectPersonDesignationController.clear();
contectPersonAltMobController.clear();
contectPersonTeleController.clear();
contectPersonMailController.clear();
mobileNumberController.clear();
companyNameController.clear();
accountError = null;
nameError = null;
mobileError = null;
stateError = null;
districtError = null;
localityError = null;
addressError = null;
banknameError = null;
bankBranchError = null;
bankIFSCError = null;
bankHolderNameError = null;
bankAcNumberError = null;
upiError = null;
contactPersonError = null;
desigantionError = null;
altMobError = null;
teleError = null;
mailError = null;
ChechkDropdownValues();
notifyListeners();
}
void ChechkDropdownValues() {
if(!_accountTypes.contains(_selectedAccountType)&&_selectedAccountType!=null){
_selectedAccountType = null;
}
if(!_states.contains(_selectedState)&&_selectedState!=null){
_selectedStateID = null;
_selectedStateValue = null;
}
if(!_districts.contains(_selectedDistricts)&&_selectedDistricts!=null){
_selectedDistrictID = null;
_selectedDistrictValue = null;
}
if(!_subLocations.contains(_selectedSubLocations)&&_selectedSubLocations!=null){
_selectedSubLocID = null;
_selectedSubLocValue = null;
}
notifyListeners();
} }
} }
...@@ -478,6 +478,8 @@ class Leadlistprovider extends ChangeNotifier { ...@@ -478,6 +478,8 @@ class Leadlistprovider extends ChangeNotifier {
subLocID, subLocID,
) async { ) async {
try { try {
_crmLeadList.clear();
notifyListeners();
var HomeProv = Provider.of<HomescreenNotifier>(context, listen: false); var HomeProv = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.crmLeadListFilterSubmitAPI( final data = await ApiCalling.crmLeadListFilterSubmitAPI(
HomeProv.empId, HomeProv.empId,
...@@ -502,8 +504,8 @@ class Leadlistprovider extends ChangeNotifier { ...@@ -502,8 +504,8 @@ class Leadlistprovider extends ChangeNotifier {
notifyListeners(); notifyListeners();
if (data.error == "0") { if (data.error == "0") {
_crmLeadList = data.leadList!; _crmLeadList = data.leadList!;
checkDropDownValues();
_isLoading = false; _isLoading = false;
checkDropDownValues();
notifyListeners(); notifyListeners();
} else { } else {
_isLoading = false; _isLoading = false;
...@@ -556,14 +558,14 @@ class Leadlistprovider extends ChangeNotifier { ...@@ -556,14 +558,14 @@ class Leadlistprovider extends ChangeNotifier {
_selectedDistrictId = null; _selectedDistrictId = null;
_selectedSubLocationId = null; _selectedSubLocationId = null;
_selectedEmployeeValue = ""; _selectedEmployeeValue = null;
_selectedSourceValue = ""; _selectedSourceValue = null;
_selectedReferenceValue = ""; _selectedReferenceValue = null;
_selectedTeamValue = ""; _selectedTeamValue = null;
_selectedSegmentValue = ""; _selectedSegmentValue = null;
_selectedDistrictValue = ""; _selectedDistrictValue = null;
_selectedStateValue = ""; _selectedStateValue = null;
_selectedSubLocationValue = ""; _selectedSubLocationValue = null;
checkDropDownValues(); checkDropDownValues();
notifyListeners(); notifyListeners();
} }
...@@ -608,5 +610,4 @@ class Leadlistprovider extends ChangeNotifier { ...@@ -608,5 +610,4 @@ class Leadlistprovider extends ChangeNotifier {
} }
notifyListeners(); notifyListeners();
} }
} }
...@@ -16,6 +16,7 @@ class Crmdashboardprovider extends ChangeNotifier{ ...@@ -16,6 +16,7 @@ class Crmdashboardprovider extends ChangeNotifier{
if(data!=null){ if(data!=null){
if(data.error=="0"){ if(data.error=="0"){
_accessPages = data.pagesAccessible!; _accessPages = data.pagesAccessible!;
_accessPages.add(PagesAccessible(mode: "",id: 0,pageName: "Nearby Leads"));
notifyListeners(); notifyListeners();
} }
} }
......
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_download_manager/flutter_download_manager.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:generp/Models/crmModels/crmLeadDetailsGenerateQuotationViewResponse.dart';
import 'package:http/http.dart' as http;
import 'package:intl/intl.dart';
import 'package:path_provider/path_provider.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:provider/provider.dart';
import 'package:url_launcher/url_launcher.dart';
import '../../Utils/commonServices.dart';
import '../../services/api_calling.dart';
import '../HomeScreenNotifier.dart';
class Crmgeneratequotationprovider extends ChangeNotifier {
final FlutterLocalNotificationsPlugin _notificationsPlugin =
FlutterLocalNotificationsPlugin();
static const platform = MethodChannel('in.webgrid.generp/download');
final GlobalKey webViewKey = GlobalKey();
var dl = DownloadManager();
TextEditingController mailIdController = TextEditingController();
TextEditingController mobileController = TextEditingController();
TextEditingController subjectsController = TextEditingController();
TextEditingController taxesController = TextEditingController();
TextEditingController SpecialNoteController = TextEditingController();
TextEditingController forController = TextEditingController();
TextEditingController paymentTermsController = TextEditingController();
String? mailIdError = "";
String? mobileError = "";
String? subjectsError = "";
String? taxesError = "";
String? SpecialNoteError = "";
String? forError = "";
String? paymentTermsError = "";
QuoteDetails _quoteDetails = QuoteDetails();
List<LeadProducts> _leadProductsList = [];
bool _isLoading = true;
String? _quotationFilePath;
LeadProducts? _selectedLeadProducts;
List<TextEditingController> editProductPriceControllers = [];
List<TextEditingController> editQuantityControllers = [];
List<TextEditingController> editTotalAmountControllers = [];
List<String?> _selectedProductIds = [];
List<String?> _selectedValues = [];
bool _submitLoading = false;
String? get quotationFilePath => _quotationFilePath;
QuoteDetails get quoteDetails => _quoteDetails;
List<LeadProducts> get leadProductsList => _leadProductsList;
LeadProducts? get selectedLeadProducts => _selectedLeadProducts;
bool get isLoading => _isLoading;
List<String?> get selectedProductIds => _selectedProductIds;
List<String?> get selectedValues => _selectedValues;
bool get submitLoading => _submitLoading;
set selectedLeadProducts(LeadProducts? value) {
_selectedLeadProducts = value;
notifyListeners();
}
void initializeForm(BuildContext context) {
// Clear existing controllers
editProductPriceControllers.clear();
editQuantityControllers.clear();
editTotalAmountControllers.clear();
_selectedProductIds.clear();
_selectedValues.clear();
// Initialize controllers for each lead product
for (var product in _leadProductsList) {
editProductPriceControllers.add(
TextEditingController(text: product.price?.toString() ?? ''),
);
editQuantityControllers.add(
TextEditingController(text: product.qty?.toString() ?? ''),
);
editTotalAmountControllers.add(
TextEditingController(
text:
(double.parse(product.price?.toString() ?? '0') *
int.parse(product.qty?.toString() ?? '0'))
.toString(),
),
);
_selectedProductIds.add(product.productId);
_selectedValues.add(product.productName);
}
// Add one empty row if the list is empty
if (_leadProductsList.isEmpty) {
editAddNewRow();
}
notifyListeners();
}
void editAddNewRow() {
editProductPriceControllers.add(TextEditingController());
editQuantityControllers.add(TextEditingController());
editTotalAmountControllers.add(TextEditingController());
_selectedProductIds.add(null);
_selectedValues.add(null);
notifyListeners();
}
void editRemoveRow(int index) {
editProductPriceControllers[index].dispose();
editQuantityControllers[index].dispose();
editTotalAmountControllers[index].dispose();
editProductPriceControllers.removeAt(index);
editQuantityControllers.removeAt(index);
editTotalAmountControllers.removeAt(index);
_selectedProductIds.removeAt(index);
_selectedValues.removeAt(index);
notifyListeners();
}
void updateSelectedProductIds(int index, LeadProducts value) {
_selectedProductIds[index] = value.id;
_selectedValues[index] = value.productName;
notifyListeners();
}
void updateTotalAmount(int index) {
final price = double.tryParse(editProductPriceControllers[index].text) ?? 0;
final qty = int.tryParse(editQuantityControllers[index].text) ?? 0;
editTotalAmountControllers[index].text = (price * qty).toString();
notifyListeners();
}
//[{"product_id":"32","price":"40000","qty":"1","net_price":"40000"},
// {"product_id":"7","price":"318437.52","qty":"1","net_price":"318437.52"}]
List<Map<String, String>> getFormData() {
final List<Map<String, String>> insertData = [];
for (int i = 0; i < editProductPriceControllers.length; i++) {
if (_selectedProductIds[i] != null) {
final rowData = {
"product_id": _selectedProductIds[i]!,
"price": editProductPriceControllers[i].text,
"qty": editQuantityControllers[i].text,
"net_price":editTotalAmountControllers[i].text
};
insertData.add(rowData);
}
}
return insertData;
}
Future<void> crmLeadDetailsGenerateQuoteViewAPIFunction(
BuildContext context,
String leadID,
) async {
try {
final prov = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.crmLeadDetailsGenerateQuotationViewAPI(
prov.empId,
prov.session,
leadID,
);
if (data != null) {
if (data.error == "0") {
_isLoading = false;
_leadProductsList = data.leadProducts ?? [];
_quoteDetails =
data.quoteDetails ??
QuoteDetails(
accountId: "",
email: "",
forText: "",
mobile: "",
name: "",
paymentTerms: "",
subject: "",
);
mailIdController.text = data.quoteDetails!.email??"-";
mobileController.text = data.quoteDetails!.mobile??"-";
subjectsController.text = data.quoteDetails!.subject??"-";
// taxesController.text = data.quoteDetails!1;
// SpecialNoteController.text = data.quoteDetails;
forController.text = data.quoteDetails!.forText??"-";
paymentTermsController.text = data.quoteDetails!.paymentTerms??"-";
notifyListeners();
} else {
_isLoading = false;
notifyListeners();
}
} else {
_isLoading = false;
notifyListeners();
}
} catch (e, s) {
print("Error: $e, Stack: $s");
}
}
Future<void> crmLeadDetailsGenerateQuoteSubmitAPIFunction(
BuildContext context,
String leadID,
quote_products,
quotation_type,
) async {
try {
final prov = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.crmLeadDetailsGenerateQuotationSubmitAPI(
prov.empId,
prov.session,
leadID,
mobileController.text,
subjectsController.text,
taxesController.text,
SpecialNoteController.text,
forController.text,
paymentTermsController.text,
mailIdController.text,
quote_products,
quotation_type,
);
if (data != null) {
if (data.error == "0") {
_quotationFilePath = data.quoteFilepath!;
if(quotation_type=="genquotedown"){
String suggestedFilename = getUniqueFilename('quotation', 'pdf');
String contentDisposition = 'attachment; filename="$suggestedFilename"';
openWhatsApp(data.quoteFilepath!);
_handleDownload(context,data.quoteFilepath!,contentDisposition,'application/octet-stream','');
}
else if(quotation_type=="genquotewhatsappbymynum"){
openWhatsApp(data.quoteFilepath!);
}
resetForm();
notifyListeners();
} else {}
} else {}
} catch (e, s) {
print("Error: $e, Stack: $s");
}
}
String getUniqueFilename(String baseName, [String ext = 'pdf']) {
final now = DateTime.now();
final formattedDate = DateFormat('yyyyMMdd_HHmmss').format(now);
return '${baseName}_$formattedDate.$ext';
}
void openWhatsApp(String path) async {
final Uri url = Uri.parse(path); // Example: 919876543210
if (await canLaunchUrl(url)) {
await launchUrl(url, mode: LaunchMode.externalApplication);
} else {
throw 'Could not launch $url';
}
}
Future<void> _handleDownload(
context,
String url,
String contentDisposition,
String mimeType,
String suggestedFilename,
) async {
// Request notification permission for Android 13+
if (Platform.isIOS) {
_handleIOSDownload(context,url, suggestedFilename);
} else if (Platform.isAndroid) {
if (await Permission.notification.request().isGranted) {
try {
// Show custom notification (optional, since DownloadManager shows its own)
if (Platform.isAndroid) {
// Call native Android Download Manager
final userAgent = 'Flutter InAppWebView';
await platform.invokeMethod('startDownload', {
'url': url,
'userAgent': userAgent,
'contentDisposition': contentDisposition,
'mimeType': mimeType,
'suggestedFilename': suggestedFilename,
});
} else if (Platform.isIOS) {
_handleIOSDownload(context,url, suggestedFilename);
}
} catch (e) {
print("Download Error $e");
}
} else {
toast(context, "Notification Permission Denied");
}
}
}
Future<void> _handleIOSDownload(context,String url, String suggestedFilename) async {
try {
// Show initial download notification
await _showDownloadNotification(0, suggestedFilename, isComplete: false);
// Get the temporary directory for iOS
final tempDir = await getTemporaryDirectory();
final fileName =
suggestedFilename.isNotEmpty
? suggestedFilename
: url.split('/').last;
final filePath = '${tempDir.path}/$fileName';
// Download the file using http
final response = await http.get(Uri.parse(url));
if (response.statusCode == 200) {
// Save the file
final file = File(filePath);
await file.writeAsBytes(response.bodyBytes);
// Show completion notification
await _showDownloadNotification(100, fileName, isComplete: true);
// Optionally, open the file or notify the user
toast(context, "File downloaded to $filePath");
} else {
throw Exception("Failed to download file: HTTP ${response.statusCode}");
}
} catch (e) {
print("iOS Download Error: $e");
await _showDownloadNotification(
0,
suggestedFilename,
isComplete: false,
isError: true,
);
toast(context, "Failed to download file: $e");
}
}
Future<void> _showDownloadNotification(
int progress,
String fileName, {
bool isComplete = false,
bool isError = false,
}) async {
final androidDetails = AndroidNotificationDetails(
'download_channel',
'Downloads',
channelDescription: 'Notifications for file downloads',
importance: Importance.high,
priority: Priority.high,
showProgress: !isComplete && !isError,
maxProgress: 100,
progress: progress,
ongoing: !isComplete && !isError,
playSound: isComplete || isError,
styleInformation: BigTextStyleInformation(
isError
? 'Download failed for $fileName'
: isComplete
? 'Download complete: $fileName'
: 'Downloading $fileName...',
),
);
final iosDetails = DarwinNotificationDetails(
presentAlert: true,
presentBadge: true,
presentSound: isComplete || isError,
subtitle:
isError
? 'Download failed'
: isComplete
? 'Download complete'
: 'Downloading...',
threadIdentifier: 'download_thread',
);
final notificationDetails = NotificationDetails(
android: androidDetails,
iOS: iosDetails,
);
await _notificationsPlugin.show(
fileName.hashCode, // Unique ID for the notification
isError
? 'Download Failed'
: isComplete
? 'Download Complete'
: 'Downloading File',
isError
? 'Failed to download $fileName'
: isComplete
? 'Successfully downloaded $fileName'
: 'Downloading $fileName ($progress%)',
notificationDetails,
);
}
onChangemailId(value){
mailIdError = "";
notifyListeners();
}
onChangemobile(value){
mobileError = "";
notifyListeners();
}
onChangesubjects(value){
subjectsError = "";
notifyListeners();
}
onChangetaxes(value){
taxesError = "";
notifyListeners();
}
onChangeSpecialNote(value){
SpecialNoteError = "";
notifyListeners();
}
onChangefor(value){
forError = "";
notifyListeners();
}
onChangepaymentTerms(value){
paymentTermsError = "";
notifyListeners();
}
resetForm(){
mailIdController.clear();
mobileController.clear();
subjectsController.clear();
taxesController.clear();
SpecialNoteController.clear();
forController.clear();
paymentTermsController.clear();
editProductPriceControllers.clear();
editQuantityControllers.clear();
editTotalAmountControllers.clear();
_selectedProductIds.clear();
_selectedValues.clear();
_leadProductsList.clear();
mailIdError = "";
mobileError = "";
subjectsError = "";
taxesError = "";
SpecialNoteError = "";
forError = "";
paymentTermsError = "";
}
}
import 'dart:async';
import 'dart:io';
import 'dart:ui' as ui;
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:generp/Notifiers/HomeScreenNotifier.dart';
import 'package:generp/screens/crm/LeadDetailsByMode.dart';
import 'package:generp/screens/genTracker/GeneratorDetails.dart';
import 'package:generp/services/api_calling.dart';
import 'package:geolocator/geolocator.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:image_picker/image_picker.dart';
import 'package:geocoding/geocoding.dart' as geocoding;
import 'package:location/location.dart' as Location;
import 'package:permission_handler/permission_handler.dart';
import 'package:provider/provider.dart';
import '../../Models/crmModels/NearbyOpenLeadsResponse.dart';
import '../../Utils/commonServices.dart';
class crmNearbyOpenLeadsProvider extends ChangeNotifier {
List<LeadList> _leadslist = [];
TextEditingController _locationController = TextEditingController();
String _googleApikey = "AIzaSyBGzvgMMKwPBAANTwaoRsAnrCpiWCj8wVs";
GoogleMapController? _mapController;
CameraPosition? _cameraPosition;
LatLng _startLocation = const LatLng(17.439112226708446, 78.43292499146135);
String _latlongs = "";
List<Marker> _markers = [];
List<String> _addresses = [];
Location.LocationData? _currentLocation;
bool _isLocationEnabled = false;
bool _hasLocationPermission = false;
Timer? _timer;
File? _image;
bool _isLoading = true;
String _selectedItem = 'Active';
double _currentValue = 1.0;
Timer? _debounceTimer;
List<LeadList> get leadsList => _leadslist;
TextEditingController get LocationController => _locationController;
String get googleAPIKey => _googleApikey;
GoogleMapController? get mapController => _mapController;
CameraPosition? get cameraPosition => _cameraPosition;
LatLng get startLocation => _startLocation;
String get latlongs => _latlongs;
List<Marker> get markers => _markers;
List<String> get addresses => _addresses;
Location.LocationData? get currentLocation => _currentLocation;
bool get isLocationEnabled => _isLocationEnabled;
bool get hasLocationPermission => _hasLocationPermission;
bool get isLoading => _isLoading;
Timer? get timer => _timer;
File? get image => _image;
String get selectedItem => _selectedItem;
double get currentValue => _currentValue;
set currentValue(value){
_currentValue = value;
notifyListeners();
}
set selectedItem(String value){
_selectedItem = value;
notifyListeners();
}
set markers(List<Marker> value){
_markers = value;
notifyListeners();
}
set mapController(value){
_mapController = value;
notifyListeners();
}
void resetAll(){
_currentValue = 1.0;
_selectedItem = "";
_markers= [];
_addresses = [];
}
Future<void> getLocationPermission(context) async {
// Check if location services are enabled
_isLocationEnabled = await Geolocator.isLocationServiceEnabled();
// Check if the app has been granted location permission
LocationPermission permission = await Geolocator.checkPermission();
_hasLocationPermission =
permission == LocationPermission.always ||
permission == LocationPermission.whileInUse;
final Location.Location location = Location.Location();
bool serviceEnabled;
Location.PermissionStatus permissionGranted;
serviceEnabled = await location.serviceEnabled();
if (!serviceEnabled) {
serviceEnabled = await location.requestService();
if (!serviceEnabled) {
return;
}
}
_isLoading = false;
permissionGranted = (await location.hasPermission());
if (permissionGranted == PermissionStatus) {
permissionGranted = (await location.requestPermission());
if (permissionGranted != PermissionStatus) {
return;
}
}
final Location.LocationData locData = await location.getLocation();
_currentLocation = locData;
if (_currentLocation != null) {
_mapController?.animateCamera(
CameraUpdate.newLatLng(
LatLng(_currentLocation!.latitude!, _currentLocation!.longitude!),
),
);
final lat = _currentLocation!.latitude;
final lang = _currentLocation!.longitude!;
_latlongs = '$lat,$lang';
LoadNearbyOpenLeadsAPI(context);
}
}
void onCameraMove(context, CameraPosition position) {
_timer?.cancel(); // Cancel any previous timer
_timer = Timer(Duration(seconds: 1), () {
getLocationPermission(context);
});
}
void debounce(VoidCallback callback, Duration duration) {
_debounceTimer?.cancel();
_debounceTimer = Timer(duration, callback);
}
Future<void> LoadNearbyOpenLeadsAPI(BuildContext context) async {
if (_latlongs.isEmpty || _currentValue <= 0) {
print("Invalid parameters: latlongs=$_latlongs, currentValue=$_currentValue");
return;
}
try {
var provider = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.loadNearbyOpenLeadsAPI(
provider.empId,
provider.session,
_latlongs,
);
if (data != null) {
if (data.error == 0) {
_leadslist = data.leadList!;
await updateMarkersFromApiResponse(context, data.leadList!);
_isLoading = false;
notifyListeners();
} else if(data.error==1){
toast(context, data.message);
}
} else {
toast(context, "Something went wrong, Please try again.");
}
} on Exception catch (e) {
print("$e");
}
}
Future<void> updateMarkersFromApiResponse(
BuildContext context,
List<LeadList> leadsList,
) async {
_markers = await createMarkersFromApiResponse(context, leadsList);
_addresses.clear();
await Future.forEach(leadsList, (store) async {
String address = await _getAddressFromLatLng(store.loc);
_addresses.add(address);
});
notifyListeners();
// for (int i = 0; i < _addresses.length; i++) {
// //print('List of Addresses:' "${addresses[i]}");
// // print('List of Addresses:' "${addresses[1]}" );
// }
}
Future<List<Marker>> createMarkersFromApiResponse(
BuildContext context,
List<LeadList> leadsList,
) async {
List<Marker> markers = [];
// print("Hello Nutsby!");
ByteData data = await rootBundle.load("assets/images/dg_set.png");
Uint8List bytes = data.buffer.asUint8List();
await Future.forEach(leadsList, (leads) async {
ui.Codec codec = await ui.instantiateImageCodec(
bytes,
targetWidth: 75,
targetHeight: 95,
);
ui.FrameInfo fi = await codec.getNextFrame();
Uint8List resizedBytes =
(await fi.image.toByteData(
format: ui.ImageByteFormat.png,
))!.buffer.asUint8List();
markers.add(
Marker(
markerId: MarkerId(leads.id.toString()),
position: _parseLatLng(leads.loc),
icon: BitmapDescriptor.fromBytes(resizedBytes),
infoWindow: InfoWindow(
title: "Name: ${leads.name}",
snippet: "Address: ${leads.address}",
),
zIndex: 100,
onTap: () {
int index = leadsList.indexWhere(
(techResponse) =>
techResponse.id == leads.id,
);
onMarkerTap(
context,
leads.id,
);
// print("index:${index}");
// Navigator.push(
// context,
// MaterialPageRoute(
// builder:
// (context) => Generatordetails(
// activityName: "NearByGenerators",
// genLocation: generator.loc,
// generatorId: generator.generatorId,
// ),
// ),
// );
},
),
);
});
return markers;
}
Future<void> onMarkerTap(context, leadID) async {
///uncomment with screen navigation
Navigator.push(
context, // Use the widget's BuildContext, which is valid here
MaterialPageRoute(
builder: (context) => LeadDetailsByMode(
mode: "",
pageTitleName: "Lead Details",
leadId:leadID ,
),
),
);
_markers = markers;
notifyListeners();
}
LatLng _parseLatLng(String? location) {
if (location != null) {
List<String> parts = location.split(',');
if (parts.length == 2) {
double lat = double.tryParse(parts[0]) ?? 0.0;
double lng = double.tryParse(parts[1]) ?? 0.0;
return LatLng(lat, lng);
}
}
return const LatLng(0.0, 0.0);
}
Future<String> _getAddressFromLatLng(String? location) async {
if (location != null) {
List<String> parts = location.split(',');
if (parts.length == 2) {
double lat = double.tryParse(parts[0]) ?? 0.0;
double lng = double.tryParse(parts[1]) ?? 0.0;
List<geocoding.Placemark> placemarks = await geocoding
.placemarkFromCoordinates(lat, lng);
if (placemarks.isNotEmpty) {
final placemark = placemarks.first;
String address =
'${placemark.street ?? ''}, '
'${placemark.thoroughfare ?? ''} '
// '${placemark.subThoroughfare ?? ''}, '
// '${placemark.name ?? ''}, '
'${placemark.subLocality ?? ''}, '
'${placemark.locality ?? ''}, '
'${placemark.administrativeArea ?? ''}, '
'${placemark.subAdministrativeArea ?? ''} '
'${placemark.postalCode ?? ''}, '
'${placemark.country ?? ''}';
return address.trim();
}
}
}
return "Address not found";
}
}
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:provider/provider.dart';
import '../../Models/crmModels/GetSegmentOnTeamResponse.dart';
import '../../Models/crmModels/crmLeadDetailsEditAccountViewResponse.dart';
import '../../services/api_calling.dart';
import '../HomeScreenNotifier.dart';
class Editcrmaccountdetailsprovider extends ChangeNotifier {
TextEditingController editCompanyNameController = TextEditingController();
List<Teams> _teamsList = [];
AccountDetails _accountDetails = AccountDetails();
List<Segments> _segmentsList = [];
Teams? _selectedTeams;
Segments? _selectedSegments;
String? _selectedSegmentId;
String? _selectedSegmentValue;
String? _selectedTeamId;
String? _selectedTeamValue;
bool _isLoading = true;
String? _companyNameError;
String? _selectedTeamError;
String? _selectedSegmentError;
bool get isLoading => _isLoading;
String? get companyNameError => _companyNameError;
String? get selectedTeamError => _selectedTeamError;
String? get selectedSegmentError => _selectedSegmentError;
List<Teams> get teamsList => _teamsList;
List<Segments> get segmentsList => _segmentsList;
Teams? get selectedTeams => _selectedTeams;
Segments? get selectedSegments => _selectedSegments;
AccountDetails get accountsDetails => _accountDetails;
String? get selectedTeamId => _selectedTeamId;
String? get selectedTeamValue => _selectedTeamValue;
String? get selectedSegmentId => _selectedSegmentId;
String? get selectedSegmentValue => _selectedSegmentValue;
set isLoading(bool value) {
_isLoading = value;
notifyListeners();
}
set companyNameError(String? value) {
_companyNameError = value;
notifyListeners();
}
set selectedTeamError(String? value) {
_selectedTeamError = value;
notifyListeners();
}
set selectedSegmentError(String? value) {
_selectedSegmentError = value;
notifyListeners();
}
set selectedTeams(Teams? value) {
_selectedTeams = value;
_selectedTeamId = value!.id!;
_selectedTeamValue = value.name;
notifyListeners();
}
set selectedSegments(Segments? value) {
_selectedSegments = value;
_selectedSegmentId = value!.id!;
_selectedSegmentValue = value.name;
notifyListeners();
}
set selectedTeamId(String? value) {
_selectedTeamId = value;
notifyListeners();
}
set selectedTeamValue(String? value) {
_selectedTeamValue = value;
notifyListeners();
}
set selectedSegmentId(String? value) {
_selectedSegmentId = value;
notifyListeners();
}
set selectedSegmentValue(String? value) {
_selectedSegmentValue = value;
notifyListeners();
}
Future<void> crmLeadDetailsEditAccountAPIFunction(
context,
leadID,
mode,
) async {
try {
var HomeProv = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.crmLeadDetailsEditAccountViewAPI(
HomeProv.empId,
HomeProv.session,
leadID,
mode,
);
_isLoading = true;
notifyListeners();
if (data != null) {
if (data.error == "0") {
_teamsList = data.teams!;
_accountDetails = data.accountDetails!;
_isLoading = false;
notifyListeners();
} else {
_isLoading = false;
notifyListeners();
}
} else {
_isLoading = false;
notifyListeners();
}
} catch (e, s) {
_isLoading = false;
notifyListeners();
}
}
Future<void> crmLeadListSegmentOnTeamAPIFunction(
context,
mode,
teamID,
) async {
try {
var prov = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.crmLeadListSegmentOnTeamAPI(
prov.empId,
prov.session,
teamID,
);
if (data != null) {
if (data.error == "0") {
_segmentsList = data.segments!;
notifyListeners();
}
}
} catch (e, s) {}
}
Future<void> crmLeadDetailsEditAccountSubmitAPIFunction(
context,
accountId,
segmentId,
teamId,
) async {
try {
if(!validateForm(context)){
return;
}
var HomeProv = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.crmLeadDetailsEditAccountSubmitAPI(
HomeProv.empId,
HomeProv.session,
accountId,
segmentId,
teamId,
editCompanyNameController.text,
);
_isLoading = true;
notifyListeners();
if (data != null) {
if (data.error == "0") {
Navigator.pop(context, true);
resetValue();
_isLoading = false;
notifyListeners();
} else {
_isLoading = false;
notifyListeners();
}
} else {
_isLoading = false;
notifyListeners();
}
} catch (e, s) {
_isLoading = false;
notifyListeners();
}
}
bool validateForm(BuildContext context) {
// Reset all errors
_companyNameError = null;
bool isValid = true;
if (_selectedTeams == null || _selectedTeamId!.isEmpty) {
_selectedTeamError = "Please select an account";
isValid = false;
}
if (_selectedSegments == null || _selectedSegmentId!.isEmpty) {
_selectedSegmentError = "Please select an account";
isValid = false;
}
if (editCompanyNameController.text.trim().isEmpty) {
_companyNameError = "Please enter Company name";
isValid = false;
}
notifyListeners();
return isValid;
}
onChangedCompanyName(value) {
_companyNameError = "";
notifyListeners();
}
void resetValue() {
_isLoading = false;
editCompanyNameController.clear();
_selectedSegments = null;
_selectedTeams = null;
_selectedTeamId = null;
_selectedSegmentId = null;
_selectedTeamValue = null;
_selectedSegmentValue = null;
}
void checkDropDownValues(){
if (!_segmentsList.contains(_selectedSegments) &&
_selectedSegments != null) {
_selectedTeamId = null;
_selectedTeamValue = null;
}
if (!_teamsList.contains(_selectedTeams) && _selectedTeams != null) {
_selectedSegmentId = null;
_selectedSegmentValue = null;
}
}
}
// import 'package:flutter/foundation.dart';
// import 'package:flutter/material.dart';
// import 'package:generp/Notifiers/HomeScreenNotifier.dart';
// import 'package:generp/services/api_calling.dart';
// import 'package:provider/provider.dart';
//
// import '../../Models/crmModels/crmLeadDetailsEditProductsViewResponse.dart';
//
// class Editproductlistprovider extends ChangeNotifier{
//
// List<Products> _productsList = [];
// List<LeadProducts> _leadProductsList = [];
//
// Products? _selectedProducts;
//
//
// List<TextEditingController> editProductPriceControllers = [];
// List<TextEditingController> editQuantityControllers = [];
// List<TextEditingController> editTotalAmountControllers = [];
//
// List<String?> _selectedProductIds = [];
// List<String?> _selectedProductValues = [];
//
// List<Map<String, String>> _insertData = [];
// bool _submitLoading = false;
//
// bool get submitLoading => _submitLoading;
//
// List<Products> get productsList => _productsList;
// List<LeadProducts> get leadProductsList => _leadProductsList;
//
// Products? get selectedProducts => _selectedProducts;
//
// List<String?> get selectedProductIds => _selectedProductIds;
// List<String?> get selectedProductValues => _selectedProductValues;
//
// set selectedProducts(Products? value){
// _selectedProducts = value;
// notifyListeners();
// }
//
// set selectedProductIds(List<String?> value){
// _selectedProductIds = value;
// notifyListeners();
// }
// set selectedProductValues(List<String?> value){
// _selectedProductValues = value;
// notifyListeners();
// }
//
// void updateSelectedProductIds(int index, Products? value) {
// _selectedProducts = value!;
//
// _selectedProductIds[index] = value!.id;
// print(_selectedProductIds[index]);
// notifyListeners();
// }
//
// set submitLoading(bool value){
// _submitLoading = value;
// notifyListeners();
// }
//
// void editAddNewRow() {
// editProductPriceControllers.add(TextEditingController());
// editQuantityControllers.add(TextEditingController());
// editTotalAmountControllers.add(TextEditingController());
// _selectedProductIds.add(null);
//
// notifyListeners();
// }
//
// void editRemoveRow(int index) {
// editProductPriceControllers[index].dispose();
// editQuantityControllers[index].dispose();
// editTotalAmountControllers[index].dispose();
// editProductPriceControllers.removeAt(index);
// editQuantityControllers.removeAt(index);
// editTotalAmountControllers.removeAt(index);
// _selectedProductIds.removeAt(index);
// notifyListeners();
// }
// //
// //
// List<Map<String, String>> getFormData() {
// _insertData = [];
// for (int i = 0; i < _productsList.length; i++) {
// final rowData = {
// "product_id": _productsList[i]!.id.toString(),
// "price": editQuantityControllers[i]!.text.toString(),
// "qty": editTotalAmountControllers[i]!.text.toString(),
// };
// _insertData.add(rowData);
// }
// notifyListeners();
// return _insertData;
// }
//
// Future<void> crmLeadDetailsEditProductsViewAPIFunction(context,leadID) async {
// try{
// final prov = Provider.of<HomescreenNotifier>(context,listen: false);
// final data = await ApiCalling.crmLeadDetailsEditProductsViewAPI(prov.empId, prov.session, leadID);
// if(data!=null){
// if(data.error=="0"){
// _leadProductsList = data.leadProducts!;
// _productsList= data.products!;
// notifyListeners();
// }else{
//
// }
// }else{
//
// }
// }catch(e,s){
//
// }
// }
//
// resetForm(){
//
// }
// }
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:generp/Notifiers/HomeScreenNotifier.dart';
import 'package:generp/services/api_calling.dart';
import 'package:provider/provider.dart';
import '../../Models/crmModels/crmLeadDetailsEditProductsViewResponse.dart';
class Editproductlistprovider extends ChangeNotifier {
List<Products> _productsList = [];
List<LeadProducts> _leadProductsList = [];
Products? _selectedProducts;
List<TextEditingController> editProductPriceControllers = [];
List<TextEditingController> editQuantityControllers = [];
List<TextEditingController> editTotalAmountControllers = [];
List<String?> _selectedProductIds = [];
List<String?> _selectedValues = [];
bool _submitLoading = false;
List<Products> get productsList => _productsList;
List<LeadProducts> get leadProductsList => _leadProductsList;
Products? get selectedProducts => _selectedProducts;
List<String?> get selectedProductIds => _selectedProductIds;
List<String?> get selectedValues => _selectedValues;
bool get submitLoading => _submitLoading;
set selectedProducts(Products? value) {
_selectedProducts = value;
notifyListeners();
}
set submitLoading(bool value) {
_submitLoading = value;
notifyListeners();
}
void initializeForm(BuildContext context) {
// Clear existing controllers
editProductPriceControllers.clear();
editQuantityControllers.clear();
editTotalAmountControllers.clear();
_selectedProductIds.clear();
_selectedValues.clear();
// Initialize controllers for each lead product
for (var product in _leadProductsList) {
editProductPriceControllers.add(TextEditingController(text: product.price?.toString() ?? ''));
editQuantityControllers.add(TextEditingController(text: product.qty?.toString() ?? ''));
editTotalAmountControllers.add(TextEditingController(
text: (double.parse(product.price?.toString() ?? '0') * int.parse(product.qty?.toString() ?? '0')).toString()));
_selectedProductIds.add(product.productId);
_selectedValues.add(product.productName);
}
// Add one empty row if the list is empty
if (_leadProductsList.isEmpty) {
editAddNewRow();
}
notifyListeners();
}
void editAddNewRow() {
editProductPriceControllers.add(TextEditingController());
editQuantityControllers.add(TextEditingController());
editTotalAmountControllers.add(TextEditingController());
_selectedProductIds.add(null);
_selectedValues.add(null);
notifyListeners();
}
void editRemoveRow(int index) {
editProductPriceControllers[index].dispose();
editQuantityControllers[index].dispose();
editTotalAmountControllers[index].dispose();
editProductPriceControllers.removeAt(index);
editQuantityControllers.removeAt(index);
editTotalAmountControllers.removeAt(index);
_selectedProductIds.removeAt(index);
_selectedValues.removeAt(index);
notifyListeners();
}
void updateSelectedProductIds(int index, Products value) {
_selectedProductIds[index] = value.id;
_selectedValues[index] = value.name;
notifyListeners();
}
void updateTotalAmount(int index) {
final price = double.tryParse(editProductPriceControllers[index].text) ?? 0;
final qty = int.tryParse(editQuantityControllers[index].text) ?? 0;
editTotalAmountControllers[index].text = (price * qty).toString();
notifyListeners();
}
List<Map<String, String>> getFormData() {
final List<Map<String, String>> insertData = [];
for (int i = 0; i < editProductPriceControllers.length; i++) {
if (_selectedProductIds[i] != null) {
final rowData = {
"product_id": _selectedProductIds[i]!,
"price": editProductPriceControllers[i].text,
"qty": editQuantityControllers[i].text,
};
insertData.add(rowData);
}
}
return insertData;
}
Future<void> crmLeadDetailsEditProductsViewAPIFunction(BuildContext context, String leadID) async {
try {
final prov = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.crmLeadDetailsEditProductsViewAPI(prov.empId, prov.session, leadID);
if (data != null && data.error == "0") {
_leadProductsList = data.leadProducts ?? [];
_productsList = data.products ?? [];
notifyListeners();
}
} catch (e, s) {
print("Error: $e, Stack: $s");
}
}
Future<void> crmLeadDetailsEditProductsSubmitAPIFunction(BuildContext context,products, String leadID) async {
try {
final prov = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.crmLeadDetailsEditProductsSubmitAPI(prov.empId, prov.session,products, leadID);
if (data != null && data.error == "0") {
resetForm();
Navigator.pop(context,true);
notifyListeners();
}
} catch (e, s) {
print("Error: $e, Stack: $s");
}
}
void submitForm(BuildContext context,leadID) async {
submitLoading = true;
final insertedData = getFormData();
print("Form Data: $insertedData");
crmLeadDetailsEditProductsSubmitAPIFunction(context,insertedData,leadID);
submitLoading = false;
}
void resetForm() {
editProductPriceControllers.clear();
editQuantityControllers.clear();
editTotalAmountControllers.clear();
_selectedProductIds.clear();
_selectedValues.clear();
_leadProductsList.clear();
notifyListeners();
}
}
\ No newline at end of file
...@@ -366,6 +366,7 @@ class Requesitionlidtdetailsprovider extends ChangeNotifier { ...@@ -366,6 +366,7 @@ class Requesitionlidtdetailsprovider extends ChangeNotifier {
Future<void> paymentrequisitionProcessSubmitAPIFunction(context, Future<void> paymentrequisitionProcessSubmitAPIFunction(context,
mode, mode,
reference_num,
payment_request_id, payment_request_id,
payment_account_id, payment_account_id,
processing_remarks, processing_remarks,
...@@ -376,8 +377,8 @@ class Requesitionlidtdetailsprovider extends ChangeNotifier { ...@@ -376,8 +377,8 @@ class Requesitionlidtdetailsprovider extends ChangeNotifier {
provider.empId, provider.empId,
provider.session, provider.session,
mode, mode,
reference_num,
payment_request_id, payment_request_id,
payment_account_id, payment_account_id,
processing_remarks, processing_remarks,
attachment, attachment,
......
...@@ -357,9 +357,13 @@ class Requestionlistprovider extends ChangeNotifier { ...@@ -357,9 +357,13 @@ class Requestionlistprovider extends ChangeNotifier {
); );
if (data != null) { if (data != null) {
if (data.error == "0") { if (data.error == "0") {
_accounts = data.accounts!; _accounts = data.accounts??[];
_paymentModes = data.paymentModes!; _paymentModes = data.paymentModes??[];
_requestingPurposes = data.requestingPurposes!; _requestingPurposes = data.requestingPurposes??[];
print('here');
print(data.requestingPurposes);
print(_accounts);
checkDropdownselected(); checkDropdownselected();
notifyListeners(); notifyListeners();
......
...@@ -123,6 +123,7 @@ Widget textControllerWidget( ...@@ -123,6 +123,7 @@ Widget textControllerWidget(
inputtype, inputtype,
readonly, readonly,
inputFormatters, inputFormatters,
[maxLength]
) { ) {
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
...@@ -141,6 +142,7 @@ Widget textControllerWidget( ...@@ -141,6 +142,7 @@ Widget textControllerWidget(
child: Padding( child: Padding(
padding: const EdgeInsets.fromLTRB(10.0, 0.0, 10, 0), padding: const EdgeInsets.fromLTRB(10.0, 0.0, 10, 0),
child: TextFormField( child: TextFormField(
maxLength: maxLength,
controller: controller, controller: controller,
readOnly: readonly, readOnly: readonly,
keyboardType: inputtype, keyboardType: inputtype,
...@@ -152,6 +154,7 @@ Widget textControllerWidget( ...@@ -152,6 +154,7 @@ Widget textControllerWidget(
? [FilteringTextInputFormatter.digitsOnly] ? [FilteringTextInputFormatter.digitsOnly]
: [], : [],
decoration: InputDecoration( decoration: InputDecoration(
counterText: "",
hintText: hintText, hintText: hintText,
hintStyle: TextStyle( hintStyle: TextStyle(
fontWeight: FontWeight.w400, fontWeight: FontWeight.w400,
......
...@@ -207,6 +207,12 @@ class MyApp extends StatelessWidget { ...@@ -207,6 +207,12 @@ class MyApp extends StatelessWidget {
ChangeNotifierProvider(create: (_) => Crmdashboardprovider()), ChangeNotifierProvider(create: (_) => Crmdashboardprovider()),
ChangeNotifierProvider(create: (_) => Leadlistprovider()), ChangeNotifierProvider(create: (_) => Leadlistprovider()),
ChangeNotifierProvider(create: (_) => crmLeadDetailsProvider()), ChangeNotifierProvider(create: (_) => crmLeadDetailsProvider()),
ChangeNotifierProvider(create: (_) => Editcrmaccountdetailsprovider()),
ChangeNotifierProvider(create: (_) => Editproductlistprovider()),
ChangeNotifierProvider(create: (_) => ProspectListProvider()),
ChangeNotifierProvider(create: (_) => crmProspectDetailsProvider()),
ChangeNotifierProvider(create: (_) => crmNearbyOpenLeadsProvider()),
ChangeNotifierProvider(create: (_) => Crmgeneratequotationprovider()),
], ],
child: Builder( child: Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
......
...@@ -118,8 +118,8 @@ class _MyHomePageState extends State<MyHomePage> { ...@@ -118,8 +118,8 @@ class _MyHomePageState extends State<MyHomePage> {
"Whizzdom", "Whizzdom",
"Common", "Common",
"Finance", "Finance",
// "Orders", "Orders",
// "CRM", "CRM",
]; ];
final icons = [ final icons = [
"assets/svg/home_icons_1.svg", "assets/svg/home_icons_1.svg",
...@@ -131,8 +131,8 @@ class _MyHomePageState extends State<MyHomePage> { ...@@ -131,8 +131,8 @@ class _MyHomePageState extends State<MyHomePage> {
"assets/svg/home_icons_81.svg", "assets/svg/home_icons_81.svg",
"assets/svg/home_icons_9.svg", "assets/svg/home_icons_9.svg",
"assets/svg/home_icons_10.svg", "assets/svg/home_icons_10.svg",
// "assets/svg/home_icons_11.svg", "assets/svg/home_icons_11.svg",
// "assets/svg/home_icons_12.svg", "assets/svg/home_icons_12.svg",
]; ];
final requiredRoles = [ final requiredRoles = [
"430", "430",
...@@ -144,8 +144,8 @@ class _MyHomePageState extends State<MyHomePage> { ...@@ -144,8 +144,8 @@ class _MyHomePageState extends State<MyHomePage> {
"431", "431",
"430", "430",
"430", "430",
// "430", "430",
// "430", "430",
]; ];
final filteredItems = <Map<String, String>>[]; final filteredItems = <Map<String, String>>[];
......
...@@ -76,7 +76,7 @@ class _AccountledgerState extends State<Accountledger> { ...@@ -76,7 +76,7 @@ class _AccountledgerState extends State<Accountledger> {
children: [ children: [
SvgPicture.asset("assets/svg/fin_ic.svg",height: 12,), SvgPicture.asset("assets/svg/fin_ic.svg",height: 12,),
SizedBox(width: 5,), SizedBox(width: 5,),
Text(overallBalance.toString()??"-",style: TextStyle( Text("₹${overallBalance.toString()}"??"-",style: TextStyle(
fontSize: 12, fontSize: 12,
),) ),)
], ],
...@@ -133,7 +133,7 @@ class _AccountledgerState extends State<Accountledger> { ...@@ -133,7 +133,7 @@ class _AccountledgerState extends State<Accountledger> {
text: TextSpan( text: TextSpan(
children: [ children: [
TextSpan( TextSpan(
text: "${totalCredit}", text: "${totalCredit}",
style: TextStyle( style: TextStyle(
color: Color(0xFFED3424), color: Color(0xFFED3424),
fontFamily: "JakartaRegular", fontFamily: "JakartaRegular",
...@@ -172,7 +172,7 @@ class _AccountledgerState extends State<Accountledger> { ...@@ -172,7 +172,7 @@ class _AccountledgerState extends State<Accountledger> {
text: TextSpan( text: TextSpan(
children: [ children: [
TextSpan( TextSpan(
text: "${totalDebit}", text: "${totalDebit}",
style: TextStyle( style: TextStyle(
color: Color(0xFFED3424), color: Color(0xFFED3424),
fontFamily: "JakartaRegular", fontFamily: "JakartaRegular",
...@@ -366,7 +366,7 @@ class _AccountledgerState extends State<Accountledger> { ...@@ -366,7 +366,7 @@ class _AccountledgerState extends State<Accountledger> {
Expanded( Expanded(
child: Text( child: Text(
textAlign: TextAlign.right, textAlign: TextAlign.right,
"${running_balance.toString()}" ?? "${running_balance.toString()}" ??
"-", "-",
style: TextStyle( style: TextStyle(
color: Color(0xFF818181), color: Color(0xFF818181),
...@@ -516,7 +516,8 @@ class _AccountledgerState extends State<Accountledger> { ...@@ -516,7 +516,8 @@ class _AccountledgerState extends State<Accountledger> {
), ),
) )
.toList(), .toList(),
value: provider.selectedAccount, value:provider.accounts.contains(provider.selectedAccount)?provider.selectedAccount:null,
// value: provider.selectedAccount,
onChanged: (Accounts? value) { onChanged: (Accounts? value) {
if (value != null) { if (value != null) {
if (provider.accounts.isNotEmpty) { if (provider.accounts.isNotEmpty) {
...@@ -536,6 +537,49 @@ class _AccountledgerState extends State<Accountledger> { ...@@ -536,6 +537,49 @@ class _AccountledgerState extends State<Accountledger> {
} }
} }
}, },
dropdownSearchData: DropdownSearchData(
searchInnerWidgetHeight: 50,
searchController:
provider
.searchAccountController,
searchInnerWidget: Padding(
padding: const EdgeInsets.all(8),
child: TextFormField(
controller:
provider
.searchAccountController,
decoration: InputDecoration(
isDense: true,
contentPadding:
const EdgeInsets.symmetric(
horizontal: 10,
vertical: 8,
),
hintText: 'Search account...',
border: OutlineInputBorder(
borderRadius:
BorderRadius.circular(8),
),
),
),
),
searchMatchFn: (item, searchValue) {
return item.value?.name
?.toLowerCase()
.contains(
searchValue.toLowerCase(),
) ??
false;
},
// Optional: clear search text when dropdown closes
),
onMenuStateChange: (isOpen) {
if (!isOpen) {
provider.searchAccountController
.clear();
}
},
buttonStyleData: ddtheme.buttonStyleData, buttonStyleData: ddtheme.buttonStyleData,
iconStyleData: ddtheme.iconStyleData, iconStyleData: ddtheme.iconStyleData,
menuItemStyleData: ddtheme.menuItemStyleData, menuItemStyleData: ddtheme.menuItemStyleData,
......
...@@ -36,10 +36,13 @@ class _AddcommonpaymentState extends State<Addcommonpayment> { ...@@ -36,10 +36,13 @@ class _AddcommonpaymentState extends State<Addcommonpayment> {
return Consumer<Accountslistprovider>( return Consumer<Accountslistprovider>(
builder: (context, provider, child) { builder: (context, provider, child) {
return WillPopScope( return WillPopScope(
onWillPop: () => onBackPressed(context), onWillPop: () async{
provider.resetValues();
return onBackPressed(context);
},
child: Scaffold( child: Scaffold(
resizeToAvoidBottomInset: true, resizeToAvoidBottomInset: true,
appBar: appbar(context, "Add Common Account"), appBar: appbar2(context, "Add Common Account",provider.resetValues,SizedBox(width: 0,)),
backgroundColor: AppColors.white, backgroundColor: AppColors.white,
body: SafeArea( body: SafeArea(
child: SizedBox( child: SizedBox(
...@@ -60,6 +63,7 @@ class _AddcommonpaymentState extends State<Addcommonpayment> { ...@@ -60,6 +63,7 @@ class _AddcommonpaymentState extends State<Addcommonpayment> {
Text("Account Details",style: TextStyle( color: AppColors.app_blue, Text("Account Details",style: TextStyle( color: AppColors.app_blue,
fontSize: 16, fontSize: 16,
fontFamily: "JakartaMedium"),), fontFamily: "JakartaMedium"),),
SizedBox(height: 10,),
Text("Account"), Text("Account"),
DropdownButtonHideUnderline( DropdownButtonHideUnderline(
child: Row( child: Row(
...@@ -93,7 +97,10 @@ class _AddcommonpaymentState extends State<Addcommonpayment> { ...@@ -93,7 +97,10 @@ class _AddcommonpaymentState extends State<Addcommonpayment> {
), ),
) )
.toList(), .toList(),
value: provider.selectedAccountType, // value: provider.selectedAccountType,
value:provider.accountTypes.contains(provider.selectedAccountType)
? provider.selectedAccountType
: null,
onChanged: (value) { onChanged: (value) {
if (value != null) { if (value != null) {
provider.selectedAccountType = value; provider.selectedAccountType = value;
...@@ -123,7 +130,9 @@ class _AddcommonpaymentState extends State<Addcommonpayment> { ...@@ -123,7 +130,9 @@ class _AddcommonpaymentState extends State<Addcommonpayment> {
"name", "name",
provider.nameController.text, provider.nameController.text,
); );
},TextInputType.text,false,null },
TextInputType.text,false,
null
),errorWidget(context,provider.nameError), ),errorWidget(context,provider.nameError),
textControllerWidget( textControllerWidget(
context, context,
...@@ -136,7 +145,8 @@ class _AddcommonpaymentState extends State<Addcommonpayment> { ...@@ -136,7 +145,8 @@ class _AddcommonpaymentState extends State<Addcommonpayment> {
"mob1", "mob1",
provider.mobileController.text, provider.mobileController.text,
); );
},TextInputType.number,false,FilteringTextInputFormatter.digitsOnly },
TextInputType.phone,false,FilteringTextInputFormatter.digitsOnly,10
), ),
errorWidget(context,provider.mobileError), errorWidget(context,provider.mobileError),
Text("State"), Text("State"),
...@@ -166,7 +176,10 @@ class _AddcommonpaymentState extends State<Addcommonpayment> { ...@@ -166,7 +176,10 @@ class _AddcommonpaymentState extends State<Addcommonpayment> {
), ),
) )
.toList(), .toList(),
value: provider.selectedState, value:provider.states.contains(provider.selectedState)
? provider.selectedState
: null,
// value: provider.selectedState,
onChanged: (States? value) { onChanged: (States? value) {
if (value != null) { if (value != null) {
if (provider.states.isNotEmpty) { if (provider.states.isNotEmpty) {
...@@ -179,6 +192,12 @@ class _AddcommonpaymentState extends State<Addcommonpayment> { ...@@ -179,6 +192,12 @@ class _AddcommonpaymentState extends State<Addcommonpayment> {
"hfjkshfg" + "hfjkshfg" +
provider.selectedStateID.toString(), provider.selectedStateID.toString(),
); );
if(provider.selectedDistricts!=null){
provider.selectedDistricts = null;
provider.selectedDistrictId = null;
provider.selectedDistrictValue = null;
}
provider.getDistrictAPI( provider.getDistrictAPI(
context, context,
provider.selectedStateID, provider.selectedStateID,
...@@ -186,6 +205,44 @@ class _AddcommonpaymentState extends State<Addcommonpayment> { ...@@ -186,6 +205,44 @@ class _AddcommonpaymentState extends State<Addcommonpayment> {
} }
} }
}, },
dropdownSearchData: DropdownSearchData(
searchInnerWidgetHeight: 50,
searchController: provider.stateSearchController,
searchInnerWidget: Padding(
padding: const EdgeInsets.all(8),
child: TextFormField(
controller:
provider
.stateSearchController,
decoration: InputDecoration(
isDense: true,
contentPadding:
const EdgeInsets.symmetric(
horizontal: 10,
vertical: 8,
),
hintText: 'Search States...',
border: OutlineInputBorder(
borderRadius:
BorderRadius.circular(8),
),
),
),
),
searchMatchFn: (item, searchValue) {
return item.value?.name
?.toLowerCase()
.contains(
searchValue.toLowerCase(),
) ??
false;
},
),
onMenuStateChange: (isOpen) {
if (!isOpen) {
provider.stateSearchController.clear();
}
},
buttonStyleData: ddtheme.buttonStyleData, buttonStyleData: ddtheme.buttonStyleData,
iconStyleData: ddtheme.iconStyleData, iconStyleData: ddtheme.iconStyleData,
menuItemStyleData: ddtheme.menuItemStyleData, menuItemStyleData: ddtheme.menuItemStyleData,
...@@ -223,7 +280,10 @@ class _AddcommonpaymentState extends State<Addcommonpayment> { ...@@ -223,7 +280,10 @@ class _AddcommonpaymentState extends State<Addcommonpayment> {
), ),
) )
.toList(), .toList(),
value: provider.selectedDistricts, value:provider.districts.contains(provider.selectedDistricts)
? provider.selectedDistricts
: null,
// value: provider.selectedDistricts,
onChanged: (Districts? value) { onChanged: (Districts? value) {
if (value != null) { if (value != null) {
if (provider.districts.isNotEmpty) { if (provider.districts.isNotEmpty) {
...@@ -237,6 +297,12 @@ class _AddcommonpaymentState extends State<Addcommonpayment> { ...@@ -237,6 +297,12 @@ class _AddcommonpaymentState extends State<Addcommonpayment> {
provider.selectedDistrictId provider.selectedDistrictId
.toString(), .toString(),
); );
if(provider.selectedSubLocations!=null){
provider.selectedSubLocations = null;
provider.selectedSubLocID = null;
provider.selectedSubLocValue = null;
}
provider.getSubLocationAPI( provider.getSubLocationAPI(
context, context,
provider.selectedDistrictId, provider.selectedDistrictId,
...@@ -244,6 +310,44 @@ class _AddcommonpaymentState extends State<Addcommonpayment> { ...@@ -244,6 +310,44 @@ class _AddcommonpaymentState extends State<Addcommonpayment> {
} }
} }
}, },
dropdownSearchData: DropdownSearchData(
searchInnerWidgetHeight: 50,
searchController: provider.districtSearchController,
searchInnerWidget: Padding(
padding: const EdgeInsets.all(8),
child: TextFormField(
controller:
provider
.districtSearchController,
decoration: InputDecoration(
isDense: true,
contentPadding:
const EdgeInsets.symmetric(
horizontal: 10,
vertical: 8,
),
hintText: 'Search Districts...',
border: OutlineInputBorder(
borderRadius:
BorderRadius.circular(8),
),
),
),
),
searchMatchFn: (item, searchValue) {
return item.value?.district
?.toLowerCase()
.contains(
searchValue.toLowerCase(),
) ??
false;
},
),
onMenuStateChange: (isOpen) {
if (!isOpen) {
provider.districtSearchController.clear();
}
},
buttonStyleData: ddtheme.buttonStyleData, buttonStyleData: ddtheme.buttonStyleData,
iconStyleData: ddtheme.iconStyleData, iconStyleData: ddtheme.iconStyleData,
menuItemStyleData: ddtheme.menuItemStyleData, menuItemStyleData: ddtheme.menuItemStyleData,
...@@ -282,7 +386,10 @@ class _AddcommonpaymentState extends State<Addcommonpayment> { ...@@ -282,7 +386,10 @@ class _AddcommonpaymentState extends State<Addcommonpayment> {
), ),
) )
.toList(), .toList(),
value: provider.selectedSubLocations, // value: provider.selectedSubLocations,
value:provider.subLocations.contains(provider.selectedSubLocations)
? provider.selectedSubLocations
: null,
onChanged: (SubLocations? value) { onChanged: (SubLocations? value) {
if (value != null) { if (value != null) {
if (provider.subLocations.isNotEmpty) { if (provider.subLocations.isNotEmpty) {
...@@ -298,6 +405,44 @@ class _AddcommonpaymentState extends State<Addcommonpayment> { ...@@ -298,6 +405,44 @@ class _AddcommonpaymentState extends State<Addcommonpayment> {
} }
} }
}, },
dropdownSearchData: DropdownSearchData(
searchInnerWidgetHeight: 50,
searchController: provider.subLocSearchController,
searchInnerWidget: Padding(
padding: const EdgeInsets.all(8),
child: TextFormField(
controller:
provider
.subLocSearchController,
decoration: InputDecoration(
isDense: true,
contentPadding:
const EdgeInsets.symmetric(
horizontal: 10,
vertical: 8,
),
hintText: 'Search Sub Locality...',
border: OutlineInputBorder(
borderRadius:
BorderRadius.circular(8),
),
),
),
),
searchMatchFn: (item, searchValue) {
return item.value?.subLocality
?.toLowerCase()
.contains(
searchValue.toLowerCase(),
) ??
false;
},
),
onMenuStateChange: (isOpen) {
if (!isOpen) {
provider.subLocSearchController.clear();
}
},
buttonStyleData: ddtheme.buttonStyleData, buttonStyleData: ddtheme.buttonStyleData,
iconStyleData: ddtheme.iconStyleData, iconStyleData: ddtheme.iconStyleData,
menuItemStyleData: ddtheme.menuItemStyleData, menuItemStyleData: ddtheme.menuItemStyleData,
...@@ -467,8 +612,8 @@ class _AddcommonpaymentState extends State<Addcommonpayment> { ...@@ -467,8 +612,8 @@ class _AddcommonpaymentState extends State<Addcommonpayment> {
floatingActionButtonLocation: floatingActionButtonLocation:
FloatingActionButtonLocation.centerFloat, FloatingActionButtonLocation.centerFloat,
bottomNavigationBar: InkResponse( bottomNavigationBar: InkResponse(
onTap: () { onTap:provider.submitClickced?null: () {
// provider.submitClicked = true; provider.submitClickced = true;
provider.submitCommonAccountsAPI(context); provider.submitCommonAccountsAPI(context);
}, },
child: Container( child: Container(
...@@ -480,7 +625,9 @@ class _AddcommonpaymentState extends State<Addcommonpayment> { ...@@ -480,7 +625,9 @@ class _AddcommonpaymentState extends State<Addcommonpayment> {
color: AppColors.app_blue, color: AppColors.app_blue,
borderRadius: BorderRadius.circular(15), borderRadius: BorderRadius.circular(15),
), ),
child: Text( child:provider.submitClickced?CircularProgressIndicator.adaptive(
valueColor: AlwaysStoppedAnimation(AppColors.white),
) :Text(
"Submit", "Submit",
style: TextStyle( style: TextStyle(
fontSize: 15, fontSize: 15,
......
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