Beispiel #1
0
            $total += $row['amount'];
            // format totals with two decimals
            $paid['users'][$row['userid']]['groups'][$row['group_id']]['total'] = number_format($paid['users'][$row['userid']]['groups'][$row['group_id']]['total'], DECIMALS, DSEP, TSEP);
            $paid['users'][$row['userid']]['total'] = number_format($paid['users'][$row['userid']]['total'], DECIMALS, DSEP, TSEP);
            $paid['users'][$row['userid']]['groups'][$row['group_id']][$row['exid']]['running_total'] += $row['amount'] + $last_running[$row['userid']][$row['group_id']];
            $last_running[$row['userid']][$row['group_id']] = $paid['users'][$row['userid']]['groups'][$row['group_id']][$row['exid']]['running_total'];
        }
        $paid['total'] = number_format($total, DECIMALS, DSEP, TSEP);
    }
    // array structure: ['users'][$userid]['groups'][$groupid][$expenseid]['amount|expense_date|description']
    return $paid;
}
$a = 1;
//$dump = new array_dump();
$a = 1;
$groupexp = get_groupexpenses($groupid);
// reverse array so earliest expense first
$groupexp = array_reverse($groupexp);
$memberlist = get_groupmembers($groupid);
$groupmemberids = get_groupmember_ids($memberlist);
$user_expenses = get_user_expenses_test($groupmemberids);
$user_paid_expenses = get_user_paid_expenses_test($groupmemberids);
$size = count($memberlist);
$expcount = count($groupexp);
foreach ($groupexp as $key => $value) {
    foreach ($groupmemberids as $keyy => $memberid) {
        if ($balance_array[$lastkey]['balance_member'][$memberid]) {
            // previous key exists for this member, use that balance
            $balance = $balance_array[$lastkey]['balance_member'][$memberid];
        } else {
            // no key for this member, balance = 0;
function get_graph_balance_array($groupid, $memberlist)
{
    $groupexp = get_groupexpenses($groupid, false, false, false, true);
    // reverse array so earliest expense first
    $groupexp = array_reverse($groupexp);
    $groupmemberids = get_groupmember_ids($memberlist);
    $user_expenses = get_user_expenses_test($groupmemberids);
    $user_paid_expenses = get_user_paid_expenses_test($groupmemberids);
    $size = count($memberlist);
    $expcount = count($groupexp);
    $balance_array = array();
    foreach ($groupexp as $key => $value) {
        $a = 1;
        foreach ($groupmemberids as $keyy => $memberid) {
            if (isset($lastkey) && $balance_array[$lastkey]['balance_member'][$memberid]) {
                // previous key exists for this member, use that balance
                $balance = $balance_array[$lastkey]['balance_member'][$memberid];
            } else {
                // no key for this member, balance = 0;
                $balance = 0;
            }
            // get last key balance, substract current expense and add paid
            $_curexp = isset($user_expenses['users'][$memberid]['groups'][$groupid][$value['expense_id']]['per_person']) ? $user_expenses['users'][$memberid]['groups'][$groupid][$value['expense_id']]['per_person'] : 0;
            $_curpay = isset($user_paid_expenses['users'][$memberid]['groups'][$groupid][$value['expense_id']]['amount']) ? $user_paid_expenses['users'][$memberid]['groups'][$groupid][$value['expense_id']]['amount'] : 0;
            $balance_array[$key]['balance_member'][$memberid] = round($balance - $_curexp + $_curpay, 2);
            $balance_array[$key]['expense_id'] = $value['expense_id'];
            $balance_array[$key]['date_time'] = $value['date'];
            $balance_array[$key]['date'] = substr($value['date'], 0, 10);
            $balance_array[$key]['isodate'] = dutchDate2iso($balance_array[$key]['date']);
            //      if ($memberid == 3) {
            //        //echo "Key: $key, expense_id: " . $value['expense_id'] . "Balance: " . $balance_array[$key]['balance_member'][$memberid] . " ==> $balance - " .
            //        $user_expenses['users'][$memberid]['groups'][$groupid][$value['expense_id']]['per_person'] . " + " . $user_paid_expenses['users'][$memberid]['groups'][$groupid][$value['expense_id']]['amount'] . "<br>";
            //      }
        }
        $lastkey = $key;
    }
    return $balance_array;
}
Beispiel #3
0
else $bname = "Back";

$topbar['leftnav'][0]['name'] = $bname;
$topbar['leftnav'][0]['url'] =  $_SESSION['back'];
$topbar['leftnav'][0]['url'] =  $backurl;*/
$back = get_back_page();
$topbar['leftnav'][0]['name'] = $back['name'];
$topbar['leftnav'][0]['url'] = $back['url'];
print_topbar($topbar);
print_body_start();
if ($showexpenses && array_key_exists(5, $permissions)) {
    if ($message) {
        print_pagetitle($message);
    }
    //$expenselist = get_groupexpenses($groupdetails['group_id'],$uid, "neg");
    $expenselist = get_groupexpenses($groupdetails['group_id'], $uid, $xtype, $user->data['user_id']);
    if (!empty($expenselist)) {
        print_expenselist_html($expenselist, $user);
    } else {
        print_pageitem_text_html("Sorry", "No expenses were found");
    }
}
//if ($ask_add && array_key_exists(0, $permissions) ) {
//  $a = "Add";
//  $b = "more members";
//  $formarray['action'] = $_SERVER['PHP_SELF'];
//  $formarray['rows'][0]['type'] = "select";
//  $formarray['rows'][0]['name'] = "number";
//  $formarray['rows'][0]['value'] = array(1=>"$a 1 $b",2=>"$a 2 $b",3=>"$a 3 $b",4=>"$a 4 $b",5=>"$a 5 $b",6=>"$a 6 $b",7=>"$a 7 $b",8=>"$a 8 $b",9=>"$a 9 $b",10=>"$a 10 $b");
//  $formarray['rows'][1]['items'] = "|mode|hidden|addmembers";
//  $formarray['rows'][2]['items'] = "|groupid|hidden|" .$groupdetails['group_id'];
Beispiel #4
0
<?php

include "inc/common.php";
// check if valid group specified and return group details
$groupdetails = check_group($_POST, $_GET);
//$expenselist = get_groupexpenses($groupdetails['group_id'],$uid, "neg");
$expenselist = get_groupexpenses($groupdetails['group_id']);
print_expenselist_excel($expenselist, $groupdetails['group_id']);