Exemplo n.º 1
0
 }
 if ($_POST['expense_owner']) {
     if (!in_array($_POST['expense_owner'], $member_ids)) {
         $errorString[] = "Invalid expense owner selected! (what are you doing??) <br />";
     }
 }
 if (!empty($errorString)) {
     $showaddform = true;
 } else {
     // no errors, add expense
     if ($_POST['expense_owner']) {
         $xuid = $_POST['expense_owner'];
     } else {
         $xuid = $user->data['user_id'];
     }
     if (book_expense($_POST['description'], $_POST['amount'], $_POST['type_id'], $timestamp, $xuid, $groupdetails['group_id'], $_POST['members'], $_POST['event_id'])) {
         //$resultString = "Expense succesfully added";
         // update achievements
         $ac = new Achievements($groupdetails['group_id']);
         $msg = "b1";
         mail_expense($_POST['description'], $_POST['amount'], $_POST['type_id'], $timestamp, $xuid, $groupdetails['group_id'], $_POST['members'], $_POST['event_id']);
     } else {
         //$resultString = "Error: Could not add expense";
         $msg = "b2";
     }
     if ($_POST['redirect'] != "") {
         $redirect = "http://" . $_SERVER['HTTP_HOST'] . DIR . $_POST['redirect'] . "&msg={$msg}";
         header("Location: {$redirect}");
         exit;
     }
 }
Exemplo n.º 2
0
    print_settle_group_list_form($settle_array, $groupdetails['group_id']);
} elseif ($mode == 'process') {
    if (!validate_check_arr($groupdetails['group_id'], $_POST['hash'])) {
        // cannot settle, transactions changed during submit
        // Start HTML output
        print_header();
        fatal_error("<b>Error:</b> Could not settle accounts, transactions occured while processing");
    }
    foreach ($settle_array as $key => $value) {
        $pay_array[$value['pay_uid']][] = array("pay_name" => $value['pay_name'], "get_uid" => $value['get_uid'], "get_name" => $value['get_name'], "sum" => $value['sum']);
    }
    $desc = "Account settlement";
    foreach ($_POST['paylist'] as $val) {
        $ids = explode('-', $val);
        foreach ($pay_array[$ids[0]] as $getter) {
            if ($ids[1] == $getter['get_uid']) {
                // echo "id {$ids[0]} ({$getter['pay_name']})  pays id {$ids[1]} ({$getter['get_name']} {$getter['sum']}<br>";
                if (book_expense($desc, $getter['sum'], 5, time(), $ids[0], $groupdetails['group_id'], array($ids[1]), 0)) {
                    //$resultString = "Accounts settled";
                    $msg = "s1";
                } else {
                    //$resultString = "Errors occured while settling accounts";
                    $msg = "s2";
                }
            }
        }
    }
    $redirect = "http://" . $_SERVER['HTTP_HOST'] . DIR . "group_detail.php?groupid=" . $groupdetails['group_id'] . "&msg={$msg}";
    header("Location: {$redirect}");
}
print_footer($user, 2, $groupdetails['group_id']);