Example #1
0
print_topbar($topbar);
print_body_start();
if ($showprofile) {
    if ($message) {
        print_pagetitle($message);
    }
    if (is_array($acList)) {
        print_achievement_html($acList, $owngroupids, $grouplist);
    }
    print_profile_html($profile, $user->data['user_id']);
    //$grouplist = get_groups($uid);
    // group_id - group_name - role - join_date - member_count
    $size = count($grouplist);
    if ($size > 0) {
        $user_expenses = get_user_expenses($uid);
        $user_paid_expenses = get_user_paid_expenses($uid);
        for ($i = 0; $i < $size; $i++) {
            if (in_array($grouplist[$i]['group_id'], $owngroupids)) {
                // only show groups that are also in user's group list
                $uexpense = $user_expenses['users'][$uid]['groups'][$grouplist[$i]['group_id']]['group_total'];
                $upaid = $user_paid_expenses['users'][$uid]['groups'][$grouplist[$i]['group_id']]['group_total'];
                $group_balance_list[$i]['group_id'] = $grouplist[$i]['group_id'];
                $group_balance_list[$i]['group_name'] = $grouplist[$i]['group_name'];
                $group_balance_list[$i]['expenses'] = number_format($uexpense, DECIMALS, DSEP, TSEP);
                $group_balance_list[$i]['paid'] = number_format($upaid, DECIMALS, DSEP, TSEP);
                $group_balance_list[$i]['balance'] = number_format($upaid - $uexpense, DECIMALS, DSEP, TSEP);
                $group_balance_list[$i]['link'] = "http://" . $_SERVER['HTTP_HOST'] . DIR . "expenses.php?groupid=" . $grouplist[$i]['group_id'] . "&uid={$uid}";
                if ($grouplist[$i]['role'] == "founder") {
                    $group_balance_list[$i]['canedit'] = true;
                } else {
                    $group_balance_list[$i]['canedit'] = false;
Example #2
0
function get_group_balance_list($groupdetails)
{
    $memberlist = get_groupmembers($groupdetails['group_id']);
    $groupmemberids = get_groupmember_ids($memberlist);
    $user_expenses = get_user_expenses($groupmemberids);
    $user_paid_expenses = get_user_paid_expenses($groupmemberids);
    $size = count($memberlist);
    for ($i = 0; $i < $size; $i++) {
        if (!empty($memberlist[$i]['username'])) {
            $uname = " (" . $memberlist[$i]['username'] . ")";
        } else {
            $uname = "";
        }
        $uexpense = $user_expenses['users'][$memberlist[$i]['user_id']]['groups'][$groupdetails['group_id']]['group_total'];
        $upaid = $user_paid_expenses['users'][$memberlist[$i]['user_id']]['groups'][$groupdetails['group_id']]['group_total'];
        $listarray[$memberlist[$i]['user_id']]['link'] = "http://" . $_SERVER['HTTP_HOST'] . DIR . "profile.php?uid=" . $memberlist[$i]['user_id'];
        //$listarray[$i]['name'] = $memberlist[$i]['realname'] . $uname;
        //$listarray[$memberlist[$i]['user_id']]['name'] = format_name($user,$memberlist[$i]['username'],$memberlist[$i]['realname']);
        $listarray[$memberlist[$i]['user_id']]['balance'] = number_format($upaid - $uexpense, DECIMALS, DSEP, TSEP);
        $listarray[$memberlist[$i]['user_id']]['unformatted_balance'] = $upaid - $uexpense;
        $listarray[$memberlist[$i]['user_id']]['user_id'] = $memberlist[$i]['user_id'];
    }
    return $listarray;
}
Example #3
0
    $formarray['rows'][1]['items'] = "Description:|description|text|" . $_POST['description'];
    $formarray['rows'][2]['items'] = "|mode|hidden|validate";
    $formarray['rows'][3]['items'] = "||submit|Add Group";
    echo create_form_html($formarray);
    unset($formarray);
}
if ($addgroupresult) {
    print_pageitem_text_html("Succes:", $addgroupresult);
}
if ($showgrouplist) {
    $grouplist = get_groups($user->data['user_id']);
    // group_id - group_name - role - join_date - member_count
    $size = count($grouplist);
    if ($size > 0) {
        $user_expenses = get_user_expenses($user->data['user_id']);
        $user_paid_expenses = get_user_paid_expenses($user->data['user_id']);
        for ($i = 0; $i < $size; $i++) {
            $uexpense = $user_expenses['users'][$user->data['user_id']]['groups'][$grouplist[$i]['group_id']]['group_total'];
            $upaid = $user_paid_expenses['users'][$user->data['user_id']]['groups'][$grouplist[$i]['group_id']]['group_total'];
            $grouplist[$i]['balance'] = number_format($upaid - $uexpense, DECIMALS, DSEP, TSEP);
            $grouplist[$i]['link'] = "http://" . $_SERVER['HTTP_HOST'] . DIR . "group_detail.php?groupid=" . $grouplist[$i]['group_id'];
        }
        print_grouplist_html($grouplist);
    } elseif (!$showgroupaddform) {
        $text = "<a href=\"http://" . $_SERVER['HTTP_HOST'] . DIR . "group.php?mode=add\">create one now!</a>";
        print_pageitem_text_html("No groups found", $text);
    }
    if ($showgroupaddlink) {
        $url = "http://" . $_SERVER['HTTP_HOST'] . DIR . "group.php?mode=add";
        $name = "Add Group";
        print_topbutton_html($name, $url);
Example #4
0
 }
 // Upcoming event
 /*          $event[$row['event_id']]['event_id'] = $row['event_id'];
         $event[$row['event_id']]['event_name'] = $row['event_name'];
         $event[$row['event_id']]['description'] = $row['event_description'];
         $event[$row['event_id']]['organizer'] = $row['organizer_id'];
         $event[$row['event_id']]['date'] = date("j M Y", $row['date']);
         $event[$row['event_id']]['expense_type'] = $row['expense_type_id']; */
 $events = get_upcoming_events($groupdetails['group_id']);
 if ($events) {
     print_upcoming_events_html($events, $groupdetails['group_id']);
 }
 $memberlist = get_groupmembers($groupdetails['group_id']);
 $groupmemberids = get_groupmember_ids($memberlist);
 $user_expenses = get_user_expenses($groupmemberids);
 $user_paid_expenses = get_user_paid_expenses($groupmemberids);
 $size = count($memberlist);
 for ($i = 0; $i < $size; $i++) {
     if (!empty($memberlist[$i]['username'])) {
         $uname = " (" . $memberlist[$i]['username'] . ")";
     } else {
         $uname = "";
     }
     $uexpense = $user_expenses['users'][$memberlist[$i]['user_id']]['groups'][$groupdetails['group_id']]['group_total'];
     $upaid = $user_paid_expenses['users'][$memberlist[$i]['user_id']]['groups'][$groupdetails['group_id']]['group_total'];
     $listarray[$i]['link'] = "http://" . $_SERVER['HTTP_HOST'] . DIR . "profile.php?uid=" . $memberlist[$i]['user_id'];
     //$listarray[$i]['name'] = $memberlist[$i]['realname'] . $uname;
     $listarray[$i]['name'] = format_name($user, $memberlist[$i]['username'], $memberlist[$i]['realname']);
     //$listarray[$i]['balance'] = number_format(($upaid-$uexpense),DECIMALS , DSEP,TSEP) ;
     $listarray[$i]['balance'] = $upaid - $uexpense;
     $listarray[$i]['user_id'] = $memberlist[$i]['user_id'];
 function updateAchievements()
 {
     foreach ($this->balancePositionLog as $pos) {
         reset($pos);
     }
     $this->achievements['longest_top_balance'] = array('key' => 'longest_top_balance', 'memberid' => key($this->balancePositionLog[0]), 'value' => $this->inDays($this->balancePositionLog[0][key($this->balancePositionLog[0])]));
     $this->achievements['longest_bottom_balance'] = array('key' => 'longest_bottom_balance', 'memberid' => key($this->balancePositionLog[count($this->balancePositionLog) - 1]), 'value' => $this->inDays($this->balancePositionLog[count($this->balancePositionLog) - 1][key($this->balancePositionLog[count($this->balancePositionLog) - 1])]));
     next($this->balancePositionLog[0]);
     $this->achievements['longest_top_balance2nd'] = array('key' => 'longest_top_balance2nd', 'memberid' => key($this->balancePositionLog[0]), 'value' => $this->inDays($this->balancePositionLog[0][key($this->balancePositionLog[0])]));
     next($this->balancePositionLog[count($this->balancePositionLog) - 1]);
     $this->achievements['longest_bottom_balance2nd'] = array('key' => 'longest_bottom_balance2nd', 'memberid' => key($this->balancePositionLog[count($this->balancePositionLog) - 1]), 'value' => $this->inDays($this->balancePositionLog[count($this->balancePositionLog) - 1][key($this->balancePositionLog[count($this->balancePositionLog) - 1])]));
     // find members always above or below 0
     // find highest and lowest balance
     // find fastest riser and faller
     $topbalance = array('memberid' => 0, 'balance' => 0);
     $lowbalance = array('memberid' => 0, 'balance' => 0);
     $fastestriser = array('memberid' => 0, 'value' => 0);
     $fastestfaller = array('memberid' => 0, 'value' => 0);
     $a = 1;
     foreach ($this->balanceArr as $exp) {
         foreach ($exp['balance_member'] as $memid => $blc) {
             if ($blc > 0) {
                 $this->members[$memid]['bal_below_zero_always'] = false;
             }
             if ($blc < 0) {
                 $this->members[$memid]['bal_above_zero_always'] = false;
             }
             if ($blc > $topbalance['balance']) {
                 $topbalance = array('memberid' => $memid, 'balance' => $blc);
             }
             if ($blc < $lowbalance['balance']) {
                 $lowbalance = array('memberid' => $memid, 'balance' => $blc);
             }
             if (!isset($lastexp)) {
                 continue;
             }
             $diff = abs($blc - floatval($lastexp['balance_member'][$memid]));
             if ($blc > floatval($lastexp['balance_member'][$memid]) && $diff > $fastestriser['value']) {
                 $fastestriser = array('memberid' => $memid, 'value' => $diff);
             }
             if ($blc < floatval($lastexp['balance_member'][$memid]) && $diff > $fastestfaller['value']) {
                 $ta = $lastexp;
                 $tb = $exp;
                 $fastestfaller = array('memberid' => $memid, 'value' => $diff);
             }
         }
         $lastexp = $exp;
     }
     $abovezero = array();
     $belowzero = array();
     foreach ($this->members as $mid => $member) {
         if ($member['bal_above_zero_always'] == true && $member['bal_below_zero_always'] == false) {
             $abovezero[] = array('memberid' => $mid, 'value' => '');
         }
         if ($member['bal_below_zero_always'] == true && $member['bal_above_zero_always'] == false) {
             $belowzero[] = array('memberid' => $mid, 'value' => '');
         }
     }
     $this->achievements['balance_always_above_zero'] = array('key' => 'balance_always_above_zero', 'value' => $abovezero);
     $this->achievements['balance_always_below_zero'] = array('key' => 'balance_always_below_zero', 'value' => $belowzero);
     $this->achievements['highest_balance'] = array('key' => 'highest_balance', 'memberid' => $topbalance['memberid'], 'value' => $topbalance['balance']);
     $this->achievements['lowest_balance'] = array('key' => 'lowest_balance', 'memberid' => $lowbalance['memberid'], 'value' => $lowbalance['balance']);
     $this->achievements['fastest_riser'] = array('key' => 'fastest_riser', 'memberid' => $fastestriser['memberid'], 'value' => $fastestriser['value']);
     $this->achievements['fastest_faller'] = array('key' => 'fastest_faller', 'memberid' => $fastestfaller['memberid'], 'value' => $fastestfaller['value']);
     // find highest and lowest paid and expense participated
     $toppaid = array('memberid' => 0, 'value' => false);
     $lowpaid = array('memberid' => 0, 'value' => false);
     $topexpense = array('memberid' => 0, 'value' => false);
     $lowexpense = array('memberid' => 0, 'value' => false);
     $expcountArray = array();
     foreach ($this->members as $uid => $details) {
         $expcountArray[$uid] = $details['expensecount'];
         $user_expenses = get_user_expenses($uid);
         $user_paid_expenses = get_user_paid_expenses($uid);
         $uexpense = $user_expenses['users'][$uid]['groups'][$this->groupid]['group_total'];
         $upaid = $user_paid_expenses['users'][$uid]['groups'][$this->groupid]['group_total'];
         if ($upaid > $toppaid['value'] || $toppaid['value'] == false) {
             $toppaid = array('memberid' => $uid, 'value' => $upaid);
         }
         if ($upaid < $lowpaid['value'] || $lowpaid['value'] == false) {
             $lowpaid = array('memberid' => $uid, 'value' => $upaid);
         }
         if ($uexpense > $topexpense['value'] || $topexpense['value'] == false) {
             $topexpense = array('memberid' => $uid, 'value' => $uexpense);
         }
         if ($uexpense < $lowexpense['value'] || $lowexpense['value'] == false) {
             $lowexpense = array('memberid' => $uid, 'value' => $uexpense);
         }
     }
     $this->achievements['most_paid'] = array('key' => 'most_paid', 'memberid' => $toppaid['memberid'], 'value' => $toppaid['value']);
     $this->achievements['least_paid'] = array('key' => 'least_paid', 'memberid' => $lowpaid['memberid'], 'value' => $lowpaid['value']);
     $this->achievements['most_spent'] = array('key' => 'most_spent', 'memberid' => $topexpense['memberid'], 'value' => $topexpense['value']);
     $this->achievements['least_spent'] = array('key' => 'least_spent', 'memberid' => $lowexpense['memberid'], 'value' => $lowexpense['value']);
     // most expenses
     arsort($expcountArray);
     $mostexpenses = array();
     $mostexpenses2nd = array();
     $expC2nd = 0;
     foreach ($expcountArray as $uid => $count) {
         if (count($mostexpenses) == 0 || $count == $mostexpenses[0]['value']) {
             $mostexpenses[] = array('memberid' => $uid, 'value' => $count);
         }
         if (count($mostexpenses2nd) == 0 && $count < $mostexpenses[0]['value'] || $count == $expC2nd && $count > 0) {
             $expC2nd = $count;
             $mostexpenses2nd[] = array('memberid' => $uid, 'value' => $count);
         }
     }
     $this->achievements['highest_expense_count'] = array('key' => 'highest_expense_count', 'value' => $mostexpenses);
     $this->achievements['highest_expense_count2nd'] = array('key' => 'highest_expense_count2nd', 'value' => $mostexpenses2nd);
     // find biggest and smallest expense
     $smallexp = array('memberid' => 0, 'value' => false);
     $bigexp = array('memberid' => 0, 'value' => false);
     foreach ($this->expenseList as $expense) {
         if (floatval($expense['amount']) > $bigexp['value'] || $bigexp['value'] == false) {
             $bigexp = array('memberid' => $expense['userid'], 'value' => floatval($expense['amount']));
         }
         if (floatval($expense['amount']) < $smallexp['value'] || $smallexp['value'] == false) {
             $smallexp = array('memberid' => $expense['userid'], 'value' => floatval($expense['amount']));
         }
     }
     $this->achievements['biggest_expense'] = array('key' => 'biggest_expense', 'memberid' => $bigexp['memberid'], 'value' => $bigexp['value']);
     $this->achievements['smallest_expense'] = array('key' => 'smallest_expense', 'memberid' => $smallexp['memberid'], 'value' => $smallexp['value']);
 }