Commit b38d986d authored by Sai Srinivas's avatar Sai Srinivas
Browse files

23-07-2025 By Sai Srinivas

CRM Lead Details, Generate Quotation & Followup and Prospect List.
parent c0252747
......@@ -33,7 +33,7 @@ class _PendingTasksListState extends State<PendingTasksList> {
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
var prov = Provider.of<Crmdashboardprovider>(context, listen: false);
prov.accessPagesAPIFunction(context);
prov.crmDashboardAPIFunction(context, "executive", "", "", "");
prov.crmDashboardAPIFunction(context);
prov.crmPendingTasksAPIFunction(context);
});
}
......
......@@ -53,3 +53,4 @@ export 'package:generp/Notifiers/crmProvider/crmNearbyOpenLeadsProvider.dart';
export 'package:generp/Notifiers/crmProvider/crmGenerateQuotationProvider.dart';
export 'package:generp/Notifiers/crmProvider/crmEditProspectAccountProvider.dart';
export 'package:generp/Notifiers/crmProvider/addProspectLeadsProvider.dart';
export 'package:generp/Notifiers/crmProvider/followUpUpdateProvider.dart';
......@@ -35,7 +35,7 @@ class _CrmdashboardScreenState extends State<CrmdashboardScreen> {
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
var prov = Provider.of<Crmdashboardprovider>(context, listen: false);
prov.accessPagesAPIFunction(context);
prov.crmDashboardAPIFunction(context, "executive", "", "", "");
prov.crmDashboardAPIFunction(context);
prov.crmPendingTasksAPIFunction(context);
});
}
......
import 'dart:io';
import 'package:dropdown_button2/dropdown_button2.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:generp/Utils/dropdownTheme.dart';
import 'package:generp/screens/crm/generateQuotationAddEditProduct.dart';
import 'package:provider/provider.dart';
import '../../Models/crmModels/crmLeadDetailsGenerateQuotationViewResponse.dart';
import '../../Notifiers/crmProvider/crmGenerateQuotationProvider.dart';
import '../../Utils/app_colors.dart';
import '../../Utils/commonWidgets.dart';
class Generatequotationscreenold extends StatefulWidget {
final leadId;
const Generatequotationscreenold({super.key, required this.leadId});
@override
State<Generatequotationscreenold> createState() =>
_GeneratequotationscreenoldState();
}
class _GeneratequotationscreenoldState extends State<Generatequotationscreenold> {
Dropdowntheme ddtheme = Dropdowntheme();
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) async {
final provider = Provider.of<Crmgeneratequotationprovider>(
context,
listen: false,
);
await provider.crmLeadDetailsGenerateQuoteViewAPIFunction(
context,
widget.leadId,
);
// Initialize controllers and dropdowns after API call
provider.initializeForm(context);
});
}
@override
Widget build(BuildContext context) {
return Consumer<Crmgeneratequotationprovider>(
builder: (context, provider, child) {
return WillPopScope(
onWillPop: () async {
// provider.resetForm();
return true;
},
child: SafeArea(
top: false,
bottom: Platform.isIOS ? false : true,
child: Scaffold(
resizeToAvoidBottomInset: true,
backgroundColor: AppColors.scaffold_bg_color,
appBar: appbar2(
context,
"Generate Quotation",
provider.resetForm,
const SizedBox(width: 0),
),
body: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
padding: EdgeInsets.symmetric(
horizontal: 10,
vertical: 10,
),
margin: EdgeInsets.symmetric(
horizontal: 10,
vertical: 10,
),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16),
),
child: Column(
children: [
textControllerWidget(
context,
provider.mailIdController,
"Email Id",
"Enter Email Id",
provider.onChangemailId,
TextInputType.emailAddress,
false,
null,
),
errorWidget(context, provider.mailIdError),
textControllerWidget(
context,
provider.mobileController,
"Mobile Number",
"Enter Mobile Number",
provider.onChangemobile,
TextInputType.phone,
false,
FilteringTextInputFormatter.digitsOnly,
),
errorWidget(context, provider.mobileError),
textControllerWidget(
context,
provider.subjectsController,
"Subject",
"Enter Subject",
provider.onChangesubjects,
TextInputType.text,
false,
null,
),
errorWidget(context, provider.subjectsError),
],
),
),
Container(
padding: EdgeInsets.symmetric(
horizontal: 10,
vertical: 10,
),
margin: EdgeInsets.symmetric(
horizontal: 10,
vertical: 10,
),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16),
),
child: Column(
children: [
InkResponse(
onTap: () async {
var res = await Navigator.push(
context,
MaterialPageRoute(
builder:
(context) =>
Generatequotationaddeditproduct(leadId: widget.leadId,),
settings: RouteSettings(name: 'Generatequotationaddeditproduct')
),
);
},
child: Container(
margin: const EdgeInsets.symmetric(vertical: 10),
height: 45,
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
color: const Color(0xFFE6F6FF),
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: AppColors.app_blue,
width: 0.5,
),
),
child: Center(
child: Text(
"+ Add Product",
style: TextStyle(
fontFamily: "JakartaMedium",
color: AppColors.app_blue,
),
),
),
),
),
if (provider.leadProductsList.isNotEmpty ||
provider
.editProductPriceControllers
.isNotEmpty) ...[
ListView.builder(
itemCount:
provider.editProductPriceControllers.length,
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemBuilder: (context, j) {
return Container(
padding: const EdgeInsets.symmetric(
horizontal: 10,
vertical: 10,
),
margin: const EdgeInsets.symmetric(
vertical: 10,
),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(20),
),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
TextWidget(context, "Product"),
DropdownButtonHideUnderline(
child: Row(
children: [
Expanded(
child: DropdownButton2<
LeadProducts
>(
isExpanded: true,
hint: const Text(
'Select Product',
style: TextStyle(
fontSize: 14,
),
overflow:
TextOverflow.ellipsis,
),
items:
provider.leadProductsList
.map(
(
ord,
) => DropdownMenuItem<
LeadProducts
>(
value: ord,
child: Text(
"(Product Name: ${ord.productName})",
style:
const TextStyle(
fontSize:
14,
),
overflow:
TextOverflow
.ellipsis,
),
),
)
.toList(),
value:
provider.selectedProductIds[j] !=
null
? provider
.leadProductsList
.firstWhere(
(ord) =>
ord.id ==
provider
.selectedProductIds[j],
orElse:
() =>
provider
.leadProductsList[0],
)
: null,
onChanged: (
LeadProducts? value,
) {
if (value != null) {
provider
.updateSelectedProductIds(
j,
value,
);
provider.selectedProductIds[j] =
value.id?.toString() ??
'';
provider.updateTotalAmount(
j,
);
}
},
buttonStyleData:
ddtheme.buttonStyleData,
iconStyleData:
ddtheme.iconStyleData,
menuItemStyleData:
ddtheme.menuItemStyleData,
dropdownStyleData:
ddtheme.dropdownStyleData,
),
),
],
),
),
const SizedBox(height: 10),
Row(
children: [
Expanded(
flex: 2,
child: textControllerWidget(
context,
provider
.editProductPriceControllers[j],
"Product Price",
"Enter Product Price",
(value) =>
provider.updateTotalAmount(j),
TextInputType.number,
false,
FilteringTextInputFormatter
.digitsOnly,
),
),
],
),
const SizedBox(height: 10),
Row(
children: [
Expanded(
flex: 2,
child: textControllerWidget(
context,
provider
.editQuantityControllers[j],
"Quantity",
"Enter Quantity",
(value) =>
provider.updateTotalAmount(j),
TextInputType.number,
false,
FilteringTextInputFormatter
.digitsOnly,
),
),
],
),
const SizedBox(height: 10),
Row(
children: [
Expanded(
flex: 2,
child: textControllerWidget(
context,
provider
.editTotalAmountControllers[j],
"Amount",
"Total Amount",
(_) {},
TextInputType.number,
true,
FilteringTextInputFormatter
.digitsOnly,
),
),
],
),
// IconButton(
// icon: const Icon(Icons.delete),
// onPressed: provider.editProductPriceControllers.length > 1
// ? () => provider.editRemoveRow(j)
// : null,
// ),
],
),
);
},
),
],
],
),
),
Container(
padding: EdgeInsets.symmetric(
horizontal: 10,
vertical: 10,
),
margin: EdgeInsets.symmetric(
horizontal: 10,
vertical: 10,
),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16),
),
child: Column(
children: [
textControllerWidget(
context,
provider.taxesController,
"Taxes",
"Enter Taxes",
provider.onChangetaxes,
TextInputType.text,
false,
null,
),
errorWidget(context, provider.taxesError),
textControllerWidget(
context,
provider.SpecialNoteController,
"Special Note",
"Enter Special Note",
provider.onChangeSpecialNote,
TextInputType.text,
false,
null,
),
errorWidget(context, provider.SpecialNoteError),
textControllerWidget(
context,
provider.forController,
"FOR",
"Enter FOR",
provider.onChangefor,
TextInputType.text,
false,
null,
),
errorWidget(context, provider.forError),
textControllerWidget(
context,
provider.paymentTermsController,
"Payment Terms",
"Enter Payment Terms",
provider.onChangepaymentTerms,
TextInputType.text,
false,
null,
),
errorWidget(context, provider.paymentTermsError),
],
),
),
],
),
),
floatingActionButtonLocation:
FloatingActionButtonLocation.centerFloat,
bottomNavigationBar: Material(
elevation: 10,
shadowColor: Colors.black54,
child: Container(
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.black26,
blurRadius: 10,
offset: Offset(0, -2),
),
],
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child: InkResponse(
onTap:
provider.submitLoading
? null
: () {
//genquotedown
final insertedData = provider.getFormData();
provider
.crmLeadDetailsGenerateQuoteSubmitAPIFunction(
context,
widget.leadId,
insertedData,
"genquotedown",
);
},
child: Container(
height: 45,
alignment: Alignment.center,
margin: const EdgeInsets.symmetric(
horizontal: 10,
vertical: 15,
),
padding: const EdgeInsets.symmetric(
horizontal: 10,
vertical: 5,
),
decoration: BoxDecoration(
// color: AppColors.app_blue,
borderRadius: BorderRadius.circular(10),
),
child:
provider.submitLoading
? CircularProgressIndicator.adaptive(
valueColor: AlwaysStoppedAnimation<Color>(
AppColors.app_blue,
),
)
: SvgPicture.asset(
"assets/svg/download_quote.svg",
),
),
),
),
SizedBox(width: 10),
Expanded(
child: InkResponse(
onTap:
provider.submitLoading
? null
: () {
//genquotemail,
final insertedData = provider.getFormData();
provider
.crmLeadDetailsGenerateQuoteSubmitAPIFunction(
context,
widget.leadId,
insertedData,
"genquotemail",
);
},
child: Container(
height: 45,
alignment: Alignment.center,
margin: const EdgeInsets.symmetric(
horizontal: 10,
vertical: 15,
),
padding: const EdgeInsets.symmetric(
horizontal: 10,
vertical: 5,
),
decoration: BoxDecoration(
// color: AppColors.app_blue,
borderRadius: BorderRadius.circular(10),
),
child:
provider.submitLoading
? CircularProgressIndicator.adaptive(
valueColor: AlwaysStoppedAnimation<Color>(
AppColors.app_blue,
),
)
: SvgPicture.asset(
"assets/svg/mail_quote.svg",
),
),
),
),
SizedBox(width: 10),
Expanded(
child: InkResponse(
onTap:
provider.submitLoading
? null
: () {
//genquotewhatsapp,
final insertedData = provider.getFormData();
provider
.crmLeadDetailsGenerateQuoteSubmitAPIFunction(
context,
widget.leadId,
insertedData,
"genquotewhatsapp",
);
},
child: Container(
height: 45,
alignment: Alignment.center,
margin: const EdgeInsets.symmetric(
horizontal: 10,
vertical: 15,
),
padding: const EdgeInsets.symmetric(
horizontal: 10,
vertical: 5,
),
decoration: BoxDecoration(
// color: AppColors.app_blue,
borderRadius: BorderRadius.circular(10),
),
child:
provider.submitLoading
? CircularProgressIndicator.adaptive(
valueColor: AlwaysStoppedAnimation<Color>(
AppColors.app_blue,
),
)
: SvgPicture.asset(
"assets/svg/whatsapp_quote.svg",
),
),
),
),
SizedBox(width: 10),
Expanded(
child: InkResponse(
onTap:
provider.submitLoading
? null
: () {
//genquotewhatsappbymynum,
final insertedData = provider.getFormData();
provider
.crmLeadDetailsGenerateQuoteSubmitAPIFunction(
context,
widget.leadId,
insertedData,
"genquotewhatsappbymynum",
);
},
child: Container(
height: 45,
alignment: Alignment.center,
margin: const EdgeInsets.symmetric(
horizontal: 10,
vertical: 15,
),
padding: const EdgeInsets.symmetric(
horizontal: 10,
vertical: 5,
),
decoration: BoxDecoration(
// color: AppColors.app_blue,
borderRadius: BorderRadius.circular(10),
),
child:
provider.submitLoading
? CircularProgressIndicator.adaptive(
valueColor: AlwaysStoppedAnimation<Color>(
AppColors.app_blue,
),
)
: SvgPicture.asset(
"assets/svg/whatsapp_quote_self.svg",
),
),
),
),
],
),
),
),
),
),
);
},
);
}
}
......@@ -61,6 +61,7 @@ import '../Models/UpdatePasswordResponse.dart';
import '../Models/VersionsResponse.dart';
import '../Models/ViewVisitDetailsResponse.dart';
import '../Models/commonModels/commonAddAccountsSubmitResponse.dart';
import '../Models/crmModels/crmAddFollowUpResponse.dart';
import '../Models/crmModels/crmDashboardResponse.dart';
import '../Models/crmModels/crmPendingTasksResponse.dart';
import '../Models/crmModels/crmUniversalSearchResponse.dart';
......@@ -3319,24 +3320,18 @@ class ApiCalling {
static Future<crmDashboardResponse?> crmDashboardAPI(
empId,
session,
mode,
from,
to,
teamemployee,
emp_loc
) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
'mode': (mode).toString(),
'from': (from).toString(),
'to': (to).toString(),
'teamemployee': (teamemployee).toString(),
'emp_loc':emp_loc.toString()
};
final res = await post(data, crmDashboardUrl, {});
if (res != null) {
print(data);
debugPrint(res.body);
print(jsonDecode(res.body)['nearby_leads']);
return crmDashboardResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
......@@ -3412,7 +3407,7 @@ class ApiCalling {
final res = await post(data, crmLeadListViewUrl, {});
if (res != null) {
print(data);
debugPrint("ListView: ${res.body}");
debugPrint("ListView2: ${res.body}");
return LeadListViewResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
......@@ -3634,6 +3629,92 @@ class ApiCalling {
}
}
static Future<CommonResponse?> crmLeadDetailsAddEditProductsAPI(
empId,
session,
lead_id,
type,lead_product_id,product_id,qty,amount
) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
'lead_id': (lead_id).toString(),
'type': (type).toString(),
'lead_product_id': (lead_product_id).toString(),
'product_id': (product_id).toString(),
'qty': (qty).toString(),
'amount': (amount).toString(),
};
final res = await post(data, crmLeadDetailsAddEditProductsUrl, {});
if (res != null) {
print("AddEditProducts $data");
debugPrint("AddEditProducts: ${res.body}");
return CommonResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static Future<crmAddFollowUpResponse?> crmLeadDetailsAddFollowUpAPI(
session_id,
emp_id,
nextapp,
orderstatus,
lead_id,
followup_feedback,
followup_type,
followupintime,
loc,
competitor,
reason,
followup_status,
next_appointment_date,
appointment_type,
sms,
app_note,
) async {
try {
Map<String, String> data = {
'session_id':session_id.toString(),
'emp_id':emp_id.toString(),
'nextapp':nextapp.toString(),
'orderstatus':orderstatus.toString(),
'lead_id':lead_id.toString(),
'followup_feedback':followup_feedback.toString(),
'followup_type':followup_type.toString(),
'followupintime':followupintime.toString(),
'loc':loc.toString(),
'competitor':competitor.toString(),
'reason':reason.toString(),
'followup_status':followup_status.toString(),
'next_appointment_date':next_appointment_date.toString(),
'appointment_type':appointment_type.toString(),
'sms':sms.toString(),
'app_note':app_note.toString(),
};
final res = await post(data, crmLeadDetailsAddFollowUpUrl, {});
if (res != null) {
print("crmAddFollowUp: $data");
debugPrint("crmAddFollowUp: ${res.body}");
return crmAddFollowUpResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static Future<crmLeadDetailsEditAccountViewResponse?>
crmLeadDetailsEditAccountViewAPI(empId, session, lead_id, mode) async {
try {
......@@ -3865,7 +3946,7 @@ class ApiCalling {
final res = await post(data, crmLeadDetailsGenerateQuotationViewUrl, {});
if (res != null) {
print(data);
debugPrint("ListView: ${res.body}");
debugPrint("ListView1: ${res.body}");
return crmLeadDetailsGenerateQuotationViewResponse.fromJson(
jsonDecode(res.body),
);
......@@ -3915,7 +3996,7 @@ class ApiCalling {
{},
);
if (res != null) {
print("Filter:${data}");
print("Filter: ${data}");
debugPrint(res.body);
return crmLeadDetailsGenerateQuotationSubmitResponse.fromJson(
jsonDecode(res.body),
......@@ -3944,7 +4025,7 @@ class ApiCalling {
final res = await post(data, crmProspectListViewUrl, {});
if (res != null) {
print(data);
debugPrint("ListView: ${res.body}");
debugPrint("ListView3: ${res.body}");
return ProspectListViewResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
......
......@@ -137,6 +137,8 @@ const crmLeadListDistrictOnStateUrl = "${baseUrl_test}get_district_on_state";
const crmLeadListSubLocOnDistrictUrl = "${baseUrl_test}get_sublocation_on_district";
const crmLeadListContactPopUpUrl = "${baseUrl_test}crm_lead_list_contact_popup";
const crmLeadDetailsUrl = "${baseUrl_test}crm_lead_details";
const crmLeadDetailsAddEditProductsUrl = "${baseUrl_test}crm_lead_details_add_edit_product";
const crmLeadDetailsAddFollowUpUrl = "${baseUrl_test}crm_lead_details_add_followup";
const crmLeadDetailsEditAccountViewUrl = "${baseUrl_test}crm_lead_details_edit_account_view";
const crmLeadDetailsEditProductsUrl = "${baseUrl_test}crm_lead_details_edit_products";
const crmLeadDetailsEditProductsViewUrl = "${baseUrl_test}crm_lead_details_edit_products_view";
......
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