diff options
author | tike <timflex@gmx.de> | 2016-02-05 22:57:57 +0100 |
---|---|---|
committer | tike <timflex@gmx.de> | 2016-02-07 13:00:28 +0100 |
commit | 661e5595c4f5844cec94f4fb304c16650fa3b211 (patch) | |
tree | a58f8ed4dc700d16d2165e474f51694d8bce4352 /includes/model/User_model.php | |
parent | 1da3cba5a70328780a362af0ec06e9f6a689562a (diff) |
issue #242 - make app caluclate number of vouchers for angels
Diffstat (limited to 'includes/model/User_model.php')
-rw-r--r-- | includes/model/User_model.php | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/includes/model/User_model.php b/includes/model/User_model.php index e1bb2733..00c3bfdd 100644 --- a/includes/model/User_model.php +++ b/includes/model/User_model.php @@ -260,4 +260,19 @@ function User_generate_password_recovery_token(&$user) { return $user['password_recovery_token']; } + +function User_get_eligable_voucher_count(&$user) { + global $voucher_settings; + + $shifts_done = count(ShiftEntries_finished_by_user($user)); + + $earned_vouchers = $user['got_voucher'] - $voucher_settings['initial_vouchers']; + $elegible_vouchers = $shifts_done / $voucher_settings['shifts_per_voucher'] - $earned_vouchers; + if ( $elegible_vouchers < 0) { + return 0; + } + + return $elegible_vouchers; +} + ?> |