leave balance cont.
parent
fbba3a93a8
commit
169a9bcc60
@ -0,0 +1,34 @@
|
|||||||
|
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/vacation_rule/get_vacation_rules_list_model.dart';
|
||||||
|
import 'package:mohem_flutter_app/models/vacation_rule/vr_item_types_list_model.dart';
|
||||||
|
|
||||||
|
class LeaveBalanceApiClient {
|
||||||
|
static final LeaveBalanceApiClient _instance = LeaveBalanceApiClient._internal();
|
||||||
|
|
||||||
|
LeaveBalanceApiClient._internal();
|
||||||
|
|
||||||
|
factory LeaveBalanceApiClient() => _instance;
|
||||||
|
|
||||||
|
Future<List<GetVacationRulesList>> getAbsenceTransactions(int pSelectedResopID) async {
|
||||||
|
String url = "${ApiConsts.erpRest}GET_ABSENCE_TRANSACTIONS";
|
||||||
|
Map<String, dynamic> postParams = {"P_PAGE_LIMIT": 50, "P_PAGE_NUM": 1, "P_MENU_TYPE": "E", "P_SELECTED_RESP_ID": pSelectedResopID};
|
||||||
|
postParams.addAll(AppState().postParamsJson);
|
||||||
|
return await ApiClient().postJsonForObject((json) {
|
||||||
|
GenericResponseModel? responseData = GenericResponseModel.fromJson(json);
|
||||||
|
return responseData.getVacationRulesList ?? [];
|
||||||
|
}, url, postParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<List<VrItemTypesList>> getVrItgetAbsenceAttendanceTypesemTypes() async {
|
||||||
|
String url = "${ApiConsts.erpRest}GET_ABSENCE_ATTENDANCE_TYPES";
|
||||||
|
Map<String, dynamic> postParams = {};
|
||||||
|
postParams.addAll(AppState().postParamsJson);
|
||||||
|
return await ApiClient().postJsonForObject((json) {
|
||||||
|
GenericResponseModel? responseData = GenericResponseModel.fromJson(json);
|
||||||
|
return responseData.vrItemTypesList ?? [];
|
||||||
|
}, url, postParams);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,51 @@
|
|||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:mohem_flutter_app/api/leave_balance_api_client.dart';
|
||||||
|
import 'package:mohem_flutter_app/classes/utils.dart';
|
||||||
|
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
|
||||||
|
import 'package:mohem_flutter_app/widgets/app_bar_widget.dart';
|
||||||
|
|
||||||
|
class AddLeaveBalanceScreen extends StatefulWidget {
|
||||||
|
AddLeaveBalanceScreen({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_AddLeaveBalanceScreenState createState() {
|
||||||
|
return _AddLeaveBalanceScreenState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AddLeaveBalanceScreenState extends State<AddLeaveBalanceScreen> {
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
getAbsenceAttendanceTypes();
|
||||||
|
}
|
||||||
|
|
||||||
|
void getAbsenceAttendanceTypes() async {
|
||||||
|
try {
|
||||||
|
Utils.showLoading(context);
|
||||||
|
var bac = await LeaveBalanceApiClient().getAbsenceTransactions(-999);
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
setState(() {});
|
||||||
|
} catch (ex) {
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
Utils.handleException(ex, context, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
appBar: AppBarWidget(
|
||||||
|
context,
|
||||||
|
title: LocaleKeys.leaveBalance.tr(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,95 @@
|
|||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:mohem_flutter_app/api/leave_balance_api_client.dart';
|
||||||
|
import 'package:mohem_flutter_app/classes/colors.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/widgets/app_bar_widget.dart';
|
||||||
|
import 'package:mohem_flutter_app/widgets/item_detail_view_widget.dart';
|
||||||
|
|
||||||
|
class LeaveBalance extends StatefulWidget {
|
||||||
|
LeaveBalance({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_LeaveBalanceState createState() {
|
||||||
|
return _LeaveBalanceState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _LeaveBalanceState extends State<LeaveBalance> {
|
||||||
|
List<String> list = [];
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
getAbsenceTransactions();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
void getAbsenceTransactions() async {
|
||||||
|
try {
|
||||||
|
Utils.showLoading(context);
|
||||||
|
var bac = await LeaveBalanceApiClient().getAbsenceTransactions(-999);
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
setState(() {});
|
||||||
|
} catch (ex) {
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
Utils.handleException(ex, context, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
appBar: AppBarWidget(
|
||||||
|
context,
|
||||||
|
title: LocaleKeys.leaveBalance.tr(),
|
||||||
|
),
|
||||||
|
body: list == null
|
||||||
|
? const SizedBox()
|
||||||
|
: (list!.isEmpty
|
||||||
|
? Utils.getNoDataWidget(context)
|
||||||
|
: ListView.separated(
|
||||||
|
physics: const BouncingScrollPhysics(),
|
||||||
|
padding: const EdgeInsets.all(21),
|
||||||
|
itemBuilder: (cxt, int parentIndex) => Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
ItemDetailView(LocaleKeys.startDateT.tr(), ""),
|
||||||
|
ItemDetailView(LocaleKeys.endDateT.tr(), ""),
|
||||||
|
ItemDetailView(LocaleKeys.absenceType.tr(), ""),
|
||||||
|
ItemDetailView(LocaleKeys.absenceCategory.tr(), ""),
|
||||||
|
ItemDetailView(LocaleKeys.days.tr(), ""),
|
||||||
|
ItemDetailView(LocaleKeys.hours.tr(), ""),
|
||||||
|
ItemDetailView(LocaleKeys.approvalStatus.tr(), ""),
|
||||||
|
ItemDetailView(LocaleKeys.absenceStatus.tr(), ""),
|
||||||
|
],
|
||||||
|
).objectContainerView(),
|
||||||
|
separatorBuilder: (cxt, index) => 12.height,
|
||||||
|
itemCount: list!.length + 1)),
|
||||||
|
floatingActionButton: Container(
|
||||||
|
height: 54,
|
||||||
|
width: 54,
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
gradient: LinearGradient(transform: GradientRotation(.83), begin: Alignment.topRight, end: Alignment.bottomLeft, colors: [
|
||||||
|
MyColors.gradiantEndColor,
|
||||||
|
MyColors.gradiantStartColor,
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
child: const Icon(Icons.add, color: Colors.white, size: 30),
|
||||||
|
).onPress(() {
|
||||||
|
Navigator.pushNamed(context, AppRoutes.addLeaveBalance);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue