Commit 2ccf19cc authored by Sai Srinivas's avatar Sai Srinivas
Browse files

04-07-2025 By Sai Srinivas

Test cases and Order Module, Crm Module.
parent 4b790bef
package `in`.webgrid.generp package `in`.webgrid.generp
import android.app.DownloadManager import android.app.DownloadManager
import android.content.Context import android.content.Context
import android.net.Uri import android.net.Uri
...@@ -9,8 +10,12 @@ import android.widget.Toast ...@@ -9,8 +10,12 @@ import android.widget.Toast
import io.flutter.embedding.android.FlutterActivity import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.MethodChannel import io.flutter.plugin.common.MethodChannel
class MainActivity : FlutterActivity(){ import java.io.File
import java.util.Base64
class MainActivity : FlutterActivity() {
private val CHANNEL = "in.webgrid.generp/download" private val CHANNEL = "in.webgrid.generp/download"
override fun configureFlutterEngine(flutterEngine: FlutterEngine) { override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine) super.configureFlutterEngine(flutterEngine)
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL).setMethodCallHandler { call, result -> MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL).setMethodCallHandler { call, result ->
...@@ -20,9 +25,10 @@ class MainActivity : FlutterActivity(){ ...@@ -20,9 +25,10 @@ class MainActivity : FlutterActivity(){
val contentDisposition = call.argument<String>("contentDisposition") val contentDisposition = call.argument<String>("contentDisposition")
val mimeType = call.argument<String>("mimeType") val mimeType = call.argument<String>("mimeType")
val suggestedFilename = call.argument<String>("suggestedFilename") val suggestedFilename = call.argument<String>("suggestedFilename")
val isBase64 = call.argument<Boolean>("isBase64") ?: false
if (url != null && userAgent != null && mimeType != null) { if (url != null && userAgent != null && mimeType != null) {
val success = startDownload(url, userAgent, contentDisposition ?: "", mimeType,suggestedFilename ?: "") val success = startDownload(url, userAgent, contentDisposition ?: "", mimeType, suggestedFilename ?: "", isBase64)
if (success) { if (success) {
result.success("Download started") result.success("Download started")
} else { } else {
...@@ -37,31 +43,18 @@ class MainActivity : FlutterActivity(){ ...@@ -37,31 +43,18 @@ class MainActivity : FlutterActivity(){
} }
} }
private fun startDownload(url: String, userAgent: String, contentDisposition: String, mimeType: String, suggestedFilename: String): Boolean { private fun startDownload(
url: String,
userAgent: String,
contentDisposition: String,
mimeType: String,
suggestedFilename: String,
isBase64: Boolean
): Boolean {
return try { return try {
// Show toast // Show toast
Toast.makeText(this, "File is being downloaded", Toast.LENGTH_SHORT).show() Toast.makeText(this, "File is being downloaded", Toast.LENGTH_SHORT).show()
// Initialize download request
val request = DownloadManager.Request(Uri.parse(url.trim()))
// Get cookies
val cookies = CookieManager.getInstance().getCookie(url) ?: ""
request.addRequestHeader("Cookie", cookies)
request.addRequestHeader("User-Agent", userAgent)
// Set description
request.setDescription("Downloading requested file....")
// Set MIME type
request.setMimeType(mimeType)
// Allow scanning by media scanner
request.allowScanningByMediaScanner()
// Set notification visibility
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
// Map MIME type to file extension // Map MIME type to file extension
val extension = when (mimeType.lowercase()) { val extension = when (mimeType.lowercase()) {
"application/pdf" -> ".pdf" "application/pdf" -> ".pdf"
...@@ -71,20 +64,16 @@ class MainActivity : FlutterActivity(){ ...@@ -71,20 +64,16 @@ class MainActivity : FlutterActivity(){
"application/vnd.openxmlformats-officedocument.wordprocessingml.document" -> ".docx" "application/vnd.openxmlformats-officedocument.wordprocessingml.document" -> ".docx"
"application/vnd.ms-excel" -> ".xls" "application/vnd.ms-excel" -> ".xls"
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" -> ".xlsx" "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" -> ".xlsx"
else -> ".bin" // Fallback for unknown types "text/csv" -> ".csv"
else -> "" // Fallback for unknown types
} }
// Guess file name // Determine file name
// val fileName = contentDisposition.takeIf { it.isNotEmpty() }?.let {
// // Parse contentDisposition to extract filename if needed
// it.split(";").find { it.trim().startsWith("filename=") }
// ?.substringAfter("filename=")?.trim('"')
// } ?: url.split("/").last()
var fileName = contentDisposition.takeIf { it.isNotEmpty() }?.let { var fileName = contentDisposition.takeIf { it.isNotEmpty() }?.let {
// Parse Content-Disposition header (e.g., attachment; filename="Genesis_Quote_70772_16_May_2025_03_17.pdf")
val regex = Regex("filename=\"?([^\"\\s;]+)\"?") val regex = Regex("filename=\"?([^\"\\s;]+)\"?")
regex.find(it)?.groupValues?.get(1) regex.find(it)?.groupValues?.get(1)
} ?: suggestedFilename.takeIf { it.isNotEmpty() } ?: url.split("/").last() } ?: suggestedFilename.takeIf { it.isNotEmpty() } ?: url.split("/").last()
// Ensure the file name has the correct extension // Ensure the file name has the correct extension
if (!fileName.endsWith(extension, ignoreCase = true)) { if (!fileName.endsWith(extension, ignoreCase = true)) {
fileName = if (fileName.contains(".")) { fileName = if (fileName.contains(".")) {
...@@ -93,19 +82,48 @@ class MainActivity : FlutterActivity(){ ...@@ -93,19 +82,48 @@ class MainActivity : FlutterActivity(){
fileName + extension fileName + extension
} }
} }
// Sanitize file name to avoid invalid characters // Sanitize file name
fileName = fileName.replace("[^a-zA-Z0-9._-]".toRegex(), "_") fileName = fileName.replace("[^a-zA-Z0-9._-]".toRegex(), "_")
// Log for debugging // Log for debugging
println("Download File: $fileName, ContentDisposition: $contentDisposition, SuggestedFilename: $suggestedFilename, MimeType: $mimeType") println("Download File: $fileName, ContentDisposition: $contentDisposition, SuggestedFilename: $suggestedFilename, MimeType: $mimeType, IsBase64: $isBase64")
// Set destination if (isBase64 && url.startsWith("data:")) {
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileName) // Handle base64 data URL
val base64Data = url.substringAfter("base64,")
val file = File(getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS), fileName)
val decodedBytes = Base64.getDecoder().decode(base64Data)
file.writeBytes(decodedBytes)
// Set title // Optionally, use DownloadManager to notify the user
val request = DownloadManager.Request(Uri.fromFile(file))
request.setMimeType(mimeType)
request.setDescription("Downloading requested file....")
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileName)
request.setTitle(fileName) request.setTitle(fileName)
request.setAllowedOverMetered(true)
request.setAllowedOverRoaming(false)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
request.setRequiresCharging(false)
request.setRequiresDeviceIdle(false)
}
request.setVisibleInDownloadsUi(true)
// Additional settings val downloadManager = getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager
downloadManager.enqueue(request)
} else {
// Handle regular URL
val request = DownloadManager.Request(Uri.parse(url.trim()))
val cookies = CookieManager.getInstance().getCookie(url) ?: ""
request.addRequestHeader("Cookie", cookies)
request.addRequestHeader("User-Agent", userAgent)
request.setDescription("Downloading requested file....")
request.setMimeType(mimeType)
request.allowScanningByMediaScanner()
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileName)
request.setTitle(fileName)
request.setAllowedOverMetered(true) request.setAllowedOverMetered(true)
request.setAllowedOverRoaming(false) request.setAllowedOverRoaming(false)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
...@@ -114,11 +132,12 @@ class MainActivity : FlutterActivity(){ ...@@ -114,11 +132,12 @@ class MainActivity : FlutterActivity(){
} }
request.setVisibleInDownloadsUi(true) request.setVisibleInDownloadsUi(true)
// Enqueue download
val downloadManager = getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager val downloadManager = getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager
downloadManager.enqueue(request) downloadManager.enqueue(request)
}
true true
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace()
false false
} }
} }
......
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="Photo">
<path fill="#b1e3ff"
d="M19 20.5H5a3.003 3.003 0 0 1-3-3v-8a3.003 3.003 0 0 1 3-3h1.28l.315-.95A2.997 2.997 0 0 1 9.441 3.5h5.118a2.997 2.997 0 0 1 2.846 2.05l.316.95H19a3.003 3.003 0 0 1 3 3v8a3.003 3.003 0 0 1-3 3Z"
class="colorb2b1ff svgShape"></path>
<path fill="#1487c9" d="M12 16.5a4 4 0 1 1 4-4 4.004 4.004 0 0 1-4 4Z"
class="color6563ff svgShape"></path>
</svg>
<svg width="21" height="21" viewBox="0 0 21 21" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M9.24857 1C4.70008 1 1 4.70008 1 9.24857C1 13.7971 4.70008 17.4971 9.24857 17.4971C11.3107 17.4971 13.1938 16.73 14.6408 15.4739L18.844 19.6771C18.8984 19.7334 18.9634 19.7783 19.0353 19.8092C19.1072 19.84 19.1845 19.8563 19.2627 19.857C19.3409 19.8577 19.4185 19.8428 19.4909 19.8131C19.5633 19.7835 19.6291 19.7398 19.6844 19.6844C19.7398 19.6291 19.7835 19.5633 19.8131 19.4909C19.8428 19.4185 19.8577 19.3409 19.857 19.2627C19.8563 19.1845 19.84 19.1072 19.8092 19.0353C19.7783 18.9634 19.7334 18.8984 19.6771 18.844L15.4739 14.6408C16.7778 13.147 17.4965 11.2314 17.4971 9.24857C17.4971 4.70008 13.7971 1 9.24857 1ZM9.24857 2.17837C13.1608 2.17837 16.3188 5.33639 16.3188 9.24857C16.3188 13.1608 13.1608 16.3188 9.24857 16.3188C5.33639 16.3188 2.17837 13.1608 2.17837 9.24857C2.17837 5.33639 5.33639 2.17837 9.24857 2.17837Z" fill="#2D2D2D" stroke="#2D2D2D"/>
</svg>
class commonAccountLedgerResponse { class commonAccountLedgerResponse {
List<LedgerList>? ledgerList; List<LedgerList>? ledgerList;
BalanceDetails? balanceDetails;
AccountDetails? accountDetails; AccountDetails? accountDetails;
String? error; String? error;
String? message; String? message;
commonAccountLedgerResponse( commonAccountLedgerResponse(
{this.ledgerList, this.accountDetails, this.error, this.message}); {this.ledgerList,
this.balanceDetails,
this.accountDetails,
this.error,
this.message});
commonAccountLedgerResponse.fromJson(Map<String, dynamic> json) { commonAccountLedgerResponse.fromJson(Map<String, dynamic> json) {
if (json['ledger_list'] != null) { if (json['ledger_list'] != null) {
...@@ -14,6 +19,9 @@ class commonAccountLedgerResponse { ...@@ -14,6 +19,9 @@ class commonAccountLedgerResponse {
ledgerList!.add(new LedgerList.fromJson(v)); ledgerList!.add(new LedgerList.fromJson(v));
}); });
} }
balanceDetails = json['balance_details'] != null
? new BalanceDetails.fromJson(json['balance_details'])
: null;
accountDetails = json['account_details'] != null accountDetails = json['account_details'] != null
? new AccountDetails.fromJson(json['account_details']) ? new AccountDetails.fromJson(json['account_details'])
: null; : null;
...@@ -26,6 +34,9 @@ class commonAccountLedgerResponse { ...@@ -26,6 +34,9 @@ class commonAccountLedgerResponse {
if (this.ledgerList != null) { if (this.ledgerList != null) {
data['ledger_list'] = this.ledgerList!.map((v) => v.toJson()).toList(); data['ledger_list'] = this.ledgerList!.map((v) => v.toJson()).toList();
} }
if (this.balanceDetails != null) {
data['balance_details'] = this.balanceDetails!.toJson();
}
if (this.accountDetails != null) { if (this.accountDetails != null) {
data['account_details'] = this.accountDetails!.toJson(); data['account_details'] = this.accountDetails!.toJson();
} }
...@@ -88,21 +99,97 @@ class LedgerList { ...@@ -88,21 +99,97 @@ class LedgerList {
} }
} }
class BalanceDetails {
String? totalDebit;
String? totalCredit;
String? balance;
BalanceDetails({this.totalDebit, this.totalCredit, this.balance});
BalanceDetails.fromJson(Map<String, dynamic> json) {
totalDebit = json['total_debit'];
totalCredit = json['total_credit'];
balance = json['balance'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['total_debit'] = this.totalDebit;
data['total_credit'] = this.totalCredit;
data['balance'] = this.balance;
return data;
}
}
class AccountDetails { class AccountDetails {
String? id; String? id;
String? type;
String? refId;
String? name; String? name;
String? address;
String? createdDatetime;
String? bankName;
String? bankBranchName;
String? bankIfscCode;
String? bankAccountHolderName;
String? bankAccountNumber;
String? bankUpiId;
String? state;
String? district;
String? subLocality;
AccountDetails({this.id, this.name}); AccountDetails(
{this.id,
this.type,
this.refId,
this.name,
this.address,
this.createdDatetime,
this.bankName,
this.bankBranchName,
this.bankIfscCode,
this.bankAccountHolderName,
this.bankAccountNumber,
this.bankUpiId,
this.state,
this.district,
this.subLocality});
AccountDetails.fromJson(Map<String, dynamic> json) { AccountDetails.fromJson(Map<String, dynamic> json) {
id = json['id']; id = json['id'];
type = json['type'];
refId = json['ref_id'];
name = json['name']; name = json['name'];
address = json['address'];
createdDatetime = json['created_datetime'];
bankName = json['bank_name'];
bankBranchName = json['bank_branch_name'];
bankIfscCode = json['bank_ifsc_code'];
bankAccountHolderName = json['bank_account_holder_name'];
bankAccountNumber = json['bank_account_number'];
bankUpiId = json['bank_upi_id'];
state = json['state'];
district = json['district'];
subLocality = json['sub_locality'];
} }
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['id'] = this.id; data['id'] = this.id;
data['type'] = this.type;
data['ref_id'] = this.refId;
data['name'] = this.name; data['name'] = this.name;
data['address'] = this.address;
data['created_datetime'] = this.createdDatetime;
data['bank_name'] = this.bankName;
data['bank_branch_name'] = this.bankBranchName;
data['bank_ifsc_code'] = this.bankIfscCode;
data['bank_account_holder_name'] = this.bankAccountHolderName;
data['bank_account_number'] = this.bankAccountNumber;
data['bank_upi_id'] = this.bankUpiId;
data['state'] = this.state;
data['district'] = this.district;
data['sub_locality'] = this.subLocality;
return data; return data;
} }
} }
class commonAddAccountsSubmitResponse {
String? error;
String? message;
String? id;
commonAddAccountsSubmitResponse({
this.error,
this.message,
this.id,
});
commonAddAccountsSubmitResponse.fromJson(Map<String, dynamic> json) {
error = json['error'];
message = json['message'];
id = json['id'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['error'] = this.error;
data['message'] = this.message;
data['id'] = this.id;
return data;
}
}
class crmDashboardResponse {
Hotleads? hotleads;
Hotleads? coldleads;
Hotleads? warmleads;
Hotleads? totalleads;
Hotleads? orderlost;
Hotleads? norequirement;
Hotleads? openEnquiries;
String? error;
String? message;
crmDashboardResponse(
{this.hotleads,
this.coldleads,
this.warmleads,
this.totalleads,
this.orderlost,
this.norequirement,
this.openEnquiries,
this.error,
this.message});
crmDashboardResponse.fromJson(Map<String, dynamic> json) {
hotleads = json['hotleads'] != null
? new Hotleads.fromJson(json['hotleads'])
: null;
coldleads = json['coldleads'] != null
? new Hotleads.fromJson(json['coldleads'])
: null;
warmleads = json['warmleads'] != null
? new Hotleads.fromJson(json['warmleads'])
: null;
totalleads = json['totalleads'] != null
? new Hotleads.fromJson(json['totalleads'])
: null;
orderlost = json['orderlost'] != null
? new Hotleads.fromJson(json['orderlost'])
: null;
norequirement = json['norequirement'] != null
? new Hotleads.fromJson(json['norequirement'])
: null;
openEnquiries = json['open_enquiries'] != null
? new Hotleads.fromJson(json['open_enquiries'])
: null;
error = json['error'];
message = json['message'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.hotleads != null) {
data['hotleads'] = this.hotleads!.toJson();
}
if (this.coldleads != null) {
data['coldleads'] = this.coldleads!.toJson();
}
if (this.warmleads != null) {
data['warmleads'] = this.warmleads!.toJson();
}
if (this.totalleads != null) {
data['totalleads'] = this.totalleads!.toJson();
}
if (this.orderlost != null) {
data['orderlost'] = this.orderlost!.toJson();
}
if (this.norequirement != null) {
data['norequirement'] = this.norequirement!.toJson();
}
if (this.openEnquiries != null) {
data['open_enquiries'] = this.openEnquiries!.toJson();
}
data['error'] = this.error;
data['message'] = this.message;
return data;
}
}
class Hotleads {
String? count;
Filter? filter;
Hotleads({this.count, this.filter});
Hotleads.fromJson(Map<String, dynamic> json) {
count = json['count'];
filter =
json['filter'] != null ? new Filter.fromJson(json['filter']) : null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['count'] = this.count;
if (this.filter != null) {
data['filter'] = this.filter!.toJson();
}
return data;
}
}
class Filter {
String? id;
String? pageName;
String? mode;
String? openStatus;
String? status;
Filter({this.id, this.pageName, this.mode, this.openStatus, this.status});
Filter.fromJson(Map<String, dynamic> json) {
id = json['id'];
pageName = json['page_name'];
mode = json['mode'];
openStatus = json['open_status'];
status = json['status'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['page_name'] = this.pageName;
data['mode'] = this.mode;
data['open_status'] = this.openStatus;
data['status'] = this.status;
return data;
}
}
class crmPendingTasksResponse {
List<PendingTasks>? pendingTasks;
String? error;
String? message;
crmPendingTasksResponse({this.pendingTasks, this.error, this.message});
crmPendingTasksResponse.fromJson(Map<String, dynamic> json) {
if (json['pending_tasks'] != null) {
pendingTasks = <PendingTasks>[];
json['pending_tasks'].forEach((v) {
pendingTasks!.add(new PendingTasks.fromJson(v));
});
}
error = json['error'];
message = json['message'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.pendingTasks != null) {
data['pending_tasks'] =
this.pendingTasks!.map((v) => v.toJson()).toList();
}
data['error'] = this.error;
data['message'] = this.message;
return data;
}
}
class PendingTasks {
String? conmob;
String? aname;
String? appdate;
String? atype;
String? anote;
String? leadid;
String? lstatus;
String? lempid;
String? aid;
PendingTasks(
{this.conmob,
this.aname,
this.appdate,
this.atype,
this.anote,
this.leadid,
this.lstatus,
this.lempid,
this.aid});
PendingTasks.fromJson(Map<String, dynamic> json) {
conmob = json['conmob'];
aname = json['aname'];
appdate = json['appdate'];
atype = json['atype'];
anote = json['anote'];
leadid = json['leadid'];
lstatus = json['lstatus'];
lempid = json['lempid'];
aid = json['aid'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['conmob'] = this.conmob;
data['aname'] = this.aname;
data['appdate'] = this.appdate;
data['atype'] = this.atype;
data['anote'] = this.anote;
data['leadid'] = this.leadid;
data['lstatus'] = this.lstatus;
data['lempid'] = this.lempid;
data['aid'] = this.aid;
return data;
}
}
class crmUniversalSearchResponse {
List<Accounts>? accounts;
List<Enquires>? enquires;
List<Leads>? leads;
String? error;
String? message;
crmUniversalSearchResponse(
{this.accounts, this.enquires, this.leads, this.error, this.message});
crmUniversalSearchResponse.fromJson(Map<String, dynamic> json) {
if (json['accounts'] != null) {
accounts = <Accounts>[];
json['accounts'].forEach((v) {
accounts!.add(new Accounts.fromJson(v));
});
}
if (json['enquires'] != null) {
enquires = <Enquires>[];
json['enquires'].forEach((v) {
enquires!.add(new Enquires.fromJson(v));
});
}
if (json['leads'] != null) {
leads = <Leads>[];
json['leads'].forEach((v) {
leads!.add(new Leads.fromJson(v));
});
}
error = json['error'];
message = json['message'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.accounts != null) {
data['accounts'] = this.accounts!.map((v) => v.toJson()).toList();
}
if (this.enquires != null) {
data['enquires'] = this.enquires!.map((v) => v.toJson()).toList();
}
if (this.leads != null) {
data['leads'] = this.leads!.map((v) => v.toJson()).toList();
}
data['error'] = this.error;
data['message'] = this.message;
return data;
}
}
class Accounts {
String? aid;
String? aname;
String? accman;
String? conper;
String? conmob;
String? aaddress;
Accounts(
{this.aid,
this.aname,
this.accman,
this.conper,
this.conmob,
this.aaddress});
Accounts.fromJson(Map<String, dynamic> json) {
aid = json['aid'];
aname = json['aname'];
accman = json['accman'];
conper = json['conper'];
conmob = json['conmob'];
aaddress = json['aaddress'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['aid'] = this.aid;
data['aname'] = this.aname;
data['accman'] = this.accman;
data['conper'] = this.conper;
data['conmob'] = this.conmob;
data['aaddress'] = this.aaddress;
return data;
}
}
class Enquires {
String? id;
String? refType;
String? refId;
String? sourceId;
String? referenceId;
String? companyId;
String? name;
String? companyName;
String? mobile;
String? altMobile;
String? emailId;
String? country;
String? state;
String? district;
String? subLocation;
String? address;
String? product;
String? requirement;
String? extraInfo;
String? feedbackStatus;
String? enquiryManagerEmpId;
String? openStatus;
String? closingReasonId;
String? closingLeadId;
String? closingEmpId;
String? closingDatetime;
String? enteredEmpId;
String? isExist;
String? createdDatetime;
String? updatedDatetime;
String? refName;
Enquires(
{this.id,
this.refType,
this.refId,
this.sourceId,
this.referenceId,
this.companyId,
this.name,
this.companyName,
this.mobile,
this.altMobile,
this.emailId,
this.country,
this.state,
this.district,
this.subLocation,
this.address,
this.product,
this.requirement,
this.extraInfo,
this.feedbackStatus,
this.enquiryManagerEmpId,
this.openStatus,
this.closingReasonId,
this.closingLeadId,
this.closingEmpId,
this.closingDatetime,
this.enteredEmpId,
this.isExist,
this.createdDatetime,
this.updatedDatetime,
this.refName});
Enquires.fromJson(Map<String, dynamic> json) {
id = json['id'];
refType = json['ref_type'];
refId = json['ref_id'];
sourceId = json['source_id'];
referenceId = json['reference_id'];
companyId = json['company_id'];
name = json['name'];
companyName = json['company_name'];
mobile = json['mobile'];
altMobile = json['alt_mobile'];
emailId = json['email_id'];
country = json['country'];
state = json['state'];
district = json['district'];
subLocation = json['sub_location'];
address = json['address'];
product = json['product'];
requirement = json['requirement'];
extraInfo = json['extra_info'];
feedbackStatus = json['feedback_status'];
enquiryManagerEmpId = json['enquiry_manager_emp_id'];
openStatus = json['open_status'];
closingReasonId = json['closing_reason_id'];
closingLeadId = json['closing_lead_id'];
closingEmpId = json['closing_emp_id'];
closingDatetime = json['closing_datetime'];
enteredEmpId = json['entered_emp_id'];
isExist = json['is_exist'];
createdDatetime = json['created_datetime'];
updatedDatetime = json['updated_datetime'];
refName = json['ref_name'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['ref_type'] = this.refType;
data['ref_id'] = this.refId;
data['source_id'] = this.sourceId;
data['reference_id'] = this.referenceId;
data['company_id'] = this.companyId;
data['name'] = this.name;
data['company_name'] = this.companyName;
data['mobile'] = this.mobile;
data['alt_mobile'] = this.altMobile;
data['email_id'] = this.emailId;
data['country'] = this.country;
data['state'] = this.state;
data['district'] = this.district;
data['sub_location'] = this.subLocation;
data['address'] = this.address;
data['product'] = this.product;
data['requirement'] = this.requirement;
data['extra_info'] = this.extraInfo;
data['feedback_status'] = this.feedbackStatus;
data['enquiry_manager_emp_id'] = this.enquiryManagerEmpId;
data['open_status'] = this.openStatus;
data['closing_reason_id'] = this.closingReasonId;
data['closing_lead_id'] = this.closingLeadId;
data['closing_emp_id'] = this.closingEmpId;
data['closing_datetime'] = this.closingDatetime;
data['entered_emp_id'] = this.enteredEmpId;
data['is_exist'] = this.isExist;
data['created_datetime'] = this.createdDatetime;
data['updated_datetime'] = this.updatedDatetime;
data['ref_name'] = this.refName;
return data;
}
}
class Leads {
String? lid;
String? aname;
String? accman;
String? conper;
String? conmob;
String? aaddress;
Leads(
{this.lid,
this.aname,
this.accman,
this.conper,
this.conmob,
this.aaddress});
Leads.fromJson(Map<String, dynamic> json) {
lid = json['lid'];
aname = json['aname'];
accman = json['accman'];
conper = json['conper'];
conmob = json['conmob'];
aaddress = json['aaddress'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['lid'] = this.lid;
data['aname'] = this.aname;
data['accman'] = this.accman;
data['conper'] = this.conper;
data['conmob'] = this.conmob;
data['aaddress'] = this.aaddress;
return data;
}
}
...@@ -4,6 +4,8 @@ class addPaymentRequestionResponse { ...@@ -4,6 +4,8 @@ class addPaymentRequestionResponse {
List<Accounts>? accounts; List<Accounts>? accounts;
List<PaymentModes>? paymentModes; List<PaymentModes>? paymentModes;
List<String>? requestingPurposes; List<String>? requestingPurposes;
List<Employees>? employees;
addPaymentRequestionResponse( addPaymentRequestionResponse(
...@@ -12,6 +14,7 @@ class addPaymentRequestionResponse { ...@@ -12,6 +14,7 @@ class addPaymentRequestionResponse {
this.accounts, this.accounts,
this.paymentModes, this.paymentModes,
this.requestingPurposes, this.requestingPurposes,
this.employees
}); });
addPaymentRequestionResponse.fromJson(Map<String, dynamic> json) { addPaymentRequestionResponse.fromJson(Map<String, dynamic> json) {
...@@ -33,6 +36,12 @@ class addPaymentRequestionResponse { ...@@ -33,6 +36,12 @@ class addPaymentRequestionResponse {
if(json['requesting_purposes']!=null){ if(json['requesting_purposes']!=null){
requestingPurposes = json['requesting_purposes'].cast<String>(); requestingPurposes = json['requesting_purposes'].cast<String>();
} }
if (json['employees'] != null) {
employees = <Employees>[];
json['employees'].forEach((v) {
employees!.add(new Employees.fromJson(v));
});
}
} }
...@@ -49,6 +58,9 @@ class addPaymentRequestionResponse { ...@@ -49,6 +58,9 @@ class addPaymentRequestionResponse {
data['error'] = this.error; data['error'] = this.error;
data['message'] = this.message; data['message'] = this.message;
data['requesting_purposes'] = this.requestingPurposes; data['requesting_purposes'] = this.requestingPurposes;
if (this.employees != null) {
data['employees'] = this.employees!.map((v) => v.toJson()).toList();
}
return data; return data;
} }
} }
...@@ -89,3 +101,21 @@ class PaymentModes { ...@@ -89,3 +101,21 @@ class PaymentModes {
return data; 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;
}
}
\ No newline at end of file
...@@ -42,6 +42,7 @@ class RequestDetails { ...@@ -42,6 +42,7 @@ class RequestDetails {
String? transDis; String? transDis;
String? description; String? description;
String? amount; String? amount;
String? formattedAmount;
String? requestedAmount; String? requestedAmount;
String? requestMode; String? requestMode;
String? status; String? status;
...@@ -73,6 +74,7 @@ class RequestDetails { ...@@ -73,6 +74,7 @@ class RequestDetails {
this.transDis, this.transDis,
this.description, this.description,
this.amount, this.amount,
this.formattedAmount,
this.requestedAmount, this.requestedAmount,
this.requestMode, this.requestMode,
this.status, this.status,
...@@ -106,6 +108,7 @@ class RequestDetails { ...@@ -106,6 +108,7 @@ class RequestDetails {
transDis = json['trans_dis']; transDis = json['trans_dis'];
description = json['description']; description = json['description'];
amount = json['amount']; amount = json['amount'];
formattedAmount = json['formatted_amount'];
requestedAmount = json['requested_amount']; requestedAmount = json['requested_amount'];
requestMode = json['request_mode']; requestMode = json['request_mode'];
status = json['status']; status = json['status'];
...@@ -140,6 +143,7 @@ class RequestDetails { ...@@ -140,6 +143,7 @@ class RequestDetails {
data['trans_dis'] = this.transDis; data['trans_dis'] = this.transDis;
data['description'] = this.description; data['description'] = this.description;
data['amount'] = this.amount; data['amount'] = this.amount;
data['formatted_amount'] = this.formattedAmount;
data['requested_amount'] = this.requestedAmount; data['requested_amount'] = this.requestedAmount;
data['request_mode'] = this.requestMode; data['request_mode'] = this.requestMode;
data['status'] = this.status; data['status'] = this.status;
...@@ -173,6 +177,7 @@ class PaymentDetails { ...@@ -173,6 +177,7 @@ class PaymentDetails {
String? accountId; String? accountId;
String? paymentModeId; String? paymentModeId;
String? amount; String? amount;
String? bankName; String? bankName;
String? bankBranchName; String? bankBranchName;
String? bankIfscCode; String? bankIfscCode;
...@@ -201,6 +206,7 @@ class PaymentDetails { ...@@ -201,6 +206,7 @@ class PaymentDetails {
this.accountId, this.accountId,
this.paymentModeId, this.paymentModeId,
this.amount, this.amount,
this.bankName, this.bankName,
this.bankBranchName, this.bankBranchName,
this.bankIfscCode, this.bankIfscCode,
...@@ -230,6 +236,7 @@ class PaymentDetails { ...@@ -230,6 +236,7 @@ class PaymentDetails {
accountId = json['account_id']; accountId = json['account_id'];
paymentModeId = json['payment_mode_id']; paymentModeId = json['payment_mode_id'];
amount = json['amount']; amount = json['amount'];
bankName = json['bank_name']; bankName = json['bank_name'];
bankBranchName = json['bank_branch_name']; bankBranchName = json['bank_branch_name'];
bankIfscCode = json['bank_ifsc_code']; bankIfscCode = json['bank_ifsc_code'];
......
class loadGeneratorDetailsResponse { class loadGeneratorDetailsResponse {
int? error; int? error;
String? genId; String? genId;
String? genHashId;
String? aname; String? aname;
String? emodel; String? emodel;
String? spname; String? spname;
...@@ -19,6 +20,7 @@ class loadGeneratorDetailsResponse { ...@@ -19,6 +20,7 @@ class loadGeneratorDetailsResponse {
String? dispDate; String? dispDate;
String? cmsngDate; String? cmsngDate;
String? status; String? status;
String? loc;
List<ComplaintCategoryList>? complaintCategoryList; List<ComplaintCategoryList>? complaintCategoryList;
List<ComplaintTypeList>? complaintTypeList; List<ComplaintTypeList>? complaintTypeList;
List<ComplaintDescriptionList>? complaintDescriptionList; List<ComplaintDescriptionList>? complaintDescriptionList;
...@@ -28,6 +30,7 @@ class loadGeneratorDetailsResponse { ...@@ -28,6 +30,7 @@ class loadGeneratorDetailsResponse {
loadGeneratorDetailsResponse( loadGeneratorDetailsResponse(
{this.error, {this.error,
this.genId, this.genId,
this.genHashId,
this.aname, this.aname,
this.emodel, this.emodel,
this.spname, this.spname,
...@@ -46,6 +49,7 @@ class loadGeneratorDetailsResponse { ...@@ -46,6 +49,7 @@ class loadGeneratorDetailsResponse {
this.dispDate, this.dispDate,
this.cmsngDate, this.cmsngDate,
this.status, this.status,
this.loc,
this.complaintCategoryList, this.complaintCategoryList,
this.complaintTypeList, this.complaintTypeList,
this.complaintDescriptionList, this.complaintDescriptionList,
...@@ -55,6 +59,7 @@ class loadGeneratorDetailsResponse { ...@@ -55,6 +59,7 @@ class loadGeneratorDetailsResponse {
loadGeneratorDetailsResponse.fromJson(Map<String, dynamic> json) { loadGeneratorDetailsResponse.fromJson(Map<String, dynamic> json) {
error = json['error']; error = json['error'];
genId = json['gen_id']; genId = json['gen_id'];
genHashId = json['gen_hash_id'];
aname = json['aname']; aname = json['aname'];
emodel = json['emodel']; emodel = json['emodel'];
spname = json['spname']; spname = json['spname'];
...@@ -73,6 +78,7 @@ class loadGeneratorDetailsResponse { ...@@ -73,6 +78,7 @@ class loadGeneratorDetailsResponse {
dispDate = json['disp_date']; dispDate = json['disp_date'];
cmsngDate = json['cmsng_date']; cmsngDate = json['cmsng_date'];
status = json['status']; status = json['status'];
loc = json['loc'];
if (json['complaint_category_list'] != null) { if (json['complaint_category_list'] != null) {
complaintCategoryList = <ComplaintCategoryList>[]; complaintCategoryList = <ComplaintCategoryList>[];
json['complaint_category_list'].forEach((v) { json['complaint_category_list'].forEach((v) {
...@@ -99,6 +105,7 @@ class loadGeneratorDetailsResponse { ...@@ -99,6 +105,7 @@ class loadGeneratorDetailsResponse {
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['gen_id'] = this.genId; data['gen_id'] = this.genId;
data['gen_hash_id'] = this.genHashId;
data['aname'] = this.aname; data['aname'] = this.aname;
data['emodel'] = this.emodel; data['emodel'] = this.emodel;
data['spname'] = this.spname; data['spname'] = this.spname;
...@@ -117,6 +124,7 @@ class loadGeneratorDetailsResponse { ...@@ -117,6 +124,7 @@ class loadGeneratorDetailsResponse {
data['disp_date'] = this.dispDate; data['disp_date'] = this.dispDate;
data['cmsng_date'] = this.cmsngDate; data['cmsng_date'] = this.cmsngDate;
data['status'] = this.status; data['status'] = this.status;
data['loc'] = this.loc;
if (this.complaintCategoryList != null) { if (this.complaintCategoryList != null) {
data['complaint_category_list'] = data['complaint_category_list'] =
this.complaintCategoryList!.map((v) => v.toJson()).toList(); this.complaintCategoryList!.map((v) => v.toJson()).toList();
......
class orderDashboardResponse {
Ordergain? ordergain;
Ordergain? dispatches;
Ordergain? pendingTasks;
Ordergain? quote;
String? error;
String? message;
orderDashboardResponse(
{this.ordergain,
this.dispatches,
this.pendingTasks,
this.quote,
this.error,
this.message});
orderDashboardResponse.fromJson(Map<String, dynamic> json) {
ordergain = json['ordergain'] != null
? new Ordergain.fromJson(json['ordergain'])
: null;
dispatches = json['dispatches'] != null
? new Ordergain.fromJson(json['dispatches'])
: null;
pendingTasks = json['pending_tasks'] != null
? new Ordergain.fromJson(json['pending_tasks'])
: null;
quote =
json['quote'] != null ? new Ordergain.fromJson(json['quote']) : null;
error = json['error'];
message = json['message'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.ordergain != null) {
data['ordergain'] = this.ordergain!.toJson();
}
if (this.dispatches != null) {
data['dispatches'] = this.dispatches!.toJson();
}
if (this.pendingTasks != null) {
data['pending_tasks'] = this.pendingTasks!.toJson();
}
if (this.quote != null) {
data['quote'] = this.quote!.toJson();
}
data['error'] = this.error;
data['message'] = this.message;
return data;
}
}
class Ordergain {
String? count;
Filter? filter;
Ordergain({this.count, this.filter});
Ordergain.fromJson(Map<String, dynamic> json) {
count = json['count'];
filter =
json['filter'] != null ? new Filter.fromJson(json['filter']) : null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['count'] = this.count;
if (this.filter != null) {
data['filter'] = this.filter!.toJson();
}
return data;
}
}
class Filter {
String? id;
String? pageName;
String? mode;
String? openStatus;
String? status;
Filter({this.id, this.pageName, this.mode, this.openStatus, this.status});
Filter.fromJson(Map<String, dynamic> json) {
id = json['id'];
pageName = json['page_name'];
mode = json['mode'];
openStatus = json['open_status'];
status = json['status'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['page_name'] = this.pageName;
data['mode'] = this.mode;
data['open_status'] = this.openStatus;
data['status'] = this.status;
return data;
}
}
class orderPendingTasksListResponse {
List<PendingTasks>? pendingTasks;
String? error;
String? message;
orderPendingTasksListResponse({this.pendingTasks, this.error, this.message});
orderPendingTasksListResponse.fromJson(Map<String, dynamic> json) {
if (json['pending_tasks'] != null) {
pendingTasks = <PendingTasks>[];
json['pending_tasks'].forEach((v) {
pendingTasks!.add(new PendingTasks.fromJson(v));
});
}
error = json['error'];
message = json['message'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.pendingTasks != null) {
data['pending_tasks'] =
this.pendingTasks!.map((v) => v.toJson()).toList();
}
data['error'] = this.error;
data['message'] = this.message;
return data;
}
}
class PendingTasks {
String? conmob;
String? aname;
String? appdate;
String? atype;
String? anote;
String? leadid;
String? lstatus;
String? lempid;
String? aid;
PendingTasks(
{this.conmob,
this.aname,
this.appdate,
this.atype,
this.anote,
this.leadid,
this.lstatus,
this.lempid,
this.aid});
PendingTasks.fromJson(Map<String, dynamic> json) {
conmob = json['conmob'];
aname = json['aname'];
appdate = json['appdate'];
atype = json['atype'];
anote = json['anote'];
leadid = json['leadid'];
lstatus = json['lstatus'];
lempid = json['lempid'];
aid = json['aid'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['conmob'] = this.conmob;
data['aname'] = this.aname;
data['appdate'] = this.appdate;
data['atype'] = this.atype;
data['anote'] = this.anote;
data['leadid'] = this.leadid;
data['lstatus'] = this.lstatus;
data['lempid'] = this.lempid;
data['aid'] = this.aid;
return data;
}
}
class ordersPdiIdByEngNumberResponse {
String? pdiId;
String? error;
String? message;
ordersPdiIdByEngNumberResponse({this.pdiId, this.error, this.message});
ordersPdiIdByEngNumberResponse.fromJson(Map<String, dynamic> json) {
pdiId = json['pdi_id'];
error = json['error'];
message = json['message'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['pdi_id'] = this.pdiId;
data['error'] = this.error;
data['message'] = this.message;
return data;
}
}
import 'dart:async'; import 'dart:async';
import 'dart:io'; import 'dart:io';
import 'package:camera/camera.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_image_compress/flutter_image_compress.dart'; import 'package:flutter_image_compress/flutter_image_compress.dart';
...@@ -30,16 +31,24 @@ class CheckInOutProvider with ChangeNotifier { ...@@ -30,16 +31,24 @@ class CheckInOutProvider with ChangeNotifier {
bool hasLocationPermission = false; bool hasLocationPermission = false;
Timer? _timer; Timer? _timer;
File? _image; File? _image;
int imagePicked = 0; int _imagePicked = 0;
bool isLoading = true; bool isLoading = true;
String? validateLocation; String? validateLocation;
String? empId; String? empId;
String? sessionId; String? sessionId;
late List<CameraDescription> _cameras;
late CameraController cam_controller;
File? get image => _image; File? get image => _image;
int get imagePicked => _imagePicked;
set imagePicked(int value){
_imagePicked = value;
notifyListeners();
}
set image(value) { set image(value) {
_image = value; _image = value;
notifyListeners();
} }
Future<void> getCurrentLocation() async { Future<void> getCurrentLocation() async {
...@@ -134,7 +143,36 @@ class CheckInOutProvider with ChangeNotifier { ...@@ -134,7 +143,36 @@ class CheckInOutProvider with ChangeNotifier {
getLocationPermission(context); getLocationPermission(context);
}); });
} }
// Future<void> getavailableCameras(context,attendanceStatus) async {
// try {
// _cameras = await availableCameras();
//
// final frontCamera = _cameras.firstWhere(
// (camera) => camera.lensDirection == CameraLensDirection.front,
// );
//
// cam_controller = CameraController(frontCamera, ResolutionPreset.max);
//
// await cam_controller.initialize();
// if (!cam_controller.value.isInitialized) return;
// final image = await cam_controller.takePicture();
// _image = File(image.path);
// imagePicked = 1;
// var file = await FlutterImageCompress.compressWithFile(
// _image!.path,
// );
// if (file != null) {
// if (attendanceStatus == 0) {
// checkIn(context);
// } else if (attendanceStatus == 1) {
// checkOut(context);
// }
// }
// } catch (e) {
// toast(context, "Failed to initialize camera");
//
// }
// }
Future<void> imgFromCamera(BuildContext context, attendanceStatus) async { Future<void> imgFromCamera(BuildContext context, attendanceStatus) async {
if (locationController.text.isEmpty) { if (locationController.text.isEmpty) {
validateLocation = "Please Enter location"; validateLocation = "Please Enter location";
...@@ -150,7 +188,7 @@ class CheckInOutProvider with ChangeNotifier { ...@@ -150,7 +188,7 @@ class CheckInOutProvider with ChangeNotifier {
); );
if (galleryImage != null) { if (galleryImage != null) {
_image = File(galleryImage.path); _image = File(galleryImage.path);
imagePicked = 1; _imagePicked = 1;
var file = await FlutterImageCompress.compressWithFile( var file = await FlutterImageCompress.compressWithFile(
galleryImage.path, galleryImage.path,
); );
...@@ -172,11 +210,11 @@ class CheckInOutProvider with ChangeNotifier { ...@@ -172,11 +210,11 @@ class CheckInOutProvider with ChangeNotifier {
empId = await SharedpreferencesService().getString("UserId"); empId = await SharedpreferencesService().getString("UserId");
sessionId = await SharedpreferencesService().getString("Session_id"); sessionId = await SharedpreferencesService().getString("Session_id");
if (kDebugMode) { if (kDebugMode) {
print(empId); // print(empId);
print(sessionId); // print(sessionId);
print(locationController.text); // print(locationController.text);
print(latlongs); // print(latlongs);
print(_image); // print(_image);
} }
try { try {
isLoading = true; isLoading = true;
...@@ -193,6 +231,7 @@ class CheckInOutProvider with ChangeNotifier { ...@@ -193,6 +231,7 @@ class CheckInOutProvider with ChangeNotifier {
toast(context, "CheckedIn Successfully"); toast(context, "CheckedIn Successfully");
await BackgroundLocationService.startLocationService(context); await BackgroundLocationService.startLocationService(context);
locationController.clear(); locationController.clear();
dispose();
Navigator.pop(context, true); Navigator.pop(context, true);
} else { } else {
toast(context, "Check-In UnSuccessful"); toast(context, "Check-In UnSuccessful");
...@@ -229,6 +268,7 @@ class CheckInOutProvider with ChangeNotifier { ...@@ -229,6 +268,7 @@ class CheckInOutProvider with ChangeNotifier {
toast(context, "Check-Out Successful"); toast(context, "Check-Out Successful");
await BackgroundLocationService.stopLocationService(); await BackgroundLocationService.stopLocationService();
locationController.clear(); locationController.clear();
dispose();
Navigator.pop(context, true); Navigator.pop(context, true);
} else { } else {
toast(context, "Check-Out UnSuccessful"); toast(context, "Check-Out UnSuccessful");
...@@ -247,7 +287,11 @@ class CheckInOutProvider with ChangeNotifier { ...@@ -247,7 +287,11 @@ class CheckInOutProvider with ChangeNotifier {
} }
void dispose() { void dispose() {
locationController.dispose(); validateLocation = null;
// locationController.dispose();
locationController.clear();
_timer?.cancel(); _timer?.cancel();
notifyListeners();
} }
} }
This diff is collapsed.
...@@ -100,7 +100,7 @@ class InventoryProvider extends ChangeNotifier { ...@@ -100,7 +100,7 @@ class InventoryProvider extends ChangeNotifier {
notifyListeners(); notifyListeners();
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute(builder: (context) => Complainthistory()), MaterialPageRoute(builder: (context) => Complainthistory(genHashID: scanData.code,)),
); );
} }
}); });
...@@ -167,7 +167,7 @@ class InventoryProvider extends ChangeNotifier { ...@@ -167,7 +167,7 @@ class InventoryProvider extends ChangeNotifier {
this._qrViewController!.pauseCamera(); this._qrViewController!.pauseCamera();
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute(builder: (context) => Complainthistory()), MaterialPageRoute(builder: (context) => Complainthistory(genHashID: genID,)),
); );
notifyListeners(); notifyListeners();
} else { } else {
......
...@@ -178,6 +178,10 @@ class Paymentdetailsprovider extends ChangeNotifier { ...@@ -178,6 +178,10 @@ class Paymentdetailsprovider extends ChangeNotifier {
Future<void> PaymentUpdateAPI(BuildContext context, reference, amount) async { Future<void> PaymentUpdateAPI(BuildContext context, reference, amount) async {
try { try {
// if(!CheckValidations(context,reference, amount)){
// return;
// }
print("came here");
var homeProvider = Provider.of<HomescreenNotifier>( var homeProvider = Provider.of<HomescreenNotifier>(
context, context,
listen: false, listen: false,
...@@ -199,6 +203,7 @@ class Paymentdetailsprovider extends ChangeNotifier { ...@@ -199,6 +203,7 @@ class Paymentdetailsprovider extends ChangeNotifier {
if (data.sessionExists == 1) { if (data.sessionExists == 1) {
if (data.error == 0) { if (data.error == 0) {
_CollectionId = data.paymentCollectionId ?? 0; _CollectionId = data.paymentCollectionId ?? 0;
print(data.paymentCollectionId);
// OTPDialogue(context); // OTPDialogue(context);
notifyListeners(); notifyListeners();
} else {} } else {}
...@@ -266,14 +271,7 @@ class Paymentdetailsprovider extends ChangeNotifier { ...@@ -266,14 +271,7 @@ class Paymentdetailsprovider extends ChangeNotifier {
_image = File(galleryImage!.path); _image = File(galleryImage!.path);
_imageName = File(galleryImage!.name); _imageName = File(galleryImage!.name);
_image_picked = 1; _image_picked = 1;
if (_image != null) { notifyListeners();
var file = FlutterImageCompress.compressWithFile(galleryImage!.path);
{
if (file != null) {
CheckValidations(context, reference, amount);
}
}
}
} catch (e) { } catch (e) {
debugPrint("mmmm: ${e.toString()}"); debugPrint("mmmm: ${e.toString()}");
} }
...@@ -295,31 +293,32 @@ class Paymentdetailsprovider extends ChangeNotifier { ...@@ -295,31 +293,32 @@ class Paymentdetailsprovider extends ChangeNotifier {
_imageName = File(galleryImage!.name); _imageName = File(galleryImage!.name);
_image_picked = 1; _image_picked = 1;
if (_image != null) { notifyListeners();
var file = FlutterImageCompress.compressWithFile(galleryImage!.path);
{
if (file != null) {
CheckValidations(context, reference, amount);
}
}
}
} catch (e) { } catch (e) {
debugPrint("mmmm: ${e.toString()}"); debugPrint("mmmm: ${e.toString()}");
} }
} }
CheckValidations(BuildContext context, reference, amount) { bool CheckValidations(BuildContext context,reference, amount) {
bool isValid = true;
if (_contactID == null || _contactID == "") { if (_contactID == null || _contactID == "") {
toast(context, "Select Phone Number"); toast(context, "Select Phone Number");
} else if (_paymentModeID == null || _paymentModeID == "") { isValid = false;
}
if (_paymentModeID == null || _paymentModeID == "") {
toast(context, "Select Payment Mode"); toast(context, "Select Payment Mode");
} else if (amount.isEmpty) { isValid = false;
}
if (amount.isEmpty) {
toast(context, "Enter Amount"); toast(context, "Enter Amount");
} else if (_image == "" || _image == null || _image_picked == 0) { isValid = false;
}
if (_image == "" || _image == null || _image_picked == 0) {
toast(context, "Select Attachment"); toast(context, "Select Attachment");
} else { isValid = false;
PaymentUpdateAPI(context, reference, amount);
} }
notifyListeners();
return isValid;
} }
String _saveAgainst = ""; String _saveAgainst = "";
......
...@@ -12,19 +12,27 @@ class Accountledgerprovider extends ChangeNotifier{ ...@@ -12,19 +12,27 @@ class Accountledgerprovider extends ChangeNotifier{
List<Accounts> _accounts = []; List<Accounts> _accounts = [];
List<LedgerList> _ledgerList = []; List<LedgerList> _ledgerList = [];
BalanceDetails _balanceDetails = BalanceDetails();
AccountDetails _accountDetails = AccountDetails(); AccountDetails _accountDetails = AccountDetails();
Accounts? _selectedAccount; Accounts? _selectedAccount;
String _selectedAcID = ""; String _selectedAcID = "";
String _selectedAcVal = ""; String _selectedAcVal = "";
bool _isLoading = true; bool _isLoading = true;
bool _showMoreDetails = false;
bool get isLoading => _isLoading; bool get isLoading => _isLoading;
bool get showMoreDetails => _showMoreDetails;
List<Accounts> get accounts => _accounts; List<Accounts> get accounts => _accounts;
List<LedgerList> get ledgerList => _ledgerList; List<LedgerList> get ledgerList => _ledgerList;
AccountDetails get acDetails => _accountDetails; AccountDetails get acDetails => _accountDetails;
BalanceDetails get balanceDetails => _balanceDetails;
Accounts? get selectedAccount => _selectedAccount; Accounts? get selectedAccount => _selectedAccount;
String get selectedAcId => _selectedAcID; String get selectedAcId => _selectedAcID;
String get selectedAcVal => _selectedAcVal; String get selectedAcVal => _selectedAcVal;
set showMoreDetails(bool value){
_showMoreDetails = value;
notifyListeners();
}
set accounts(List<Accounts> value){ set accounts(List<Accounts> value){
_accounts = value; _accounts = value;
notifyListeners(); notifyListeners();
...@@ -90,6 +98,7 @@ class Accountledgerprovider extends ChangeNotifier{ ...@@ -90,6 +98,7 @@ class Accountledgerprovider extends ChangeNotifier{
if(data.error=="0"){ if(data.error=="0"){
_isLoading = false; _isLoading = false;
_ledgerList= data.ledgerList!; _ledgerList= data.ledgerList!;
_balanceDetails = data.balanceDetails!;
_accountDetails= data.accountDetails!; _accountDetails= data.accountDetails!;
if (_selectedAccount != null && if (_selectedAccount != null &&
!_accounts.contains(_selectedAccount)) { !_accounts.contains(_selectedAccount)) {
...@@ -99,9 +108,10 @@ class Accountledgerprovider extends ChangeNotifier{ ...@@ -99,9 +108,10 @@ class Accountledgerprovider extends ChangeNotifier{
notifyListeners(); notifyListeners();
} else if(data.error=="1"){ } else if(data.error=="1"){
_isLoading = false; _isLoading = false;
}
notifyListeners(); notifyListeners();
} }
}
}catch (e,s){ }catch (e,s){
} }
......
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.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/screens/commom/accountsListDetails.dart';
import 'package:generp/screens/finance/financeDashboard.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';
...@@ -21,7 +24,8 @@ class Accountslistprovider extends ChangeNotifier { ...@@ -21,7 +24,8 @@ class Accountslistprovider extends ChangeNotifier {
TextEditingController bankAcNumberController = TextEditingController(); TextEditingController bankAcNumberController = TextEditingController();
TextEditingController bankUpiController = TextEditingController(); TextEditingController bankUpiController = TextEditingController();
TextEditingController contactPersonController = TextEditingController(); TextEditingController contactPersonController = TextEditingController();
TextEditingController contectPersonDesignationController = TextEditingController(); TextEditingController contectPersonDesignationController =
TextEditingController();
TextEditingController contectPersonAltMobController = TextEditingController(); TextEditingController contectPersonAltMobController = TextEditingController();
TextEditingController contectPersonTeleController = TextEditingController(); TextEditingController contectPersonTeleController = TextEditingController();
TextEditingController contectPersonMailController = TextEditingController(); TextEditingController contectPersonMailController = TextEditingController();
...@@ -87,7 +91,7 @@ class Accountslistprovider extends ChangeNotifier { ...@@ -87,7 +91,7 @@ class Accountslistprovider extends ChangeNotifier {
set isVisible(bool value) { set isVisible(bool value) {
_isVisible = value; _isVisible = value;
if(value==true){ if (value == true) {
addMoreDetailsError = null; addMoreDetailsError = null;
} }
notifyListeners(); notifyListeners();
...@@ -239,7 +243,6 @@ class Accountslistprovider extends ChangeNotifier { ...@@ -239,7 +243,6 @@ class Accountslistprovider extends ChangeNotifier {
); );
if (data != null) { if (data != null) {
if (data.error == "0") { if (data.error == "0") {
_subLocations = data.subLocations!; _subLocations = data.subLocations!;
notifyListeners(); notifyListeners();
} }
...@@ -262,28 +265,30 @@ class Accountslistprovider extends ChangeNotifier { ...@@ -262,28 +265,30 @@ class Accountslistprovider extends ChangeNotifier {
mobileError = null; mobileError = null;
notifyListeners(); notifyListeners();
} else if (data.error == "1") { } else if (data.error == "1") {
if(data.message?.contains("name already exists") ?? false){ if (data.message?.contains("name already exists") ?? false) {
nameError = data.message??""; nameError = data.message ?? "";
}else{ } else {
mobileError = data.message??""; mobileError = data.message ?? "";
} }
notifyListeners(); notifyListeners();
// toast(context, data.message); // toast(context, data.message);
} }
} }
} catch (e, s) {} } catch (e, s) {}
} }
bool hasFilledAdditionalDetails = false; bool hasFilledAdditionalDetails = false;
bool _submitClicked = false; bool _submitClicked = false;
bool get submitClickced => _submitClicked; bool get submitClickced => _submitClicked;
set submitClickced(bool value){ set submitClickced(bool value) {
_submitClicked = value; _submitClicked = value;
notifyListeners(); notifyListeners();
} }
Future<void> submitCommonAccountsAPI(context) async {
Future<void> submitCommonAccountsAPI(context, from) async {
try { try {
if (!validatereceiptForm(context)) { if (!validatereceiptForm(context)) {
// _submitClicked = false; // _submitClicked = false;
...@@ -317,7 +322,23 @@ class Accountslistprovider extends ChangeNotifier { ...@@ -317,7 +322,23 @@ class Accountslistprovider extends ChangeNotifier {
if (data.error == "0") { if (data.error == "0") {
_submitClicked = false; _submitClicked = false;
notifyListeners(); notifyListeners();
Navigator.pop(context); var res = data.id!;
if (from == "Requesition") {
Navigator.pop(context, res);
} else if (from == "Dashboard") {
print("here");
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(
builder: (context) => Accountslistdetails(accountID: data.id),
),
(Route<dynamic> route) {
return route.settings.arguments == 'Financedashboard';
},
);
}
resetValues(); resetValues();
toast(context, data.message); toast(context, data.message);
} else if (data.error == "1") { } else if (data.error == "1") {
...@@ -328,7 +349,7 @@ class Accountslistprovider extends ChangeNotifier { ...@@ -328,7 +349,7 @@ class Accountslistprovider extends ChangeNotifier {
_submitClicked = false; _submitClicked = false;
notifyListeners(); notifyListeners();
} }
}else{ } else {
_submitClicked = false; _submitClicked = false;
notifyListeners(); notifyListeners();
} }
...@@ -371,6 +392,10 @@ class Accountslistprovider extends ChangeNotifier { ...@@ -371,6 +392,10 @@ class Accountslistprovider extends ChangeNotifier {
mobileError = "Please Enter Mobile Number"; mobileError = "Please Enter Mobile Number";
isValid = false; isValid = false;
} }
if (contactPersonController.text.trim().isEmpty) {
contactPersonError = "Please Enter Contact Person Name";
isValid = false;
}
// //
// //
// if (!_isVisible && !hasFilledAdditionalDetails) { // if (!_isVisible && !hasFilledAdditionalDetails) {
...@@ -453,7 +478,6 @@ class Accountslistprovider extends ChangeNotifier { ...@@ -453,7 +478,6 @@ class Accountslistprovider extends ChangeNotifier {
// //
// } // }
// if (contectPersonTeleController.text.trim().isEmpty) { // if (contectPersonTeleController.text.trim().isEmpty) {
// teleError= "Please Enter Telephone"; isValid = false; // teleError= "Please Enter Telephone"; isValid = false;
// } // }
...@@ -469,6 +493,7 @@ class Accountslistprovider extends ChangeNotifier { ...@@ -469,6 +493,7 @@ class Accountslistprovider extends ChangeNotifier {
nameError = null; nameError = null;
notifyListeners(); notifyListeners();
} }
void updateMobile(String value) { void updateMobile(String value) {
mobileError = null; mobileError = null;
notifyListeners(); notifyListeners();
...@@ -515,29 +540,31 @@ class Accountslistprovider extends ChangeNotifier { ...@@ -515,29 +540,31 @@ class Accountslistprovider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
void updateContactPerson(String value){ void updateContactPerson(String value) {
contactPersonError = null; contactPersonError = null;
notifyListeners(); notifyListeners();
} }
void updateDesignation(String value){
void updateDesignation(String value) {
desigantionError = null; desigantionError = null;
notifyListeners(); notifyListeners();
} }
void updateAltMobile(String value){
void updateAltMobile(String value) {
altMobError = null; altMobError = null;
notifyListeners(); notifyListeners();
} }
void updateTeleMobile(String value){ void updateTeleMobile(String value) {
teleError = null; teleError = null;
notifyListeners(); notifyListeners();
} }
void updateMail(String value){
void updateMail(String value) {
mailError = null; mailError = null;
notifyListeners(); notifyListeners();
...@@ -634,18 +661,21 @@ class Accountslistprovider extends ChangeNotifier { ...@@ -634,18 +661,21 @@ class Accountslistprovider extends ChangeNotifier {
} }
void ChechkDropdownValues() { void ChechkDropdownValues() {
if(!_accountTypes.contains(_selectedAccountType)&&_selectedAccountType!=null){ if (!_accountTypes.contains(_selectedAccountType) &&
_selectedAccountType != null) {
_selectedAccountType = null; _selectedAccountType = null;
} }
if(!_states.contains(_selectedState)&&_selectedState!=null){ if (!_states.contains(_selectedState) && _selectedState != null) {
_selectedStateID = null; _selectedStateID = null;
_selectedStateValue = null; _selectedStateValue = null;
} }
if(!_districts.contains(_selectedDistricts)&&_selectedDistricts!=null){ if (!_districts.contains(_selectedDistricts) &&
_selectedDistricts != null) {
_selectedDistrictID = null; _selectedDistrictID = null;
_selectedDistrictValue = null; _selectedDistrictValue = null;
} }
if(!_subLocations.contains(_selectedSubLocations)&&_selectedSubLocations!=null){ if (!_subLocations.contains(_selectedSubLocations) &&
_selectedSubLocations != null) {
_selectedSubLocID = null; _selectedSubLocID = null;
_selectedSubLocValue = null; _selectedSubLocValue = null;
} }
......
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