Skip to content

Commit

Permalink
Merge pull request #14 from ryanaidilp/4.2.1
Browse files Browse the repository at this point in the history
Add new features & some improvements from 4.1.8 to 4.2.1
  • Loading branch information
ryanaidilp committed Jan 10, 2021
2 parents 174ca89 + 1dc7b1a commit 6567208
Show file tree
Hide file tree
Showing 46 changed files with 4,337 additions and 888 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ android {
applicationId "com.banuacoders.siap"
minSdkVersion 24
targetSdkVersion 30
versionCode 27
versionName '4.1.8'
versionCode 31
versionName '4.2.1'
}

signingConfigs {
Expand Down
Binary file added assets/logo/balaesang.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/logo/banuacoders.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/logo/logo_color.png
Binary file not shown.
Binary file removed assets/logo/logo_color_b.png
Binary file not shown.
8 changes: 7 additions & 1 deletion lib/models/employee.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ class Employee {
this.department,
this.status,
this.position,
this.presences});
this.presences,
this.rank,
this.group});

final String nip;
final String name;
Expand All @@ -19,6 +21,8 @@ class Employee {
final String department;
final String status;
final String position;
final String rank;
final String group;
final List<Presence> presences;

factory Employee.fromJson(Map<String, dynamic> json) {
Expand All @@ -28,6 +32,8 @@ class Employee {
phone: json[USER_PHONE_FIELD] as String,
gender: json[USER_GENDER_FIELD] as String,
department: json[USER_DEPARTMENT_FIELD] as String,
rank: json[USER_RANK_FIELD] as String,
group: json[USER_GROUP_FIELD] as String,
status: json[USER_STATUS_FIELD] as String,
position: json[USER_POSITION_FIELD] as String,
presences: json[USER_PRESENCES_FIELD] != null
Expand Down
38 changes: 38 additions & 0 deletions lib/models/paid_leave.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import 'package:spo_balaesang/models/user.dart';
import 'package:spo_balaesang/utils/app_const.dart';

class PaidLeave {
const PaidLeave(
{this.title,
this.id,
this.category,
this.photo,
this.description,
this.startDate,
this.dueDate,
this.isApproved,
this.user});

final int id;
final String title;
final String category;
final String description;
final bool isApproved;
final DateTime startDate;
final DateTime dueDate;
final String photo;
final User user;

factory PaidLeave.fromJson(Map<String, dynamic> json) => PaidLeave(
id: json[PAID_LEAVE_ID_FIELD] as int,
title: json[PAID_LEAVE_TITLE_FIELD] as String,
category: json[PAID_LEAVE_CATEGORY_FIELD] as String,
description: json[PAID_LEAVE_DESCRIPTION_FIELD] as String,
isApproved: json[PAID_LEAVE_IS_APPROVED_FIELD] as bool,
startDate: DateTime.parse(json[PAID_LEAVE_START_DATE_FIELD]),
dueDate: DateTime.parse(json[PAID_LEAVE_DUE_DATE_FIELD]),
photo: json[PAID_LEAVE_PHOTO_FIELD] as String,
user: json[PAID_LEAVE_USER_FIELD] != null
? User.fromJson(json[PAID_LEAVE_USER_FIELD])
: null);
}
5 changes: 4 additions & 1 deletion lib/models/presence.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import 'package:spo_balaesang/utils/app_const.dart';

class Presence {
const Presence(
{this.date,
{this.id,
this.date,
this.codeType,
this.status,
this.attendTime,
Expand All @@ -12,6 +13,7 @@ class Presence {
this.startTime,
this.endTime});

final int id;
final DateTime date;
final String codeType;
final String status;
Expand All @@ -23,6 +25,7 @@ class Presence {

factory Presence.fromJson(Map<String, dynamic> json) {
return Presence(
id: json[USER_ID_FIELD] as int,
date: DateTime.parse(json[PRESENCE_DATE_FIELD].toString()),
codeType: json[PRESENCE_CODE_TYPE_FIELD] as String,
status: json[PRESENCE_STATUS_FIELD] as String,
Expand Down
11 changes: 9 additions & 2 deletions lib/models/report/absent_report.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@ import 'package:spo_balaesang/models/report/yearly.dart';
import 'package:spo_balaesang/utils/app_const.dart';

class AbsentReport {
const AbsentReport({this.daily, this.monthly, this.yearly, this.holidays});
const AbsentReport(
{this.daily,
this.monthly,
this.yearly,
this.holidays,
this.totalWorkDay});

final List<Daily> daily;
final Monthly monthly;
final Yearly yearly;
final List<Holiday> holidays;
final int totalWorkDay;

factory AbsentReport.fromJson(Map<String, dynamic> json) => AbsentReport(
daily: (json[ABSENT_REPORT_DAILY_FIELD] as List<dynamic>)
Expand All @@ -20,5 +26,6 @@ class AbsentReport {
yearly: Yearly.fromJson(json[ABSENT_REPORT_YEARLY_FIELD]),
holidays: (json[ABSENT_REPORT_HOLIDAYS_FIELD] as List<dynamic>)
.map((item) => Holiday.fromJson(item))
.toList());
.toList(),
totalWorkDay: json[REPORT_TOTAL_WORK_DAY_FIELD] as int);
}
21 changes: 18 additions & 3 deletions lib/models/report/daily.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,35 @@ class Daily {
}

class DailyData {
const DailyData({this.attendType, this.attendTime, this.attendStatus});
const DailyData(
{this.attendType,
this.attendTime,
this.attendStatus,
this.startTime,
this.address,
this.photo});

final String attendType;
final String attendTime;
final String attendStatus;
final DateTime startTime;
final String address;
final String photo;

factory DailyData.fromJson(Map<String, dynamic> json) => DailyData(
attendTime: json[DAILY_DATA_ATTEND_TIME_FIELD],
attendType: json[DAILY_DATA_ATTEND_TYPE_FIELD],
attendStatus: json[DAILY_DATA_ATTEND_STATUS_FIELD]);
attendStatus: json[DAILY_DATA_ATTEND_STATUS_FIELD],
startTime: DateTime.parse(json[PRESENCE_START_TIME_FIELD]),
address: json[LOCATION_ADDRESS_FIELD] as String,
photo: json[PRESENCE_PHOTO_FIELD] as String);

Map<String, dynamic> toMap() => <String, dynamic>{
DAILY_DATA_ATTEND_TYPE_FIELD: this.attendType,
DAILY_DATA_ATTEND_TIME_FIELD: this.attendTime,
DAILY_DATA_ATTEND_STATUS_FIELD: this.attendStatus
DAILY_DATA_ATTEND_STATUS_FIELD: this.attendStatus,
PRESENCE_START_TIME_FIELD: this.startTime.toString(),
LOCATION_ADDRESS_FIELD: this.address,
PRESENCE_PHOTO_FIELD: this.photo
};
}
13 changes: 11 additions & 2 deletions lib/models/report/monthly.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
import 'package:spo_balaesang/utils/app_const.dart';

class Monthly {
const Monthly({this.lateCount, this.attendancePercentage});
const Monthly(
{this.lateCount,
this.attendancePercentage,
this.leaveEarlyCount,
this.notMorningParadeCount});

final double attendancePercentage;
final int lateCount;
final int leaveEarlyCount;
final int notMorningParadeCount;

factory Monthly.fromJson(Map<String, dynamic> json) => Monthly(
attendancePercentage:
double.parse(json[REPORT_ATTENDANCE_PERCENTAGE_FIELD].toString()),
lateCount: json[REPORT_LATE_COUNT_FIELD] as int);
lateCount: json[REPORT_LATE_COUNT_FIELD] as int,
leaveEarlyCount: json[REPORT_LEAVE_EARLY_COUNT_FIELD] as int,
notMorningParadeCount:
json[REPORT_NOT_MORNING_PARADE_COUNT_FIELD] as int);
}
27 changes: 26 additions & 1 deletion lib/models/report/yearly.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,27 @@ class Yearly {
this.absent,
this.lateCount,
this.absentPermission,
this.leaveEarlyCount,
this.notMorningParadeCount,
this.annualLeave,
this.importantReasonLeave,
this.sickLeave,
this.maternityLeave,
this.outOfLiabilityLeave,
});

final double attendancePercentage;
final int lateCount;
final int leaveEarlyCount;
final int notMorningParadeCount;
final Map<String, dynamic> absentPermission;
final Map<String, dynamic> outstation;
final Map<String, dynamic> absent;
final Map<String, dynamic> annualLeave;
final Map<String, dynamic> importantReasonLeave;
final Map<String, dynamic> sickLeave;
final Map<String, dynamic> maternityLeave;
final Map<String, dynamic> outOfLiabilityLeave;

factory Yearly.fromJson(Map<String, dynamic> json) {
return Yearly(
Expand All @@ -23,6 +37,17 @@ class Yearly {
absent: json[YEARLY_ABSENT_FIELD] as Map<String, dynamic>,
absentPermission:
json[YEARLY_ABSENT_PERMISSION_FIELD] as Map<String, dynamic>,
outstation: json[YEARLY_OUTSTATION_FIELD] as Map<String, dynamic>);
outstation: json[YEARLY_OUTSTATION_FIELD] as Map<String, dynamic>,
leaveEarlyCount: json[REPORT_LEAVE_EARLY_COUNT_FIELD] as int,
notMorningParadeCount:
json[REPORT_NOT_MORNING_PARADE_COUNT_FIELD] as int,
annualLeave: json[REPORT_ANNUAL_LEAVE_FIELD] as Map<String, dynamic>,
importantReasonLeave:
json[REPORT_IMPORTANT_REASON_LEAVE_FIELD] as Map<String, dynamic>,
sickLeave: json[REPORT_SICK_LEAVE_FIELD] as Map<String, dynamic>,
maternityLeave:
json[REPORT_MATERNITY_LEAVE_FIELD] as Map<String, dynamic>,
outOfLiabilityLeave:
json[REPORT_OUT_OF_LIABILITY_LEAVE_FIELD] as Map<String, dynamic>);
}
}
10 changes: 8 additions & 2 deletions lib/models/user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ class User {
this.nextPresence,
this.presences,
this.holiday,
this.isWeekend});
this.isWeekend,
this.rank,
this.group});

final int id;
final String nip;
Expand All @@ -33,6 +35,8 @@ class User {
final List<Presence> presences;
final Holiday holiday;
final bool isWeekend;
final String rank;
final String group;

factory User.fromJson(Map<String, dynamic> json) {
return User(
Expand All @@ -59,6 +63,8 @@ class User {
? (json[USER_PRESENCES_FIELD] as List<dynamic>)
.map((json) => Presence.fromJson(json))
.toList()
: []);
: [],
rank: json[USER_RANK_FIELD] as String,
group: json[USER_GROUP_FIELD] as String);
}
}
10 changes: 9 additions & 1 deletion lib/network/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ enum Endpoint {
readNotifications,
deleteNotifications,
sendNotifications,
statistics
statistics,
paidLeave,
employeePaidLeave,
approvePaidLeave,
cancelAttendance
}

class API {
Expand All @@ -43,5 +47,9 @@ class API {
Endpoint.deleteNotifications: 'notifications/delete',
Endpoint.sendNotifications: 'notifications/send',
Endpoint.statistics: 'statistics',
Endpoint.paidLeave: 'paid-leave',
Endpoint.employeePaidLeave: 'paid-leave/all',
Endpoint.approvePaidLeave: 'paid-leave/approve',
Endpoint.cancelAttendance: 'presence/cancel'
};
}
68 changes: 68 additions & 0 deletions lib/repositories/data_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -261,4 +261,72 @@ class DataRepository {
}
return response;
}

Future<Map<String, dynamic>> getAllPaidLeave() async {
Map<String, dynamic> data;
try {
data = await apiService.getEndpointData(endpoint: Endpoint.paidLeave);
} catch (e) {
print(e.toString());
}
return data;
}

Future<Map<String, dynamic>> getAllEmployeePaidLeave() async {
Map<String, dynamic> data;
try {
data = await apiService.getEndpointData(
endpoint: Endpoint.employeePaidLeave);
} catch (e) {
print(e.toString());
}
return data;
}

Future<Response> approvePaidLeave(Map<String, dynamic> data) async {
Response response;
try {
response = await apiService.postEndpointWithToken(
endpoint: Endpoint.approvePaidLeave, data: data);
} catch (e) {
print(e.toString());
}
return response;
}

Future<Map<String, dynamic>> paidLeave(Map<String, dynamic> data) async {
Map<String, dynamic> result;
try {
var response = await apiService.postEndpointWithToken(
endpoint: Endpoint.paidLeave, data: data);
result = jsonDecode(response.body);
} catch (e) {
print(e.toString());
}
return result;
}

Future<Map<String, dynamic>> getEmployeePresence(DateTime date) async {
Map<String, dynamic> data;
try {
data =
await apiService.getEndpointData(endpoint: Endpoint.presence, query: {
'date': date.toString(),
});
} catch (e) {
print(e.toString());
}
return data;
}

Future<Response> cancelAttendance(Map<String, dynamic> data) async {
Response response;
try {
response = await apiService.postEndpointWithToken(
endpoint: Endpoint.cancelAttendance, data: data);
} catch (e) {
print(e.toString());
}
return response;
}
}
Loading

0 comments on commit 6567208

Please sign in to comment.