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,33 +82,63 @@ class MainActivity : FlutterActivity(){ ...@@ -93,33 +82,63 @@ 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
request.setTitle(fileName) 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.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
request.setAllowedOverMetered(true) downloadManager.enqueue(request)
request.setAllowedOverRoaming(false) } else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { // Handle regular URL
request.setRequiresCharging(false) val request = DownloadManager.Request(Uri.parse(url.trim()))
request.setRequiresDeviceIdle(false) val cookies = CookieManager.getInstance().getCookie(url) ?: ""
} request.addRequestHeader("Cookie", cookies)
request.setVisibleInDownloadsUi(true) 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.setAllowedOverRoaming(false)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
request.setRequiresCharging(false)
request.setRequiresDeviceIdle(false)
}
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
} }
} }
} }
\ No newline at end of file
<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;
} }
} }
...@@ -82,6 +94,24 @@ class PaymentModes { ...@@ -82,6 +94,24 @@ class PaymentModes {
name = json['name']; name = json['name'];
} }
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['name'] = this.name;
return data;
}
}
class 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() { 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;
......
...@@ -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();
} }
} }
import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:generp/Utils/commonServices.dart'; import 'package:generp/Utils/commonServices.dart';
...@@ -6,6 +8,7 @@ import 'package:generp/services/api_calling.dart'; ...@@ -6,6 +8,7 @@ import 'package:generp/services/api_calling.dart';
import 'package:geolocator/geolocator.dart'; import 'package:geolocator/geolocator.dart';
import 'package:geolocator/geolocator.dart' as geo_location; import 'package:geolocator/geolocator.dart' as geo_location;
import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:image_picker/image_picker.dart';
import 'package:location/location.dart' as Location; import 'package:location/location.dart' as Location;
import 'package:permission_handler/permission_handler.dart'; import 'package:permission_handler/permission_handler.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
...@@ -16,7 +19,7 @@ import '../Utils/app_colors.dart'; ...@@ -16,7 +19,7 @@ import '../Utils/app_colors.dart';
import 'HomeScreenNotifier.dart'; import 'HomeScreenNotifier.dart';
class Generatordetailsprovider extends ChangeNotifier { class Generatordetailsprovider extends ChangeNotifier {
bool _submitLoading = false;
PermissionStatus _cameraPermissionStatus = PermissionStatus.denied; PermissionStatus _cameraPermissionStatus = PermissionStatus.denied;
PermissionStatus _LocationPermissionStatus = PermissionStatus.denied; PermissionStatus _LocationPermissionStatus = PermissionStatus.denied;
final GlobalKey scannerKey = GlobalKey(debugLabel: 'QR'); final GlobalKey scannerKey = GlobalKey(debugLabel: 'QR');
...@@ -28,6 +31,7 @@ class Generatordetailsprovider extends ChangeNotifier { ...@@ -28,6 +31,7 @@ class Generatordetailsprovider extends ChangeNotifier {
FocusNode engineNoFocusNode = FocusNode(); FocusNode engineNoFocusNode = FocusNode();
List<C_List> _complaintList = []; List<C_List> _complaintList = [];
String? _genID = "-"; String? _genID = "-";
String? _genHashID = "-";
String? _aname = "-"; String? _aname = "-";
String? _emodel = "-"; String? _emodel = "-";
String? _spname = "-"; String? _spname = "-";
...@@ -46,11 +50,17 @@ class Generatordetailsprovider extends ChangeNotifier { ...@@ -46,11 +50,17 @@ class Generatordetailsprovider extends ChangeNotifier {
String? _dispDate = "-"; String? _dispDate = "-";
String? _cmsngDate = "-"; String? _cmsngDate = "-";
String? _status = "-"; String? _status = "-";
String? _genLocation = "-";
String? _genLocationLatLngs;
String _title = "-"; String _title = "-";
String _subTitle = "-"; String _subTitle = "-";
bool _isLoading = false; bool _isLoading = false;
String? _scannedGenID; String? _scannedGenID;
final ImagePicker _picker = ImagePicker();
File? _image;
File? _imageName;
int _imagePicked = 0;
LatLng startLocation = const LatLng(17.439112226708446, 78.43292499146135); LatLng startLocation = const LatLng(17.439112226708446, 78.43292499146135);
LatLng? currentLocationLatLng; LatLng? currentLocationLatLng;
String latlongs = ""; String latlongs = "";
...@@ -62,6 +72,31 @@ class Generatordetailsprovider extends ChangeNotifier { ...@@ -62,6 +72,31 @@ class Generatordetailsprovider extends ChangeNotifier {
ComplaintCategoryList? _selectedCategoryType; ComplaintCategoryList? _selectedCategoryType;
ComplaintDescriptionList? _selectedDescriptionType; ComplaintDescriptionList? _selectedDescriptionType;
File? get image => _image;
File? get imagePath => _imageName;
int get imagePicked => _imagePicked;
String? _imageError;
String? get imageError => _imageError;
set imagePath(File? value) {
_imageName = value;
notifyListeners();
}
set imageFilePath(File? value) {
_image = value;
notifyListeners();
}
set imagePicked(value) {
_imagePicked = value;
notifyListeners();
}
String? _selectedType; String? _selectedType;
String? _selectedTypeId; String? _selectedTypeId;
...@@ -71,6 +106,8 @@ class Generatordetailsprovider extends ChangeNotifier { ...@@ -71,6 +106,8 @@ class Generatordetailsprovider extends ChangeNotifier {
String? _selectedDescription; String? _selectedDescription;
String? _selectedDescriptionId; String? _selectedDescriptionId;
bool get submitLoading => _submitLoading;
List<ComplaintTypeList> get complaintTypeDropdown => _complaintTypeDropdown; List<ComplaintTypeList> get complaintTypeDropdown => _complaintTypeDropdown;
List<ComplaintCategoryList> get complaintCategorydropdown => List<ComplaintCategoryList> get complaintCategorydropdown =>
...@@ -106,6 +143,8 @@ class Generatordetailsprovider extends ChangeNotifier { ...@@ -106,6 +143,8 @@ class Generatordetailsprovider extends ChangeNotifier {
String? get genID => _genID; String? get genID => _genID;
String? get genHashID => _genHashID;
String? get aname => _aname; String? get aname => _aname;
String? get emodel => _emodel; String? get emodel => _emodel;
...@@ -142,18 +181,35 @@ class Generatordetailsprovider extends ChangeNotifier { ...@@ -142,18 +181,35 @@ class Generatordetailsprovider extends ChangeNotifier {
String? get status => _status; String? get status => _status;
String? get genLocation => _genLocation;
String? get genLocationLatLngs => _genLocationLatLngs;
bool get isLoading => _isLoading; bool get isLoading => _isLoading;
bool get hasPermission => _hasPermission; bool get hasPermission => _hasPermission;
bool get hasLocationPermission => _hasLocationPermission; bool get hasLocationPermission => _hasLocationPermission;
String? get scannedGenID => _scannedGenID; String? get scannedGenID => _scannedGenID;
QRViewController? get qrViewController => _qrViewController; QRViewController? get qrViewController => _qrViewController;
set scannedGenID(String? id) { set genLocationLatLngs(String? value) {
_genLocationLatLngs = value;
notifyListeners();
}
set submitLoading(bool value) {
_submitLoading = value;
notifyListeners();
}
set scannedGenID(String? id) {
_scannedGenID = id; _scannedGenID = id;
notifyListeners(); notifyListeners();
} }
set selectedComplaintType(value) { set selectedComplaintType(value) {
_selectedComplaintType = value; _selectedComplaintType = value;
_selectedType = value.name; _selectedType = value.name;
...@@ -203,12 +259,12 @@ class Generatordetailsprovider extends ChangeNotifier { ...@@ -203,12 +259,12 @@ class Generatordetailsprovider extends ChangeNotifier {
_selectedDescriptionId = value; _selectedDescriptionId = value;
} }
void resetForm(){ void resetForm() {
_qrViewController!.dispose(); _qrViewController!.dispose();
engNoController.clear(); engNoController.clear();
_selectedComplaintType = null; _selectedComplaintType = null;
_selectedCategoryType= null; _selectedCategoryType = null;
_selectedDescriptionType= null; _selectedDescriptionType = null;
_selectedType = ""; _selectedType = "";
_selectedTypeId = ""; _selectedTypeId = "";
_selectedCategory = ""; _selectedCategory = "";
...@@ -322,12 +378,12 @@ class Generatordetailsprovider extends ChangeNotifier { ...@@ -322,12 +378,12 @@ class Generatordetailsprovider extends ChangeNotifier {
Future<void> getLocationPermission(BuildContext context) async { Future<void> getLocationPermission(BuildContext context) async {
isLocationEnabled = await Geolocator.isLocationServiceEnabled(); isLocationEnabled = await Geolocator.isLocationServiceEnabled();
LocationPermission permission = await Geolocator.checkPermission(); LocationPermission permission = await Geolocator.checkPermission();
_hasLocationPermission = permission == LocationPermission.always || _hasLocationPermission =
permission == LocationPermission.always ||
permission == LocationPermission.whileInUse; permission == LocationPermission.whileInUse;
final Location.Location location = Location.Location(); final Location.Location location = Location.Location();
if (!isLocationEnabled || !hasLocationPermission) { if (!isLocationEnabled || !hasLocationPermission) {
permission = await Geolocator.requestPermission(); permission = await Geolocator.requestPermission();
if (permission != LocationPermission.always && if (permission != LocationPermission.always &&
...@@ -338,7 +394,8 @@ class Generatordetailsprovider extends ChangeNotifier { ...@@ -338,7 +394,8 @@ class Generatordetailsprovider extends ChangeNotifier {
return AlertDialog( return AlertDialog(
title: Text('Location Permission Required'), title: Text('Location Permission Required'),
content: Text( content: Text(
'Please allow the app to access your location for core functionality.'), 'Please allow the app to access your location for core functionality.',
),
actions: <Widget>[ actions: <Widget>[
TextButton( TextButton(
style: ButtonStyle( style: ButtonStyle(
...@@ -376,7 +433,8 @@ class Generatordetailsprovider extends ChangeNotifier { ...@@ -376,7 +433,8 @@ class Generatordetailsprovider extends ChangeNotifier {
Future<void> getCurrentLocation() async { Future<void> getCurrentLocation() async {
try { try {
Position position = await Geolocator.getCurrentPosition( Position position = await Geolocator.getCurrentPosition(
desiredAccuracy: geo_location.LocationAccuracy.high); desiredAccuracy: geo_location.LocationAccuracy.high,
);
currentLocationLatLng = LatLng(position.latitude, position.longitude); currentLocationLatLng = LatLng(position.latitude, position.longitude);
notifyListeners(); notifyListeners();
} catch (e) { } catch (e) {
...@@ -392,24 +450,34 @@ class Generatordetailsprovider extends ChangeNotifier { ...@@ -392,24 +450,34 @@ class Generatordetailsprovider extends ChangeNotifier {
controller!.pauseCamera(); controller!.pauseCamera();
if (from == "Generator Details") { if (from == "Generator Details") {
_genID = scanData.code; _genID = scanData.code;
_genHashID = scanData.code;
notifyListeners();
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute(builder: (context) => Generatordetails(generatorId: scanData.code,)), MaterialPageRoute(
builder: (context) => Generatordetails(generatorId: scanData.code),
),
); );
} else if (from == "Register Complaint") { } else if (from == "Register Complaint") {
_genID = scanData.code; _genID = scanData.code;
_genHashID = scanData.code;
notifyListeners();
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute(builder: (context) => Registercomplaint()), MaterialPageRoute(builder: (context) => Registercomplaint()),
); );
} else if (from == "Tag Location") { } else if (from == "Tag Location") {
_genID = scanData.code; _genID = scanData.code;
_genHashID = scanData.code;
notifyListeners();
print(scanData.code); print(scanData.code);
TagLocationAPIFunction(HomeProvider, context, scanData.code,"Scanner"); TagLocationAPIFunction(HomeProvider, context, scanData.code, "Scanner");
} else if (from == "Tag Generator") { } else if (from == "Tag Generator") {
_genID = scanData.code; _genID = scanData.code;
_genHashID = scanData.code;
notifyListeners();
print(scanData.code); print(scanData.code);
showTagGeneratorBottomSheet(context,_genID); showTagGeneratorBottomSheet(context, scanData.code);
// TagGeneraorAPIFunction(HomeProvider, context, scanData.code); // TagGeneraorAPIFunction(HomeProvider, context, scanData.code);
} }
}); });
...@@ -419,9 +487,13 @@ class Generatordetailsprovider extends ChangeNotifier { ...@@ -419,9 +487,13 @@ class Generatordetailsprovider extends ChangeNotifier {
homeProvider, homeProvider,
BuildContext context, BuildContext context,
from, from,
genID, genID, [
) async { number,
]) async {
print("$number index calling");
try { try {
_submitLoading = true;
notifyListeners();
final data = await ApiCalling.LoadGeneratorDetailsAPI( final data = await ApiCalling.LoadGeneratorDetailsAPI(
homeProvider.empId, homeProvider.empId,
homeProvider.session, homeProvider.session,
...@@ -430,7 +502,9 @@ class Generatordetailsprovider extends ChangeNotifier { ...@@ -430,7 +502,9 @@ class Generatordetailsprovider extends ChangeNotifier {
if (data != null) { if (data != null) {
if (data.error == 0) { if (data.error == 0) {
_submitLoading = false;
_genID = data.genId; _genID = data.genId;
_genHashID = data.genHashId;
_aname = data.aname; _aname = data.aname;
_emodel = data.emodel; _emodel = data.emodel;
_spname = data.spname; _spname = data.spname;
...@@ -449,9 +523,10 @@ class Generatordetailsprovider extends ChangeNotifier { ...@@ -449,9 +523,10 @@ class Generatordetailsprovider extends ChangeNotifier {
_dispDate = data.dispDate; _dispDate = data.dispDate;
_cmsngDate = data.cmsngDate; _cmsngDate = data.cmsngDate;
_status = data.status; _status = data.status;
_complaintTypeDropdown = data.complaintTypeList??[]; _genLocation = data.loc;
_complaintCategorydropdown = data.complaintCategoryList??[]; _complaintTypeDropdown = data.complaintTypeList ?? [];
_complaintDescriptionDropdown = data.complaintDescriptionList??[]; _complaintCategorydropdown = data.complaintCategoryList ?? [];
_complaintDescriptionDropdown = data.complaintDescriptionList ?? [];
if (_selectedComplaintType != null && if (_selectedComplaintType != null &&
!_complaintTypeDropdown.contains(_selectedComplaintType)) { !_complaintTypeDropdown.contains(_selectedComplaintType)) {
_selectedComplaintType = null; _selectedComplaintType = null;
...@@ -475,11 +550,21 @@ class Generatordetailsprovider extends ChangeNotifier { ...@@ -475,11 +550,21 @@ class Generatordetailsprovider extends ChangeNotifier {
_selectedDescriptionId = ""; _selectedDescriptionId = "";
} }
notifyListeners(); notifyListeners();
Navigator.pop(context);
if (from == "Generator Details") { if (from == "Generator Details") {
this._qrViewController!.pauseCamera(); this._qrViewController!.pauseCamera();
Navigator.push( Navigator.pushAndRemoveUntil(
context, context,
MaterialPageRoute(builder: (context) => Generatordetails(generatorId: _genID,)), MaterialPageRoute(
builder:
(context) => Generatordetails(
generatorId: _genID,
activityName: "Generator Details",
),
),
(Route<dynamic> route) {
return route.settings.arguments == 'Gentrackerdashboard';
},
); );
} else if (from == "Register Complaint") { } else if (from == "Register Complaint") {
this._qrViewController!.pauseCamera(); this._qrViewController!.pauseCamera();
...@@ -488,25 +573,31 @@ class Generatordetailsprovider extends ChangeNotifier { ...@@ -488,25 +573,31 @@ class Generatordetailsprovider extends ChangeNotifier {
MaterialPageRoute(builder: (context) => Registercomplaint()), MaterialPageRoute(builder: (context) => Registercomplaint()),
); );
} }
} else if (data.error == 1) {
}
else if (data.error == 1) {
toast(context, "Enter Correct ID"); toast(context, "Enter Correct ID");
} else {} _submitLoading = false;
notifyListeners();
} else {
_submitLoading = false;
notifyListeners();
}
} else {
_submitLoading = false;
notifyListeners();
} }
} on Error catch (e) { } on Error catch (e) {
_submitLoading = false;
notifyListeners();
print(e.toString()); print(e.toString());
} }
} }
Future<void> LoadTechniciangeneratorDetailsApifunction( Future<void> LoadTechniciangeneratorDetailsApifunction(
homeProvider, homeProvider,
BuildContext context, BuildContext context,
from, from,
genID, genID,
) async { ) async {
try { try {
final data = await ApiCalling.LoadTechnicianGeneratorDetailsAPI( final data = await ApiCalling.LoadTechnicianGeneratorDetailsAPI(
homeProvider.empId, homeProvider.empId,
...@@ -535,9 +626,9 @@ class Generatordetailsprovider extends ChangeNotifier { ...@@ -535,9 +626,9 @@ class Generatordetailsprovider extends ChangeNotifier {
_dispDate = data.dispDate; _dispDate = data.dispDate;
_cmsngDate = data.cmsngDate; _cmsngDate = data.cmsngDate;
_status = data.status; _status = data.status;
_complaintTypeDropdown = data.complaintTypeList??[]; _complaintTypeDropdown = data.complaintTypeList ?? [];
_complaintCategorydropdown = data.complaintCategoryList??[]; _complaintCategorydropdown = data.complaintCategoryList ?? [];
_complaintDescriptionDropdown = data.complaintDescriptionList??[]; _complaintDescriptionDropdown = data.complaintDescriptionList ?? [];
if (_selectedComplaintType != null && if (_selectedComplaintType != null &&
!_complaintTypeDropdown.contains(_selectedComplaintType)) { !_complaintTypeDropdown.contains(_selectedComplaintType)) {
_selectedComplaintType = null; _selectedComplaintType = null;
...@@ -565,7 +656,9 @@ class Generatordetailsprovider extends ChangeNotifier { ...@@ -565,7 +656,9 @@ class Generatordetailsprovider extends ChangeNotifier {
this._qrViewController!.pauseCamera(); this._qrViewController!.pauseCamera();
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute(builder: (context) => Generatordetails(generatorId: _genID,)), MaterialPageRoute(
builder: (context) => Generatordetails(generatorId: _genID),
),
); );
} else if (from == "Register Complaint") { } else if (from == "Register Complaint") {
this._qrViewController!.pauseCamera(); this._qrViewController!.pauseCamera();
...@@ -574,13 +667,9 @@ class Generatordetailsprovider extends ChangeNotifier { ...@@ -574,13 +667,9 @@ class Generatordetailsprovider extends ChangeNotifier {
MaterialPageRoute(builder: (context) => Registercomplaint()), MaterialPageRoute(builder: (context) => Registercomplaint()),
); );
} }
} else if (data.error == 1) {
}
else if (data.error == 1) {
toast(context, "Enter Correct ID"); toast(context, "Enter Correct ID");
} else {} } else {}
} }
} on Error catch (e) { } on Error catch (e) {
print(e.toString()); print(e.toString());
...@@ -680,35 +769,50 @@ class Generatordetailsprovider extends ChangeNotifier { ...@@ -680,35 +769,50 @@ class Generatordetailsprovider extends ChangeNotifier {
Future<void> TagLocationAPIFunction( Future<void> TagLocationAPIFunction(
homeProvider, homeProvider,
BuildContext context, BuildContext context,
genID,[fromHere] genID, [
) async { fromHere,
]) async {
_submitLoading = true;
notifyListeners();
if (!valid()) {
return;
}
try { try {
final data = await ApiCalling.TagLocationAPI( final data = await ApiCalling.TagLocationAPI(
homeProvider.empId, homeProvider.empId,
homeProvider.session, homeProvider.session,
genID, genID,
latlongs, latlongs,
_image,
); );
print(latlongs); print(latlongs);
if (data != null) { if (data != null) {
if (data.sessionExists == 1) { if (data.sessionExists == 1) {
if (data.error == 0) { if (data.error == 0) {
_submitLoading = false;
notifyListeners();
toast(context, "Location Tagged Successfully!!"); toast(context, "Location Tagged Successfully!!");
Navigator.pop(context); // Navigator.pop(context);
if(fromHere!="Scanner"){ // if(fromHere!="Scanner"){
//
Navigator.pop(context); // Navigator.pop(context);
} // }
notifyListeners(); notifyListeners();
_isLoading = false; _isLoading = false;
} else if (data.error == 1) { } else if (data.error == 1) {
toast(context, "Please Check Entered ID!!"); toast(context, "Please Check Entered ID!!");
_submitLoading = false;
notifyListeners();
} else { } else {
_isLoading = true; _isLoading = true;
print("error"); print("error");
_submitLoading = false;
notifyListeners();
} }
} else { } else {
_isLoading = true; _isLoading = true;
_submitLoading = false;
notifyListeners();
// SharedpreferencesService().clearPreferences(); // SharedpreferencesService().clearPreferences();
// toast(context, "Your Session expired, Please Login Again!"); // toast(context, "Your Session expired, Please Login Again!");
// Navigator.push( // Navigator.push(
...@@ -718,20 +822,38 @@ class Generatordetailsprovider extends ChangeNotifier { ...@@ -718,20 +822,38 @@ class Generatordetailsprovider extends ChangeNotifier {
} }
} else { } else {
_isLoading = true; _isLoading = true;
_submitLoading = false;
notifyListeners();
toast(context, "Something Went Wrong, Please try again!"); toast(context, "Something Went Wrong, Please try again!");
print("error2"); print("error2");
} }
} on Error catch (e) { } on Error catch (e) {
_submitLoading = false;
notifyListeners();
print(e.toString()); print(e.toString());
} }
} }
bool valid() {
bool isValid = true;
if (_image == null || _imagePicked == 0) {
_imageError = "Please Add Proof";
notifyListeners();
}
notifyListeners();
return isValid;
}
Future<void> TagGeneraorAPIFunction( Future<void> TagGeneraorAPIFunction(
homeProvider, homeProvider,
BuildContext context, BuildContext context,
genID,engineNumber,[fromHere] genID,
) async { engineNumber, [
fromHere,
]) async {
try { try {
_submitLoading = true;
notifyListeners();
final data = await ApiCalling.TagGeneratorAPI( final data = await ApiCalling.TagGeneratorAPI(
homeProvider.empId, homeProvider.empId,
homeProvider.session, homeProvider.session,
...@@ -742,25 +864,44 @@ class Generatordetailsprovider extends ChangeNotifier { ...@@ -742,25 +864,44 @@ class Generatordetailsprovider extends ChangeNotifier {
if (data != null) { if (data != null) {
if (data.sessionExists == 1) { if (data.sessionExists == 1) {
if (data.error == 0) { if (data.error == 0) {
_submitLoading = false;
toast(context, "Generator Tagged Successfully!!"); toast(context, "Generator Tagged Successfully!!");
Navigator.pop(context); Navigator.pop(context);
if(fromHere!="Scanner"){ if (fromHere != "Scanner") {
Navigator.pop(context); Navigator.pop(context);
} }
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(
builder: (context) => const Gentrackerdashboard(),
),
(Route<dynamic> route) {
// Stop removing routes when Gentrackerdashboard is found
return route.settings is MaterialPageRoute &&
(route.settings as MaterialPageRoute).builder(context)
is Gentrackerdashboard;
},
);
notifyListeners(); notifyListeners();
_isLoading = false; _isLoading = false;
} else if (data.error == 1) { } else if (data.error == 1) {
toast(context, "Please Check Entered ID!!"); _submitLoading = false;
}else if (data.error == 2) { notifyListeners();
toast(context, data.message); toast(context, data.message);
} } else if (data.error == 2) {
else { _submitLoading = false;
notifyListeners();
toast(context, data.message);
} else {
_isLoading = true; _isLoading = true;
_submitLoading = false;
notifyListeners();
print("error"); print("error");
} }
} else { } else {
_isLoading = true; _isLoading = true;
_submitLoading = false;
notifyListeners();
// SharedpreferencesService().clearPreferences(); // SharedpreferencesService().clearPreferences();
// toast(context, "Your Session expired, Please Login Again!"); // toast(context, "Your Session expired, Please Login Again!");
// Navigator.push( // Navigator.push(
...@@ -770,15 +911,38 @@ class Generatordetailsprovider extends ChangeNotifier { ...@@ -770,15 +911,38 @@ class Generatordetailsprovider extends ChangeNotifier {
} }
} else { } else {
_isLoading = true; _isLoading = true;
_submitLoading = false;
notifyListeners();
toast(context, "Something Went Wrong, Please try again!"); toast(context, "Something Went Wrong, Please try again!");
print("error2"); print("error2");
} }
} on Error catch (e) { } on Error catch (e) {
_submitLoading = false;
notifyListeners();
print(e.toString()); print(e.toString());
} }
} }
Future<void> showTagGeneratorBottomSheet(BuildContext context,genID) { imgFromCamera() async {
// Capture a photo
try {
final XFile? galleryImage = await _picker.pickImage(
source: ImageSource.camera,
imageQuality: 50,
);
debugPrint("added");
_image = File(galleryImage!.path);
_imageName = File(galleryImage!.name);
_imagePicked = 1;
_imageError = null;
notifyListeners();
} catch (e) {
debugPrint("mmmm: ${e.toString()}");
}
}
Future<void> showTagGeneratorBottomSheet(BuildContext context, genID) {
return showModalBottomSheet( return showModalBottomSheet(
useSafeArea: true, useSafeArea: true,
isDismissible: true, isDismissible: true,
...@@ -794,9 +958,9 @@ class Generatordetailsprovider extends ChangeNotifier { ...@@ -794,9 +958,9 @@ class Generatordetailsprovider extends ChangeNotifier {
child: Padding( child: Padding(
padding: EdgeInsets.only( padding: EdgeInsets.only(
bottom: bottom:
MediaQuery.of( MediaQuery.of(
context, context,
).viewInsets.bottom, // This handles keyboard ).viewInsets.bottom, // This handles keyboard
), ),
child: Container( child: Container(
margin: EdgeInsets.only( margin: EdgeInsets.only(
...@@ -806,8 +970,8 @@ class Generatordetailsprovider extends ChangeNotifier { ...@@ -806,8 +970,8 @@ class Generatordetailsprovider extends ChangeNotifier {
top: 30, top: 30,
), ),
child: Consumer2<Generatordetailsprovider, HomescreenNotifier>( child: Consumer<HomescreenNotifier>(
builder: (context, provider, homeProvider, child) { builder: (context, homeProvider, child) {
return SingleChildScrollView( return SingleChildScrollView(
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
...@@ -827,14 +991,14 @@ class Generatordetailsprovider extends ChangeNotifier { ...@@ -827,14 +991,14 @@ class Generatordetailsprovider extends ChangeNotifier {
alignment: Alignment.center, alignment: Alignment.center,
decoration: BoxDecoration( decoration: BoxDecoration(
color: AppColors.text_field_color, color: AppColors.text_field_color,
borderRadius: BorderRadius.circular(20), borderRadius: BorderRadius.circular(15),
border: border:
engineNoFocusNode.hasFocus engineNoFocusNode.hasFocus
? Border.all( ? Border.all(
color: AppColors.app_blue, color: AppColors.app_blue,
width: 0.5, width: 0.5,
) )
: null, : null,
), ),
// alignment: Alignment.center, // alignment: Alignment.center,
margin: EdgeInsets.only(left: 5.0, right: 5.0), margin: EdgeInsets.only(left: 5.0, right: 5.0),
...@@ -849,7 +1013,8 @@ class Generatordetailsprovider extends ChangeNotifier { ...@@ -849,7 +1013,8 @@ class Generatordetailsprovider extends ChangeNotifier {
controller: engNoController, controller: engNoController,
keyboardType: TextInputType.text, keyboardType: TextInputType.text,
focusNode: engineNoFocusNode, focusNode: engineNoFocusNode,
textCapitalization: TextCapitalization.characters, textCapitalization:
TextCapitalization.characters,
style: TextStyle(fontSize: 14), style: TextStyle(fontSize: 14),
onChanged: (value) {}, onChanged: (value) {},
onTapOutside: (event) { onTapOutside: (event) {
...@@ -859,6 +1024,7 @@ class Generatordetailsprovider extends ChangeNotifier { ...@@ -859,6 +1024,7 @@ class Generatordetailsprovider extends ChangeNotifier {
decoration: InputDecoration( decoration: InputDecoration(
isDense: true, isDense: true,
hintStyle: TextStyle( hintStyle: TextStyle(
color: AppColors.grey_semi,
fontWeight: FontWeight.w400, fontWeight: FontWeight.w400,
fontSize: 14, fontSize: 14,
), ),
...@@ -871,12 +1037,19 @@ class Generatordetailsprovider extends ChangeNotifier { ...@@ -871,12 +1037,19 @@ class Generatordetailsprovider extends ChangeNotifier {
), ),
), ),
InkWell( InkWell(
onTap: () { onTap:
_submitLoading
TagGeneraorAPIFunction(homeProvider, context, genID,engNoController.text); ? null
: () {
_submitLoading = true;
}, notifyListeners();
TagGeneraorAPIFunction(
homeProvider,
context,
genID,
engNoController.text,
);
},
child: Container( child: Container(
alignment: Alignment.center, alignment: Alignment.center,
height: 45, height: 45,
...@@ -888,14 +1061,24 @@ class Generatordetailsprovider extends ChangeNotifier { ...@@ -888,14 +1061,24 @@ class Generatordetailsprovider extends ChangeNotifier {
), ),
decoration: BoxDecoration( decoration: BoxDecoration(
color: AppColors.app_blue, //1487C9 color: AppColors.app_blue, //1487C9
borderRadius: BorderRadius.circular(30.0), borderRadius: BorderRadius.circular(15.0),
), ),
child: Center( child: Center(
child: Text( child:
"Submit", _submitLoading
textAlign: TextAlign.center, ? CircularProgressIndicator.adaptive(
style: TextStyle(color: Colors.white), valueColor: AlwaysStoppedAnimation(
), AppColors.white,
),
padding: EdgeInsets.all(8.0),
)
: Text(
"Submit",
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
),
),
), ),
), ),
), ),
...@@ -912,4 +1095,26 @@ class Generatordetailsprovider extends ChangeNotifier { ...@@ -912,4 +1095,26 @@ class Generatordetailsprovider extends ChangeNotifier {
}, },
); );
} }
// imgFromGallery(context) async {
// // Pick an image
// try {
// final XFile? galleryImage = await _picker.pickImage(
// source: ImageSource.gallery,
// );
// final bytes = (await galleryImage?.readAsBytes())?.lengthInBytes;
// final kb = bytes! / 1024;
// final mb = kb / 1024;
//
// debugPrint("Jenny: bytes:$bytes, kb:$kb, mb: $mb");
//
// _image = File(galleryImage!.path);
// _imageName = File(galleryImage!.name);
// _imagePicked = 1;
// notifyListeners();
// // var file = FlutterImageCompress.compressWithFile(galleryImage!.path);
// } catch (e) {
// debugPrint("mmmm: ${e.toString()}");
// }
// }
} }
...@@ -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,8 +108,9 @@ class Accountledgerprovider extends ChangeNotifier{ ...@@ -99,8 +108,9 @@ 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();
...@@ -481,65 +506,67 @@ class Accountslistprovider extends ChangeNotifier { ...@@ -481,65 +506,67 @@ class Accountslistprovider extends ChangeNotifier {
void updateBankName(String value) { void updateBankName(String value) {
banknameError = null; banknameError = null;
notifyListeners(); notifyListeners();
} }
void updateBankBranch(String value) { void updateBankBranch(String value) {
bankBranchError = null; bankBranchError = null;
notifyListeners(); notifyListeners();
} }
void updateIFSC(String value) { void updateIFSC(String value) {
bankIFSCError = null; bankIFSCError = null;
notifyListeners(); notifyListeners();
} }
void updateHolder(String value) { void updateHolder(String value) {
bankHolderNameError = null; bankHolderNameError = null;
notifyListeners(); notifyListeners();
} }
void updateNumber(String value) { void updateNumber(String value) {
bankAcNumberError = null; bankAcNumberError = null;
notifyListeners(); notifyListeners();
} }
void updateUPI(String value) { void updateUPI(String value) {
upiError = null; upiError = null;
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