Pending Transactions implemented
parent
12225d8a25
commit
427c5fb5b6
@ -0,0 +1,36 @@
|
|||||||
|
import 'package:mohem_flutter_app/api/api_client.dart';
|
||||||
|
import 'package:mohem_flutter_app/app_state/app_state.dart';
|
||||||
|
import 'package:mohem_flutter_app/classes/consts.dart';
|
||||||
|
import 'package:mohem_flutter_app/models/generic_response_model.dart';
|
||||||
|
import 'package:mohem_flutter_app/models/pending_transactions/get_pending_transactions_details.dart';
|
||||||
|
import 'package:mohem_flutter_app/models/pending_transactions/get_req_functions.dart';
|
||||||
|
|
||||||
|
class PendingTransactionsApiClient {
|
||||||
|
static final PendingTransactionsApiClient _instance = PendingTransactionsApiClient._internal();
|
||||||
|
|
||||||
|
PendingTransactionsApiClient._internal();
|
||||||
|
|
||||||
|
factory PendingTransactionsApiClient() => _instance;
|
||||||
|
|
||||||
|
Future<List<GetPendingTransactionsFunctions>> getPendingReqFunctions() async {
|
||||||
|
String url = "${ApiConsts.erpRest}GET_PENDING_REQ_FUNCTIONS";
|
||||||
|
Map<String, dynamic> postParams = {};
|
||||||
|
|
||||||
|
postParams.addAll(AppState().postParamsJson);
|
||||||
|
return await ApiClient().postJsonForObject((json) {
|
||||||
|
GenericResponseModel? responseData = GenericResponseModel.fromJson(json);
|
||||||
|
return responseData.getPendingTransactionsFunctions ?? [];
|
||||||
|
}, url, postParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<List<GetPendingTransactionsDetails>> getPendingTransactionsDetails(String functionID, String dateFrom, String dateTo) async {
|
||||||
|
String url = "${ApiConsts.erpRest}GET_PENDING_REQ_DETAILS";
|
||||||
|
Map<String, dynamic> postParams = {"P_FUNCTION_ID": functionID, "P_PAGE_LIMIT": 20, "P_PAGE_NUM": 1, "P_CREATION_DATE_FROM": dateFrom, "P_CREATION_DATE_TO": dateTo};
|
||||||
|
|
||||||
|
postParams.addAll(AppState().postParamsJson);
|
||||||
|
return await ApiClient().postJsonForObject((json) {
|
||||||
|
GenericResponseModel? responseData = GenericResponseModel.fromJson(json);
|
||||||
|
return responseData.getPendingTransactionsDetails ?? [];
|
||||||
|
}, url, postParams);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,56 @@
|
|||||||
|
class GetPendingTransactionsDetails {
|
||||||
|
String? cREATIONDATE;
|
||||||
|
int? fROMROWNUM;
|
||||||
|
String? iTEMKEY;
|
||||||
|
int? nOOFROWS;
|
||||||
|
String? rEQUESTTYPE;
|
||||||
|
int? rOWNUM;
|
||||||
|
int? tOROWNUM;
|
||||||
|
String? tRANSACTIONCREATEDFOR;
|
||||||
|
int? tRANSACTIONID;
|
||||||
|
String? tRANSACTIONINITIATOR;
|
||||||
|
String? uSERFUNCTIONNAME;
|
||||||
|
|
||||||
|
GetPendingTransactionsDetails(
|
||||||
|
{this.cREATIONDATE,
|
||||||
|
this.fROMROWNUM,
|
||||||
|
this.iTEMKEY,
|
||||||
|
this.nOOFROWS,
|
||||||
|
this.rEQUESTTYPE,
|
||||||
|
this.rOWNUM,
|
||||||
|
this.tOROWNUM,
|
||||||
|
this.tRANSACTIONCREATEDFOR,
|
||||||
|
this.tRANSACTIONID,
|
||||||
|
this.tRANSACTIONINITIATOR,
|
||||||
|
this.uSERFUNCTIONNAME});
|
||||||
|
|
||||||
|
GetPendingTransactionsDetails.fromJson(Map<String, dynamic> json) {
|
||||||
|
cREATIONDATE = json['CREATION_DATE'];
|
||||||
|
fROMROWNUM = json['FROM_ROW_NUM'];
|
||||||
|
iTEMKEY = json['ITEM_KEY'];
|
||||||
|
nOOFROWS = json['NO_OF_ROWS'];
|
||||||
|
rEQUESTTYPE = json['REQUEST_TYPE'];
|
||||||
|
rOWNUM = json['ROW_NUM'];
|
||||||
|
tOROWNUM = json['TO_ROW_NUM'];
|
||||||
|
tRANSACTIONCREATEDFOR = json['TRANSACTION_CREATED_FOR'];
|
||||||
|
tRANSACTIONID = json['TRANSACTION_ID'];
|
||||||
|
tRANSACTIONINITIATOR = json['TRANSACTION_INITIATOR'];
|
||||||
|
uSERFUNCTIONNAME = json['USER_FUNCTION_NAME'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['CREATION_DATE'] = this.cREATIONDATE;
|
||||||
|
data['FROM_ROW_NUM'] = this.fROMROWNUM;
|
||||||
|
data['ITEM_KEY'] = this.iTEMKEY;
|
||||||
|
data['NO_OF_ROWS'] = this.nOOFROWS;
|
||||||
|
data['REQUEST_TYPE'] = this.rEQUESTTYPE;
|
||||||
|
data['ROW_NUM'] = this.rOWNUM;
|
||||||
|
data['TO_ROW_NUM'] = this.tOROWNUM;
|
||||||
|
data['TRANSACTION_CREATED_FOR'] = this.tRANSACTIONCREATEDFOR;
|
||||||
|
data['TRANSACTION_ID'] = this.tRANSACTIONID;
|
||||||
|
data['TRANSACTION_INITIATOR'] = this.tRANSACTIONINITIATOR;
|
||||||
|
data['USER_FUNCTION_NAME'] = this.uSERFUNCTIONNAME;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
class GetPendingTransactionsFunctions {
|
||||||
|
int? fUNCTIONID;
|
||||||
|
String? fUNCTIONNAME;
|
||||||
|
String? fUNCTIONPROMPT;
|
||||||
|
|
||||||
|
GetPendingTransactionsFunctions(
|
||||||
|
{this.fUNCTIONID, this.fUNCTIONNAME, this.fUNCTIONPROMPT});
|
||||||
|
|
||||||
|
GetPendingTransactionsFunctions.fromJson(Map<String, dynamic> json) {
|
||||||
|
fUNCTIONID = json['FUNCTION_ID'];
|
||||||
|
fUNCTIONNAME = json['FUNCTION_NAME'];
|
||||||
|
fUNCTIONPROMPT = json['FUNCTION_PROMPT'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['FUNCTION_ID'] = this.fUNCTIONID;
|
||||||
|
data['FUNCTION_NAME'] = this.fUNCTIONNAME;
|
||||||
|
data['FUNCTION_PROMPT'] = this.fUNCTIONPROMPT;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,182 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:mohem_flutter_app/api/pending_transactions_api_client.dart';
|
||||||
|
import 'package:mohem_flutter_app/classes/colors.dart';
|
||||||
|
import 'package:mohem_flutter_app/classes/date_uitl.dart';
|
||||||
|
import 'package:mohem_flutter_app/classes/utils.dart';
|
||||||
|
import 'package:mohem_flutter_app/config/routes.dart';
|
||||||
|
import 'package:mohem_flutter_app/extensions/int_extensions.dart';
|
||||||
|
import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
|
||||||
|
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
|
||||||
|
import 'package:mohem_flutter_app/models/pending_transactions/get_req_functions.dart';
|
||||||
|
import 'package:mohem_flutter_app/widgets/app_bar_widget.dart';
|
||||||
|
import 'package:mohem_flutter_app/widgets/button/default_button.dart';
|
||||||
|
import 'package:mohem_flutter_app/widgets/dynamic_forms/dynamic_textfield_widget.dart';
|
||||||
|
|
||||||
|
class PendingTransactions extends StatefulWidget {
|
||||||
|
const PendingTransactions({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_PendingTransactionsState createState() => _PendingTransactionsState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _PendingTransactionsState extends State<PendingTransactions> {
|
||||||
|
List<GetPendingTransactionsFunctions> getPendingTransactionsFunctions = [];
|
||||||
|
GetPendingTransactionsFunctions? selectedFunction;
|
||||||
|
|
||||||
|
DateTime selectedDateFrom = DateTime.now();
|
||||||
|
DateTime selectedDateTo = DateTime.now();
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
getRequestTypes();
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
appBar: AppBarWidget(
|
||||||
|
context,
|
||||||
|
title: "Pending Transactions",
|
||||||
|
),
|
||||||
|
body: SingleChildScrollView(
|
||||||
|
child: Container(
|
||||||
|
width: double.infinity,
|
||||||
|
padding: const EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 10),
|
||||||
|
margin: const EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 10),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: const Color(0xff000000).withOpacity(.05),
|
||||||
|
blurRadius: 26,
|
||||||
|
offset: const Offset(0, -3),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
12.height,
|
||||||
|
PopupMenuButton(
|
||||||
|
child: DynamicTextFieldWidget(
|
||||||
|
"Please select request type",
|
||||||
|
selectedFunction?.fUNCTIONPROMPT ?? "",
|
||||||
|
isEnable: false,
|
||||||
|
isPopup: true,
|
||||||
|
isInputTypeNum: true,
|
||||||
|
isReadOnly: false,
|
||||||
|
).paddingOnly(bottom: 12),
|
||||||
|
itemBuilder: (_) => <PopupMenuItem<int>>[
|
||||||
|
for (int i = 0; i < getPendingTransactionsFunctions!.length; i++) PopupMenuItem<int>(child: Text(getPendingTransactionsFunctions![i].fUNCTIONPROMPT!), value: i),
|
||||||
|
],
|
||||||
|
onSelected: (int popupIndex) {
|
||||||
|
selectedFunction = getPendingTransactionsFunctions![popupIndex];
|
||||||
|
setState(() {});
|
||||||
|
}),
|
||||||
|
12.height,
|
||||||
|
DynamicTextFieldWidget(
|
||||||
|
"Date From: ",
|
||||||
|
selectedDateFrom.toString().split(" ")[0],
|
||||||
|
suffixIconData: Icons.calendar_today,
|
||||||
|
isEnable: false,
|
||||||
|
onTap: () async {
|
||||||
|
selectedDateFrom = await _selectDate(context, DateTime.now());
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
).paddingOnly(bottom: 12),
|
||||||
|
12.height,
|
||||||
|
DynamicTextFieldWidget(
|
||||||
|
"Date To: ",
|
||||||
|
selectedDateTo.toString().split(" ")[0],
|
||||||
|
suffixIconData: Icons.calendar_today,
|
||||||
|
isEnable: false,
|
||||||
|
onTap: () async {
|
||||||
|
selectedDateTo = await _selectDate(context, DateTime.now());
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
).paddingOnly(bottom: 12),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
bottomSheet: Container(
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
color: MyColors.white,
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(color: MyColors.lightGreyEFColor, spreadRadius: 3),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: DefaultButton(
|
||||||
|
LocaleKeys.submit.tr(),
|
||||||
|
selectedFunction == null
|
||||||
|
? null
|
||||||
|
: () async {
|
||||||
|
openRequestDetails();
|
||||||
|
})
|
||||||
|
.insideContainer,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<DateTime> _selectDate(BuildContext context, DateTime selectedDate) async {
|
||||||
|
DateTime time = selectedDate;
|
||||||
|
if (!Platform.isIOS) {
|
||||||
|
await showCupertinoModalPopup(
|
||||||
|
context: context,
|
||||||
|
builder: (cxt) => Container(
|
||||||
|
height: 250,
|
||||||
|
color: Colors.white,
|
||||||
|
child: CupertinoDatePicker(
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
mode: CupertinoDatePickerMode.date,
|
||||||
|
onDateTimeChanged: (value) {
|
||||||
|
if (value != null && value != selectedDate) {
|
||||||
|
time = value;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
initialDateTime: selectedDate,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
final DateTime? picked =
|
||||||
|
await showDatePicker(context: context, initialDate: selectedDate, initialEntryMode: DatePickerEntryMode.calendarOnly, firstDate: DateTime(2015, 8), lastDate: DateTime(2101));
|
||||||
|
if (picked != null && picked != selectedDate) {
|
||||||
|
time = picked;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
|
void getRequestTypes() async {
|
||||||
|
try {
|
||||||
|
Utils.showLoading(context);
|
||||||
|
getPendingTransactionsFunctions = await PendingTransactionsApiClient().getPendingReqFunctions();
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
} catch (ex) {
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
Utils.handleException(ex, context, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void openRequestDetails() async {
|
||||||
|
await Navigator.pushNamed(context, AppRoutes.pendingTransactionsDetails,
|
||||||
|
arguments: {"selectedFunctionID": selectedFunction?.fUNCTIONID, "dateFrom": DateUtil.convertDateToString(selectedDateFrom), "dateTo": DateUtil.convertDateToString(selectedDateTo)});
|
||||||
|
}
|
||||||
|
|
||||||
|
void getPendingReqDetails() async {
|
||||||
|
try {
|
||||||
|
Utils.showLoading(context);
|
||||||
|
getPendingTransactionsFunctions = await PendingTransactionsApiClient().getPendingReqFunctions();
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
} catch (ex) {
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
Utils.handleException(ex, context, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,137 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:mohem_flutter_app/api/pending_transactions_api_client.dart';
|
||||||
|
import 'package:mohem_flutter_app/classes/colors.dart';
|
||||||
|
import 'package:mohem_flutter_app/classes/utils.dart';
|
||||||
|
import 'package:mohem_flutter_app/extensions/int_extensions.dart';
|
||||||
|
import 'package:mohem_flutter_app/extensions/string_extensions.dart';
|
||||||
|
import 'package:mohem_flutter_app/models/pending_transactions/get_pending_transactions_details.dart';
|
||||||
|
import 'package:mohem_flutter_app/widgets/app_bar_widget.dart';
|
||||||
|
|
||||||
|
class PendingTransactionsDetails extends StatefulWidget {
|
||||||
|
const PendingTransactionsDetails({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_PendingTransactionsDetailsState createState() => _PendingTransactionsDetailsState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _PendingTransactionsDetailsState extends State<PendingTransactionsDetails> {
|
||||||
|
String functionID = "";
|
||||||
|
String dateFrom = "";
|
||||||
|
String dateTo = "";
|
||||||
|
|
||||||
|
List<GetPendingTransactionsDetails> getPendingTransactionsDetails = [];
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
getFunctionID() {
|
||||||
|
if (functionID == "") {
|
||||||
|
final arguments = (ModalRoute.of(context)?.settings.arguments ?? <String, dynamic>{}) as Map;
|
||||||
|
functionID = arguments["selectedFunctionID"].toString();
|
||||||
|
dateFrom = arguments["dateFrom"];
|
||||||
|
dateTo = arguments["dateTo"];
|
||||||
|
getTicketTransactions();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
getFunctionID();
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
appBar: AppBarWidget(
|
||||||
|
context,
|
||||||
|
title: "Pending Transactions",
|
||||||
|
),
|
||||||
|
body: getPendingTransactionsDetails.isNotEmpty
|
||||||
|
? Container(
|
||||||
|
margin: const EdgeInsets.only(top: 10.0),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: ListView.separated(
|
||||||
|
physics: const BouncingScrollPhysics(),
|
||||||
|
shrinkWrap: true,
|
||||||
|
itemBuilder: (BuildContext context, int index) {
|
||||||
|
return Container(
|
||||||
|
width: double.infinity,
|
||||||
|
padding: const EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 10),
|
||||||
|
margin: const EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 10),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: const Color(0xff000000).withOpacity(.05),
|
||||||
|
blurRadius: 26,
|
||||||
|
offset: const Offset(0, -3),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
"Created For ".toText14(color: MyColors.grey57Color),
|
||||||
|
getPendingTransactionsDetails[index].tRANSACTIONCREATEDFOR!.toText14(color: MyColors.grey57Color),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
getPendingTransactionsDetails[index].cREATIONDATE!.split(" ")[0].toText12(color: MyColors.grey70Color),
|
||||||
|
getPendingTransactionsDetails[index].cREATIONDATE!.split(" ")[1].toText12(color: MyColors.grey70Color),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
"Request Name: ".toText14(color: MyColors.grey57Color),
|
||||||
|
getPendingTransactionsDetails[index].uSERFUNCTIONNAME!.toText12(color: MyColors.grey57Color),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.only(top: 0.0),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
"Request Type: ".toText14(color: MyColors.grey57Color),
|
||||||
|
getPendingTransactionsDetails[index].rEQUESTTYPE!.toText14(color: MyColors.redColor),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
separatorBuilder: (BuildContext context, int index) => 12.height,
|
||||||
|
itemCount: getPendingTransactionsDetails.length ?? 0))
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Utils.getNoDataWidget(context),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void getTicketTransactions() async {
|
||||||
|
try {
|
||||||
|
Utils.showLoading(context);
|
||||||
|
getPendingTransactionsDetails = await PendingTransactionsApiClient().getPendingTransactionsDetails(functionID, dateFrom, dateTo);
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
setState(() {});
|
||||||
|
} catch (ex) {
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
Utils.handleException(ex, context, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue