Commit 8cdaca01 authored by Sai Srinivas's avatar Sai Srinivas
Browse files

29-07-2025 By Sai Srinivas

CRM test cases
parent e079c6e8
class LeadDetailsResponse { class LeadDetailsResponse {
String? error; String? error;
int? sessionExists;
LeadDetails? leadDetails; LeadDetails? leadDetails;
AccountDetails? accountDetails; AccountDetails? accountDetails;
List<LeadProducts>? leadProducts; List<LeadProducts>? leadProducts;
...@@ -12,6 +13,7 @@ class LeadDetailsResponse { ...@@ -12,6 +13,7 @@ class LeadDetailsResponse {
LeadDetailsResponse( LeadDetailsResponse(
{this.error, {this.error,
this.sessionExists,
this.leadDetails, this.leadDetails,
this.accountDetails, this.accountDetails,
this.leadProducts, this.leadProducts,
...@@ -25,6 +27,7 @@ class LeadDetailsResponse { ...@@ -25,6 +27,7 @@ class LeadDetailsResponse {
LeadDetailsResponse.fromJson(Map<String, dynamic> json) { LeadDetailsResponse.fromJson(Map<String, dynamic> json) {
error = json['error']; error = json['error'];
sessionExists = json['session_exists'];
leadDetails = json['lead_details'] != null leadDetails = json['lead_details'] != null
? new LeadDetails.fromJson(json['lead_details']) ? new LeadDetails.fromJson(json['lead_details'])
: null; : null;
...@@ -68,6 +71,7 @@ class LeadDetailsResponse { ...@@ -68,6 +71,7 @@ class LeadDetailsResponse {
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>(); final Map<String, dynamic> data = new Map<String, dynamic>();
data['error'] = this.error; data['error'] = this.error;
data['session_exists'] = this.sessionExists;
if (this.leadDetails != null) { if (this.leadDetails != null) {
data['lead_details'] = this.leadDetails!.toJson(); data['lead_details'] = this.leadDetails!.toJson();
} }
......
...@@ -3,9 +3,10 @@ class crmLeadDetailsEditProductsViewResponse { ...@@ -3,9 +3,10 @@ class crmLeadDetailsEditProductsViewResponse {
List<LeadProducts>? leadProducts; List<LeadProducts>? leadProducts;
String? error; String? error;
String? message; String? message;
int? sessionExists;
crmLeadDetailsEditProductsViewResponse( crmLeadDetailsEditProductsViewResponse(
{this.products, this.leadProducts, this.error, this.message}); {this.products, this.leadProducts, this.error, this.message, this.sessionExists});
crmLeadDetailsEditProductsViewResponse.fromJson(Map<String, dynamic> json) { crmLeadDetailsEditProductsViewResponse.fromJson(Map<String, dynamic> json) {
if (json['products'] != null) { if (json['products'] != null) {
...@@ -22,6 +23,7 @@ class crmLeadDetailsEditProductsViewResponse { ...@@ -22,6 +23,7 @@ class crmLeadDetailsEditProductsViewResponse {
} }
error = json['error']; error = json['error'];
message = json['message']; message = json['message'];
sessionExists = json['session_exists'];
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
...@@ -35,6 +37,7 @@ class crmLeadDetailsEditProductsViewResponse { ...@@ -35,6 +37,7 @@ class crmLeadDetailsEditProductsViewResponse {
} }
data['error'] = this.error; data['error'] = this.error;
data['message'] = this.message; data['message'] = this.message;
data['session_exists'] = this.sessionExists;
return data; return data;
} }
} }
......
class crmLeadDetailsGenerateQuotationViewResponse { class crmLeadDetailsGenerateQuotationViewResponse {
QuoteDetails? quoteDetails; QuoteDetails? quoteDetails;
List<LeadProducts>? leadProducts; List<LeadProducts>? leadProducts;
List<Products>? products;
String? error; String? error;
String? message; String? message;
int? sessionExists; int? sessionExists;
crmLeadDetailsGenerateQuotationViewResponse( crmLeadDetailsGenerateQuotationViewResponse(
{this.quoteDetails, this.leadProducts, this.error, this.message,this.sessionExists}); {this.quoteDetails,
this.leadProducts,
this.products,
this.error,
this.message,
this.sessionExists});
crmLeadDetailsGenerateQuotationViewResponse.fromJson( crmLeadDetailsGenerateQuotationViewResponse.fromJson(
Map<String, dynamic> json) { Map<String, dynamic> json) {
...@@ -19,6 +25,12 @@ class crmLeadDetailsGenerateQuotationViewResponse { ...@@ -19,6 +25,12 @@ class crmLeadDetailsGenerateQuotationViewResponse {
leadProducts!.add(new LeadProducts.fromJson(v)); leadProducts!.add(new LeadProducts.fromJson(v));
}); });
} }
if (json['products'] != null) {
products = <Products>[];
json['products'].forEach((v) {
products!.add(new Products.fromJson(v));
});
}
error = json['error']; error = json['error'];
message = json['message']; message = json['message'];
sessionExists = json['session_exists']; sessionExists = json['session_exists'];
...@@ -33,6 +45,9 @@ class crmLeadDetailsGenerateQuotationViewResponse { ...@@ -33,6 +45,9 @@ class crmLeadDetailsGenerateQuotationViewResponse {
data['lead_products'] = data['lead_products'] =
this.leadProducts!.map((v) => v.toJson()).toList(); this.leadProducts!.map((v) => v.toJson()).toList();
} }
if (this.products != null) {
data['products'] = this.products!.map((v) => v.toJson()).toList();
}
data['error'] = this.error; data['error'] = this.error;
data['message'] = this.message; data['message'] = this.message;
data['session_exists'] = this.sessionExists; data['session_exists'] = this.sessionExists;
...@@ -87,12 +102,12 @@ class LeadProducts { ...@@ -87,12 +102,12 @@ class LeadProducts {
String? productId; String? productId;
String? qty; String? qty;
String? price; String? price;
String? prodTotalPrice;
String? date; String? date;
String? isDel; String? isDel;
String? isExists; String? isExists;
String? createdDatetime; String? createdDatetime;
String? updatedDatetime; String? updatedDatetime;
String? prodTotalPrice;
String? productName; String? productName;
LeadProducts( LeadProducts(
...@@ -101,12 +116,12 @@ class LeadProducts { ...@@ -101,12 +116,12 @@ class LeadProducts {
this.productId, this.productId,
this.qty, this.qty,
this.price, this.price,
this.prodTotalPrice,
this.date, this.date,
this.isDel, this.isDel,
this.isExists, this.isExists,
this.createdDatetime, this.createdDatetime,
this.updatedDatetime, this.updatedDatetime,
this.prodTotalPrice,
this.productName}); this.productName});
LeadProducts.fromJson(Map<String, dynamic> json) { LeadProducts.fromJson(Map<String, dynamic> json) {
...@@ -115,12 +130,12 @@ class LeadProducts { ...@@ -115,12 +130,12 @@ class LeadProducts {
productId = json['product_id']; productId = json['product_id'];
qty = json['qty']; qty = json['qty'];
price = json['price']; price = json['price'];
prodTotalPrice = json['prod_total_price'];
date = json['date']; date = json['date'];
isDel = json['is_del']; isDel = json['is_del'];
isExists = json['is_exists']; isExists = json['is_exists'];
createdDatetime = json['created_datetime']; createdDatetime = json['created_datetime'];
updatedDatetime = json['updated_datetime']; updatedDatetime = json['updated_datetime'];
prodTotalPrice = json['prod_total_price'];
productName = json['product_name']; productName = json['product_name'];
} }
...@@ -131,13 +146,32 @@ class LeadProducts { ...@@ -131,13 +146,32 @@ class LeadProducts {
data['product_id'] = this.productId; data['product_id'] = this.productId;
data['qty'] = this.qty; data['qty'] = this.qty;
data['price'] = this.price; data['price'] = this.price;
data['prod_total_price'] = this.prodTotalPrice;
data['date'] = this.date; data['date'] = this.date;
data['is_del'] = this.isDel; data['is_del'] = this.isDel;
data['is_exists'] = this.isExists; data['is_exists'] = this.isExists;
data['created_datetime'] = this.createdDatetime; data['created_datetime'] = this.createdDatetime;
data['updated_datetime'] = this.updatedDatetime; data['updated_datetime'] = this.updatedDatetime;
data['prod_total_price'] = this.prodTotalPrice;
data['product_name'] = this.productName; data['product_name'] = this.productName;
return data; 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 crmNewLeadsProspectsViewResponse {
String? error;
String? message;
int? sessionExists;
List<Employees>? employees;
List<Sources>? sources;
List<Teams>? teams;
List<States>? states;
List<Products>? products;
List<String>? salutation;
crmNewLeadsProspectsViewResponse({
this.error,
this.message,
this.sessionExists,
this.employees,
this.sources,
this.teams,
this.states,
this.products,
this.salutation,
});
crmNewLeadsProspectsViewResponse.fromJson(Map<String, dynamic> json) {
json['error'] = error;
json['message'] = message;
json['session_exists'] = sessionExists;
if (json['employees'] != null) {
employees = <Employees>[];
json['employees'].forEach((v) {
employees!.add(new Employees.fromJson(v));
});
}
if (json['sources'] != null) {
sources = <Sources>[];
json['sources'].forEach((v) {
sources!.add(new Sources.fromJson(v));
});
}
if (json['teams'] != null) {
teams = <Teams>[];
json['teams'].forEach((v) {
teams!.add(new Teams.fromJson(v));
});
}
if (json['states'] != null) {
states = <States>[];
json['states'].forEach((v) {
states!.add(new States.fromJson(v));
});
}
if (json['products'] != null) {
products = <Products>[];
json['products'].forEach((v) {
products!.add(new Products.fromJson(v));
});
}
salutation = json['salutation'].cast<String>();
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['error'] = this.error;
data['message'] = this.message;
data['session_exists'] = this.sessionExists;
if (this.employees != null) {
data['employees'] = this.employees!.map((v) => v.toJson()).toList();
}
if (this.sources != null) {
data['sources'] = this.sources!.map((v) => v.toJson()).toList();
}
if (this.teams != null) {
data['teams'] = this.teams!.map((v) => v.toJson()).toList();
}
if (this.states != null) {
data['states'] = this.states!.map((v) => v.toJson()).toList();
}
if (this.products != null) {
data['products'] = this.products!.map((v) => v.toJson()).toList();
}
data['salutation'] = this.salutation;
return data;
}
}
class Employees {
String? id;
String? name;
Employees({this.id, this.name});
Employees.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 Sources {
String? id;
String? name;
Sources({this.id, this.name});
Sources.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 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 States {
String? id;
String? name;
States({this.id, this.name});
States.fromJson(Map<String, dynamic> json) {
id = json['id'];
name = json['name'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['name'] = this.name;
return data;
}
}
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 crmSelectedProductDetailsResponse {
ProductsData? productsData;
String? error;
String? message;
crmSelectedProductDetailsResponse({this.productsData, this.error, this.message});
crmSelectedProductDetailsResponse.fromJson(Map<String, dynamic> json) {
productsData = json['data'] != null ? new ProductsData.fromJson(json['data']) : null;
error = json['error'];
message = json['message'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.productsData != null) {
data['data'] = this.productsData!.toJson();
}
data['error'] = this.error;
data['message'] = this.message;
return data;
}
}
class ProductsData {
String? id;
String? name;
String? application;
String? rating;
String? ratingKw;
String? ordStatus;
String? description;
String? price;
String? createdOn;
String? empId;
String? materialMasterId;
String? isGenerator;
String? isExists;
String? createdDatetime;
String? updatedDatetime;
ProductsData(
{this.id,
this.name,
this.application,
this.rating,
this.ratingKw,
this.ordStatus,
this.description,
this.price,
this.createdOn,
this.empId,
this.materialMasterId,
this.isGenerator,
this.isExists,
this.createdDatetime,
this.updatedDatetime});
ProductsData.fromJson(Map<String, dynamic> json) {
id = json['id'];
name = json['name'];
application = json['application'];
rating = json['rating'];
ratingKw = json['rating_kw'];
ordStatus = json['ord_status'];
description = json['description'];
price = json['price'];
createdOn = json['created_on'];
empId = json['emp_id'];
materialMasterId = json['material_master_id'];
isGenerator = json['is_generator'];
isExists = json['is_exists'];
createdDatetime = json['created_datetime'];
updatedDatetime = json['updated_datetime'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['name'] = this.name;
data['application'] = this.application;
data['rating'] = this.rating;
data['rating_kw'] = this.ratingKw;
data['ord_status'] = this.ordStatus;
data['description'] = this.description;
data['price'] = this.price;
data['created_on'] = this.createdOn;
data['emp_id'] = this.empId;
data['material_master_id'] = this.materialMasterId;
data['is_generator'] = this.isGenerator;
data['is_exists'] = this.isExists;
data['created_datetime'] = this.createdDatetime;
data['updated_datetime'] = this.updatedDatetime;
return data;
}
}
class CommonResponse { class CommonResponse {
String? error; String? error;
String? message; String? message;
int? sessionExists;
CommonResponse({this.error, this.message}); CommonResponse({this.error, this.message, this.sessionExists});
CommonResponse.fromJson(Map<String, dynamic> json) { CommonResponse.fromJson(Map<String, dynamic> json) {
error = json['error']; error = json['error'];
message = json['message']; message = json['message'];
sessionExists = json['session_exists'];
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>(); final Map<String, dynamic> data = new Map<String, dynamic>();
data['error'] = this.error; data['error'] = this.error;
data['message'] = this.message; data['message'] = this.message;
data['session_exists'] = this.sessionExists;
return data; return data;
} }
} }
...@@ -33,6 +33,8 @@ class Leadlistprovider extends ChangeNotifier { ...@@ -33,6 +33,8 @@ class Leadlistprovider extends ChangeNotifier {
List<LeadList> _crmLeadList = []; List<LeadList> _crmLeadList = [];
List<String?> _leadStatusList = []; List<String?> _leadStatusList = [];
List<String?> _openStatusList = []; List<String?> _openStatusList = [];
List<String?> _alphabetList = [];
Sources? _selectedSources; Sources? _selectedSources;
Teams? _selectedTeams; Teams? _selectedTeams;
...@@ -45,6 +47,7 @@ class Leadlistprovider extends ChangeNotifier { ...@@ -45,6 +47,7 @@ class Leadlistprovider extends ChangeNotifier {
Contacts? _selectedContacts; Contacts? _selectedContacts;
String? _selectedLeadStatus; String? _selectedLeadStatus;
String? _selectedOpenStatus; String? _selectedOpenStatus;
String? _selectedAlphabet;
String? _selectedSourceId; String? _selectedSourceId;
String? _selectedSourceValue; String? _selectedSourceValue;
...@@ -97,19 +100,21 @@ class Leadlistprovider extends ChangeNotifier { ...@@ -97,19 +100,21 @@ class Leadlistprovider extends ChangeNotifier {
List<String?> get leadStatusList => _leadStatusList; List<String?> get leadStatusList => _leadStatusList;
List<String?> get alphabetList => _alphabetList;
List<String?> get openStatusList => _openStatusList; List<String?> get openStatusList => _openStatusList;
Sources? get selectedSources => _selectedSources; Sources? get selectedSource => _selectedSources;
Teams? get selectedTeams => _selectedTeams; Teams? get selectedTeam => _selectedTeams;
States? get selectedStates => _selectedStates; States? get selectedStates => _selectedStates;
Employees? get selectedEmployees => _selectedEmployees; Employees? get selectedEmployee => _selectedEmployees;
References? get selectedReferences => _selectedReferences; References? get selectedReference => _selectedReferences;
Segments? get selectedSegments => _selectedSegments; Segments? get selectedSegment => _selectedSegments;
Districts? get selectedDistricts => _selectedDistricts; Districts? get selectedDistricts => _selectedDistricts;
...@@ -157,19 +162,26 @@ class Leadlistprovider extends ChangeNotifier { ...@@ -157,19 +162,26 @@ class Leadlistprovider extends ChangeNotifier {
String? get selectedContactValue => _selectedContactValue; String? get selectedContactValue => _selectedContactValue;
String? get selectedAlphabet => _selectedAlphabet;
set isLoading(bool value) { set isLoading(bool value) {
_isLoading = value; _isLoading = value;
notifyListeners(); notifyListeners();
} }
set selectedSources(Sources? value) { set selectedAlphabet(String? value){
_selectedAlphabet = value;
notifyListeners();
}
set selectedSource(Sources? value) {
_selectedSources = value; _selectedSources = value;
_selectedSourceId = value!.id!; _selectedSourceId = value!.id!;
_selectedSourceValue = value!.name!; _selectedSourceValue = value!.name!;
notifyListeners(); notifyListeners();
} }
set selectedTeams(Teams? value) { set selectedTeam(Teams? value) {
_selectedTeams = value; _selectedTeams = value;
_selectedTeamId = value!.id!; _selectedTeamId = value!.id!;
_selectedTeamValue = value.name; _selectedTeamValue = value.name;
...@@ -183,21 +195,21 @@ class Leadlistprovider extends ChangeNotifier { ...@@ -183,21 +195,21 @@ class Leadlistprovider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
set selectedEmployees(Employees? value) { set selectedEmployee(Employees? value) {
_selectedEmployees = value; _selectedEmployees = value;
_selectedEmployeeId = value!.id!; _selectedEmployeeId = value!.id!;
_selectedEmployeeValue = value.name; _selectedEmployeeValue = value.name;
notifyListeners(); notifyListeners();
} }
set selectedReferences(References? value) { set selectedReference(References? value) {
_selectedReferences = value; _selectedReferences = value;
_selectedReferenceId = value!.id!; _selectedReferenceId = value!.id!;
_selectedReferenceValue = value.name; _selectedReferenceValue = value.name;
notifyListeners(); notifyListeners();
} }
set selectedSegments(Segments? value) { set selectedSegment(Segments? value) {
_selectedSegments = value; _selectedSegments = value;
_selectedSegmentId = value!.id!; _selectedSegmentId = value!.id!;
_selectedSegmentValue = value.name; _selectedSegmentValue = value.name;
...@@ -345,6 +357,8 @@ class Leadlistprovider extends ChangeNotifier { ...@@ -345,6 +357,8 @@ class Leadlistprovider extends ChangeNotifier {
"Order Gain", "Order Gain",
"Order Lost", "Order Lost",
]; ];
_alphabetList = List.generate(26, (index) => String.fromCharCode(index + 65));
_openStatusList = ["open", "Closed", "All"]; _openStatusList = ["open", "Closed", "All"];
_sourcesList = data.sources!; _sourcesList = data.sources!;
_teamsList = data.teams!; _teamsList = data.teams!;
...@@ -466,16 +480,13 @@ class Leadlistprovider extends ChangeNotifier { ...@@ -466,16 +480,13 @@ class Leadlistprovider extends ChangeNotifier {
Future<void> crmLeadListAPIFunction( Future<void> crmLeadListAPIFunction(
context, context,
mode, mode,
employeeID,
leadStatus, leadStatus,
openStatus, openStatus,
sourceID, sourceID,
referenceID, referenceID,
teamID, teamID,
segmentID, segmentID,
stateID, alphabet
districtID,
subLocID,
) async { ) async {
try { try {
_isLoading = true; _isLoading = true;
...@@ -486,8 +497,6 @@ class Leadlistprovider extends ChangeNotifier { ...@@ -486,8 +497,6 @@ class Leadlistprovider extends ChangeNotifier {
HomeProv.empId, HomeProv.empId,
HomeProv.session, HomeProv.session,
mode, mode,
employeeID,
sLeadIDController.text,
leadStatus, leadStatus,
openStatus, openStatus,
mobileNumberController.text, mobileNumberController.text,
...@@ -496,9 +505,7 @@ class Leadlistprovider extends ChangeNotifier { ...@@ -496,9 +505,7 @@ class Leadlistprovider extends ChangeNotifier {
referenceID, referenceID,
teamID, teamID,
segmentID, segmentID,
stateID, alphabet
districtID,
subLocID,
); );
if (data != null) { if (data != null) {
_isLoading = true; _isLoading = true;
......
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/screens/LoginScreen.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 '../../Models/crmModels/GetDistrictOnStateResponse.dart';
import '../../Models/crmModels/GetSegmentOnTeamResponse.dart';
import '../../Models/crmModels/GetSourceOnReferenceResponse.dart';
import '../../Models/crmModels/GetSubLocOnDistrictResponse.dart';
import '../../Models/crmModels/crmNewLeadsProspectsViewResponse.dart';
import '../../Utils/commonServices.dart';
import '../../services/api_calling.dart';
import '../HomeScreenNotifier.dart';
class Addnewleadsandprospectsprovider extends ChangeNotifier {
final FlutterLocalNotificationsPlugin _notificationsPlugin =
FlutterLocalNotificationsPlugin();
static const platform = MethodChannel('in.webgrid.generp/download');
final GlobalKey webViewKey = GlobalKey();
var dl = DownloadManager();
TextEditingController addProductPriceController = TextEditingController();
TextEditingController addQuantityController = TextEditingController();
TextEditingController addTotalAmountController = TextEditingController();
TextEditingController companyNameController = TextEditingController();
TextEditingController contactPersonNameController = TextEditingController();
TextEditingController customerMailIdController = TextEditingController();
TextEditingController mobileController = TextEditingController();
TextEditingController alternateMobileController = TextEditingController();
TextEditingController telephoneController = TextEditingController();
TextEditingController designationController = TextEditingController();
TextEditingController addressController = TextEditingController();
TextEditingController taxesController = TextEditingController();
TextEditingController SpecialNoteController = TextEditingController();
TextEditingController forController = TextEditingController();
TextEditingController paymentTermsController = TextEditingController();
List<Map<String, dynamic>> _productRows = []; // For backend
List<Map<String, dynamic>> get productRows => _productRows;
List<Employees> _employeesList = [];
List<Sources> _sourcesList = [];
List<Teams> _teamsList = [];
List<States> _statesList = [];
List<Products> _productsList = [];
List<String> _salutationList = [];
List<Districts> _districtsList = [];
List<SubLocations> _subLocationsList = [];
List<References> _referencesList = [];
List<Segments> _segmentsList = [];
Employees? _selectedEmployees;
String? _selectedEmployeesId;
String? _selectedEmployeesValue;
Sources? _selectedSources;
String? _selectedSourcesId;
String? _selectedSourcesValue;
Teams? _selectedTeams;
String? _selectedTeamsId;
String? _selectedTeamsValue;
States? _selectedStates;
String? _selectedStatesId;
String? _selectedStatesValue;
Products? _selectedProducts;
String? _selectedProductsId;
String? _selectedProductsValue;
String? _selectedSalutation;
Districts? _selectedDistricts;
SubLocations? _selectedSubLocations;
References? _selectedReferences;
Segments? _selectedSegments;
String? _selectedDistrictId;
String? _selectedDistrictValue;
String? _selectedSubLocationId;
String? _selectedSubLocationValue;
String? _selectedReferenceId;
String? _selectedReferenceValue;
String? _selectedSegmentId;
String? _selectedSegmentValue;
String? _selectedLeadStatus;
String? get selectedLeadStatus => _selectedLeadStatus;
List<Employees> get employeesList => _employeesList;
List<Sources> get sourcesList => _sourcesList;
List<Teams> get teamsList => _teamsList;
List<States> get statesList => _statesList;
List<Products> get productsList => _productsList;
List<String> get salutationList => _salutationList;
Employees? get selectedEmployees => _selectedEmployees;
String? get selectedEmployeesId => _selectedEmployeesId;
String? get selectedEmployeesValue => _selectedEmployeesValue;
Sources? get selectedSources => _selectedSources;
String? get selectedSourcesId => _selectedSourcesId;
String? get selectedSourcesValue => _selectedSourcesValue;
Teams? get selectedTeams => _selectedTeams;
String? get selectedTeamsId => _selectedTeamsId;
String? get selectedTeamsValue => _selectedTeamsValue;
States? get selectedStates => _selectedStates;
String? get selectedStatesId => _selectedStatesId;
String? get selectedStatesValue => _selectedStatesValue;
Products? get selectedProducts => _selectedProducts;
String? get selectedProductsId => _selectedProductsId;
String? get selectedProductsValue => _selectedProductsValue;
String? get selectedSalutation => _selectedSalutation;
List<Districts> get districtsList => _districtsList;
List<SubLocations> get subLocationsList => _subLocationsList;
List<References> get referencesList => _referencesList;
List<Segments> get segmentsList => _segmentsList;
References? get selectedReference => _selectedReferences;
Segments? get selectedSegment => _selectedSegments;
Districts? get selectedDistricts => _selectedDistricts;
SubLocations? get selectedSubLocations => _selectedSubLocations;
String? get selectedDistrictId => _selectedDistrictId;
String? get selectedDistrictValue => _selectedDistrictValue;
String? get selectedSubLocationId => _selectedSubLocationId;
String? get selectedSubLocationValue => _selectedSubLocationValue;
String? get selectedReferenceId => _selectedReferenceId;
String? get selectedReferenceValue => _selectedReferenceValue;
String? get selectedSegmentId => _selectedSegmentId;
String? get selectedSegmentValue => _selectedSegmentValue;
set selectedLeadStatus(String? value) {
_selectedLeadStatus = value;
notifyListeners();
}
set selectedEmployees(Employees? value) {
_selectedEmployees = value;
_selectedEmployeesId = value!.id;
_selectedEmployeesValue = value!.name;
notifyListeners();
}
set selectedEmployeesId(String? value) {
_selectedEmployeesId = value;
notifyListeners();
}
set selectedEmployeesValue(String? value) {
_selectedEmployeesValue = value;
notifyListeners();
}
set selectedSources(Sources? value) {
_selectedSources = value;
_selectedSourcesId = value!.id;
_selectedSourcesValue = value!.name;
notifyListeners();
}
set selectedSourcesId(String? value) {
_selectedSourcesId = value;
notifyListeners();
}
set selectedSourcesValue(String? value) {
_selectedSourcesValue = value;
notifyListeners();
}
set selectedTeams(Teams? value) {
_selectedTeams = value;
_selectedTeamsId = value!.id;
_selectedTeamsValue = value!.name;
notifyListeners();
}
set selectedTeamsId(String? value) {
_selectedTeamsId = value;
notifyListeners();
}
set selectedTeamsValue(String? value) {
_selectedTeamsValue = value;
notifyListeners();
}
set selectedStates(States? value) {
_selectedStates = value;
_selectedStatesId = value!.id;
_selectedStatesValue = value!.name;
notifyListeners();
}
set selectedStatesId(String? value) {
_selectedStatesId = value;
notifyListeners();
}
set selectedStatesValue(String? value) {
_selectedStatesValue = value;
notifyListeners();
}
set selectedProducts(Products? value) {
_selectedProducts = value;
_selectedProductsId = value!.id;
_selectedProductsValue = value!.name;
notifyListeners();
}
set selectedProductsId(String? value) {
_selectedProductsId = value;
notifyListeners();
}
set selectedProductsValue(String? value) {
_selectedProductsValue = value;
notifyListeners();
}
set selectedSalutation(String? value) {
_selectedSalutation = value;
notifyListeners();
}
set selectedDistricts(Districts? value) {
_selectedDistricts = value;
_selectedDistrictId = value!.id!;
_selectedDistrictValue = value.district;
notifyListeners();
}
set selectedSubLocations(SubLocations? value) {
_selectedSubLocations = value;
_selectedSubLocationId = value!.id!;
_selectedSubLocationValue = value.subLocality;
notifyListeners();
}
set selectedDistrictId(String? value) {
_selectedDistrictId = value;
notifyListeners();
}
set selectedDistrictValue(String? value) {
_selectedDistrictValue = value;
notifyListeners();
}
set selectedSubLocationId(String? value) {
_selectedSubLocationId = value;
notifyListeners();
}
set selectedSubLocationValue(String? value) {
_selectedSubLocationValue = value;
notifyListeners();
}
set selectedReference(References? value) {
_selectedReferences = value;
_selectedReferenceId = value!.id!;
_selectedReferenceValue = value.name;
notifyListeners();
}
set selectedSegment(Segments? value) {
_selectedSegments = value;
_selectedSegmentId = value!.id!;
_selectedSegmentValue = value.name;
notifyListeners();
}
set selectedReferenceId(String? value) {
_selectedReferenceId = value;
notifyListeners();
}
set selectedReferenceValue(String? value) {
_selectedReferenceValue = value;
notifyListeners();
}
set selectedSegmentId(String? value) {
_selectedSegmentId = value;
notifyListeners();
}
set selectedSegmentValue(String? value) {
_selectedSegmentValue = value;
notifyListeners();
}
set productRows(value) {
_productRows = value;
notifyListeners();
}
String? mailIdError = "";
String? companynameError = "";
String? salutationError = "";
String? nameError = "";
String? AlternatemobileError = "";
String? TelephoneError = "";
String? mobileError = "";
String? addressError = "";
String? designationError = "";
String? taxesError = "";
String? SpecialNoteError = "";
String? forError = "";
String? paymentTermsError = "";
String? sourceError = "";
String? referenceError = "";
String? teamsError = "";
String? segmentsError = "";
String? statesError = "";
String? districtsError = "";
String? subLocError = "";
String? leadStatusError = "";
bool _isLoading = true;
bool _submitLoading = false;
bool get isLoading => _isLoading;
bool get submitLoading => _submitLoading;
set submitLoading(bool value) {
_submitLoading = value;
notifyListeners();
}
void addEditUpdateTotalAmount(value) {
final price = double.tryParse(addProductPriceController.text) ?? 0;
final qty = int.tryParse(addQuantityController.text) ?? 0;
addTotalAmountController.text = (price * qty).toString();
notifyListeners();
}
void addInitializeForm(BuildContext context) {
addProductPriceController.clear();
addQuantityController.clear();
addTotalAmountController.clear();
notifyListeners();
}
void updateSelectedProductIds(int index, value) {
notifyListeners();
}
Future<void> crmAddLeadsView(context, mode) async {
try {
final prov = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.crmNewLeadsProspectsViewAPI(
prov.empId,
prov.session,
mode,
);
if (data != null) {
if (data.error == "0") {
_employeesList = data.employees!;
_sourcesList = data.sources!;
_teamsList = data.teams!;
_statesList = data.states!;
_productsList = data.products!;
_salutationList = data.salutation!;
notifyListeners();
} else {}
} else {}
} catch (e, s) {}
}
Future<void> crmLeadListDistrictsOnStateAPIFunction(
context,
mode,
stateID,
) async {
try {
var prov = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.crmDistrictsOnStateAPI(
prov.empId,
prov.session,
stateID,
);
if (data != null) {
if (data.error == "0") {
_districtsList = data.districts!;
notifyListeners();
}
}
} catch (e, s) {}
}
Future<void> crmLeadListSubLocOnDistrictAPIFunction(
context,
mode,
districtID,
) async {
try {
var prov = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.crmSubLocOnDistrictAPI(
prov.empId,
prov.session,
districtID,
);
if (data != null) {
if (data.error == "0") {
_subLocationsList = data.subLocations!;
notifyListeners();
}
}
} catch (e, s) {}
}
Future<void> crmLeadListSourceOnReferenceAPIFunction(
context,
mode,
sourceID,
) async {
try {
var prov = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.crmLeadListSourceOnReferenceAPI(
prov.empId,
prov.session,
sourceID,
);
if (data != null) {
if (data.error == "0") {
_referencesList = data.references!;
notifyListeners();
}
}
} catch (e, s) {}
}
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> crmAddNewLeadsAndProspectsAPIFunction(
BuildContext context,
mode,
acc_manager_id,
salutation_name,
district,
state,
segment,
source,
reference,
team,
sub_locality,
lead_status,
products,
) async {
try {
final prov = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.crmNewLeadsProspectsSubmitAPI(
prov.session,
prov.empId,
mode,
acc_manager_id,
salutation_name,
companyNameController.text,
contactPersonNameController.text,
district,
state,
addressController.text,
segment,
source,
reference,
team,
sub_locality,
mobileController.text,
alternateMobileController.text,
telephoneController.text,
customerMailIdController.text,
designationController.text,
lead_status,
products,
);
if (data != null) {
if (data.error == "0") {
Navigator.pop(context, true);
toast(context, data.message);
resetForm();
notifyListeners();
} else {}
} else {}
} catch (e, s) {
print("Error: $e, Stack: $s");
}
}
onChangemailId(value) {
mailIdError = "";
notifyListeners();
}
onChangeCompanyName(value) {
companynameError = "";
notifyListeners();
}
onChangeContactPersonName(value) {
nameError = "";
notifyListeners();
}
onChangeAlternatemobile(value) {
AlternatemobileError = "";
notifyListeners();
}
onChangeTelephone(value) {
TelephoneError = "";
notifyListeners();
}
onChangemobile(value) {
mobileError = "";
notifyListeners();
}
onChangeaddress(value) {
addressError = "";
notifyListeners();
}
onChangedesignation(value) {
designationError = "";
notifyListeners();
}
onChangetaxes(value) {
taxesError = "";
notifyListeners();
}
onChangeSpecialNote(value) {
SpecialNoteError = "";
notifyListeners();
}
onChangefor(value) {
forError = "";
notifyListeners();
}
onChangepaymentTerms(value) {
paymentTermsError = "";
notifyListeners();
}
void resetForm() {
checkDropdownReset();
_productRows.clear();
addProductPriceController.clear();
addQuantityController.clear();
addTotalAmountController.clear();
notifyListeners();
}
void checkDropdownReset() {
notifyListeners();
}
bool validateStep1(){
bool isValid = true;
if(_selectedSalutation!=null||_selectedSalutation!=''){
isValid = false;
salutationError = "Please Select Salutation";
}
if(companyNameController.text.trim().isEmpty){
companynameError = "Please Enter Company Name";
isValid = false;
}
if(contactPersonNameController.text.trim().isEmpty){
nameError = "Please Enter Name";
isValid = false;
}
// if(customerMailIdController.text.trim().isEmpty){
// mailIdError = "Please enter Email Id";
// isValid = false;
// }
if(mobileController.text.trim().isEmpty){
mobileError = "Please enter Mobile Number";
isValid = false;
}
// if(designationController.text.trim().isEmpty){
// designationError = "Please enter Designation";
// isValid = false;
// }
notifyListeners();
return isValid;
}
bool validateStep2(){
bool isValid = true;
// if(alternateMobileController.text.trim().isEmpty){
// AlternatemobileError = "";
// isValid = false;
//
// }
// if(telephoneController.text.trim().isEmpty){
// isValid = false;
//
// }
if(_selectedSources!=null||_selectedSourcesId!.isEmpty){
sourceError = "Please Select Source";
isValid = false;
}
if(_selectedReferences!=null||_selectedReferenceId!.isEmpty){
referenceError = "Please Select Reference";
isValid = false;
}
if(_selectedTeams!=null||_selectedTeamsId!.isEmpty){
teamsError = "Please Select Team";
isValid = false;
}
if(_selectedSegments!=null||_selectedSegmentId!.isEmpty){
segmentsError = "Please Select Segement";
isValid = false;
}
notifyListeners();
return isValid;
}
bool validateStep3(){
bool isValid = true;
if(_selectedStates!=null||_selectedStatesId!.isEmpty){
statesError = "Please Select State";
isValid = false;
}
if(_selectedDistricts!=null||_selectedDistrictId!.isEmpty){
districtsError = "Please Select District";
isValid = false;
}
if(_selectedSubLocations!=null||_selectedSubLocationId!.isEmpty){
subLocError = "Please Select Sub Location";
isValid = false;
}
if(_selectedLeadStatus!=null||_selectedLeadStatus!.isEmpty){
leadStatusError = "Please Select Lead Status";
isValid = false;
}
if(addressController.text.trim().isEmpty){
addressError = "Please Enter address";
isValid = false;
}
notifyListeners();
return isValid;
}
resetForm2() {
customerMailIdController.clear();
mobileController.clear();
addressController.clear();
taxesController.clear();
SpecialNoteController.clear();
forController.clear();
paymentTermsController.clear();
mailIdError = "";
mobileError = "";
addressError = "";
designationError = "";
taxesError = "";
SpecialNoteError = "";
forError = "";
paymentTermsError = "";
}
}
...@@ -4,10 +4,13 @@ import 'package:generp/Models/crmModels/crmProspectDetailsAddLeadsResponse.dart' ...@@ -4,10 +4,13 @@ import 'package:generp/Models/crmModels/crmProspectDetailsAddLeadsResponse.dart'
import 'package:generp/Notifiers/HomeScreenNotifier.dart'; import 'package:generp/Notifiers/HomeScreenNotifier.dart';
import 'package:generp/Utils/commonServices.dart'; import 'package:generp/Utils/commonServices.dart';
import 'package:generp/services/api_calling.dart'; import 'package:generp/services/api_calling.dart';
import 'package:get/get.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
class Addprospectleadsprovider extends ChangeNotifier { import '../../Models/crmModels/crmSelectedProductDetailsResponse.dart';
import 'crmProspectDetailsProvider.dart';
class Addprospectleadsprovider extends ChangeNotifier {
TextEditingController searchController = TextEditingController(); TextEditingController searchController = TextEditingController();
List<Products> _leadProductsList = []; List<Products> _leadProductsList = [];
...@@ -18,10 +21,17 @@ class Addprospectleadsprovider extends ChangeNotifier { ...@@ -18,10 +21,17 @@ class Addprospectleadsprovider extends ChangeNotifier {
String? _selectedEmployeeId; String? _selectedEmployeeId;
String? _selectedEmployeeValue; String? _selectedEmployeeValue;
Products? _selectedProducts; Products? _selectedProducts;
String? _selectedProductsID;
String? _selectedProductsName;
ProductsData? _selectedProductsDeatilsData;
TextEditingController addLeadProductPriceController = TextEditingController(); TextEditingController addLeadProductPriceController = TextEditingController();
TextEditingController addLeadProductQtyController = TextEditingController(); TextEditingController addLeadProductQtyController = TextEditingController();
TextEditingController addLeadProductTotalPriceController = TextEditingController(); TextEditingController addLeadProductTotalPriceController =
TextEditingController();
String? qtyError;
String? priceError;
String? statusError;
List<TextEditingController> editProductPriceControllers = []; List<TextEditingController> editProductPriceControllers = [];
List<TextEditingController> editQuantityControllers = []; List<TextEditingController> editQuantityControllers = [];
...@@ -29,43 +39,71 @@ class Addprospectleadsprovider extends ChangeNotifier { ...@@ -29,43 +39,71 @@ class Addprospectleadsprovider extends ChangeNotifier {
List<String?> _selectedProductIds = []; List<String?> _selectedProductIds = [];
List<String?> _selectedValues = []; List<String?> _selectedValues = [];
bool _submitLoading = false; bool _submitLoading = false;
ProductsData? get selectedProductsDetailsData => _selectedProductsDeatilsData;
List<Products> get leadProductsList => _leadProductsList; List<Products> get leadProductsList => _leadProductsList;
Products? get selectedProducts => _selectedProducts; Products? get selectedProducts => _selectedProducts;
String? get selectedProductsID => _selectedProductsID;
String? get selectedProductsName => _selectedProductsName;
List<String?> get selectedProductIds => _selectedProductIds; List<String?> get selectedProductIds => _selectedProductIds;
List<String?> get selectedValues => _selectedValues; List<String?> get selectedValues => _selectedValues;
bool get submitLoading => _submitLoading; bool get submitLoading => _submitLoading;
List<LeadEmployees> get employeeList => _employeeList; List<LeadEmployees> get employeeList => _employeeList;
List<String> get statusList => _statusList; List<String> get statusList => _statusList;
LeadEmployees? get selectedEmployee => _selectedEmployees; LeadEmployees? get selectedEmployee => _selectedEmployees;
String? get selectedStatus => _selectedStatus; String? get selectedStatus => _selectedStatus;
String? get selectedEmployeeId => _selectedEmployeeId; String? get selectedEmployeeId => _selectedEmployeeId;
String? get selectedEmployeeValue => _selectedEmployeeValue;
String? get selectedEmployeeValue => _selectedEmployeeValue;
set selectedEmployee(LeadEmployees? value){ set selectedEmployee(LeadEmployees? value) {
_selectedEmployees = value; _selectedEmployees = value;
_selectedEmployeeId = value!.id!; _selectedEmployeeId = value!.id!;
_selectedEmployeeValue = value!.name!; _selectedEmployeeValue = value!.name!;
notifyListeners(); notifyListeners();
} }
set selectedStatus(String? value){ set selectedStatus(String? value) {
_selectedStatus = value; _selectedStatus = value;
statusError = null;
notifyListeners(); notifyListeners();
} }
set selectedEmployeeId(String? value){ set selectedEmployeeId(String? value) {
_selectedEmployeeId = value; _selectedEmployeeId = value;
notifyListeners(); notifyListeners();
} }
set selectedEmployeeValue(String? value){
set selectedEmployeeValue(String? value) {
_selectedEmployeeValue = value; _selectedEmployeeValue = value;
notifyListeners(); notifyListeners();
} }
set selectedProducts(Products? value) { set selectedProducts(Products? value) {
_selectedProducts = value; _selectedProducts = value;
_selectedProductsID = value!.id;
_selectedProductsName = value.name;
notifyListeners();
}
set selectedProductsID(String? value) {
_selectedProductsID = value;
notifyListeners();
}
set selectedProductsName(String? value) {
_selectedProductsName = value;
notifyListeners(); notifyListeners();
} }
...@@ -90,6 +128,28 @@ class Addprospectleadsprovider extends ChangeNotifier { ...@@ -90,6 +128,28 @@ class Addprospectleadsprovider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
Future<void> crmSelectedProductDetailsApiFunction(
BuildContext context,
String productId,
) async {
try {
final prov = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.crmSelectedProductDetailsApi(
prov.empId,
prov.session,
productId,
);
if (data != null && data.error == "0") {
_selectedProductsDeatilsData = data.productsData!;
addLeadProductPriceController.text= data.productsData!.price!;
notifyListeners();
}
} catch (e, s) {
print("Error: $e, Stack: $s");
}
}
void editAddNewRow() { void editAddNewRow() {
editProductPriceControllers.add(TextEditingController()); editProductPriceControllers.add(TextEditingController());
editQuantityControllers.add(TextEditingController()); editQuantityControllers.add(TextEditingController());
...@@ -132,7 +192,7 @@ class Addprospectleadsprovider extends ChangeNotifier { ...@@ -132,7 +192,7 @@ class Addprospectleadsprovider extends ChangeNotifier {
"product_id": _selectedProductIds[i]!, "product_id": _selectedProductIds[i]!,
"price": editProductPriceControllers[i].text, "price": editProductPriceControllers[i].text,
"qty": editQuantityControllers[i].text, "qty": editQuantityControllers[i].text,
"net_price":editTotalAmountControllers[i].text "net_price": editTotalAmountControllers[i].text,
}; };
insertData.add(rowData); insertData.add(rowData);
} }
...@@ -140,10 +200,17 @@ class Addprospectleadsprovider extends ChangeNotifier { ...@@ -140,10 +200,17 @@ class Addprospectleadsprovider extends ChangeNotifier {
return insertData; return insertData;
} }
Future<void> crmProspectDetailsAddLeadsViewAPIFunction(BuildContext context, String mode) async { Future<void> crmProspectDetailsAddLeadsViewAPIFunction(
BuildContext context,
String mode,
) async {
try { try {
final prov = Provider.of<HomescreenNotifier>(context, listen: false); final prov = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.crmProspectDetailsAddLeadViewAPI(prov.empId, prov.session, mode); final data = await ApiCalling.crmProspectDetailsAddLeadViewAPI(
prov.empId,
prov.session,
mode,
);
if (data != null && data.error == "0") { if (data != null && data.error == "0") {
_leadProductsList = data.products!; _leadProductsList = data.products!;
_employeeList = data.employees!; _employeeList = data.employees!;
...@@ -155,13 +222,31 @@ class Addprospectleadsprovider extends ChangeNotifier { ...@@ -155,13 +222,31 @@ class Addprospectleadsprovider extends ChangeNotifier {
} }
} }
Future<void> crmProspectDetailsAddLeadsSubmitAPIFunction(BuildContext context,mode, account_id, acc_manager_id, products, lead_status) async { Future<void> crmProspectDetailsAddLeadsSubmitAPIFunction(
BuildContext context,
mode,
account_id,
acc_manager_id,
products,
lead_status,
) async {
try { try {
_submitLoading = true;
notifyListeners();
final prov = Provider.of<HomescreenNotifier>(context, listen: false); final prov = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.crmProspectDetailsAddLeadSubmitAPI(prov.empId, prov.session, mode, account_id, acc_manager_id, products, lead_status); final data = await ApiCalling.crmProspectDetailsAddLeadSubmitAPI(
prov.empId,
prov.session,
mode,
account_id,
acc_manager_id,
products,
lead_status,
);
if (data != null && data.error == "0") { if (data != null && data.error == "0") {
_submitLoading = false;
resetForm(); resetForm();
Navigator.pop(context,true); Navigator.pop(context, true);
toast(context, data.message); toast(context, data.message);
notifyListeners(); notifyListeners();
} }
...@@ -170,26 +255,113 @@ class Addprospectleadsprovider extends ChangeNotifier { ...@@ -170,26 +255,113 @@ class Addprospectleadsprovider extends ChangeNotifier {
} }
} }
void submitForm(BuildContext context,mode,accId,empID,status) async { Future<void> crmProspectDetailsAddLeadsSubmitAPIFunctionNew(
BuildContext context,
mode,
leadId,
account_id,
productId,
lead_status,
) async {
try {
if (!validateform(context)) {
return;
}
_submitLoading = true;
notifyListeners();
final prov = Provider.of<HomescreenNotifier>(context, listen: false);
final prov2 = Provider.of<crmProspectDetailsProvider>(
context,
listen: false,
);
final data = await ApiCalling.crmProspectDetailsAddLeadAPI(
prov.empId,
prov.session,
account_id,
productId,
addLeadProductQtyController.text,
addLeadProductPriceController.text,
lead_status,
);
if (data != null) {
if (data.error == "0") {
_submitLoading = false;
resetForm();
Navigator.pop(context, true);
prov2.crmProspectDetailsAPIFunction(context, leadId);
toast(context, data.message);
notifyListeners();
} else {
_submitLoading = false;
notifyListeners();
}
} else {
_submitLoading = false;
notifyListeners();
}
} catch (e, s) {
_submitLoading = false;
notifyListeners();
print("Error: $e, Stack: $s");
}
}
bool validateform(context) {
bool isValid = true;
qtyError = null;
priceError = null;
statusError = null;
if (addLeadProductQtyController.text.trim().isEmpty) {
qtyError = "Please Enter Quantity";
isValid = false;
}
if (addLeadProductPriceController.text.trim().isEmpty) {
priceError = "Please Enter Price";
isValid = false;
}
if (_selectedStatus == null || _selectedStatus!.isEmpty) {
statusError = "Please select a status";
isValid = false;
}
notifyListeners();
return isValid;
}
void submitForm(BuildContext context, mode, accId, empID, status) async {
submitLoading = true; submitLoading = true;
final insertedData = getFormData(); final insertedData = getFormData();
print("Form Data: $insertedData"); print("Form Data: $insertedData");
crmProspectDetailsAddLeadsSubmitAPIFunction(context,mode,accId,empID,insertedData,status); crmProspectDetailsAddLeadsSubmitAPIFunction(
context,
mode,
accId,
empID,
insertedData,
status,
);
submitLoading = false; submitLoading = false;
} }
onChnageProductPrice(value){ onChnageProductPrice(value) {
priceError = null;
notifyListeners(); notifyListeners();
} }
onChnageProductQty(value){
onChnageProductQty(value) {
qtyError = null;
notifyListeners(); notifyListeners();
} }
onChnageProductTotalPrice(value){
onChnageProductTotalPrice(value) {
notifyListeners(); notifyListeners();
} }
void resetForm() { void resetForm() {
qtyError = null;
priceError = null;
statusError = null;
searchController.clear(); searchController.clear();
editProductPriceControllers.clear(); editProductPriceControllers.clear();
editQuantityControllers.clear(); editQuantityControllers.clear();
...@@ -198,18 +370,30 @@ class Addprospectleadsprovider extends ChangeNotifier { ...@@ -198,18 +370,30 @@ class Addprospectleadsprovider extends ChangeNotifier {
_selectedValues.clear(); _selectedValues.clear();
_leadProductsList.clear(); _leadProductsList.clear();
_selectedStatus = null; _selectedStatus = null;
_selectedProducts = null;
_selectedEmployeeId = null; _selectedEmployeeId = null;
_selectedEmployeeValue = null; _selectedEmployeeValue = null;
_selectedProductsID = null;
_selectedProductsName = null;
addLeadProductPriceController.clear();
addLeadProductQtyController.clear();
addLeadProductTotalPriceController.clear();
checkDropDownReset(); checkDropDownReset();
notifyListeners(); notifyListeners();
} }
checkDropDownReset(){
if(!_employeeList.contains(_selectedEmployees)&&_selectedEmployees!=null){ checkDropDownReset() {
_selectedEmployeeId = null; // if (!_employeeList.contains(_selectedEmployees) &&
_selectedEmployeeValue = null; // _selectedEmployees != null) {
// _selectedEmployeeId = null;
// _selectedEmployeeValue = null;
// }
if (!_leadProductsList.contains(_selectedProducts) &&
_selectedProducts != null) {
_selectedProductsID = null;
_selectedProductsName = null;
} }
notifyListeners(); notifyListeners();
} }
} }
...@@ -6,6 +6,7 @@ import 'package:flutter/services.dart'; ...@@ -6,6 +6,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_download_manager/flutter_download_manager.dart'; import 'package:flutter_download_manager/flutter_download_manager.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:generp/Models/crmModels/crmLeadDetailsGenerateQuotationViewResponse.dart'; import 'package:generp/Models/crmModels/crmLeadDetailsGenerateQuotationViewResponse.dart';
import 'package:generp/Models/crmModels/crmSelectedProductDetailsResponse.dart';
import 'package:generp/screens/LoginScreen.dart'; import 'package:generp/screens/LoginScreen.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
...@@ -24,7 +25,7 @@ class Crmgeneratequotationprovider extends ChangeNotifier { ...@@ -24,7 +25,7 @@ class Crmgeneratequotationprovider extends ChangeNotifier {
final GlobalKey webViewKey = GlobalKey(); final GlobalKey webViewKey = GlobalKey();
var dl = DownloadManager(); var dl = DownloadManager();
ProductsData? _selectedProductsDeatilsData;
TextEditingController addEditProductPriceController = TextEditingController(); TextEditingController addEditProductPriceController = TextEditingController();
TextEditingController addEditQuantityController = TextEditingController(); TextEditingController addEditQuantityController = TextEditingController();
TextEditingController addEditTotalAmountController = TextEditingController(); TextEditingController addEditTotalAmountController = TextEditingController();
...@@ -44,6 +45,8 @@ class Crmgeneratequotationprovider extends ChangeNotifier { ...@@ -44,6 +45,8 @@ class Crmgeneratequotationprovider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
String? _selectedTaxes;
String? mailIdError = ""; String? mailIdError = "";
String? mobileError = ""; String? mobileError = "";
String? subjectsError = ""; String? subjectsError = "";
...@@ -54,16 +57,24 @@ class Crmgeneratequotationprovider extends ChangeNotifier { ...@@ -54,16 +57,24 @@ class Crmgeneratequotationprovider extends ChangeNotifier {
QuoteDetails _quoteDetails = QuoteDetails(); QuoteDetails _quoteDetails = QuoteDetails();
List<LeadProducts> _leadProductsList = []; List<LeadProducts> _leadProductsList = [];
List<Products> _productsList = [];
bool _isLoading = true; bool _isLoading = true;
String? _quotationFilePath; String? _quotationFilePath;
LeadProducts? _selectedLeadProducts; LeadProducts? _selectedLeadProducts;
Products? _selectedProducts;
String? _selectedAddEditLeadProductId; String? _selectedAddEditLeadProductId;
String? _selectedAddEditLeadProductName; String? _selectedAddEditLeadProductName;
String? _selectedAddEditProductName;
String? _selectedAddEditProductId;
List<TextEditingController> editProductPriceControllers = []; List<TextEditingController> editProductPriceControllers = [];
List<TextEditingController> editQuantityControllers = []; List<TextEditingController> editQuantityControllers = [];
List<TextEditingController> editTotalAmountControllers = []; List<TextEditingController> editTotalAmountControllers = [];
ProductsData? get selectedProductsDetailsData => _selectedProductsDeatilsData;
String? get selectedTaxes => _selectedTaxes;
List<String?> _selectedProductIds = []; List<String?> _selectedProductIds = [];
List<String?> _selectedValues = []; List<String?> _selectedValues = [];
bool _submitLoading = false; bool _submitLoading = false;
...@@ -73,13 +84,25 @@ class Crmgeneratequotationprovider extends ChangeNotifier { ...@@ -73,13 +84,25 @@ class Crmgeneratequotationprovider extends ChangeNotifier {
QuoteDetails get quoteDetails => _quoteDetails; QuoteDetails get quoteDetails => _quoteDetails;
List<LeadProducts> get leadProductsList => _leadProductsList; List<LeadProducts> get leadProductsList => _leadProductsList;
List<Products> get productsList => _productsList;
set leadProductsList(List<LeadProducts> value) { set leadProductsList(List<LeadProducts> value) {
_leadProductsList = value; _leadProductsList = value;
notifyListeners(); notifyListeners();
} }
set productsList(List<Products> value) {
_productsList = value;
notifyListeners();
}
set selectedTaxes(String? value){
_selectedTaxes = value;
notifyListeners();
}
LeadProducts? get selectedLeadProducts => _selectedLeadProducts; LeadProducts? get selectedLeadProducts => _selectedLeadProducts;
Products? get selectedProducts => _selectedProducts;
bool get isLoading => _isLoading; bool get isLoading => _isLoading;
...@@ -89,6 +112,10 @@ class Crmgeneratequotationprovider extends ChangeNotifier { ...@@ -89,6 +112,10 @@ class Crmgeneratequotationprovider extends ChangeNotifier {
String? get selectedAddEditLeadProductName => _selectedAddEditLeadProductName; String? get selectedAddEditLeadProductName => _selectedAddEditLeadProductName;
String? get selectedAddEditProductId => _selectedAddEditProductId;
String? get selectedAddEditProductName => _selectedAddEditProductName;
List<String?> get selectedValues => _selectedValues; List<String?> get selectedValues => _selectedValues;
bool get submitLoading => _submitLoading; bool get submitLoading => _submitLoading;
...@@ -100,6 +127,23 @@ class Crmgeneratequotationprovider extends ChangeNotifier { ...@@ -100,6 +127,23 @@ class Crmgeneratequotationprovider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
set selectedProducts(Products? value){
_selectedProducts = value;
_selectedAddEditProductId = value!.id!;
_selectedAddEditProductName = value!.name;
notifyListeners();
}
set selectedAddEditProductId(String? value){
_selectedAddEditProductId = value;
notifyListeners();
}
set selectedAddEditProductName(String? value){
_selectedAddEditProductName= value;
notifyListeners();
}
set selectedAddEditLeadProductId(String? value) { set selectedAddEditLeadProductId(String? value) {
_selectedAddEditLeadProductId = value; _selectedAddEditLeadProductId = value;
notifyListeners(); notifyListeners();
...@@ -136,6 +180,7 @@ class Crmgeneratequotationprovider extends ChangeNotifier { ...@@ -136,6 +180,7 @@ class Crmgeneratequotationprovider extends ChangeNotifier {
} }
void addEditInitializeForm(BuildContext context) { void addEditInitializeForm(BuildContext context) {
checkDropdownReset();
addEditProductPriceController.clear(); addEditProductPriceController.clear();
addEditQuantityController.clear(); addEditQuantityController.clear();
addEditTotalAmountController.clear(); addEditTotalAmountController.clear();
...@@ -146,6 +191,7 @@ class Crmgeneratequotationprovider extends ChangeNotifier { ...@@ -146,6 +191,7 @@ class Crmgeneratequotationprovider extends ChangeNotifier {
} }
void preFillFormForEdit(LeadProducts product) { void preFillFormForEdit(LeadProducts product) {
checkDropdownReset();
selectedLeadProducts = product; selectedLeadProducts = product;
selectedAddEditLeadProductId = product.id; selectedAddEditLeadProductId = product.id;
selectedAddEditLeadProductName = product.productName; selectedAddEditLeadProductName = product.productName;
...@@ -191,7 +237,27 @@ class Crmgeneratequotationprovider extends ChangeNotifier { ...@@ -191,7 +237,27 @@ class Crmgeneratequotationprovider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
Future<void> crmSelectedProductDetailsApiFunction(
BuildContext context,
String productId,
) async {
try {
final prov = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.crmSelectedProductDetailsApi(
prov.empId,
prov.session,
productId,
);
if (data != null && data.error == "0") {
_selectedProductsDeatilsData = data.productsData!;
addEditProductPriceController.text= data.productsData!.price!;
notifyListeners();
}
} catch (e, s) {
print("Error: $e, Stack: $s");
}
}
void editAddNewRow() { void editAddNewRow() {
editProductPriceControllers.add(TextEditingController()); editProductPriceControllers.add(TextEditingController());
editQuantityControllers.add(TextEditingController()); editQuantityControllers.add(TextEditingController());
...@@ -261,6 +327,7 @@ class Crmgeneratequotationprovider extends ChangeNotifier { ...@@ -261,6 +327,7 @@ class Crmgeneratequotationprovider extends ChangeNotifier {
if (data.error == "0") { if (data.error == "0") {
_isLoading = false; _isLoading = false;
_leadProductsList = data.leadProducts ?? []; _leadProductsList = data.leadProducts ?? [];
_productsList = data.products ?? [];
_quoteDetails = _quoteDetails =
data.quoteDetails ?? data.quoteDetails ??
...@@ -297,13 +364,7 @@ class Crmgeneratequotationprovider extends ChangeNotifier { ...@@ -297,13 +364,7 @@ class Crmgeneratequotationprovider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
} else { } else {
Navigator.push( sessionDoesNotExist(context);
context,
MaterialPageRoute(
builder: (context) => LoginScreen(),
settings: RouteSettings(name: 'LoginScreen'),
),
);
} }
} else { } else {
_isLoading = false; _isLoading = false;
...@@ -563,6 +624,7 @@ class Crmgeneratequotationprovider extends ChangeNotifier { ...@@ -563,6 +624,7 @@ class Crmgeneratequotationprovider extends ChangeNotifier {
void resetForm() { void resetForm() {
checkDropdownReset(); checkDropdownReset();
_productRows.clear(); _productRows.clear();
selectedTaxes = null;
addEditProductPriceController.clear(); addEditProductPriceController.clear();
addEditQuantityController.clear(); addEditQuantityController.clear();
addEditTotalAmountController.clear(); addEditTotalAmountController.clear();
...@@ -572,6 +634,9 @@ class Crmgeneratequotationprovider extends ChangeNotifier { ...@@ -572,6 +634,9 @@ class Crmgeneratequotationprovider extends ChangeNotifier {
_selectedLeadProducts = null; _selectedLeadProducts = null;
_selectedAddEditLeadProductId = null; _selectedAddEditLeadProductId = null;
_selectedAddEditLeadProductName = null; _selectedAddEditLeadProductName = null;
_selectedAddEditProductName = null;
_selectedAddEditProductId = null;
_selectedProducts = null;
notifyListeners(); notifyListeners();
} }
...@@ -585,6 +650,9 @@ class Crmgeneratequotationprovider extends ChangeNotifier { ...@@ -585,6 +650,9 @@ class Crmgeneratequotationprovider extends ChangeNotifier {
} }
resetForm2() { resetForm2() {
_selectedAddEditProductName = null;
_selectedAddEditProductId = null;
_selectedProducts = null;
mailIdController.clear(); mailIdController.clear();
mobileController.clear(); mobileController.clear();
subjectsController.clear(); subjectsController.clear();
...@@ -605,5 +673,6 @@ class Crmgeneratequotationprovider extends ChangeNotifier { ...@@ -605,5 +673,6 @@ class Crmgeneratequotationprovider extends ChangeNotifier {
SpecialNoteError = ""; SpecialNoteError = "";
forError = ""; forError = "";
paymentTermsError = ""; paymentTermsError = "";
notifyListeners();
} }
} }
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:generp/Utils/commonServices.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
...@@ -208,7 +209,9 @@ class crmLeadDetailsProvider extends ChangeNotifier { ...@@ -208,7 +209,9 @@ class crmLeadDetailsProvider extends ChangeNotifier {
_isLoading = true; _isLoading = true;
notifyListeners(); notifyListeners();
if (data != null) { if (data != null) {
if(data.sessionExists==1){
if (data.error == "0") { if (data.error == "0") {
print("calling");
_leadDetails = data.leadDetails!; _leadDetails = data.leadDetails!;
_accountDetails = data.accountDetails!; _accountDetails = data.accountDetails!;
_leadProducts = data.leadProducts!; _leadProducts = data.leadProducts!;
...@@ -224,6 +227,10 @@ class crmLeadDetailsProvider extends ChangeNotifier { ...@@ -224,6 +227,10 @@ class crmLeadDetailsProvider extends ChangeNotifier {
_isLoading = false; _isLoading = false;
notifyListeners(); notifyListeners();
} }
}else{
sessionDoesNotExist(context);
}
}else{ }else{
_isLoading = false; _isLoading = false;
notifyListeners(); notifyListeners();
...@@ -289,6 +296,37 @@ class crmLeadDetailsProvider extends ChangeNotifier { ...@@ -289,6 +296,37 @@ class crmLeadDetailsProvider extends ChangeNotifier {
} }
} }
Future<void> crmCheckFields(context,value,type) async {
try {
var prov = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.crmCheckAccountFieldsApi(prov.empId, prov.session,value,type);
if (data != null) {
if (data.error == "0") {
nameError = null;
mobileNumError = null;
altMobError = null;
notifyListeners();
}else if(data.error=="1"){
if(type=="name"){
nameError = data.message!;
}else if(type == 'mob1'){
mobileNumError = data.message!;
}else if(type == 'mob2'){
altMobError = data.message!;
}
notifyListeners();
}
}else{
notifyListeners();
}
} catch (e, s) {
notifyListeners();
}
}
Future<void> crmLeadDetailsAddAppointmentAPIFunction(context, leadID, appointmentDate, appointmentType, note) async { Future<void> crmLeadDetailsAddAppointmentAPIFunction(context, leadID, appointmentDate, appointmentType, note) async {
try { try {
var prov = Provider.of<HomescreenNotifier>(context, listen: false); var prov = Provider.of<HomescreenNotifier>(context, listen: false);
...@@ -353,6 +391,7 @@ class crmLeadDetailsProvider extends ChangeNotifier { ...@@ -353,6 +391,7 @@ class crmLeadDetailsProvider extends ChangeNotifier {
style: TextStyle(fontFamily: "JakartaMedium",color: AppColors.app_blue), style: TextStyle(fontFamily: "JakartaMedium",color: AppColors.app_blue),
), ),
onPressed: () { onPressed: () {
setDate(_date ?? DateTime.now() );
Navigator.pop(context); Navigator.pop(context);
}, },
), ),
......
...@@ -251,6 +251,38 @@ class crmProspectDetailsProvider extends ChangeNotifier { ...@@ -251,6 +251,38 @@ class crmProspectDetailsProvider extends ChangeNotifier {
} }
} }
Future<void> crmCheckFields(context,value,type) async {
try {
var prov = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.crmCheckAccountFieldsApi(prov.empId, prov.session,value,type);
if (data != null) {
if (data.error == "0") {
nameError = null;
mobileNumError = null;
altMobError = null;
notifyListeners();
}else if(data.error=="1"){
if(type=="name"){
nameError = data.message!;
}else if(type == 'mob1'){
mobileNumError = data.message!;
}else if(type == 'mob2'){
altMobError = data.message!;
}
notifyListeners();
}
}else{
notifyListeners();
}
} catch (e, s) {
notifyListeners();
}
}
Future<void> crmProspectDetailsAddContactAPIFunction(context, accID) async { Future<void> crmProspectDetailsAddContactAPIFunction(context, accID) async {
try { try {
var prov = Provider.of<HomescreenNotifier>(context, listen: false); var prov = Provider.of<HomescreenNotifier>(context, listen: false);
...@@ -345,6 +377,7 @@ class crmProspectDetailsProvider extends ChangeNotifier { ...@@ -345,6 +377,7 @@ class crmProspectDetailsProvider extends ChangeNotifier {
style: TextStyle(fontFamily: "JakartaMedium",color: AppColors.app_blue), style: TextStyle(fontFamily: "JakartaMedium",color: AppColors.app_blue),
), ),
onPressed: () { onPressed: () {
setDate(_date ?? DateTime.now() );
Navigator.pop(context); Navigator.pop(context);
}, },
), ),
......
...@@ -122,10 +122,14 @@ ...@@ -122,10 +122,14 @@
// } // }
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:generp/Models/crmModels/crmSelectedProductDetailsResponse.dart';
import 'package:generp/Notifiers/HomeScreenNotifier.dart'; import 'package:generp/Notifiers/HomeScreenNotifier.dart';
import 'package:generp/Utils/SharedpreferencesService.dart';
import 'package:generp/Utils/commonServices.dart';
import 'package:generp/services/api_calling.dart'; import 'package:generp/services/api_calling.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import '../../Models/crmModels/crmLeadDetailsEditProductsViewResponse.dart'; import '../../Models/crmModels/crmLeadDetailsEditProductsViewResponse.dart';
import '../../screens/LoginScreen.dart';
import 'crmLeadDetailsProvider.dart'; import 'crmLeadDetailsProvider.dart';
class Editproductlistprovider extends ChangeNotifier { class Editproductlistprovider extends ChangeNotifier {
...@@ -135,6 +139,7 @@ class Editproductlistprovider extends ChangeNotifier { ...@@ -135,6 +139,7 @@ class Editproductlistprovider extends ChangeNotifier {
List<Products> _productsList = []; List<Products> _productsList = [];
List<LeadProducts> _leadProductsList = []; List<LeadProducts> _leadProductsList = [];
Products? _selectedProducts; Products? _selectedProducts;
ProductsData? _selectedProductsDeatilsData;
String? _selectedAddEditProductId; String? _selectedAddEditProductId;
String? _selectedAddEditProductName; String? _selectedAddEditProductName;
List<TextEditingController> editProductPriceControllers = []; List<TextEditingController> editProductPriceControllers = [];
...@@ -143,11 +148,15 @@ class Editproductlistprovider extends ChangeNotifier { ...@@ -143,11 +148,15 @@ class Editproductlistprovider extends ChangeNotifier {
List<String?> _selectedProductIds = []; List<String?> _selectedProductIds = [];
List<String?> _selectedValues = []; List<String?> _selectedValues = [];
bool _submitLoading = false; bool _submitLoading = false;
String? qtyError;
String? priceError;
String? productError;
List<Products> get productsList => _productsList; List<Products> get productsList => _productsList;
List<LeadProducts> get leadProductsList => _leadProductsList; List<LeadProducts> get leadProductsList => _leadProductsList;
ProductsData? get selectedProductsDetailsData => _selectedProductsDeatilsData;
Products? get selectedProducts => _selectedProducts; Products? get selectedProducts => _selectedProducts;
String? get selectedAddEditProductId => _selectedAddEditProductId; String? get selectedAddEditProductId => _selectedAddEditProductId;
...@@ -164,6 +173,7 @@ class Editproductlistprovider extends ChangeNotifier { ...@@ -164,6 +173,7 @@ class Editproductlistprovider extends ChangeNotifier {
_selectedProducts = value; _selectedProducts = value;
_selectedAddEditProductId = value!.id!; _selectedAddEditProductId = value!.id!;
_selectedAddEditProductName = value.name; _selectedAddEditProductName = value.name;
productError = null;
notifyListeners(); notifyListeners();
} }
...@@ -285,16 +295,50 @@ class Editproductlistprovider extends ChangeNotifier { ...@@ -285,16 +295,50 @@ class Editproductlistprovider extends ChangeNotifier {
prov.session, prov.session,
leadID, leadID,
); );
if (data != null && data.error == "0") {
if (data != null){
if(data.sessionExists==1){
if( data.error == "0") {
_leadProductsList = data.leadProducts ?? []; _leadProductsList = data.leadProducts ?? [];
_productsList = data.products ?? []; _productsList = data.products ?? [];
notifyListeners(); notifyListeners();
} }
}else{
sessionDoesNotExist(context);
}
}
} catch (e, s) { } catch (e, s) {
print("Error: $e, Stack: $s"); print("Error: $e, Stack: $s");
} }
} }
Future<void> crmSelectedProductDetailsApiFunction(
BuildContext context,
String productId,
) async {
try {
final prov = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.crmSelectedProductDetailsApi(
prov.empId,
prov.session,
productId,
);
if (data != null && data.error == "0") {
_selectedProductsDeatilsData = data.productsData!;
addEditProductPriceController.text= data.productsData!.price!;
notifyListeners();
}
} catch (e, s) {
print("Error: $e, Stack: $s");
}
}
Future<void> crmLeadDetailsEditProductsSubmitAPIFunction( Future<void> crmLeadDetailsEditProductsSubmitAPIFunction(
BuildContext context, BuildContext context,
products, products,
...@@ -327,6 +371,9 @@ class Editproductlistprovider extends ChangeNotifier { ...@@ -327,6 +371,9 @@ class Editproductlistprovider extends ChangeNotifier {
productId, productId,
) async { ) async {
try { try {
if(!validateform(context)){
return;
}
_submitLoading = true; _submitLoading = true;
notifyListeners(); notifyListeners();
final prov = Provider.of<HomescreenNotifier>(context, listen: false); final prov = Provider.of<HomescreenNotifier>(context, listen: false);
...@@ -339,7 +386,7 @@ class Editproductlistprovider extends ChangeNotifier { ...@@ -339,7 +386,7 @@ class Editproductlistprovider extends ChangeNotifier {
leadProductId, leadProductId,
productId, productId,
addEditQuantityController.text, addEditQuantityController.text,
addEditTotalAmountController.text, addEditProductPriceController.text,
); );
if (data != null && data.error == "0") { if (data != null && data.error == "0") {
_submitLoading = false; _submitLoading = false;
...@@ -358,6 +405,28 @@ class Editproductlistprovider extends ChangeNotifier { ...@@ -358,6 +405,28 @@ class Editproductlistprovider extends ChangeNotifier {
} }
} }
bool validateform(context){
bool isValid = true;
qtyError = null;
priceError = null;
productError = null;
if(addEditQuantityController.text.trim().isEmpty){
qtyError = "Please Enter Quantity";
isValid = false;
}
if(addEditTotalAmountController.text.trim().isEmpty){
priceError = "Please Enter Price";
isValid = false;
}
if (_selectedProducts == null || _selectedAddEditProductId!.isEmpty) {
productError = "Please select a Product";
isValid = false;
}
notifyListeners();
return isValid;
}
void submitForm(BuildContext context, leadID) async { void submitForm(BuildContext context, leadID) async {
submitLoading = true; submitLoading = true;
final insertedData = getFormData(); final insertedData = getFormData();
......
...@@ -264,6 +264,7 @@ class followUpUpdateProvider extends ChangeNotifier { ...@@ -264,6 +264,7 @@ class followUpUpdateProvider extends ChangeNotifier {
), ),
), ),
onPressed: () { onPressed: () {
setDate(_date ?? DateTime.now() );
Navigator.pop(context); Navigator.pop(context);
}, },
), ),
......
...@@ -703,6 +703,7 @@ class Requestionlistprovider extends ChangeNotifier { ...@@ -703,6 +703,7 @@ class Requestionlistprovider extends ChangeNotifier {
), ),
), ),
onPressed: () { onPressed: () {
setDate(_date ?? DateTime.now() );
Navigator.pop(context); Navigator.pop(context);
}, },
), ),
......
...@@ -960,6 +960,7 @@ class Paymentreceiptsprovider extends ChangeNotifier { ...@@ -960,6 +960,7 @@ class Paymentreceiptsprovider extends ChangeNotifier {
), ),
), ),
onPressed: () { onPressed: () {
Navigator.pop(context); Navigator.pop(context);
}, },
), ),
...@@ -972,6 +973,7 @@ class Paymentreceiptsprovider extends ChangeNotifier { ...@@ -972,6 +973,7 @@ class Paymentreceiptsprovider extends ChangeNotifier {
), ),
), ),
onPressed: () { onPressed: () {
setDate(_date ?? DateTime.now() );
Navigator.pop(context); Navigator.pop(context);
}, },
), ),
......
...@@ -1586,6 +1586,7 @@ class Addorderprovider extends ChangeNotifier { ...@@ -1586,6 +1586,7 @@ class Addorderprovider extends ChangeNotifier {
style: TextStyle(fontFamily: "JakartaMedium",color: AppColors.app_blue), style: TextStyle(fontFamily: "JakartaMedium",color: AppColors.app_blue),
), ),
onPressed: () { onPressed: () {
setDate(_date ?? DateTime.now() );
Navigator.pop(context); Navigator.pop(context);
}, },
), ),
......
...@@ -624,6 +624,7 @@ class Addpaymentprovider extends ChangeNotifier{ ...@@ -624,6 +624,7 @@ class Addpaymentprovider extends ChangeNotifier{
style: TextStyle(fontFamily: "JakartaMedium",color: AppColors.app_blue), style: TextStyle(fontFamily: "JakartaMedium",color: AppColors.app_blue),
), ),
onPressed: () { onPressed: () {
setDate(_date ?? DateTime.now() );
Navigator.pop(context); Navigator.pop(context);
}, },
), ),
......
...@@ -5,6 +5,9 @@ import 'package:connectivity_plus/connectivity_plus.dart'; ...@@ -5,6 +5,9 @@ import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart'; import 'package:fluttertoast/fluttertoast.dart';
import '../screens/LoginScreen.dart';
import 'SharedpreferencesService.dart';
toast(context, text) { toast(context, text) {
// OwnToast(context, text, "0"); // OwnToast(context, text, "0");
Fluttertoast.showToast( Fluttertoast.showToast(
...@@ -17,6 +20,21 @@ toast(context, text) { ...@@ -17,6 +20,21 @@ toast(context, text) {
fontSize: 15.0, fontSize: 15.0,
); );
} }
void sessionDoesNotExist(context) {
SharedpreferencesService().clearPreferences();
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => LoginScreen(),
settings: RouteSettings(name: 'LoginScreen'),
),
);
}
String connection = "Online"; String connection = "Online";
class MyConnectivity { class MyConnectivity {
......
...@@ -222,10 +222,12 @@ Widget textControllerWidget( ...@@ -222,10 +222,12 @@ Widget textControllerWidget(
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
if(textHead!="")...[
Padding( Padding(
padding: const EdgeInsets.only(bottom: 5.0, top: 8.0), padding: const EdgeInsets.only(bottom: 5.0, top: 8.0),
child: Text(textHead), child: Text(textHead),
), ),
],
Container( Container(
height: hintText == "Enter Description" || hintText=="Write Feedback" ? 150 : 50, height: hintText == "Enter Description" || hintText=="Write Feedback" ? 150 : 50,
alignment: Alignment.center, alignment: Alignment.center,
......
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