Skip to content

Commit

Permalink
Absence Activity
Browse files Browse the repository at this point in the history
#5
- add usosc to childes absences and attendances
  • Loading branch information
eurosecom committed Apr 1, 2017
1 parent 8346db8 commit f4822bf
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
10 changes: 6 additions & 4 deletions app/src/main/java/com/eusecom/attendance/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,11 @@ public void onClick(DialogInterface dialog,

final String userId = FirebaseAuth.getInstance().getCurrentUser().getUid();
String icox = SettingsActivity.getUsIco(MainActivity.this);
String oscx = SettingsActivity.getUsOsc(MainActivity.this);
Long tsLong = System.currentTimeMillis() / 1000;
String ts = tsLong.toString();

writeAttendance(icox, userId, "0", "1","Incoming work", ts, ts, "0", "0", "0", "0", ts);
writeAttendance(icox, userId, "0", "1","Incoming work", ts, ts, "0", "0", "0", "0", ts, oscx);

}
})
Expand Down Expand Up @@ -249,10 +250,11 @@ public void onClick(DialogInterface dialog,

final String userId = FirebaseAuth.getInstance().getCurrentUser().getUid();
String icox = SettingsActivity.getUsIco(MainActivity.this);
String oscx = SettingsActivity.getUsOsc(MainActivity.this);
Long tsLong = System.currentTimeMillis()/1000;
String ts = tsLong.toString();

writeAttendance(icox,userId,"0","2","Leaving work",ts,ts,"0","0","0","0", ts );
writeAttendance(icox,userId,"0","2","Leaving work",ts,ts,"0","0","0","0", ts, oscx );

}
})
Expand Down Expand Up @@ -333,7 +335,7 @@ public void onClick(View v) {

// [START basic_write]
private void writeAttendance(String usico, String usid, String ume, String dmxa, String dmna, String daod, String dado, String dnixa,
String hodxb, String longi, String lati, String datm) {
String hodxb, String longi, String lati, String datm, String usosc) {

String key = mDatabase.child("attendances").push().getKey();
String gpslat;
Expand All @@ -352,7 +354,7 @@ private void writeAttendance(String usico, String usid, String ume, String dmxa,
mGPS.showSettingsAlert();
}

Attendance attendance = new Attendance(usico, usid, ume, dmxa, dmna, daod, dado, dnixa, hodxb, gpslon, gpslat, datm );
Attendance attendance = new Attendance(usico, usid, ume, dmxa, dmna, daod, dado, dnixa, hodxb, gpslon, gpslat, datm, usosc );

Map<String, Object> attValues = attendance.toMap();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,10 +336,11 @@ public void onDataChange(DataSnapshot dataSnapshot) {
} else {
// Write new absence
String icox = SettingsActivity.getUsIco(NewAbsenceActivity.this);
String oscx = SettingsActivity.getUsOsc(NewAbsenceActivity.this);
Long tsLong = System.currentTimeMillis() / 1000;
String ts = tsLong.toString();

writeAbsence(icox, userId, "0", dmaxx, dmnxx, dateodlx, datedolx, "0", hodinyx, "0", "0", ts);
writeAbsence(icox, userId, "0", dmaxx, dmnxx, dateodlx, datedolx, "0", hodinyx, "0", "0", ts, oscx);

}

Expand All @@ -360,7 +361,7 @@ public void onCancelled(DatabaseError databaseError) {

// [START basic_write]
private void writeAbsence(String usico, String usid, String ume, String dmxa, String dmna, String daod, String dado, String dnixa,
String hodxb, String longi, String lati, String datm) {
String hodxb, String longi, String lati, String datm, String usosc) {

String userIDX = FirebaseAuth.getInstance().getCurrentUser().getUid();
String key = mDatabase.child("absences").push().getKey();
Expand All @@ -380,7 +381,7 @@ private void writeAbsence(String usico, String usid, String ume, String dmxa, St
mGPS.showSettingsAlert();
}

Attendance attendance = new Attendance(usico, userIDX, ume, dmxa, dmna, daod, dado, dnixa, hodxb, gpslon, gpslat, datm );
Attendance attendance = new Attendance(usico, userIDX, ume, dmxa, dmna, daod, dado, dnixa, hodxb, gpslon, gpslat, datm, usosc );

Map<String, Object> attValues = attendance.toMap();

Expand Down
14 changes: 12 additions & 2 deletions app/src/main/java/com/eusecom/attendance/models/Attendance.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class Attendance {
public String datm;
private HashMap<String, Object> dats;
public String aprv;
public String usosc;

public Attendance() {
// Default constructor required for calls to DataSnapshot.getValue(User.class)
Expand All @@ -33,7 +34,7 @@ public Attendance() {


public Attendance(String usico, String usid, String ume, String dmxa, String dmna, String daod, String dado, String dnixa,
String hodxb, String longi, String lati, String datm, String aprv) {
String hodxb, String longi, String lati, String datm, String usosc, String aprv) {
this.usico = usico;
this.usid = usid;
this.ume = ume;
Expand All @@ -51,10 +52,11 @@ public Attendance(String usico, String usid, String ume, String dmxa, String dmn
datsObj.put("date", ServerValue.TIMESTAMP);
this.dats = datsObj;
this.aprv = aprv;
this.usosc = usosc;
}

public Attendance(String usico, String usid, String ume, String dmxa, String dmna, String daod, String dado, String dnixa,
String hodxb, String longi, String lati, String datm ) {
String hodxb, String longi, String lati, String datm, String usosc ) {
this.usico = usico;
this.usid = usid;
this.ume = ume;
Expand All @@ -72,6 +74,7 @@ public Attendance(String usico, String usid, String ume, String dmxa, String dmn
datsObj.put("date", ServerValue.TIMESTAMP);
this.dats = datsObj;
this.aprv = "0";
this.usosc = usosc;
}

public String getUsico() {
Expand All @@ -80,6 +83,12 @@ public String getUsico() {

}

public String getUsosc() {

return this.usosc;

}

// [START post_to_map]
@Exclude
public Map<String, Object> toMap() {
Expand All @@ -98,6 +107,7 @@ public Map<String, Object> toMap() {
result.put("datm", datm);
result.put("dats", dats);
result.put("dats", dats);
result.put("usosc", usosc);
result.put("aprv", aprv);

return result;
Expand Down

0 comments on commit f4822bf

Please sign in to comment.