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
import android.app.DownloadManager
import android.content.Context
import android.net.Uri
......@@ -9,8 +10,12 @@ import android.widget.Toast
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
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"
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL).setMethodCallHandler { call, result ->
......@@ -20,9 +25,10 @@ class MainActivity : FlutterActivity(){
val contentDisposition = call.argument<String>("contentDisposition")
val mimeType = call.argument<String>("mimeType")
val suggestedFilename = call.argument<String>("suggestedFilename")
val isBase64 = call.argument<Boolean>("isBase64") ?: false
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) {
result.success("Download started")
} else {
......@@ -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 {
// Show toast
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
val extension = when (mimeType.lowercase()) {
"application/pdf" -> ".pdf"
......@@ -71,20 +64,16 @@ class MainActivity : FlutterActivity(){
"application/vnd.openxmlformats-officedocument.wordprocessingml.document" -> ".docx"
"application/vnd.ms-excel" -> ".xls"
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" -> ".xlsx"
else -> ".bin" // Fallback for unknown types
"text/csv" -> ".csv"
else -> "" // Fallback for unknown types
}
// Guess 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()
// Determine file name
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;]+)\"?")
regex.find(it)?.groupValues?.get(1)
} ?: suggestedFilename.takeIf { it.isNotEmpty() } ?: url.split("/").last()
// Ensure the file name has the correct extension
if (!fileName.endsWith(extension, ignoreCase = true)) {
fileName = if (fileName.contains(".")) {
......@@ -93,33 +82,63 @@ class MainActivity : FlutterActivity(){
fileName + extension
}
}
// Sanitize file name to avoid invalid characters
// Sanitize file name
fileName = fileName.replace("[^a-zA-Z0-9._-]".toRegex(), "_")
// 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
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileName)
if (isBase64 && url.startsWith("data:")) {
// 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
request.setTitle(fileName)
// 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.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
request.setAllowedOverMetered(true)
request.setAllowedOverRoaming(false)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
request.setRequiresCharging(false)
request.setRequiresDeviceIdle(false)
}
request.setVisibleInDownloadsUi(true)
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.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
downloadManager.enqueue(request)
val downloadManager = getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager
downloadManager.enqueue(request)
}
true
} catch (e: Exception) {
e.printStackTrace()
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 {
List<LedgerList>? ledgerList;
BalanceDetails? balanceDetails;
AccountDetails? accountDetails;
String? error;
String? message;
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) {
if (json['ledger_list'] != null) {
......@@ -14,6 +19,9 @@ class commonAccountLedgerResponse {
ledgerList!.add(new LedgerList.fromJson(v));
});
}
balanceDetails = json['balance_details'] != null
? new BalanceDetails.fromJson(json['balance_details'])
: null;
accountDetails = json['account_details'] != null
? new AccountDetails.fromJson(json['account_details'])
: null;
......@@ -26,6 +34,9 @@ class commonAccountLedgerResponse {
if (this.ledgerList != null) {
data['ledger_list'] = this.ledgerList!.map((v) => v.toJson()).toList();
}
if (this.balanceDetails != null) {
data['balance_details'] = this.balanceDetails!.toJson();
}
if (this.accountDetails != null) {
data['account_details'] = this.accountDetails!.toJson();
}
......@@ -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 {
String? id;
String? type;
String? refId;
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) {
id = json['id'];
type = json['type'];
refId = json['ref_id'];
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() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['type'] = this.type;
data['ref_id'] = this.refId;
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;
}
}
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 {
List<Accounts>? accounts;
List<PaymentModes>? paymentModes;
List<String>? requestingPurposes;
List<Employees>? employees;
addPaymentRequestionResponse(
......@@ -12,6 +14,7 @@ class addPaymentRequestionResponse {
this.accounts,
this.paymentModes,
this.requestingPurposes,
this.employees
});
addPaymentRequestionResponse.fromJson(Map<String, dynamic> json) {
......@@ -33,6 +36,12 @@ class addPaymentRequestionResponse {
if(json['requesting_purposes']!=null){
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 {
data['error'] = this.error;
data['message'] = this.message;
data['requesting_purposes'] = this.requestingPurposes;
if (this.employees != null) {
data['employees'] = this.employees!.map((v) => v.toJson()).toList();
}
return data;
}
}
......@@ -82,6 +94,24 @@ class PaymentModes {
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() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
......
......@@ -42,6 +42,7 @@ class RequestDetails {
String? transDis;
String? description;
String? amount;
String? formattedAmount;
String? requestedAmount;
String? requestMode;
String? status;
......@@ -73,6 +74,7 @@ class RequestDetails {
this.transDis,
this.description,
this.amount,
this.formattedAmount,
this.requestedAmount,
this.requestMode,
this.status,
......@@ -106,6 +108,7 @@ class RequestDetails {
transDis = json['trans_dis'];
description = json['description'];
amount = json['amount'];
formattedAmount = json['formatted_amount'];
requestedAmount = json['requested_amount'];
requestMode = json['request_mode'];
status = json['status'];
......@@ -140,6 +143,7 @@ class RequestDetails {
data['trans_dis'] = this.transDis;
data['description'] = this.description;
data['amount'] = this.amount;
data['formatted_amount'] = this.formattedAmount;
data['requested_amount'] = this.requestedAmount;
data['request_mode'] = this.requestMode;
data['status'] = this.status;
......@@ -173,6 +177,7 @@ class PaymentDetails {
String? accountId;
String? paymentModeId;
String? amount;
String? bankName;
String? bankBranchName;
String? bankIfscCode;
......@@ -201,6 +206,7 @@ class PaymentDetails {
this.accountId,
this.paymentModeId,
this.amount,
this.bankName,
this.bankBranchName,
this.bankIfscCode,
......@@ -230,6 +236,7 @@ class PaymentDetails {
accountId = json['account_id'];
paymentModeId = json['payment_mode_id'];
amount = json['amount'];
bankName = json['bank_name'];
bankBranchName = json['bank_branch_name'];
bankIfscCode = json['bank_ifsc_code'];
......
class loadGeneratorDetailsResponse {
int? error;
String? genId;
String? genHashId;
String? aname;
String? emodel;
String? spname;
......@@ -19,6 +20,7 @@ class loadGeneratorDetailsResponse {
String? dispDate;
String? cmsngDate;
String? status;
String? loc;
List<ComplaintCategoryList>? complaintCategoryList;
List<ComplaintTypeList>? complaintTypeList;
List<ComplaintDescriptionList>? complaintDescriptionList;
......@@ -28,6 +30,7 @@ class loadGeneratorDetailsResponse {
loadGeneratorDetailsResponse(
{this.error,
this.genId,
this.genHashId,
this.aname,
this.emodel,
this.spname,
......@@ -46,6 +49,7 @@ class loadGeneratorDetailsResponse {
this.dispDate,
this.cmsngDate,
this.status,
this.loc,
this.complaintCategoryList,
this.complaintTypeList,
this.complaintDescriptionList,
......@@ -55,6 +59,7 @@ class loadGeneratorDetailsResponse {
loadGeneratorDetailsResponse.fromJson(Map<String, dynamic> json) {
error = json['error'];
genId = json['gen_id'];
genHashId = json['gen_hash_id'];
aname = json['aname'];
emodel = json['emodel'];
spname = json['spname'];
......@@ -73,6 +78,7 @@ class loadGeneratorDetailsResponse {
dispDate = json['disp_date'];
cmsngDate = json['cmsng_date'];
status = json['status'];
loc = json['loc'];
if (json['complaint_category_list'] != null) {
complaintCategoryList = <ComplaintCategoryList>[];
json['complaint_category_list'].forEach((v) {
......@@ -99,6 +105,7 @@ class loadGeneratorDetailsResponse {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['error'] = this.error;
data['gen_id'] = this.genId;
data['gen_hash_id'] = this.genHashId;
data['aname'] = this.aname;
data['emodel'] = this.emodel;
data['spname'] = this.spname;
......@@ -117,6 +124,7 @@ class loadGeneratorDetailsResponse {
data['disp_date'] = this.dispDate;
data['cmsng_date'] = this.cmsngDate;
data['status'] = this.status;
data['loc'] = this.loc;
if (this.complaintCategoryList != null) {
data['complaint_category_list'] =
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:io';
import 'package:camera/camera.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_image_compress/flutter_image_compress.dart';
......@@ -30,16 +31,24 @@ class CheckInOutProvider with ChangeNotifier {
bool hasLocationPermission = false;
Timer? _timer;
File? _image;
int imagePicked = 0;
int _imagePicked = 0;
bool isLoading = true;
String? validateLocation;
String? empId;
String? sessionId;
late List<CameraDescription> _cameras;
late CameraController cam_controller;
File? get image => _image;
int get imagePicked => _imagePicked;
set imagePicked(int value){
_imagePicked = value;
notifyListeners();
}
set image(value) {
_image = value;
notifyListeners();
}
Future<void> getCurrentLocation() async {
......@@ -134,7 +143,36 @@ class CheckInOutProvider with ChangeNotifier {
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 {
if (locationController.text.isEmpty) {
validateLocation = "Please Enter location";
......@@ -150,7 +188,7 @@ class CheckInOutProvider with ChangeNotifier {
);
if (galleryImage != null) {
_image = File(galleryImage.path);
imagePicked = 1;
_imagePicked = 1;
var file = await FlutterImageCompress.compressWithFile(
galleryImage.path,
);
......@@ -172,11 +210,11 @@ class CheckInOutProvider with ChangeNotifier {
empId = await SharedpreferencesService().getString("UserId");
sessionId = await SharedpreferencesService().getString("Session_id");
if (kDebugMode) {
print(empId);
print(sessionId);
print(locationController.text);
print(latlongs);
print(_image);
// print(empId);
// print(sessionId);
// print(locationController.text);
// print(latlongs);
// print(_image);
}
try {
isLoading = true;
......@@ -193,6 +231,7 @@ class CheckInOutProvider with ChangeNotifier {
toast(context, "CheckedIn Successfully");
await BackgroundLocationService.startLocationService(context);
locationController.clear();
dispose();
Navigator.pop(context, true);
} else {
toast(context, "Check-In UnSuccessful");
......@@ -229,6 +268,7 @@ class CheckInOutProvider with ChangeNotifier {
toast(context, "Check-Out Successful");
await BackgroundLocationService.stopLocationService();
locationController.clear();
dispose();
Navigator.pop(context, true);
} else {
toast(context, "Check-Out UnSuccessful");
......@@ -247,7 +287,11 @@ class CheckInOutProvider with ChangeNotifier {
}
void dispose() {
locationController.dispose();
validateLocation = null;
// locationController.dispose();
locationController.clear();
_timer?.cancel();
notifyListeners();
}
}
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
import 'package:generp/Utils/commonServices.dart';
......@@ -6,6 +8,7 @@ import 'package:generp/services/api_calling.dart';
import 'package:geolocator/geolocator.dart';
import 'package:geolocator/geolocator.dart' as geo_location;
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:permission_handler/permission_handler.dart';
import 'package:provider/provider.dart';
......@@ -16,7 +19,7 @@ import '../Utils/app_colors.dart';
import 'HomeScreenNotifier.dart';
class Generatordetailsprovider extends ChangeNotifier {
bool _submitLoading = false;
PermissionStatus _cameraPermissionStatus = PermissionStatus.denied;
PermissionStatus _LocationPermissionStatus = PermissionStatus.denied;
final GlobalKey scannerKey = GlobalKey(debugLabel: 'QR');
......@@ -28,6 +31,7 @@ class Generatordetailsprovider extends ChangeNotifier {
FocusNode engineNoFocusNode = FocusNode();
List<C_List> _complaintList = [];
String? _genID = "-";
String? _genHashID = "-";
String? _aname = "-";
String? _emodel = "-";
String? _spname = "-";
......@@ -46,11 +50,17 @@ class Generatordetailsprovider extends ChangeNotifier {
String? _dispDate = "-";
String? _cmsngDate = "-";
String? _status = "-";
String? _genLocation = "-";
String? _genLocationLatLngs;
String _title = "-";
String _subTitle = "-";
bool _isLoading = false;
String? _scannedGenID;
final ImagePicker _picker = ImagePicker();
File? _image;
File? _imageName;
int _imagePicked = 0;
LatLng startLocation = const LatLng(17.439112226708446, 78.43292499146135);
LatLng? currentLocationLatLng;
String latlongs = "";
......@@ -62,6 +72,31 @@ class Generatordetailsprovider extends ChangeNotifier {
ComplaintCategoryList? _selectedCategoryType;
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? _selectedTypeId;
......@@ -71,6 +106,8 @@ class Generatordetailsprovider extends ChangeNotifier {
String? _selectedDescription;
String? _selectedDescriptionId;
bool get submitLoading => _submitLoading;
List<ComplaintTypeList> get complaintTypeDropdown => _complaintTypeDropdown;
List<ComplaintCategoryList> get complaintCategorydropdown =>
......@@ -106,6 +143,8 @@ class Generatordetailsprovider extends ChangeNotifier {
String? get genID => _genID;
String? get genHashID => _genHashID;
String? get aname => _aname;
String? get emodel => _emodel;
......@@ -142,18 +181,35 @@ class Generatordetailsprovider extends ChangeNotifier {
String? get status => _status;
String? get genLocation => _genLocation;
String? get genLocationLatLngs => _genLocationLatLngs;
bool get isLoading => _isLoading;
bool get hasPermission => _hasPermission;
bool get hasLocationPermission => _hasLocationPermission;
String? get scannedGenID => _scannedGenID;
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;
notifyListeners();
}
set selectedComplaintType(value) {
_selectedComplaintType = value;
_selectedType = value.name;
......@@ -203,12 +259,12 @@ class Generatordetailsprovider extends ChangeNotifier {
_selectedDescriptionId = value;
}
void resetForm(){
void resetForm() {
_qrViewController!.dispose();
engNoController.clear();
_selectedComplaintType = null;
_selectedCategoryType= null;
_selectedDescriptionType= null;
_selectedCategoryType = null;
_selectedDescriptionType = null;
_selectedType = "";
_selectedTypeId = "";
_selectedCategory = "";
......@@ -322,12 +378,12 @@ class Generatordetailsprovider extends ChangeNotifier {
Future<void> getLocationPermission(BuildContext context) async {
isLocationEnabled = await Geolocator.isLocationServiceEnabled();
LocationPermission permission = await Geolocator.checkPermission();
_hasLocationPermission = permission == LocationPermission.always ||
_hasLocationPermission =
permission == LocationPermission.always ||
permission == LocationPermission.whileInUse;
final Location.Location location = Location.Location();
if (!isLocationEnabled || !hasLocationPermission) {
permission = await Geolocator.requestPermission();
if (permission != LocationPermission.always &&
......@@ -338,7 +394,8 @@ class Generatordetailsprovider extends ChangeNotifier {
return AlertDialog(
title: Text('Location Permission Required'),
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>[
TextButton(
style: ButtonStyle(
......@@ -376,7 +433,8 @@ class Generatordetailsprovider extends ChangeNotifier {
Future<void> getCurrentLocation() async {
try {
Position position = await Geolocator.getCurrentPosition(
desiredAccuracy: geo_location.LocationAccuracy.high);
desiredAccuracy: geo_location.LocationAccuracy.high,
);
currentLocationLatLng = LatLng(position.latitude, position.longitude);
notifyListeners();
} catch (e) {
......@@ -392,24 +450,34 @@ class Generatordetailsprovider extends ChangeNotifier {
controller!.pauseCamera();
if (from == "Generator Details") {
_genID = scanData.code;
_genHashID = scanData.code;
notifyListeners();
Navigator.push(
context,
MaterialPageRoute(builder: (context) => Generatordetails(generatorId: scanData.code,)),
MaterialPageRoute(
builder: (context) => Generatordetails(generatorId: scanData.code),
),
);
} else if (from == "Register Complaint") {
_genID = scanData.code;
_genHashID = scanData.code;
notifyListeners();
Navigator.push(
context,
MaterialPageRoute(builder: (context) => Registercomplaint()),
);
} else if (from == "Tag Location") {
_genID = scanData.code;
_genHashID = scanData.code;
notifyListeners();
print(scanData.code);
TagLocationAPIFunction(HomeProvider, context, scanData.code,"Scanner");
TagLocationAPIFunction(HomeProvider, context, scanData.code, "Scanner");
} else if (from == "Tag Generator") {
_genID = scanData.code;
_genHashID = scanData.code;
notifyListeners();
print(scanData.code);
showTagGeneratorBottomSheet(context,_genID);
showTagGeneratorBottomSheet(context, scanData.code);
// TagGeneraorAPIFunction(HomeProvider, context, scanData.code);
}
});
......@@ -419,9 +487,13 @@ class Generatordetailsprovider extends ChangeNotifier {
homeProvider,
BuildContext context,
from,
genID,
) async {
genID, [
number,
]) async {
print("$number index calling");
try {
_submitLoading = true;
notifyListeners();
final data = await ApiCalling.LoadGeneratorDetailsAPI(
homeProvider.empId,
homeProvider.session,
......@@ -430,7 +502,9 @@ class Generatordetailsprovider extends ChangeNotifier {
if (data != null) {
if (data.error == 0) {
_submitLoading = false;
_genID = data.genId;
_genHashID = data.genHashId;
_aname = data.aname;
_emodel = data.emodel;
_spname = data.spname;
......@@ -449,9 +523,10 @@ class Generatordetailsprovider extends ChangeNotifier {
_dispDate = data.dispDate;
_cmsngDate = data.cmsngDate;
_status = data.status;
_complaintTypeDropdown = data.complaintTypeList??[];
_complaintCategorydropdown = data.complaintCategoryList??[];
_complaintDescriptionDropdown = data.complaintDescriptionList??[];
_genLocation = data.loc;
_complaintTypeDropdown = data.complaintTypeList ?? [];
_complaintCategorydropdown = data.complaintCategoryList ?? [];
_complaintDescriptionDropdown = data.complaintDescriptionList ?? [];
if (_selectedComplaintType != null &&
!_complaintTypeDropdown.contains(_selectedComplaintType)) {
_selectedComplaintType = null;
......@@ -475,11 +550,21 @@ class Generatordetailsprovider extends ChangeNotifier {
_selectedDescriptionId = "";
}
notifyListeners();
Navigator.pop(context);
if (from == "Generator Details") {
this._qrViewController!.pauseCamera();
Navigator.push(
Navigator.pushAndRemoveUntil(
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") {
this._qrViewController!.pauseCamera();
......@@ -488,25 +573,31 @@ class Generatordetailsprovider extends ChangeNotifier {
MaterialPageRoute(builder: (context) => Registercomplaint()),
);
}
}
else if (data.error == 1) {
} else if (data.error == 1) {
toast(context, "Enter Correct ID");
} else {}
_submitLoading = false;
notifyListeners();
} else {
_submitLoading = false;
notifyListeners();
}
} else {
_submitLoading = false;
notifyListeners();
}
} on Error catch (e) {
_submitLoading = false;
notifyListeners();
print(e.toString());
}
}
Future<void> LoadTechniciangeneratorDetailsApifunction(
homeProvider,
BuildContext context,
from,
genID,
) async {
homeProvider,
BuildContext context,
from,
genID,
) async {
try {
final data = await ApiCalling.LoadTechnicianGeneratorDetailsAPI(
homeProvider.empId,
......@@ -535,9 +626,9 @@ class Generatordetailsprovider extends ChangeNotifier {
_dispDate = data.dispDate;
_cmsngDate = data.cmsngDate;
_status = data.status;
_complaintTypeDropdown = data.complaintTypeList??[];
_complaintCategorydropdown = data.complaintCategoryList??[];
_complaintDescriptionDropdown = data.complaintDescriptionList??[];
_complaintTypeDropdown = data.complaintTypeList ?? [];
_complaintCategorydropdown = data.complaintCategoryList ?? [];
_complaintDescriptionDropdown = data.complaintDescriptionList ?? [];
if (_selectedComplaintType != null &&
!_complaintTypeDropdown.contains(_selectedComplaintType)) {
_selectedComplaintType = null;
......@@ -565,7 +656,9 @@ class Generatordetailsprovider extends ChangeNotifier {
this._qrViewController!.pauseCamera();
Navigator.push(
context,
MaterialPageRoute(builder: (context) => Generatordetails(generatorId: _genID,)),
MaterialPageRoute(
builder: (context) => Generatordetails(generatorId: _genID),
),
);
} else if (from == "Register Complaint") {
this._qrViewController!.pauseCamera();
......@@ -574,13 +667,9 @@ class Generatordetailsprovider extends ChangeNotifier {
MaterialPageRoute(builder: (context) => Registercomplaint()),
);
}
}
else if (data.error == 1) {
} else if (data.error == 1) {
toast(context, "Enter Correct ID");
} else {}
}
} on Error catch (e) {
print(e.toString());
......@@ -680,35 +769,50 @@ class Generatordetailsprovider extends ChangeNotifier {
Future<void> TagLocationAPIFunction(
homeProvider,
BuildContext context,
genID,[fromHere]
) async {
genID, [
fromHere,
]) async {
_submitLoading = true;
notifyListeners();
if (!valid()) {
return;
}
try {
final data = await ApiCalling.TagLocationAPI(
homeProvider.empId,
homeProvider.session,
genID,
latlongs,
_image,
);
print(latlongs);
if (data != null) {
if (data.sessionExists == 1) {
if (data.error == 0) {
_submitLoading = false;
notifyListeners();
toast(context, "Location Tagged Successfully!!");
Navigator.pop(context);
if(fromHere!="Scanner"){
Navigator.pop(context);
}
// Navigator.pop(context);
// if(fromHere!="Scanner"){
//
// Navigator.pop(context);
// }
notifyListeners();
_isLoading = false;
} else if (data.error == 1) {
toast(context, "Please Check Entered ID!!");
_submitLoading = false;
notifyListeners();
} else {
_isLoading = true;
print("error");
_submitLoading = false;
notifyListeners();
}
} else {
_isLoading = true;
_submitLoading = false;
notifyListeners();
// SharedpreferencesService().clearPreferences();
// toast(context, "Your Session expired, Please Login Again!");
// Navigator.push(
......@@ -718,20 +822,38 @@ class Generatordetailsprovider extends ChangeNotifier {
}
} else {
_isLoading = true;
_submitLoading = false;
notifyListeners();
toast(context, "Something Went Wrong, Please try again!");
print("error2");
}
} on Error catch (e) {
_submitLoading = false;
notifyListeners();
print(e.toString());
}
}
bool valid() {
bool isValid = true;
if (_image == null || _imagePicked == 0) {
_imageError = "Please Add Proof";
notifyListeners();
}
notifyListeners();
return isValid;
}
Future<void> TagGeneraorAPIFunction(
homeProvider,
BuildContext context,
genID,engineNumber,[fromHere]
) async {
genID,
engineNumber, [
fromHere,
]) async {
try {
_submitLoading = true;
notifyListeners();
final data = await ApiCalling.TagGeneratorAPI(
homeProvider.empId,
homeProvider.session,
......@@ -742,25 +864,44 @@ class Generatordetailsprovider extends ChangeNotifier {
if (data != null) {
if (data.sessionExists == 1) {
if (data.error == 0) {
_submitLoading = false;
toast(context, "Generator Tagged Successfully!!");
Navigator.pop(context);
if(fromHere!="Scanner"){
if (fromHere != "Scanner") {
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();
_isLoading = false;
} else if (data.error == 1) {
toast(context, "Please Check Entered ID!!");
}else if (data.error == 2) {
_submitLoading = false;
notifyListeners();
toast(context, data.message);
}
else {
} else if (data.error == 2) {
_submitLoading = false;
notifyListeners();
toast(context, data.message);
} else {
_isLoading = true;
_submitLoading = false;
notifyListeners();
print("error");
}
} else {
_isLoading = true;
_submitLoading = false;
notifyListeners();
// SharedpreferencesService().clearPreferences();
// toast(context, "Your Session expired, Please Login Again!");
// Navigator.push(
......@@ -770,15 +911,38 @@ class Generatordetailsprovider extends ChangeNotifier {
}
} else {
_isLoading = true;
_submitLoading = false;
notifyListeners();
toast(context, "Something Went Wrong, Please try again!");
print("error2");
}
} on Error catch (e) {
_submitLoading = false;
notifyListeners();
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(
useSafeArea: true,
isDismissible: true,
......@@ -794,9 +958,9 @@ class Generatordetailsprovider extends ChangeNotifier {
child: Padding(
padding: EdgeInsets.only(
bottom:
MediaQuery.of(
context,
).viewInsets.bottom, // This handles keyboard
MediaQuery.of(
context,
).viewInsets.bottom, // This handles keyboard
),
child: Container(
margin: EdgeInsets.only(
......@@ -806,8 +970,8 @@ class Generatordetailsprovider extends ChangeNotifier {
top: 30,
),
child: Consumer2<Generatordetailsprovider, HomescreenNotifier>(
builder: (context, provider, homeProvider, child) {
child: Consumer<HomescreenNotifier>(
builder: (context, homeProvider, child) {
return SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
......@@ -827,14 +991,14 @@ class Generatordetailsprovider extends ChangeNotifier {
alignment: Alignment.center,
decoration: BoxDecoration(
color: AppColors.text_field_color,
borderRadius: BorderRadius.circular(20),
borderRadius: BorderRadius.circular(15),
border:
engineNoFocusNode.hasFocus
? Border.all(
color: AppColors.app_blue,
width: 0.5,
)
: null,
engineNoFocusNode.hasFocus
? Border.all(
color: AppColors.app_blue,
width: 0.5,
)
: null,
),
// alignment: Alignment.center,
margin: EdgeInsets.only(left: 5.0, right: 5.0),
......@@ -849,7 +1013,8 @@ class Generatordetailsprovider extends ChangeNotifier {
controller: engNoController,
keyboardType: TextInputType.text,
focusNode: engineNoFocusNode,
textCapitalization: TextCapitalization.characters,
textCapitalization:
TextCapitalization.characters,
style: TextStyle(fontSize: 14),
onChanged: (value) {},
onTapOutside: (event) {
......@@ -859,6 +1024,7 @@ class Generatordetailsprovider extends ChangeNotifier {
decoration: InputDecoration(
isDense: true,
hintStyle: TextStyle(
color: AppColors.grey_semi,
fontWeight: FontWeight.w400,
fontSize: 14,
),
......@@ -871,12 +1037,19 @@ class Generatordetailsprovider extends ChangeNotifier {
),
),
InkWell(
onTap: () {
TagGeneraorAPIFunction(homeProvider, context, genID,engNoController.text);
},
onTap:
_submitLoading
? null
: () {
_submitLoading = true;
notifyListeners();
TagGeneraorAPIFunction(
homeProvider,
context,
genID,
engNoController.text,
);
},
child: Container(
alignment: Alignment.center,
height: 45,
......@@ -888,14 +1061,24 @@ class Generatordetailsprovider extends ChangeNotifier {
),
decoration: BoxDecoration(
color: AppColors.app_blue, //1487C9
borderRadius: BorderRadius.circular(30.0),
borderRadius: BorderRadius.circular(15.0),
),
child: Center(
child: Text(
"Submit",
textAlign: TextAlign.center,
style: TextStyle(color: Colors.white),
),
child:
_submitLoading
? CircularProgressIndicator.adaptive(
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 {
},
);
}
// 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 {
notifyListeners();
Navigator.push(
context,
MaterialPageRoute(builder: (context) => Complainthistory()),
MaterialPageRoute(builder: (context) => Complainthistory(genHashID: scanData.code,)),
);
}
});
......@@ -167,7 +167,7 @@ class InventoryProvider extends ChangeNotifier {
this._qrViewController!.pauseCamera();
Navigator.push(
context,
MaterialPageRoute(builder: (context) => Complainthistory()),
MaterialPageRoute(builder: (context) => Complainthistory(genHashID: genID,)),
);
notifyListeners();
} else {
......
......@@ -178,6 +178,10 @@ class Paymentdetailsprovider extends ChangeNotifier {
Future<void> PaymentUpdateAPI(BuildContext context, reference, amount) async {
try {
// if(!CheckValidations(context,reference, amount)){
// return;
// }
print("came here");
var homeProvider = Provider.of<HomescreenNotifier>(
context,
listen: false,
......@@ -199,6 +203,7 @@ class Paymentdetailsprovider extends ChangeNotifier {
if (data.sessionExists == 1) {
if (data.error == 0) {
_CollectionId = data.paymentCollectionId ?? 0;
print(data.paymentCollectionId);
// OTPDialogue(context);
notifyListeners();
} else {}
......@@ -266,14 +271,7 @@ class Paymentdetailsprovider extends ChangeNotifier {
_image = File(galleryImage!.path);
_imageName = File(galleryImage!.name);
_image_picked = 1;
if (_image != null) {
var file = FlutterImageCompress.compressWithFile(galleryImage!.path);
{
if (file != null) {
CheckValidations(context, reference, amount);
}
}
}
notifyListeners();
} catch (e) {
debugPrint("mmmm: ${e.toString()}");
}
......@@ -295,31 +293,32 @@ class Paymentdetailsprovider extends ChangeNotifier {
_imageName = File(galleryImage!.name);
_image_picked = 1;
if (_image != null) {
var file = FlutterImageCompress.compressWithFile(galleryImage!.path);
{
if (file != null) {
CheckValidations(context, reference, amount);
}
}
}
notifyListeners();
} catch (e) {
debugPrint("mmmm: ${e.toString()}");
}
}
CheckValidations(BuildContext context, reference, amount) {
bool CheckValidations(BuildContext context,reference, amount) {
bool isValid = true;
if (_contactID == null || _contactID == "") {
toast(context, "Select Phone Number");
} else if (_paymentModeID == null || _paymentModeID == "") {
isValid = false;
}
if (_paymentModeID == null || _paymentModeID == "") {
toast(context, "Select Payment Mode");
} else if (amount.isEmpty) {
isValid = false;
}
if (amount.isEmpty) {
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");
} else {
PaymentUpdateAPI(context, reference, amount);
isValid = false;
}
notifyListeners();
return isValid;
}
String _saveAgainst = "";
......
......@@ -12,19 +12,27 @@ class Accountledgerprovider extends ChangeNotifier{
List<Accounts> _accounts = [];
List<LedgerList> _ledgerList = [];
BalanceDetails _balanceDetails = BalanceDetails();
AccountDetails _accountDetails = AccountDetails();
Accounts? _selectedAccount;
String _selectedAcID = "";
String _selectedAcVal = "";
bool _isLoading = true;
bool _showMoreDetails = false;
bool get isLoading => _isLoading;
bool get showMoreDetails => _showMoreDetails;
List<Accounts> get accounts => _accounts;
List<LedgerList> get ledgerList => _ledgerList;
AccountDetails get acDetails => _accountDetails;
BalanceDetails get balanceDetails => _balanceDetails;
Accounts? get selectedAccount => _selectedAccount;
String get selectedAcId => _selectedAcID;
String get selectedAcVal => _selectedAcVal;
set showMoreDetails(bool value){
_showMoreDetails = value;
notifyListeners();
}
set accounts(List<Accounts> value){
_accounts = value;
notifyListeners();
......@@ -90,6 +98,7 @@ class Accountledgerprovider extends ChangeNotifier{
if(data.error=="0"){
_isLoading = false;
_ledgerList= data.ledgerList!;
_balanceDetails = data.balanceDetails!;
_accountDetails= data.accountDetails!;
if (_selectedAccount != null &&
!_accounts.contains(_selectedAccount)) {
......@@ -99,8 +108,9 @@ class Accountledgerprovider extends ChangeNotifier{
notifyListeners();
} else if(data.error=="1"){
_isLoading = false;
notifyListeners();
}
notifyListeners();
}
}catch (e,s){
......
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:generp/Notifiers/HomeScreenNotifier.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:provider/provider.dart';
......@@ -21,7 +24,8 @@ class Accountslistprovider extends ChangeNotifier {
TextEditingController bankAcNumberController = TextEditingController();
TextEditingController bankUpiController = TextEditingController();
TextEditingController contactPersonController = TextEditingController();
TextEditingController contectPersonDesignationController = TextEditingController();
TextEditingController contectPersonDesignationController =
TextEditingController();
TextEditingController contectPersonAltMobController = TextEditingController();
TextEditingController contectPersonTeleController = TextEditingController();
TextEditingController contectPersonMailController = TextEditingController();
......@@ -87,7 +91,7 @@ class Accountslistprovider extends ChangeNotifier {
set isVisible(bool value) {
_isVisible = value;
if(value==true){
if (value == true) {
addMoreDetailsError = null;
}
notifyListeners();
......@@ -239,7 +243,6 @@ class Accountslistprovider extends ChangeNotifier {
);
if (data != null) {
if (data.error == "0") {
_subLocations = data.subLocations!;
notifyListeners();
}
......@@ -262,28 +265,30 @@ class Accountslistprovider extends ChangeNotifier {
mobileError = null;
notifyListeners();
} else if (data.error == "1") {
if(data.message?.contains("name already exists") ?? false){
nameError = data.message??"";
}else{
mobileError = data.message??"";
if (data.message?.contains("name already exists") ?? false) {
nameError = data.message ?? "";
} else {
mobileError = data.message ?? "";
}
notifyListeners();
// toast(context, data.message);
}
}
} catch (e, s) {}
}
bool hasFilledAdditionalDetails = false;
bool _submitClicked = false;
bool get submitClickced => _submitClicked;
set submitClickced(bool value){
set submitClickced(bool value) {
_submitClicked = value;
notifyListeners();
}
Future<void> submitCommonAccountsAPI(context) async {
Future<void> submitCommonAccountsAPI(context, from) async {
try {
if (!validatereceiptForm(context)) {
// _submitClicked = false;
......@@ -317,7 +322,23 @@ class Accountslistprovider extends ChangeNotifier {
if (data.error == "0") {
_submitClicked = false;
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();
toast(context, data.message);
} else if (data.error == "1") {
......@@ -328,7 +349,7 @@ class Accountslistprovider extends ChangeNotifier {
_submitClicked = false;
notifyListeners();
}
}else{
} else {
_submitClicked = false;
notifyListeners();
}
......@@ -371,6 +392,10 @@ class Accountslistprovider extends ChangeNotifier {
mobileError = "Please Enter Mobile Number";
isValid = false;
}
if (contactPersonController.text.trim().isEmpty) {
contactPersonError = "Please Enter Contact Person Name";
isValid = false;
}
//
//
// if (!_isVisible && !hasFilledAdditionalDetails) {
......@@ -453,7 +478,6 @@ class Accountslistprovider extends ChangeNotifier {
//
// }
// if (contectPersonTeleController.text.trim().isEmpty) {
// teleError= "Please Enter Telephone"; isValid = false;
// }
......@@ -469,6 +493,7 @@ class Accountslistprovider extends ChangeNotifier {
nameError = null;
notifyListeners();
}
void updateMobile(String value) {
mobileError = null;
notifyListeners();
......@@ -481,65 +506,67 @@ class Accountslistprovider extends ChangeNotifier {
void updateBankName(String value) {
banknameError = null;
notifyListeners();
}
void updateBankBranch(String value) {
bankBranchError = null;
notifyListeners();
}
void updateIFSC(String value) {
bankIFSCError = null;
notifyListeners();
}
void updateHolder(String value) {
bankHolderNameError = null;
notifyListeners();
}
void updateNumber(String value) {
bankAcNumberError = null;
notifyListeners();
}
void updateUPI(String value) {
upiError = null;
notifyListeners();
}
void updateContactPerson(String value){
void updateContactPerson(String value) {
contactPersonError = null;
notifyListeners();
notifyListeners();
}
void updateDesignation(String value){
void updateDesignation(String value) {
desigantionError = null;
notifyListeners();
}
void updateAltMobile(String value){
void updateAltMobile(String value) {
altMobError = null;
notifyListeners();
}
void updateTeleMobile(String value){
void updateTeleMobile(String value) {
teleError = null;
notifyListeners();
}
void updateMail(String value){
void updateMail(String value) {
mailError = null;
notifyListeners();
}
......@@ -634,18 +661,21 @@ class Accountslistprovider extends ChangeNotifier {
}
void ChechkDropdownValues() {
if(!_accountTypes.contains(_selectedAccountType)&&_selectedAccountType!=null){
if (!_accountTypes.contains(_selectedAccountType) &&
_selectedAccountType != null) {
_selectedAccountType = null;
}
if(!_states.contains(_selectedState)&&_selectedState!=null){
if (!_states.contains(_selectedState) && _selectedState != null) {
_selectedStateID = null;
_selectedStateValue = null;
}
if(!_districts.contains(_selectedDistricts)&&_selectedDistricts!=null){
if (!_districts.contains(_selectedDistricts) &&
_selectedDistricts != null) {
_selectedDistrictID = null;
_selectedDistrictValue = null;
}
if(!_subLocations.contains(_selectedSubLocations)&&_selectedSubLocations!=null){
if (!_subLocations.contains(_selectedSubLocations) &&
_selectedSubLocations != null) {
_selectedSubLocID = 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