fix issue
parent
89058f9e59
commit
d640ce29de
@ -0,0 +1,62 @@
|
||||
|
||||
|
||||
class GetSubordinatesLeavesTotalVacationsList {
|
||||
String? aBSENCEATTENDANCETYPENAME;
|
||||
String? cALENDARENTRYDESC;
|
||||
String? dATEEND;
|
||||
String? dATESTART;
|
||||
String? eMPLOYEENAME;
|
||||
String? eMPLOYEENUMBER;
|
||||
String? lEAVETYPE;
|
||||
int? oRGANIZATIONID;
|
||||
String? oRGANIZATIONNAME;
|
||||
String? pOSITIONTITLE;
|
||||
String? rEPLACEMENTNAME;
|
||||
String? sTATUS;
|
||||
|
||||
GetSubordinatesLeavesTotalVacationsList(
|
||||
{this.aBSENCEATTENDANCETYPENAME,
|
||||
this.cALENDARENTRYDESC,
|
||||
this.dATEEND,
|
||||
this.dATESTART,
|
||||
this.eMPLOYEENAME,
|
||||
this.eMPLOYEENUMBER,
|
||||
this.lEAVETYPE,
|
||||
this.oRGANIZATIONID,
|
||||
this.oRGANIZATIONNAME,
|
||||
this.pOSITIONTITLE,
|
||||
this.rEPLACEMENTNAME,
|
||||
this.sTATUS});
|
||||
|
||||
GetSubordinatesLeavesTotalVacationsList.fromJson(Map<String, dynamic> json) {
|
||||
aBSENCEATTENDANCETYPENAME = json['ABSENCE_ATTENDANCE_TYPE_NAME'];
|
||||
cALENDARENTRYDESC = json['CALENDAR_ENTRY_DESC'];
|
||||
dATEEND = json['DATE_END'];
|
||||
dATESTART = json['DATE_START'];
|
||||
eMPLOYEENAME = json['EMPLOYEE_NAME'];
|
||||
eMPLOYEENUMBER = json['EMPLOYEE_NUMBER'];
|
||||
lEAVETYPE = json['LEAVE_TYPE'];
|
||||
oRGANIZATIONID = json['ORGANIZATION_ID'];
|
||||
oRGANIZATIONNAME = json['ORGANIZATION_NAME'];
|
||||
pOSITIONTITLE = json['POSITION_TITLE'];
|
||||
rEPLACEMENTNAME = json['REPLACEMENT_NAME'];
|
||||
sTATUS = json['STATUS'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['ABSENCE_ATTENDANCE_TYPE_NAME'] = this.aBSENCEATTENDANCETYPENAME;
|
||||
data['CALENDAR_ENTRY_DESC'] = this.cALENDARENTRYDESC;
|
||||
data['DATE_END'] = this.dATEEND;
|
||||
data['DATE_START'] = this.dATESTART;
|
||||
data['EMPLOYEE_NAME'] = this.eMPLOYEENAME;
|
||||
data['EMPLOYEE_NUMBER'] = this.eMPLOYEENUMBER;
|
||||
data['LEAVE_TYPE'] = this.lEAVETYPE;
|
||||
data['ORGANIZATION_ID'] = this.oRGANIZATIONID;
|
||||
data['ORGANIZATION_NAME'] = this.oRGANIZATIONNAME;
|
||||
data['POSITION_TITLE'] = this.pOSITIONTITLE;
|
||||
data['REPLACEMENT_NAME'] = this.rEPLACEMENTNAME;
|
||||
data['STATUS'] = this.sTATUS;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,175 @@
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:mohem_flutter_app/api/my_team/my_team_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/string_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/my_team/get_subordinates_leaves_total_vacations_list_model.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 SubordinateLeave extends StatefulWidget {
|
||||
const SubordinateLeave({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_SubordinateLeaveState createState() => _SubordinateLeaveState();
|
||||
}
|
||||
|
||||
class _SubordinateLeaveState extends State<SubordinateLeave> {
|
||||
List<GetSubordinatesLeavesTotalVacationsList> getSubordinatesLeavesTotalList = [];
|
||||
DateTime selectedDateFrom = DateTime.now();
|
||||
DateTime selectedDateTo = DateTime.now();
|
||||
bool showList = false;
|
||||
// DateTime dateFrom = DateFormat("MMM/DD/YYYY").format(selectedDateFrom) as DateTime;
|
||||
// DateTime dateTo = DateFormat("MMM/DD/YYYY").format(selectedDateTo) as DateTime;
|
||||
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
void getSubordinatesLeaves()async {
|
||||
try {
|
||||
Utils.showLoading(context);
|
||||
getSubordinatesLeavesTotalList = await MyTeamApiClient().getSubordinatesLeavesList(selectedDateFrom.toIso8601String(), selectedDateTo.toIso8601String());
|
||||
Utils.hideLoading(context);
|
||||
} catch (ex) {da
|
||||
Utils.hideLoading(context);
|
||||
Utils.handleException(ex, context, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBarWidget(
|
||||
context,
|
||||
title: "Subordinate Leave",
|
||||
),
|
||||
backgroundColor: MyColors.backgroundColor,
|
||||
body: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
DynamicTextFieldWidget(
|
||||
LocaleKeys.dateFrom.tr(),
|
||||
selectedDateFrom.toString().split(" ")[0],
|
||||
suffixIconData: Icons.calendar_today,
|
||||
isEnable: false,
|
||||
onTap: () async {
|
||||
selectedDateFrom = await _selectDate(context, DateTime.now());
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
12.height,
|
||||
DynamicTextFieldWidget(
|
||||
LocaleKeys.dateTo.tr(),
|
||||
selectedDateTo.toString().split(" ")[0],
|
||||
suffixIconData: Icons.calendar_today,
|
||||
isEnable: false,
|
||||
onTap: () async {
|
||||
selectedDateTo = await _selectDate(context, DateTime.now());
|
||||
setState(() {});
|
||||
},
|
||||
)
|
||||
],
|
||||
).objectContainerView(),
|
||||
!showList?
|
||||
SingleChildScrollView(
|
||||
child: ListView.separated(
|
||||
scrollDirection: Axis.vertical,
|
||||
shrinkWrap: true,
|
||||
physics: ScrollPhysics(),
|
||||
separatorBuilder: (cxt, index) => 12.height,
|
||||
itemCount: getSubordinatesLeavesTotalList.length,
|
||||
itemBuilder: (context, index) {
|
||||
var diffDays = selectedDateTo.difference(selectedDateFrom).inDays;
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
// CircleAvatar(
|
||||
// radius: 25,
|
||||
// backgroundImage: MemoryImage(Utils.getPostBytes(getSubordinatesLeavesTotalList[index].eMPLOYEEIMAGE)),
|
||||
// backgroundColor: Colors.black,
|
||||
// ),
|
||||
SvgPicture.asset("assets/images/clock.svg"),
|
||||
10.width,
|
||||
"${getSubordinatesLeavesTotalList[index].eMPLOYEENAME}".toText16(isBold: true, color: MyColors.grey3AColor),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
"From: ${getSubordinatesLeavesTotalList[index].dATESTART}".toText10(isBold: true, color: MyColors.grey57Color),
|
||||
"To: ${getSubordinatesLeavesTotalList[index].dATEEND}".toText10(isBold: true, color: MyColors.grey57Color),
|
||||
],
|
||||
).expanded,
|
||||
"Number of days: $diffDays".toText13(color: MyColors.grey3AColor),
|
||||
],
|
||||
).objectContainerView();
|
||||
}),
|
||||
).objectContainerView()
|
||||
:Container(),
|
||||
],
|
||||
),
|
||||
),
|
||||
DefaultButton(
|
||||
LocaleKeys.submit.tr(), () async {
|
||||
getSubordinatesLeaves();
|
||||
setState(() {
|
||||
showList= true;
|
||||
});
|
||||
showList= true;
|
||||
}).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 {
|
||||
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;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue