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

gen erp 08-10

parent d2c9404a
...@@ -61,7 +61,6 @@ ...@@ -61,7 +61,6 @@
</intent-filter> </intent-filter>
<intent-filter android:autoVerify="true"> <intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.BROWSABLE" />
...@@ -70,6 +69,11 @@ ...@@ -70,6 +69,11 @@
<data android:host="whizzdom.gengroup.in" /> <data android:host="whizzdom.gengroup.in" />
<data android:pathPrefix="" /> <data android:pathPrefix="" />
</intent-filter> </intent-filter>
<intent-filter>
<action android:name="FLUTTER_NOTIFICATION_CLICK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity> </activity>
<meta-data <meta-data
android:name="flutter_deeplinking_enabled" android:name="flutter_deeplinking_enabled"
......
<svg width="21" height="22" viewBox="0 0 21 22" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_1_1917)">
<path d="M20.1475 11.0416C20.1475 16.6068 15.6361 21.1182 10.0709 21.1182C4.50558 21.1182 -0.00585938 16.6068 -0.00585938 11.0416C-0.00585938 5.47629 4.50558 0.964844 10.0709 0.964844C15.6361 0.964844 20.1475 5.47629 20.1475 11.0416Z" fill="#FFC107"/>
<path d="M12.1329 15.621C11.9992 15.621 11.8654 15.5826 11.7464 15.5019L6.70795 12.0667C6.4597 11.8964 6.34984 11.5849 6.43874 11.2963C6.52747 11.0077 6.79417 10.8117 7.09543 10.8117H9.15657C10.0407 10.8117 10.7598 10.0926 10.7598 9.2086C10.7598 8.32463 10.0407 7.60554 9.15657 7.60554H7.09543C6.71617 7.60554 6.40838 7.29775 6.40838 6.91849C6.40838 6.53924 6.71617 6.23145 7.09543 6.23145H9.15657C10.7982 6.23145 12.1339 7.56696 12.1339 9.2086C12.1339 10.7961 10.8843 12.0979 9.31693 12.1821L12.5214 14.367C12.8347 14.5804 12.9152 15.0083 12.7019 15.3214C12.569 15.5157 12.3528 15.621 12.1329 15.621Z" fill="#FAFAFA"/>
<path d="M13.0497 7.60554H7.09525C6.716 7.60554 6.4082 7.29775 6.4082 6.91849C6.4082 6.53924 6.716 6.23145 7.09525 6.23145H13.0497C13.429 6.23145 13.7368 6.53924 13.7368 6.91849C13.7368 7.29775 13.429 7.60554 13.0497 7.60554Z" fill="#FAFAFA"/>
<path d="M13.0497 10.1241H7.09525C6.716 10.1241 6.4082 9.8163 6.4082 9.43705C6.4082 9.0578 6.716 8.75 7.09525 8.75H13.0497C13.429 8.75 13.7368 9.0578 13.7368 9.43705C13.7368 9.8163 13.429 10.1241 13.0497 10.1241Z" fill="#FAFAFA"/>
</g>
<defs>
<clipPath id="clip0_1_1917">
<rect width="20.1534" height="20.1534" fill="white" transform="translate(-0.00585938 0.964844)"/>
</clipPath>
</defs>
</svg>
<svg width="22" height="20" viewBox="0 0 22 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M19.17 19.3281C18.2386 19.5383 11.9178 19.7886 10.9836 19.7368C10.9836 19.7368 10.1202 19.7335 9.09516 19.6516C8.48121 19.6026 7.99342 19.5604 7.42326 19.4692C6.44126 19.3112 6.01897 18.897 6.01897 18.8978C7.31357 19.7669 8.53907 18.864 8.73957 17.6281C8.80004 17.203 8.83867 16.775 8.85529 16.3459C12.996 16.3861 17.1364 16.3096 21.2766 16.1165C21.2312 16.6196 21.0878 17.3046 21.0648 17.4023C20.8736 18.23 20.3239 19.1614 19.17 19.3281ZM3.54226 2.83374C3.55271 2.51592 3.51253 2.20492 3.33051 1.99277C3.22323 1.85053 2.6603 1.42262 2.00818 1.54436C1.58347 1.62392 1.23873 1.92889 1.07158 2.32587C0.999978 2.4966 0.943901 2.67344 0.904026 2.85424C0.881927 2.95308 0.743305 3.59476 0.703125 4.09781C1.62406 4.05522 2.54485 4.01812 3.46551 3.98651C3.50047 3.51118 3.53141 3.07563 3.54226 2.83374ZM17.8926 10.1208C17.9139 11.0852 17.7785 13.7981 17.6222 15.4648C15.4091 15.5295 13.1891 15.5636 10.9893 15.5636C10.2833 15.5636 9.56728 15.56 8.85971 15.5532H8.85207C8.64495 15.5532 8.44606 15.6343 8.29792 15.7791C8.14978 15.9238 8.06414 16.1208 8.05932 16.3279C8.04398 16.7213 8.00858 17.1137 7.95324 17.5035C7.86485 18.0432 7.47791 18.4498 7.0524 18.4498C6.3396 18.4731 5.93981 18.2489 5.51712 17.9419C4.62793 17.2954 4.40573 16.1631 4.3997 16.1382C4.22653 14.6612 4.02964 11.2306 4.06018 10.1208C4.05094 9.41365 4.1088 7.76908 4.21206 6.28482C4.22412 5.71949 4.4202 3.45413 4.45314 2.73048C4.48328 1.87826 4.05134 0.909514 2.78968 0.962552C3.30399 0.777321 10.0454 0.453067 10.978 0.505703C12.2638 0.505703 14.229 0.688121 14.9297 0.859691C16.0797 1.15421 17.1879 2.33551 17.4611 3.51158C17.6463 4.23201 17.9288 8.80492 17.8926 10.1208ZM13.1891 9.22963C13.1891 9.02716 13.1087 8.83298 12.9655 8.68981C12.8224 8.54664 12.6282 8.46621 12.4257 8.46621H7.36741C7.16494 8.46621 6.97076 8.54664 6.82759 8.68981C6.68442 8.83298 6.60399 9.02716 6.60399 9.22963C6.60399 9.4321 6.68442 9.62628 6.82759 9.76945C6.97076 9.91262 7.16494 9.99305 7.36741 9.99305H12.4257C12.6282 9.99305 12.8224 9.91262 12.9655 9.76945C13.1087 9.62628 13.1891 9.4321 13.1891 9.22963ZM15.3749 6.01963C15.3749 5.81716 15.2945 5.62298 15.1513 5.47981C15.0082 5.33664 14.814 5.25621 14.6115 5.25621H7.36741C7.26716 5.25621 7.16789 5.27595 7.07526 5.31432C6.98264 5.35269 6.89848 5.40892 6.82759 5.47981C6.7567 5.5507 6.70047 5.63486 6.6621 5.72748C6.62374 5.82011 6.60399 5.91938 6.60399 6.01963C6.60399 6.11989 6.62374 6.21916 6.6621 6.31178C6.70047 6.40441 6.7567 6.48856 6.82759 6.55945C6.89848 6.63035 6.98264 6.68658 7.07526 6.72494C7.16789 6.76331 7.26716 6.78306 7.36741 6.78306H14.6111C14.7114 6.78311 14.8107 6.7634 14.9034 6.72506C14.996 6.68672 15.0803 6.63049 15.1512 6.5596C15.2221 6.4887 15.2784 6.40452 15.3168 6.31187C15.3552 6.21923 15.3749 6.11992 15.3749 6.01963Z" fill="url(#paint0_linear_1_12857)"/>
<defs>
<linearGradient id="paint0_linear_1_12857" x1="18.9215" y1="27.2575" x2="-3.66815" y2="-12.5131" gradientUnits="userSpaceOnUse">
<stop stop-color="#0893B1"/>
<stop offset="1" stop-color="#68D0E6"/>
</linearGradient>
</defs>
</svg>
...@@ -141,6 +141,8 @@ class AccountDetails { ...@@ -141,6 +141,8 @@ class AccountDetails {
String? state; String? state;
String? district; String? district;
String? subLocality; String? subLocality;
String? pincode;
String? date;
AccountDetails({ AccountDetails({
this.id, this.id,
...@@ -158,6 +160,8 @@ class AccountDetails { ...@@ -158,6 +160,8 @@ class AccountDetails {
this.state, this.state,
this.district, this.district,
this.subLocality, this.subLocality,
this.pincode,
this.date,
}); });
AccountDetails.fromJson(Map<String, dynamic> json) { AccountDetails.fromJson(Map<String, dynamic> json) {
...@@ -176,8 +180,12 @@ class AccountDetails { ...@@ -176,8 +180,12 @@ class AccountDetails {
state = json['state']; state = json['state'];
district = json['district']; district = json['district'];
subLocality = json['sub_locality']; subLocality = json['sub_locality'];
pincode = json['pincode'];
date = json['date'];
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = Map<String, dynamic>(); final Map<String, dynamic> data = Map<String, dynamic>();
data['id'] = id; data['id'] = id;
...@@ -195,6 +203,8 @@ class AccountDetails { ...@@ -195,6 +203,8 @@ class AccountDetails {
data['state'] = state; data['state'] = state;
data['district'] = district; data['district'] = district;
data['sub_locality'] = subLocality; data['sub_locality'] = subLocality;
data['pincode'] = pincode;
data['date'] = date;
return data; return data;
} }
} }
...@@ -341,6 +341,7 @@ class LeadProducts { ...@@ -341,6 +341,7 @@ class LeadProducts {
String? createdDatetime; String? createdDatetime;
String? updatedDatetime; String? updatedDatetime;
String? productName; String? productName;
String? remarks;
LeadProducts({ LeadProducts({
this.id, this.id,
...@@ -355,6 +356,7 @@ class LeadProducts { ...@@ -355,6 +356,7 @@ class LeadProducts {
this.createdDatetime, this.createdDatetime,
this.updatedDatetime, this.updatedDatetime,
this.productName, this.productName,
this.remarks
}); });
LeadProducts.fromJson(Map<String, dynamic> json) { LeadProducts.fromJson(Map<String, dynamic> json) {
...@@ -370,6 +372,7 @@ class LeadProducts { ...@@ -370,6 +372,7 @@ class LeadProducts {
createdDatetime = json['created_datetime']; createdDatetime = json['created_datetime'];
updatedDatetime = json['updated_datetime']; updatedDatetime = json['updated_datetime'];
productName = json['product_name']; productName = json['product_name'];
remarks = json['remarks'];
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
...@@ -386,6 +389,7 @@ class LeadProducts { ...@@ -386,6 +389,7 @@ class LeadProducts {
data['created_datetime'] = createdDatetime; data['created_datetime'] = createdDatetime;
data['updated_datetime'] = updatedDatetime; data['updated_datetime'] = updatedDatetime;
data['product_name'] = productName; data['product_name'] = productName;
data['remarks'] = remarks;
return data; return data;
} }
} }
......
...@@ -77,6 +77,7 @@ class LeadProducts { ...@@ -77,6 +77,7 @@ class LeadProducts {
String? createdDatetime; String? createdDatetime;
String? updatedDatetime; String? updatedDatetime;
String? productName; String? productName;
String? remarks;
LeadProducts({ LeadProducts({
this.id, this.id,
...@@ -90,6 +91,7 @@ class LeadProducts { ...@@ -90,6 +91,7 @@ class LeadProducts {
this.createdDatetime, this.createdDatetime,
this.updatedDatetime, this.updatedDatetime,
this.productName, this.productName,
this.remarks
}); });
LeadProducts.fromJson(Map<String, dynamic> json) { LeadProducts.fromJson(Map<String, dynamic> json) {
...@@ -104,6 +106,7 @@ class LeadProducts { ...@@ -104,6 +106,7 @@ class LeadProducts {
createdDatetime = json['created_datetime']; createdDatetime = json['created_datetime'];
updatedDatetime = json['updated_datetime']; updatedDatetime = json['updated_datetime'];
productName = json['product_name']; productName = json['product_name'];
remarks = json["remarks"];
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
...@@ -119,6 +122,7 @@ class LeadProducts { ...@@ -119,6 +122,7 @@ class LeadProducts {
data['created_datetime'] = createdDatetime; data['created_datetime'] = createdDatetime;
data['updated_datetime'] = updatedDatetime; data['updated_datetime'] = updatedDatetime;
data['product_name'] = productName; data['product_name'] = productName;
data['remarks'] = remarks;
return data; return data;
} }
} }
...@@ -87,17 +87,20 @@ class Employees { ...@@ -87,17 +87,20 @@ class Employees {
String? id; String? id;
String? name; String? name;
Employees({this.id, this.name}); Employees({this.id, this.name});
Employees.fromJson(Map<String, dynamic> json) { Employees.fromJson(Map<String, dynamic> json) {
id = json['id']; id = json['id'];
name = json['name']; name = json['name'];
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{}; final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id; data['id'] = id;
data['name'] = name; data['name'] = name;
return data; return data;
} }
} }
...@@ -162,18 +165,21 @@ class States { ...@@ -162,18 +165,21 @@ class States {
class Products { class Products {
String? id; String? id;
String? name; String? name;
String? remarks;
Products({this.id, this.name}); Products({this.id, this.name});
Products.fromJson(Map<String, dynamic> json) { Products.fromJson(Map<String, dynamic> json) {
id = json['id']; id = json['id'];
name = json['name']; name = json['name'];
remarks = json['remarks'];
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{}; final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id; data['id'] = id;
data['name'] = name; data['name'] = name;
data['remarks'];
return data; return data;
} }
} }
...@@ -43,6 +43,7 @@ class ProductsData { ...@@ -43,6 +43,7 @@ class ProductsData {
String? isExists; String? isExists;
String? createdDatetime; String? createdDatetime;
String? updatedDatetime; String? updatedDatetime;
String? remarks;
ProductsData({ ProductsData({
this.id, this.id,
...@@ -60,6 +61,7 @@ class ProductsData { ...@@ -60,6 +61,7 @@ class ProductsData {
this.isExists, this.isExists,
this.createdDatetime, this.createdDatetime,
this.updatedDatetime, this.updatedDatetime,
this.remarks,
}); });
ProductsData.fromJson(Map<String, dynamic> json) { ProductsData.fromJson(Map<String, dynamic> json) {
...@@ -78,6 +80,7 @@ class ProductsData { ...@@ -78,6 +80,7 @@ class ProductsData {
isExists = json['is_exists']; isExists = json['is_exists'];
createdDatetime = json['created_datetime']; createdDatetime = json['created_datetime'];
updatedDatetime = json['updated_datetime']; updatedDatetime = json['updated_datetime'];
remarks = json['remarks'];
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
...@@ -97,6 +100,7 @@ class ProductsData { ...@@ -97,6 +100,7 @@ class ProductsData {
data['is_exists'] = isExists; data['is_exists'] = isExists;
data['created_datetime'] = createdDatetime; data['created_datetime'] = createdDatetime;
data['updated_datetime'] = updatedDatetime; data['updated_datetime'] = updatedDatetime;
data['remarks'] = remarks;
return data; return data;
} }
} }
class AdvanceListResponse {
List<AdvanceList>? advanceList;
String? error;
String? message;
int? sessionExists;
AdvanceListResponse(
{this.advanceList, this.error, this.message, this.sessionExists});
AdvanceListResponse.fromJson(Map<String, dynamic> json) {
if (json['advance_list'] != null) {
advanceList = <AdvanceList>[];
json['advance_list'].forEach((v) {
advanceList!.add(new AdvanceList.fromJson(v));
});
}
error = json['error'];
message = json['message'];
sessionExists = json['session_exists'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.advanceList != null) {
data['advance_list'] = this.advanceList!.map((v) => v.toJson()).toList();
}
data['error'] = this.error;
data['message'] = this.message;
data['session_exists'] = this.sessionExists;
return data;
}
}
class AdvanceList {
String? id;
String? createdDatetime;
String? narration;
String? issuedAmount;
String? deductedAmount;
String? type;
AdvanceList(
{this.id,
this.createdDatetime,
this.narration,
this.issuedAmount,
this.deductedAmount,
this.type
});
AdvanceList.fromJson(Map<String, dynamic> json) {
id = json['id'];
createdDatetime = json['created_datetime'];
narration = json['narration'];
issuedAmount = json['issued_amount'];
deductedAmount = json['deducted_amount'];
type = json['type'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['created_datetime'] = this.createdDatetime;
data['narration'] = this.narration;
data['issued_amount'] = this.issuedAmount;
data['deducted_amount'] = this.deductedAmount;
data['type'] = this.type;
return data;
}
}
class CasualLeaveHistoryResponse {
List<CasualLeaveHistory>? casualLeaveHistory;
String? error;
String? message;
int? sessionExists;
CasualLeaveHistoryResponse(
{this.casualLeaveHistory, this.error, this.message, this.sessionExists});
CasualLeaveHistoryResponse.fromJson(Map<String, dynamic> json) {
if (json['casual_leave_history'] != null) {
casualLeaveHistory = <CasualLeaveHistory>[];
json['casual_leave_history'].forEach((v) {
casualLeaveHistory!.add(new CasualLeaveHistory.fromJson(v));
});
}
error = json['error'];
message = json['message'];
sessionExists = json['session_exists'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.casualLeaveHistory != null) {
data['casual_leave_history'] =
this.casualLeaveHistory!.map((v) => v.toJson()).toList();
}
data['error'] = this.error;
data['message'] = this.message;
data['session_exists'] = this.sessionExists;
return data;
}
}
class CasualLeaveHistory {
String? des;
String? type;
String? cnt;
String? year;
CasualLeaveHistory({this.des, this.type, this.cnt, this.year});
CasualLeaveHistory.fromJson(Map<String, dynamic> json) {
des = json['des'];
type = json['type'];
cnt = json['cnt'];
year = json['year'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['des'] = this.des;
data['type'] = this.type;
data['cnt'] = this.cnt;
data['year'] = this.year;
return data;
}
}
import '../commonModels/commonAccountLedgerResponse.dart';
class AddOrderViewResponse { class AddOrderViewResponse {
List<Employees>? employees; List<Employees>? employees;
List<States>? states; List<States>? states;
...@@ -8,6 +10,15 @@ class AddOrderViewResponse { ...@@ -8,6 +10,15 @@ class AddOrderViewResponse {
String? error; String? error;
String? message; String? message;
// 🔹 New fields
AccountDetails? accountDetails;
List<Product>? productList;
String? feedback;
String? followupType;
String? inTime;
String? loc;
int? sessionExists;
AddOrderViewResponse({ AddOrderViewResponse({
this.employees, this.employees,
this.states, this.states,
...@@ -19,6 +30,7 @@ class AddOrderViewResponse { ...@@ -19,6 +30,7 @@ class AddOrderViewResponse {
this.message, this.message,
}); });
AddOrderViewResponse.fromJson(Map<String, dynamic> json) { AddOrderViewResponse.fromJson(Map<String, dynamic> json) {
if (json['employees'] != null) { if (json['employees'] != null) {
employees = <Employees>[]; employees = <Employees>[];
...@@ -38,9 +50,18 @@ class AddOrderViewResponse { ...@@ -38,9 +50,18 @@ class AddOrderViewResponse {
saleProducts!.add(SaleProducts.fromJson(v)); saleProducts!.add(SaleProducts.fromJson(v));
}); });
} }
unloadingScope = json['unloading_scope'].cast<String>(); // 🔹 add this
freightScope = json['freight_scope'].cast<String>(); accountDetails = json['account_details'] != null
erectionScope = json['erection_scope'].cast<String>(); ? AccountDetails.fromJson(json['account_details']) // from addOrderAccontDetailsResponse.dart
: null;
unloadingScope =
(json['unloading_scope'] as List?)?.map((e) => e.toString()).toList();
freightScope =
(json['freight_scope'] as List?)?.map((e) => e.toString()).toList();
erectionScope =
(json['erection_scope'] as List?)?.map((e) => e.toString()).toList();
error = json['error']; error = json['error'];
message = json['message']; message = json['message'];
} }
...@@ -84,6 +105,25 @@ class Employees { ...@@ -84,6 +105,25 @@ class Employees {
} }
} }
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 = <String, dynamic>{};
data['id'] = id;
data['name'] = name;
return data;
}
}
class SaleProducts { class SaleProducts {
String? id; String? id;
String? productCode; String? productCode;
...@@ -105,6 +145,7 @@ class SaleProducts { ...@@ -105,6 +145,7 @@ class SaleProducts {
String? refId; String? refId;
String? price; String? price;
String? type; String? type;
String? status; // ✅ Added field
String? productionProcessId; String? productionProcessId;
String? createdBy; String? createdBy;
String? datetime; String? datetime;
...@@ -132,6 +173,7 @@ class SaleProducts { ...@@ -132,6 +173,7 @@ class SaleProducts {
this.refId, this.refId,
this.price, this.price,
this.type, this.type,
this.status,
this.productionProcessId, this.productionProcessId,
this.createdBy, this.createdBy,
this.datetime, this.datetime,
...@@ -160,6 +202,7 @@ class SaleProducts { ...@@ -160,6 +202,7 @@ class SaleProducts {
refId = json['ref_id']; refId = json['ref_id'];
price = json['price']; price = json['price'];
type = json['type']; type = json['type'];
status = json['status']; // ✅ Added
productionProcessId = json['production_process_id']; productionProcessId = json['production_process_id'];
createdBy = json['created_by']; createdBy = json['created_by'];
datetime = json['datetime']; datetime = json['datetime'];
...@@ -189,6 +232,7 @@ class SaleProducts { ...@@ -189,6 +232,7 @@ class SaleProducts {
data['ref_id'] = refId; data['ref_id'] = refId;
data['price'] = price; data['price'] = price;
data['type'] = type; data['type'] = type;
data['status'] = status; // ✅ Added
data['production_process_id'] = productionProcessId; data['production_process_id'] = productionProcessId;
data['created_by'] = createdBy; data['created_by'] = createdBy;
data['datetime'] = datetime; data['datetime'] = datetime;
...@@ -198,21 +242,25 @@ class SaleProducts { ...@@ -198,21 +242,25 @@ class SaleProducts {
} }
} }
class States {
String? id; class Product {
String? productId;
String? name; String? name;
String? price;
States({this.id, this.name}); Product({this.productId, this.name, this.price});
States.fromJson(Map<String, dynamic> json) { Product.fromJson(Map<String, dynamic> json) {
id = json['id']; productId = json['product_id'];
name = json['name']; name = json['name'];
price = json['price'];
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{}; final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id; data['product_id'] = productId;
data['name'] = name; data['name'] = name;
data['price'] = price;
return data; return data;
} }
} }
...@@ -1235,20 +1235,27 @@ class Leadlistprovider extends ChangeNotifier { ...@@ -1235,20 +1235,27 @@ class Leadlistprovider extends ChangeNotifier {
'empId: ${HomeProv.empId}, session: ${HomeProv.session}, pageNumber: $_currentPage', 'empId: ${HomeProv.empId}, session: ${HomeProv.session}, pageNumber: $_currentPage',
); );
if (data != null && data.error == "0") { if(data != null){
if ( data.error == "0") {
print("Lead List Length ${data.leadList!.length}");
if (append) { if (append) {
_crmLeadList.addAll(data.leadList ?? []); _crmLeadList.addAll(data.leadList ?? []);
} else { } else {
_crmLeadList = data.leadList ?? []; _crmLeadList = data.leadList ?? [];
} }
if (data.leadList == null || data.leadList!.length < 10) { if (data.leadList!.length < 15) {
_hasMoreData = false; // no more pages _hasMoreData = false; // no more pages
} }
} else { } else if(data.error=="1") {
if (!append) _errorMessage = "No leads found!"; if (!append) _errorMessage = "No leads found!";
_hasMoreData = false; _hasMoreData = false;
} }
}else{
_hasMoreData = false;
}
} catch (e) { } catch (e) {
_errorMessage = "Error: $e"; _errorMessage = "Error: $e";
} }
......
...@@ -41,6 +41,7 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier { ...@@ -41,6 +41,7 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier {
TextEditingController addProductPriceController = TextEditingController(); TextEditingController addProductPriceController = TextEditingController();
TextEditingController addQuantityController = TextEditingController(); TextEditingController addQuantityController = TextEditingController();
TextEditingController addTotalAmountController = TextEditingController(); TextEditingController addTotalAmountController = TextEditingController();
TextEditingController remarkController = TextEditingController();
TextEditingController companyNameController = TextEditingController(); TextEditingController companyNameController = TextEditingController();
TextEditingController contactPersonNameController = TextEditingController(); TextEditingController contactPersonNameController = TextEditingController();
...@@ -58,6 +59,8 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier { ...@@ -58,6 +59,8 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier {
List<Map<String, dynamic>> _productRows = []; // For backend List<Map<String, dynamic>> _productRows = []; // For backend
List<Map<String, dynamic>> get productRows => _productRows; List<Map<String, dynamic>> get productRows => _productRows;
ProductsData? _selectedProductsDeatilsData; ProductsData? _selectedProductsDeatilsData;
List<Employees> _employeesList = []; List<Employees> _employeesList = [];
List<Sources> _sourcesList = []; List<Sources> _sourcesList = [];
...@@ -84,6 +87,7 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier { ...@@ -84,6 +87,7 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier {
String? _selectedStatesId; String? _selectedStatesId;
String? _selectedStatesValue; String? _selectedStatesValue;
Products? _selectedProducts; Products? _selectedProducts;
String? _selectedProductsRemarks;
String? _selectedProductsId; String? _selectedProductsId;
String? _selectedProductsValue; String? _selectedProductsValue;
String? _selectedSalutation; String? _selectedSalutation;
...@@ -143,6 +147,8 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier { ...@@ -143,6 +147,8 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier {
Products? get selectedProducts => _selectedProducts; Products? get selectedProducts => _selectedProducts;
String? get selectedProductsRemarks => _selectedProductsRemarks;
String? get selectedProductsId => _selectedProductsId; String? get selectedProductsId => _selectedProductsId;
String? get selectedProductsValue => _selectedProductsValue; String? get selectedProductsValue => _selectedProductsValue;
...@@ -263,6 +269,7 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier { ...@@ -263,6 +269,7 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier {
if (value != null) { if (value != null) {
_selectedProductsId = value.id; _selectedProductsId = value.id;
_selectedProductsValue = value.name; _selectedProductsValue = value.name;
_selectedProductsRemarks = value.remarks;
} }
notifyListeners(); notifyListeners();
...@@ -278,6 +285,11 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier { ...@@ -278,6 +285,11 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
set selectedProductsRemark(String? value) {
_selectedProductsRemarks = value;
notifyListeners();
}
set selectedSalutation(String? value) { set selectedSalutation(String? value) {
_selectedSalutation = value; _selectedSalutation = value;
salutationError = null; salutationError = null;
...@@ -430,6 +442,7 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier { ...@@ -430,6 +442,7 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier {
addProductPriceController.text = product['price'] ?? ''; addProductPriceController.text = product['price'] ?? '';
addQuantityController.text = product['qty'] ?? ''; addQuantityController.text = product['qty'] ?? '';
addTotalAmountController.text = product['net_price'] ?? ''; addTotalAmountController.text = product['net_price'] ?? '';
remarkController.text = product['remarks'] ?? '';
notifyListeners(); notifyListeners();
} }
...@@ -443,6 +456,7 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier { ...@@ -443,6 +456,7 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier {
void addInitializeForm(BuildContext context) { void addInitializeForm(BuildContext context) {
addProductPriceController.clear(); addProductPriceController.clear();
addQuantityController.clear(); addQuantityController.clear();
remarkController.clear();
addTotalAmountController.clear(); addTotalAmountController.clear();
notifyListeners(); notifyListeners();
...@@ -477,6 +491,44 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier { ...@@ -477,6 +491,44 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier {
} catch (e) {} } catch (e) {}
} }
/// check phone number and name existence on server
Future<bool> checkAccountFieldExistence(
BuildContext context, {
required String type, // e.g. "mob1", "mob2", "name"
required String typeValue,
}) async {
try {
final prov = Provider.of<HomescreenNotifier>(context, listen: false);
final res = await ApiCalling.crmCheckAccountFieldsApi(
prov.empId,
prov.session,
typeValue,
type,
);
if (res != null) {
if (res.error == "0") {
// ✅ No error -> field available
debugPrint("✅ $type is available: $typeValue");
return true;
} else {
// ❌ Field already exists
debugPrint("⚠️ $type already exists: $typeValue");
return false;
}
} else {
debugPrint("❌ Null Response while checking $type");
return false;
}
} catch (e, s) {
debugPrint("❌ Error in checkAccountFieldExistence: $e \n$s");
return false;
}
}
Future<void> crmLeadListDistrictsOnStateAPIFunction( Future<void> crmLeadListDistrictsOnStateAPIFunction(
context, context,
mode, mode,
...@@ -645,6 +697,7 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier { ...@@ -645,6 +697,7 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier {
if (data != null && data.error == "0") { if (data != null && data.error == "0") {
_selectedProductsDeatilsData = data.productsData!; _selectedProductsDeatilsData = data.productsData!;
addProductPriceController.text = data.productsData!.price!; addProductPriceController.text = data.productsData!.price!;
remarkController.text = data.productsData!.remarks!;
notifyListeners(); notifyListeners();
} }
} catch (e, s) { } catch (e, s) {
...@@ -662,10 +715,8 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier { ...@@ -662,10 +715,8 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
onChangeContactPersonName(value) {
nameError = "";
notifyListeners();
}
onChangeAlternatemobile(value) { onChangeAlternatemobile(value) {
AlternatemobileError = ""; AlternatemobileError = "";
...@@ -677,11 +728,51 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier { ...@@ -677,11 +728,51 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
onChangemobile(value) { Future<void> onChangeContactPersonName(BuildContext context, String value) async {
nameError = "";
if (value.isEmpty) {
nameError = "Name cannot be empty";
} else if (value.length < 3) {
nameError = "Name must be at least 3 characters";
} else {
final exists = await checkAccountFieldExistence(
context,
type: "name",
typeValue: value,
);
if (!exists) {
nameError = "Name already exists";
} else {
nameError = null;
}
}
notifyListeners();
}
Future<void> onChangemobile(BuildContext context, String value) async {
mobileError = ""; mobileError = "";
if (value.isEmpty) {
mobileError = "Mobile number cannot be empty";
} else if (value.length != 10) {
mobileError = "Mobile number must be 10 digits";
} else {
// ✅ Call API to check existence
final exists = await checkAccountFieldExistence(
context,
type: "mob1", // or "mob2" depending on which mobile field you are validating
typeValue: value,
);
if (!exists) {
mobileError = "Mobile number already exists";
} else {
mobileError = null;
}
}
notifyListeners(); notifyListeners();
} }
onChangeaddress(value) { onChangeaddress(value) {
addressError = ""; addressError = "";
notifyListeners(); notifyListeners();
...@@ -715,6 +806,7 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier { ...@@ -715,6 +806,7 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier {
void resetForm() { void resetForm() {
checkDropdownReset(); checkDropdownReset();
_productRows.clear(); _productRows.clear();
remarkController.clear();
sourceSearchController.clear(); sourceSearchController.clear();
referenceSearchController.clear(); referenceSearchController.clear();
teamSearchController.clear(); teamSearchController.clear();
...@@ -752,6 +844,7 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier { ...@@ -752,6 +844,7 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier {
_selectedStatesId = null; _selectedStatesId = null;
_selectedStatesValue = null; _selectedStatesValue = null;
_selectedProducts = null; _selectedProducts = null;
_selectedProductsRemarks = null;
_selectedProductsId = null; _selectedProductsId = null;
_selectedProductsValue = null; _selectedProductsValue = null;
_selectedSalutation = null; _selectedSalutation = null;
...@@ -798,6 +891,7 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier { ...@@ -798,6 +891,7 @@ class Addnewleadsandprospectsprovider extends ChangeNotifier {
_selectedProducts != null) { _selectedProducts != null) {
_selectedProductsId = null; _selectedProductsId = null;
_selectedProductsValue = null; _selectedProductsValue = null;
_selectedProductsRemarks = null;
} }
if (!_employeesList.contains(_selectedEmployees) && if (!_employeesList.contains(_selectedEmployees) &&
_selectedEmployees != null) { _selectedEmployees != null) {
......
...@@ -23,11 +23,12 @@ class Addprospectleadsprovider extends ChangeNotifier { ...@@ -23,11 +23,12 @@ class Addprospectleadsprovider extends ChangeNotifier {
Products? _selectedProducts; Products? _selectedProducts;
String? _selectedProductsID; String? _selectedProductsID;
String? _selectedProductsName; String? _selectedProductsName;
String? _selectedProductsRemark;
ProductsData? _selectedProductsDeatilsData; ProductsData? _selectedProductsDeatilsData;
TextEditingController addLeadProductPriceController = TextEditingController(); TextEditingController addLeadProductPriceController = TextEditingController();
TextEditingController addLeadProductQtyController = TextEditingController(); TextEditingController addLeadProductQtyController = TextEditingController();
TextEditingController addLeadProductTotalPriceController = TextEditingController addLeadProductTotalPriceController = TextEditingController();
TextEditingController(); TextEditingController addLeadProductRemarksController = TextEditingController();
String? qtyError; String? qtyError;
String? priceError; String? priceError;
...@@ -36,8 +37,11 @@ class Addprospectleadsprovider extends ChangeNotifier { ...@@ -36,8 +37,11 @@ class Addprospectleadsprovider extends ChangeNotifier {
List<TextEditingController> editProductPriceControllers = []; List<TextEditingController> editProductPriceControllers = [];
List<TextEditingController> editQuantityControllers = []; List<TextEditingController> editQuantityControllers = [];
List<TextEditingController> editTotalAmountControllers = []; List<TextEditingController> editTotalAmountControllers = [];
List<TextEditingController> editRemarkControllers = [];
final List<String?> _selectedProductIds = []; final List<String?> _selectedProductIds = [];
final List<String?> _selectedValues = []; final List<String?> _selectedValues = [];
bool _submitLoading = false; bool _submitLoading = false;
ProductsData? get selectedProductsDetailsData => _selectedProductsDeatilsData; ProductsData? get selectedProductsDetailsData => _selectedProductsDeatilsData;
...@@ -49,6 +53,8 @@ class Addprospectleadsprovider extends ChangeNotifier { ...@@ -49,6 +53,8 @@ class Addprospectleadsprovider extends ChangeNotifier {
String? get selectedProductsName => _selectedProductsName; String? get selectedProductsName => _selectedProductsName;
String? get selectedProductsRemark => _selectedProductsRemark;
List<String?> get selectedProductIds => _selectedProductIds; List<String?> get selectedProductIds => _selectedProductIds;
List<String?> get selectedValues => _selectedValues; List<String?> get selectedValues => _selectedValues;
...@@ -193,6 +199,7 @@ class Addprospectleadsprovider extends ChangeNotifier { ...@@ -193,6 +199,7 @@ class Addprospectleadsprovider extends ChangeNotifier {
"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,
"remarks": editRemarkControllers[i].text,
}; };
insertData.add(rowData); insertData.add(rowData);
} }
...@@ -282,6 +289,7 @@ class Addprospectleadsprovider extends ChangeNotifier { ...@@ -282,6 +289,7 @@ class Addprospectleadsprovider extends ChangeNotifier {
addLeadProductQtyController.text, addLeadProductQtyController.text,
addLeadProductPriceController.text, addLeadProductPriceController.text,
leadStatus, leadStatus,
addLeadProductRemarksController.text,
); );
if (data != null) { if (data != null) {
if (data.error == "0") { if (data.error == "0") {
...@@ -364,6 +372,7 @@ class Addprospectleadsprovider extends ChangeNotifier { ...@@ -364,6 +372,7 @@ class Addprospectleadsprovider extends ChangeNotifier {
statusError = null; statusError = null;
searchController.clear(); searchController.clear();
editProductPriceControllers.clear(); editProductPriceControllers.clear();
addLeadProductRemarksController.clear();
editQuantityControllers.clear(); editQuantityControllers.clear();
editTotalAmountControllers.clear(); editTotalAmountControllers.clear();
_selectedProductIds.clear(); _selectedProductIds.clear();
...@@ -375,6 +384,7 @@ class Addprospectleadsprovider extends ChangeNotifier { ...@@ -375,6 +384,7 @@ class Addprospectleadsprovider extends ChangeNotifier {
_selectedEmployeeValue = null; _selectedEmployeeValue = null;
_selectedProductsID = null; _selectedProductsID = null;
_selectedProductsName = null; _selectedProductsName = null;
_selectedProductsRemark = null;
addLeadProductPriceController.clear(); addLeadProductPriceController.clear();
addLeadProductQtyController.clear(); addLeadProductQtyController.clear();
addLeadProductTotalPriceController.clear(); addLeadProductTotalPriceController.clear();
...@@ -393,6 +403,8 @@ class Addprospectleadsprovider extends ChangeNotifier { ...@@ -393,6 +403,8 @@ class Addprospectleadsprovider extends ChangeNotifier {
_selectedProducts != null) { _selectedProducts != null) {
_selectedProductsID = null; _selectedProductsID = null;
_selectedProductsName = null; _selectedProductsName = null;
_selectedProductsRemark = null;
} }
notifyListeners(); notifyListeners();
} }
......
...@@ -141,6 +141,7 @@ class Editproductlistprovider extends ChangeNotifier { ...@@ -141,6 +141,7 @@ class Editproductlistprovider extends ChangeNotifier {
TextEditingController addEditProductPriceController = TextEditingController(); TextEditingController addEditProductPriceController = TextEditingController();
TextEditingController addEditQuantityController = TextEditingController(); TextEditingController addEditQuantityController = TextEditingController();
TextEditingController addEditTotalAmountController = TextEditingController(); TextEditingController addEditTotalAmountController = TextEditingController();
TextEditingController addEditRemarkController = TextEditingController();
List<Products> _productsList = []; List<Products> _productsList = [];
List<LeadProducts> _leadProductsList = []; List<LeadProducts> _leadProductsList = [];
Products? _selectedProducts; Products? _selectedProducts;
...@@ -150,12 +151,14 @@ class Editproductlistprovider extends ChangeNotifier { ...@@ -150,12 +151,14 @@ class Editproductlistprovider extends ChangeNotifier {
List<TextEditingController> editProductPriceControllers = []; List<TextEditingController> editProductPriceControllers = [];
List<TextEditingController> editQuantityControllers = []; List<TextEditingController> editQuantityControllers = [];
List<TextEditingController> editTotalAmountControllers = []; List<TextEditingController> editTotalAmountControllers = [];
List<TextEditingController> editRemarkControllers = [];
final List<String?> _selectedProductIds = []; final List<String?> _selectedProductIds = [];
final List<String?> _selectedValues = []; final List<String?> _selectedValues = [];
bool _submitLoading = false; bool _submitLoading = false;
String? qtyError; String? qtyError;
String? priceError; String? priceError;
String? productError; String? productError;
String? remarkError;
bool get editProductDetailsClicked => _editProductDetailsClicked; bool get editProductDetailsClicked => _editProductDetailsClicked;
bool get editContactDetailsClicked => _editContactDetailsClicked; bool get editContactDetailsClicked => _editContactDetailsClicked;
...@@ -234,6 +237,7 @@ class Editproductlistprovider extends ChangeNotifier { ...@@ -234,6 +237,7 @@ class Editproductlistprovider extends ChangeNotifier {
editProductPriceControllers.clear(); editProductPriceControllers.clear();
editQuantityControllers.clear(); editQuantityControllers.clear();
editTotalAmountControllers.clear(); editTotalAmountControllers.clear();
editRemarkControllers.clear();
_selectedProductIds.clear(); _selectedProductIds.clear();
_selectedValues.clear(); _selectedValues.clear();
...@@ -253,6 +257,9 @@ class Editproductlistprovider extends ChangeNotifier { ...@@ -253,6 +257,9 @@ class Editproductlistprovider extends ChangeNotifier {
.toString(), .toString(),
), ),
); );
editRemarkControllers.add(
TextEditingController(text: product.remarks?.toString() ?? ''),
);
_selectedProductIds.add(product.productId); _selectedProductIds.add(product.productId);
_selectedValues.add(product.productName); _selectedValues.add(product.productName);
} }
...@@ -281,6 +288,7 @@ class Editproductlistprovider extends ChangeNotifier { ...@@ -281,6 +288,7 @@ class Editproductlistprovider extends ChangeNotifier {
editProductPriceControllers.removeAt(index); editProductPriceControllers.removeAt(index);
editQuantityControllers.removeAt(index); editQuantityControllers.removeAt(index);
editTotalAmountControllers.removeAt(index); editTotalAmountControllers.removeAt(index);
editRemarkControllers.removeAt(index);
_selectedProductIds.removeAt(index); _selectedProductIds.removeAt(index);
_selectedValues.removeAt(index); _selectedValues.removeAt(index);
notifyListeners(); notifyListeners();
...@@ -314,6 +322,7 @@ class Editproductlistprovider extends ChangeNotifier { ...@@ -314,6 +322,7 @@ class Editproductlistprovider 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,
"remarks": editRemarkControllers[i].text,
}; };
insertData.add(rowData); insertData.add(rowData);
} }
...@@ -401,6 +410,7 @@ class Editproductlistprovider extends ChangeNotifier { ...@@ -401,6 +410,7 @@ class Editproductlistprovider extends ChangeNotifier {
type, type,
leadProductId, leadProductId,
productId, productId,
prductRemark,
) async { ) async {
try { try {
if (!validateform(context)) { if (!validateform(context)) {
...@@ -419,6 +429,7 @@ class Editproductlistprovider extends ChangeNotifier { ...@@ -419,6 +429,7 @@ class Editproductlistprovider extends ChangeNotifier {
productId, productId,
addEditQuantityController.text, addEditQuantityController.text,
addEditProductPriceController.text, addEditProductPriceController.text,
addEditRemarkController.text,
); );
if (data != null && data.error == "0") { if (data != null && data.error == "0") {
_submitLoading = false; _submitLoading = false;
...@@ -477,10 +488,12 @@ class Editproductlistprovider extends ChangeNotifier { ...@@ -477,10 +488,12 @@ class Editproductlistprovider extends ChangeNotifier {
_quotationDetailsClicked = false; _quotationDetailsClicked = false;
addEditProductPriceController.clear(); addEditProductPriceController.clear();
addEditQuantityController.clear(); addEditQuantityController.clear();
addEditRemarkController.clear();
addEditTotalAmountController.clear(); addEditTotalAmountController.clear();
editProductPriceControllers.clear(); editProductPriceControllers.clear();
editQuantityControllers.clear(); editQuantityControllers.clear();
editTotalAmountControllers.clear(); editTotalAmountControllers.clear();
editRemarkControllers.clear();
_selectedProductIds.clear(); _selectedProductIds.clear();
_selectedProducts = null; _selectedProducts = null;
_selectedAddEditProductId = null; _selectedAddEditProductId = null;
......
...@@ -9,6 +9,7 @@ import 'package:intl/intl.dart'; ...@@ -9,6 +9,7 @@ import 'package:intl/intl.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import '../../screens/crm/LeadDetailsByMode.dart'; import '../../screens/crm/LeadDetailsByMode.dart';
import '../../screens/order/addOrder.dart';
import '../../services/api_calling.dart'; import '../../services/api_calling.dart';
import 'crmLeadDetailsProvider.dart'; import 'crmLeadDetailsProvider.dart';
...@@ -165,17 +166,24 @@ class followUpUpdateProvider extends ChangeNotifier { ...@@ -165,17 +166,24 @@ class followUpUpdateProvider extends ChangeNotifier {
competitor, competitor,
leadStatus, leadStatus,
appointmentType, appointmentType,
feedback,
inTime,
loc,
sms, [ sms, [
mode, mode,
]) async { ]) async {
try { try {
// validate form before API call
if (!valid()) { if (!valid()) {
return; return;
} }
_submitLoading = true; _submitLoading = true;
notifyListeners(); notifyListeners();
final prov = Provider.of<HomescreenNotifier>(context, listen: false); final prov = Provider.of<HomescreenNotifier>(context, listen: false);
final prov2 = Provider.of<crmLeadDetailsProvider>(context, listen: false); final prov2 = Provider.of<crmLeadDetailsProvider>(context, listen: false);
final data = await ApiCalling.crmLeadDetailsAddFollowUpAPI( final data = await ApiCalling.crmLeadDetailsAddFollowUpAPI(
prov.session, prov.session,
prov.empId, prov.empId,
...@@ -194,24 +202,44 @@ class followUpUpdateProvider extends ChangeNotifier { ...@@ -194,24 +202,44 @@ class followUpUpdateProvider extends ChangeNotifier {
sms, sms,
noteController.text, noteController.text,
); );
debugPrint("status ================ $orderStatus");
if (data != null && data.error == "0") { if (data != null && data.error == "0") {
_submitLoading = false; _submitLoading = false;
resetForm(); resetForm();
if (fromScreen == "Pending Tasks") {
if (orderStatus == "Order Gain") {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => AddorderScreen(
key: UniqueKey(),
mode: mode,
pageTitleName: "Add Order",
leadId: leadID,
feedback: feedback,
followupType: followupType,
inTime: inTime,
loc: loc,
),
),
);
} else if (fromScreen == "Pending Tasks") {
Navigator.pushAndRemoveUntil( Navigator.pushAndRemoveUntil(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: builder: (_) => LeadDetailsByMode(
(context) => LeadDetailsByMode(
mode: "executive", mode: "executive",
pageTitleName: "Lead Details", pageTitleName: "Lead Details",
leadId: leadID ?? "-", leadId: leadID ?? "-",
), ),
settings: RouteSettings(name: "LeadDetailsByMode"), settings: const RouteSettings(name: "LeadDetailsByMode"),
), ),
(Route<dynamic> route) { (Route<dynamic> route) =>
return route.settings.name == 'CrmdashboardScreen'; route.settings.name == 'CrmdashboardScreen',
},
); );
} else { } else {
Navigator.pop(context); Navigator.pop(context);
...@@ -229,10 +257,11 @@ class followUpUpdateProvider extends ChangeNotifier { ...@@ -229,10 +257,11 @@ class followUpUpdateProvider extends ChangeNotifier {
} catch (e, s) { } catch (e, s) {
_submitLoading = false; _submitLoading = false;
notifyListeners(); notifyListeners();
print("Error: $e, Stack: $s"); debugPrint("Error: $e, Stack: $s");
} }
} }
bool valid() { bool valid() {
followupError = null; followupError = null;
followupFeedbackError = null; followupFeedbackError = null;
......
...@@ -390,45 +390,85 @@ class Requesitionlidtdetailsprovider extends ChangeNotifier { ...@@ -390,45 +390,85 @@ class Requesitionlidtdetailsprovider extends ChangeNotifier {
} }
Future<void> paymentrequisitionApproveSubmitAPIFunction( Future<void> paymentrequisitionApproveSubmitAPIFunction(
context, BuildContext context,
mode, String mode,
paymentRequestId, String payment_request_id,
approvedAmount, String approved_amount,
approveRemarks, String approve_remarks,
proposedPaymentAccountId, String proposed_payment_account_id,
) async { ) async {
print("🎯 === PROVIDER METHOD STARTED ===");
try { try {
if (!validateApproval( print("🔍 Starting validation...");
approvedAmount, if (!validateApproval(approved_amount, approve_remarks, proposed_payment_account_id)) {
approveRemarks, print("❌ VALIDATION FAILED - Stopping execution");
proposedPaymentAccountId,
)) {
return; return;
} }
print("✅ Validation passed");
var provider = Provider.of<HomescreenNotifier>(context, listen: false); print("👤 Getting home provider...");
var homeProvider = Provider.of<HomescreenNotifier>(context, listen: false);
print("👤 Emp ID: ${homeProvider.empId}, Session: ${homeProvider.session}");
print("🌐 Calling API...");
final data = await ApiCalling.ApprovePaymentRequestSubmitAPI( final data = await ApiCalling.ApprovePaymentRequestSubmitAPI(
provider.empId, homeProvider.empId,
provider.session, homeProvider.session,
mode, mode,
paymentRequestId, payment_request_id,
approvedAmount, approved_amount,
approveRemarks, approve_remarks,
proposedPaymentAccountId, proposed_payment_account_id,
); );
print("🌐 API call completed");
if (data != null) { if (data != null) {
print("📡 API Response: error=${data.error}, message=${data.message}");
if (data.error == "0") { if (data.error == "0") {
paymentRequesitionDetails(context, paymentRequestId); print("✅ API SUCCESS - Processing...");
// Check if context is still valid before UI operations
if (context.mounted) {
print("🎯 Context mounted - performing UI operations");
paymentRequesitionDetails(context, payment_request_id);
resetAll(); resetAll();
toast(context, data.message); toast(context, data.message);
Navigator.pop(context, true); Navigator.pop(context, true);
print("✅ UI operations completed");
} else {
print("⚠️ Context not mounted - skipping UI operations");
}
notifyListeners(); notifyListeners();
print("✅ Notify listeners called");
} else {
print("❌ API returned error: ${data.message}");
if (context.mounted) {
toast(context, data.message ?? "Submission failed");
} }
} }
} catch (e) {} } else {
print("❌ NULL response from API");
if (context.mounted) {
toast(context, "No response from server");
}
}
} catch (e, s) {
print("💥 EXCEPTION in provider method: $e");
print("📋 Stack trace: $s");
// Show error to user
if (context.mounted) {
toast(context, "Error: ${e.toString()}");
}
} }
print("🎯 === PROVIDER METHOD COMPLETED ===");
}
editPrevalues() { editPrevalues() {
editPaymentRequestedAmountController.text = editPaymentRequestedAmountController.text =
_requestDetails.requestedAmount ?? "-"; _requestDetails.requestedAmount ?? "-";
...@@ -530,35 +570,72 @@ class Requesitionlidtdetailsprovider extends ChangeNotifier { ...@@ -530,35 +570,72 @@ class Requesitionlidtdetailsprovider extends ChangeNotifier {
} }
bool validateApproval( bool validateApproval(
approvedAmount, String approvedAmount, // Add type for clarity
approveRemarks, String approveRemarks, // Add type for clarity
proposedPaymentAccountId, String proposedPaymentAccountId, // Add type for clarity
) { ) {
print("🔍 === VALIDATION STARTED ===");
print(" Approved Amount: '$approvedAmount'");
print(" Requested Amount: '${requestedAmount.text}'");
print(" Remarks: '$approveRemarks'");
print(" Payment Account ID: '$proposedPaymentAccountId'");
print(" Selected ID: '$_selectedID'");
remarksError = null; remarksError = null;
ApprovedAmountError = null; ApprovedAmountError = null;
selectpaymentAccountError = null; selectpaymentAccountError = null;
bool isValid = true; bool isValid = true;
if (approvedAmount.toString().trim().isEmpty) {
// Fix 1: Use the String parameter directly (no .text)
if (approvedAmount.trim().isEmpty) {
ApprovedAmountError = "Enter Amount"; ApprovedAmountError = "Enter Amount";
isValid = false; isValid = false;
print("❌ Approved amount is empty");
} }
if (approveRemarks.toString().trim().isEmpty) {
// Fix 2: Use the String parameter directly (no .text)
if (approveRemarks.trim().isEmpty) {
remarksError = "Please Enter Remarks"; remarksError = "Please Enter Remarks";
isValid = false; isValid = false;
print("❌ Remarks are empty");
} }
// Fix 3: Parse the String parameters, not .text
if (approvedAmount.trim().isNotEmpty && requestedAmount.text.trim().isNotEmpty) {
try {
final numberFormat = NumberFormat.decimalPattern(); final numberFormat = NumberFormat.decimalPattern();
if (numberFormat.parse(approvedAmount.text) > double approved = numberFormat.parse(approvedAmount.trim()).toDouble();
numberFormat.parse(requestedAmount.text)) { double requested = numberFormat.parse(requestedAmount.text.trim()).toDouble();
ApprovedAmountError =
"Approved Amount should not be greater than requested amount"; print("💰 Amount Comparison: Approved: $approved, Requested: $requested");
if (approved > requested) {
ApprovedAmountError = "Approved Amount should not be greater than requested amount";
isValid = false;
print("❌ Approved amount exceeds requested amount");
}
} catch (e) {
print("💥 Error parsing amounts: $e");
ApprovedAmountError = "Invalid amount format";
isValid = false; isValid = false;
} }
if (_selectedPaymentAccounts == null || _selectedID.isEmpty) { }
// Fix 4: Use the parameter OR check both for consistency
if (proposedPaymentAccountId.isEmpty && _selectedID.isEmpty) {
selectpaymentAccountError = "Please select an account"; selectpaymentAccountError = "Please select an account";
isValid = false; isValid = false;
print("❌ No payment account selected");
} else if (proposedPaymentAccountId.isNotEmpty && _selectedID.isEmpty) {
// If parameter has value but _selectedID doesn't, sync them
_selectedID = proposedPaymentAccountId;
print("🔄 Synced selected ID from parameter: $_selectedID");
} }
_submitClicked = false; _submitClicked = false;
notifyListeners(); notifyListeners();
print("🔍 === VALIDATION RESULT: $isValid ===");
return isValid; return isValid;
} }
......
import 'package:flutter/material.dart';
import '../../Models/hrmModels/advanceListResponse.dart';
import '../../services/api_calling.dart';
class AdvanceListProvider extends ChangeNotifier {
bool _isLoading = false;
bool get isLoading => _isLoading;
String? _errorMessage;
String? get errorMessage => _errorMessage;
List<AdvanceList> _advanceList = [];
List<AdvanceList> get advanceList => _advanceList;
int _currentPage = 1;
int get currentPage => _currentPage;
bool _hasMore = true;
bool get hasMore => _hasMore;
/// Fetch Advance List
Future<void> fetchAdvanceList(
BuildContext context, String session, String empId,
{int page = 1, bool loadMore = false}) async {
if (_isLoading) return;
_isLoading = true;
if (!loadMore) {
_errorMessage = null;
_advanceList = [];
_currentPage = 1;
_hasMore = true;
}
notifyListeners();
try {
final response = await ApiCalling.advanceListAPI(session, empId, page);
debugPrint('lenght: ${response?.advanceList?.length}, empId: ${empId}, session: ${session}, pageNumber: $page');
if (response != null) {
if (response.error == "0") {
final newList = response.advanceList ?? [];
if (loadMore) {
_advanceList.addAll(newList);
} else {
_advanceList = newList;
}
_currentPage = page;
_hasMore = newList.isNotEmpty;
} else {
_errorMessage = response.message ?? "Something went wrong";
}
} else {
_errorMessage = "No response from server";
}
} catch (e) {
_errorMessage = "Failed to fetch advance list: $e";
} finally {
_isLoading = false;
notifyListeners();
}
}
/// Refresh Advance List
Future<void> refreshAdvanceList(
BuildContext context, String session, String empId) async {
await fetchAdvanceList(context, session, empId, page: 1, loadMore: false);
}
/// Load More (Pagination)
Future<void> loadMoreAdvanceList(
BuildContext context, String session, String empId) async {
if (!_hasMore || _isLoading) return;
await fetchAdvanceList(context, session, empId,
page: _currentPage + 1, loadMore: true);
}
/// Clear state
void clear() {
_advanceList = [];
_errorMessage = null;
_currentPage = 1;
_hasMore = true;
notifyListeners();
}
}
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../../Models/hrmModels/casualLeaveHistoryResponse.dart';
import '../../services/api_calling.dart';
import '../HomeScreenNotifier.dart';
class CasualLeaveHistoryProvider extends ChangeNotifier {
/// --- Variables ---
List<CasualLeaveHistory> casualLeaveHistoryList = [];
bool isLoading = false;
String? errorMessage;
/// --- Fetch Casual Leave History ---
Future<void> fetchCasualLeaveHistory(BuildContext context) async {
isLoading = true;
errorMessage = null;
notifyListeners();
try {
final homeProvider = Provider.of<HomescreenNotifier>(context, listen: false);
final response = await ApiCalling.casualLeaveHistoryAPI(
homeProvider.session,
homeProvider.empId,
);
if (response != null) {
if (response.error != null && response.error != "0") {
errorMessage = response.message ?? "Something went wrong";
casualLeaveHistoryList = [];
} else {
casualLeaveHistoryList = response.casualLeaveHistory ?? [];
}
} else {
errorMessage = "No response from server";
}
} catch (e) {
errorMessage = "Failed to load leave history: $e";
} finally {
isLoading = false;
notifyListeners();
}
}
/// --- Clear data (optional) ---
void clearHistory() {
casualLeaveHistoryList.clear();
errorMessage = null;
notifyListeners();
}
}
...@@ -89,7 +89,7 @@ class Addorderprovider extends ChangeNotifier { ...@@ -89,7 +89,7 @@ class Addorderprovider extends ChangeNotifier {
List<String> _tpcApplicable = []; List<String> _tpcApplicable = [];
List<TpcList> _tpcAgent = []; List<TpcList> _tpcAgent = [];
AccountDetails _accountDetails = AccountDetails();
String? selectAccountError; String? selectAccountError;
String? orderDateError; String? orderDateError;
...@@ -309,7 +309,6 @@ class Addorderprovider extends ChangeNotifier { ...@@ -309,7 +309,6 @@ class Addorderprovider extends ChangeNotifier {
String? get selectedTpcAgentValue => _selectedTpcAgentValue; String? get selectedTpcAgentValue => _selectedTpcAgentValue;
AccountDetails get accountDetails => _accountDetails;
set accountList(List<AccountList> value) { set accountList(List<AccountList> value) {
_accountList = value; _accountList = value;
...@@ -529,10 +528,7 @@ class Addorderprovider extends ChangeNotifier { ...@@ -529,10 +528,7 @@ class Addorderprovider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
set accountDetails(AccountDetails value) {
_accountDetails = value;
notifyListeners();
}
set imagePath(File? value) { set imagePath(File? value) {
_imageName = value; _imageName = value;
...@@ -812,13 +808,18 @@ class Addorderprovider extends ChangeNotifier { ...@@ -812,13 +808,18 @@ class Addorderprovider extends ChangeNotifier {
// }; // };
// } // }
Future<void> ordersAddOrderAPIViewFunction(context, mode) async { Future<void> ordersAddOrderAPIViewFunction(context, mode, leadId, feedback, followupType, inTime, loc) async {
try { try {
final provider = Provider.of<HomescreenNotifier>(context, listen: false); final provider = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.addOrderViewAPI( final data = await ApiCalling.addOrderViewAPI(
provider.empId, provider.empId,
provider.session, provider.session,
mode, mode,
leadId,
feedback,
followupType,
inTime,
loc
); );
if (data != null) { if (data != null) {
if (data.error == "0") { if (data.error == "0") {
...@@ -839,6 +840,116 @@ class Addorderprovider extends ChangeNotifier { ...@@ -839,6 +840,116 @@ class Addorderprovider extends ChangeNotifier {
} catch (e) {} } catch (e) {}
} }
// AccountDetails _accountDetails = AccountDetails();
//
// AccountDetails get accountDetails => _accountDetails;
AccountDetails? _accountDetails; // nullable
AccountDetails? get accountDetails => _accountDetails;
set accountDetails(AccountDetails? value) {
_accountDetails = value;
notifyListeners();
}
Future<void> fetchAddOrderViewData(
BuildContext context,
String empId,
String session,
String mode,
leadId,
feedback,
followupType,
inTime,
loc
) async {
debugPrint("🔥 fetchAddOrderViewData CALLED with leadId=$leadId, mode=$mode");
try {
_isLoading = true;
notifyListeners();
final response = await ApiCalling.addOrderViewAPI(
empId, session, mode, leadId, feedback, followupType, inTime, loc
);
if (response != null) {
if (response.error == "0") {
_tpcApplicable = ["Yes", "No"];
_erectionScope = response.erectionScope ?? [];
_unloadingScope = response.unloadingScope ?? [];
_freightScope = response.freightScope ?? [];
_employees = response.employees ?? [];
_billingStates = response.states ?? [];
_dispatchStates = response.states ?? [];
_saleProducts = response.saleProducts ?? [];
// getSubLocationAPI(context, response.accountDetails?.subLocality);
// getDistrictAPI(context, response.accountDetails?.district);
// _billingStates = response.accountDetails?.state as List<States>;
checkDropdownselected();
notifyListeners();
} else {}
} else {}
debugPrint(" data to all fields##################################");
if (response != null) {
debugPrint("Employees: ${response.accountDetails?.pincode}");
debugPrint("States: ${response.accountDetails?.state}");
debugPrint("Sale Products: ${response.accountDetails?.address}");
debugPrint("Account Details Name: ${response.accountDetails?.name}");
debugPrint("District: ${response.accountDetails?.district}");
debugPrint("Sub location: ${response.accountDetails?.name}");
} else {
debugPrint("Response is NULL");
}
if (response != null && response.error == "0") {
// Save accountDetails safely
_accountDetails = AccountDetails(
id: response.accountDetails?.id,
name: response.accountDetails?.name,
address: response.accountDetails?.address,
state: response.accountDetails?.state,
pincode: response.accountDetails?.pincode,
date: response.accountDetails?.date,
subLocality: response.accountDetails?.subLocality,
district: response.accountDetails?.district,
);
// Save lists safely
_unloadingScope = response.unloadingScope ?? [];
_freightScope = response.freightScope ?? [];
_erectionScope = response.erectionScope ?? [];
// default selections
if (_employees.isNotEmpty) selectedEmployees = _employees.first;
if (leadId != "")
if (_billingStates.isNotEmpty) selecetdBillingStates = _billingStates.first;
if (_billingDistricts.isNotEmpty) selectedBillingDistricts = _billingDistricts.first;
if (_billingStates.isNotEmpty) selecetdBillingStates = _billingStates.first;
if (_dispatchStates.isNotEmpty) selecetdDispatchStates = _dispatchStates.first;
if (_saleProducts.isNotEmpty) selectedSaleProducts = _saleProducts.first;
if (_unloadingScope.isNotEmpty) selectedUnloadingScope = _unloadingScope.first;
if (_freightScope.isNotEmpty) selectedFreightScope = _freightScope.first;
if (_erectionScope.isNotEmpty) selectedErectionScope = _erectionScope.first;
notifyListeners(); // notify listeners/UI
} else {
debugPrint("API Error: ${response?.message}");
}
} catch (e) {
debugPrint("Provider Error in fetchAddOrderViewData: $e");
} finally {
_isLoading = false;
notifyListeners();
}
}
void checkDropdownselected() { void checkDropdownselected() {
if (_selectedAccountList != null && if (_selectedAccountList != null &&
!_accountList.contains(_selectedAccountList)) { !_accountList.contains(_selectedAccountList)) {
...@@ -972,12 +1083,12 @@ class Addorderprovider extends ChangeNotifier { ...@@ -972,12 +1083,12 @@ class Addorderprovider extends ChangeNotifier {
if (data.error == "0") { if (data.error == "0") {
_billingDistricts = data.districts!; _billingDistricts = data.districts!;
_selectedBillingDistricts = data.districts!.firstWhere( _selectedBillingDistricts = data.districts!.firstWhere(
(e) => e.id == accountDetails.district!, (e) => e.id == accountDetails?.district!,
); );
_selectedBillingDistrictValue = _selectedBillingDistrictValue =
data.districts! data.districts!
.firstWhere((e) => e.id == accountDetails.district!) .firstWhere((e) => e.id == accountDetails?.district!)
.district; .district;
notifyListeners(); notifyListeners();
...@@ -1020,12 +1131,12 @@ class Addorderprovider extends ChangeNotifier { ...@@ -1020,12 +1131,12 @@ class Addorderprovider extends ChangeNotifier {
if (data.error == "0") { if (data.error == "0") {
_billingSubLocations = data.subLocations!; _billingSubLocations = data.subLocations!;
_selectedBillingSubLocations = data.subLocations!.firstWhere( _selectedBillingSubLocations = data.subLocations!.firstWhere(
(e) => e.id == accountDetails.subLocality!, (e) => e.id == accountDetails?.subLocality!,
); );
_selectedBillingSubLocValue = _selectedBillingSubLocValue =
data.subLocations! data.subLocations!
.firstWhere((e) => e.id == accountDetails.subLocality!) .firstWhere((e) => e.id == accountDetails?.subLocality!)
.subLocality; .subLocality;
notifyListeners(); notifyListeners();
......
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