Skip to content

Commit d248cb9

Browse files
committed
up
1 parent 66cf3db commit d248cb9

File tree

6 files changed

+143
-67
lines changed

6 files changed

+143
-67
lines changed

lib/config.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class Config {
2-
static const String APP_VERISON = "1.0.42+43";
2+
static const String APP_VERISON = "1.0.43+44";
33
static DateTime dummyTime = DateTime(
44
1,
55
1,

lib/services/mailService.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ class MailService extends AuthService {
88
AuthService.BASE_URI + 'api/mail/send/',
99
method: 'POST',
1010
body: payload);
11-
print(response.body);
1211
if (response.statusCode == 200) {
1312
print("success");
1413
return true;

lib/views/Admin/Attendance/SoloAttendance.dart

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,24 @@ class _SoloAttendanceState extends State<SoloAttendance> {
4747
desiredAccuracy: LocationAccuracy.high);
4848
}
4949

50+
List<String> parentEmail = [];
51+
5052
getData() async {
5153
setState(() {
5254
loading = true;
5355
});
5456
await getLocation();
5557
user = await UserService.getUser();
58+
if (user.parentId != "") {
59+
var parentIdList = user.parentId.split(",");
60+
print(parentIdList.length);
61+
for (var i = 0; i < parentIdList.length; i++) {
62+
User parent = await UserService.getUserById(parentIdList[i]);
63+
setState(() {
64+
parentEmail.add(parent.officialEmail);
65+
});
66+
}
67+
}
5668
if (widget.attendanceElement != null) {
5769
attendanceElement = await AttendanceService.getLogById(
5870
widget.attendanceElement.attendanceId);
@@ -101,13 +113,15 @@ class _SoloAttendanceState extends State<SoloAttendance> {
101113
tempAttendance.diff_km =
102114
user.bikeReading == 1 ? endMeter - startMeter : 0;
103115
}
104-
MailService.sendMail(jsonEncode({
105-
"name": user.name,
106-
"type": "Punch Out",
107-
"lat": position.latitude,
108-
"long": position.longitude,
109-
110-
}));
116+
if (parentEmail.isNotEmpty) {
117+
MailService.sendMail(jsonEncode({
118+
"name": user.name,
119+
"type": "Punch Out",
120+
"lat": position.latitude,
121+
"long": position.longitude,
122+
"to": parentEmail
123+
}));
124+
}
111125
var result = await AttendanceService.updateLog(tempAttendance.toJson(), id);
112126
if (result && id != "-") {
113127
showInSnackBar(
@@ -149,13 +163,15 @@ class _SoloAttendanceState extends State<SoloAttendance> {
149163
position.latitude.toString() + "," + position.longitude.toString(),
150164
"geo_out": 0,
151165
};
152-
MailService.sendMail(jsonEncode({
153-
"name": user.name,
154-
"type": "Punch In",
155-
"lat": position.latitude,
156-
"long": position.longitude,
157-
158-
}));
166+
if (parentEmail.isNotEmpty) {
167+
MailService.sendMail(jsonEncode({
168+
"name": user.name,
169+
"type": "Punch In",
170+
"lat": position.latitude,
171+
"long": position.longitude,
172+
"to": parentEmail
173+
}));
174+
}
159175
var result = await AttendanceService.createLog(payload);
160176
if (result != false) {
161177
setState(() {

lib/views/Employee/Attendance/SoloAttendanceScreen.dart

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,17 @@ class _SoloAttendanceState extends State<SoloAttendance> {
5252
loading = true;
5353
});
5454
await getLocation();
55-
user = await UserService.getUser();
56-
print(user.parentId);
55+
user = await UserService.getUser();
56+
if (user.parentId != "") {
57+
var parentIdList = user.parentId.split(",");
58+
print(parentIdList.length);
59+
for (var i = 0; i < parentIdList.length; i++) {
60+
User parent = await UserService.getUserById(parentIdList[i]);
61+
setState(() {
62+
parentEmail.add(parent.officialEmail);
63+
});
64+
}
65+
}
5766
if (widget.attendanceElement != null) {
5867
attendanceElement = await AttendanceService.getLogById(
5968
widget.attendanceElement.attendanceId);
@@ -86,6 +95,7 @@ class _SoloAttendanceState extends State<SoloAttendance> {
8695
loading = false;
8796
});
8897
}
98+
List<String> parentEmail = [];
8999

90100
updateLog() async {
91101
DateTime startTime = DateTime.parse(start);
@@ -101,14 +111,23 @@ class _SoloAttendanceState extends State<SoloAttendance> {
101111
if (id != "-") {
102112
tempAttendance = await AttendanceService.getLogById(id);
103113
print(tempAttendance.toJson());
114+
tempAttendance.meterOut = user.bikeReading == 1 ? endMeter : 0;
104115
tempAttendance.geo_out =
105116
position.latitude.toString() + "," + position.longitude.toString();
106-
tempAttendance.meterOut = user.bikeReading == 1 ? endMeter : 0;
107117
tempAttendance.punchOut = endTime;
108118
tempAttendance.workHour = endTime.difference(startTime).inHours;
109119
tempAttendance.diff_km =
110120
user.bikeReading == 1 ? endMeter - startMeter : 0;
111121
}
122+
if (parentEmail.isNotEmpty) {
123+
MailService.sendMail(jsonEncode({
124+
"name": user.name,
125+
"type": "Punch Out",
126+
"lat": position.latitude,
127+
"long": position.longitude,
128+
"to": parentEmail
129+
}));
130+
}
112131
var result = await AttendanceService.updateLog(tempAttendance.toJson(), id);
113132
if (result && id != "-") {
114133
showInSnackBar(
@@ -149,13 +168,15 @@ class _SoloAttendanceState extends State<SoloAttendance> {
149168
position.latitude.toString() + "," + position.longitude.toString(),
150169
"geo_out": 0,
151170
};
152-
await MailService.sendMail(jsonEncode({
153-
"name": user.name,
154-
"type": "Punch In",
155-
"lat": position.latitude,
156-
"long": position.longitude,
157-
158-
}));
171+
if (parentEmail.isNotEmpty) {
172+
MailService.sendMail(jsonEncode({
173+
"name": user.name,
174+
"type": "Punch In",
175+
"lat": position.latitude,
176+
"long": position.longitude,
177+
"to": parentEmail
178+
}));
179+
}
159180
var result = await AttendanceService.createLog(payload);
160181
if (result != false) {
161182
setState(() {

lib/views/Manager/Attendance/SoloAttendance.dart

Lines changed: 80 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import 'package:propview/config.dart';
66
import 'package:propview/models/Attendance.dart';
77
import 'package:propview/models/User.dart';
88
import 'package:propview/services/attendanceService.dart';
9+
import 'package:propview/services/mailService.dart';
910
import 'package:propview/services/userService.dart';
1011
import 'package:propview/utils/progressBar.dart';
1112
import 'package:propview/utils/snackBar.dart';
@@ -46,16 +47,29 @@ class _SoloAttendanceState extends State<SoloAttendance> {
4647
desiredAccuracy: LocationAccuracy.high);
4748
}
4849

50+
List<String> parentEmail = [];
4951
getData() async {
5052
setState(() {
5153
loading = true;
5254
});
5355
await getLocation();
5456
user = await UserService.getUser();
57+
if (user.parentId != "") {
58+
var parentIdList = user.parentId.split(",");
59+
print((parentIdList));
60+
print(parentIdList.length);
61+
for (var i = 0; i < parentIdList.length; i++) {
62+
User parent = await UserService.getUserById(parentIdList[i]);
63+
setState(() {
64+
parentEmail.add(parent.officialEmail);
65+
});
66+
}
67+
}
5568
if (widget.attendanceElement != null) {
5669
attendanceElement = await AttendanceService.getLogById(
5770
widget.attendanceElement.attendanceId);
5871
}
72+
print((parentEmail));
5973
getPunch();
6074
setState(() {
6175
loading = false;
@@ -85,36 +99,44 @@ class _SoloAttendanceState extends State<SoloAttendance> {
8599
});
86100
}
87101

88-
updateLog() async {
89-
DateTime startTime = DateTime.parse(start);
90-
DateTime endTime = DateTime.parse(end);
91-
AttendanceElement tempAttendance;
92-
if (id != "-") {
93-
tempAttendance = await AttendanceService.getLogById(id);
94-
print(tempAttendance.toJson());
95-
tempAttendance.geo_out =
96-
position.latitude.toString() + "," + position.longitude.toString();
97-
tempAttendance.meterOut = user.bikeReading == 1 ? endMeter : 0;
98-
tempAttendance.punchOut = endTime;
99-
tempAttendance.workHour = endTime.difference(startTime).inHours;
100-
tempAttendance.diff_km =
101-
user.bikeReading == 1 ? endMeter - startMeter : 0;
102-
}
103-
var result =
104-
await AttendanceService.updateLog(tempAttendance.toJson(), id);
105-
if (result && id != "-") {
106-
showInSnackBar(
107-
context,
108-
"Attendance updated successfully",
109-
1500,
110-
);
111-
} else {
112-
showInSnackBar(
113-
context,
114-
"Attendance updation failed",
115-
1500,
116-
);
117-
}
102+
updateLog() async {
103+
DateTime startTime = DateTime.parse(start);
104+
DateTime endTime = DateTime.parse(end);
105+
AttendanceElement tempAttendance;
106+
if (id != "-") {
107+
tempAttendance = await AttendanceService.getLogById(id);
108+
print(tempAttendance.toJson());
109+
tempAttendance.geo_out =
110+
position.latitude.toString() + "," + position.longitude.toString();
111+
tempAttendance.meterOut = user.bikeReading == 1 ? endMeter : 0;
112+
tempAttendance.punchOut = endTime;
113+
tempAttendance.workHour = endTime.difference(startTime).inHours;
114+
tempAttendance.diff_km =
115+
user.bikeReading == 1 ? endMeter - startMeter : 0;
116+
}
117+
if (parentEmail.isNotEmpty) {
118+
MailService.sendMail(jsonEncode({
119+
"name": user.name,
120+
"type": "Punch Out",
121+
"lat": position.latitude,
122+
"long": position.longitude,
123+
"to": parentEmail
124+
}));
125+
}
126+
var result = await AttendanceService.updateLog(tempAttendance.toJson(), id);
127+
if (result && id != "-") {
128+
showInSnackBar(
129+
context,
130+
"Attendance updated successfully",
131+
1500,
132+
);
133+
} else {
134+
showInSnackBar(
135+
context,
136+
"Attendance updation failed",
137+
1500,
138+
);
139+
}
118140
}
119141

120142
createLog() async {
@@ -141,6 +163,15 @@ class _SoloAttendanceState extends State<SoloAttendance> {
141163
position.latitude.toString() + "," + position.longitude.toString(),
142164
"geo_out": 0,
143165
};
166+
if (parentEmail.isNotEmpty) {
167+
MailService.sendMail(jsonEncode({
168+
"name": user.name,
169+
"type": "Punch In",
170+
"lat": position.latitude,
171+
"long": position.longitude,
172+
"to": parentEmail
173+
}));
174+
}
144175
var result = await AttendanceService.createLog(payload);
145176
if (result != false) {
146177
setState(() {
@@ -185,7 +216,7 @@ class _SoloAttendanceState extends State<SoloAttendance> {
185216
@override
186217
Widget build(BuildContext context) {
187218
return WillPopScope(
188-
onWillPop: () async{
219+
onWillPop: () async {
189220
Navigator.of(context).push(
190221
MaterialPageRoute(
191222
builder: (context) => LandingScreen(
@@ -300,10 +331,12 @@ class _SoloAttendanceState extends State<SoloAttendance> {
300331
Padding(
301332
padding: EdgeInsets.symmetric(horizontal: 32.0),
302333
child: Row(
303-
mainAxisAlignment: MainAxisAlignment.spaceBetween,
334+
mainAxisAlignment:
335+
MainAxisAlignment.spaceBetween,
304336
children: [
305337
Column(
306-
crossAxisAlignment: CrossAxisAlignment.start,
338+
crossAxisAlignment:
339+
CrossAxisAlignment.start,
307340
mainAxisSize: MainAxisSize.min,
308341
children: [
309342
Text(
@@ -354,7 +387,8 @@ class _SoloAttendanceState extends State<SoloAttendance> {
354387
],
355388
),
356389
Column(
357-
crossAxisAlignment: CrossAxisAlignment.start,
390+
crossAxisAlignment:
391+
CrossAxisAlignment.start,
358392
mainAxisSize: MainAxisSize.min,
359393
children: [
360394
Text(
@@ -417,7 +451,8 @@ class _SoloAttendanceState extends State<SoloAttendance> {
417451
if (start == "--/--/-- -- : --") {
418452
showDialog(
419453
context: context,
420-
builder: (context) => AlertDialog(
454+
builder: (context) =>
455+
AlertDialog(
421456
content: Text(
422457
"Do you want to punch in now?"),
423458
actions: [
@@ -431,7 +466,8 @@ class _SoloAttendanceState extends State<SoloAttendance> {
431466
} else {
432467
showDialog(
433468
context: context,
434-
builder: (context) => AlertDialog(
469+
builder: (context) =>
470+
AlertDialog(
435471
content: Text(
436472
"Do you want to punch out now?"),
437473
actions: [
@@ -448,7 +484,8 @@ class _SoloAttendanceState extends State<SoloAttendance> {
448484
if (start == "--/--/-- -- : --") {
449485
showDialog(
450486
context: context,
451-
builder: (context) => AlertDialog(
487+
builder: (context) =>
488+
AlertDialog(
452489
content: Text(
453490
"Do you want to punch in now?"),
454491
actions: [
@@ -462,7 +499,8 @@ class _SoloAttendanceState extends State<SoloAttendance> {
462499
} else {
463500
showDialog(
464501
context: context,
465-
builder: (context) => AlertDialog(
502+
builder: (context) =>
503+
AlertDialog(
466504
content: Text(
467505
"Do you want to punch out now?"),
468506
actions: [
@@ -530,7 +568,8 @@ class _SoloAttendanceState extends State<SoloAttendance> {
530568
if (start == "--/--/-- -- : --") {
531569
showDialog(
532570
context: context,
533-
builder: (context) => AlertDialog(
571+
builder: (context) =>
572+
AlertDialog(
534573
content: Text(
535574
"Do you want to punch in now?"),
536575
actions: [
@@ -571,7 +610,8 @@ class _SoloAttendanceState extends State<SoloAttendance> {
571610
if (start == "--/--/-- -- : --") {
572611
showDialog(
573612
context: context,
574-
builder: (context) => AlertDialog(
613+
builder: (context) =>
614+
AlertDialog(
575615
content: Text(
576616
"Do you want to punch in now?"),
577617
actions: [

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: A new Flutter project.
33

44
publish_to: 'none'
55

6-
version: 1.0.42+43
6+
version: 1.0.43+44
77

88
environment:
99
sdk: ">=2.7.0 <3.0.0"

0 commit comments

Comments
 (0)