} } print "<div class='{$class}'>"; print $approveReturnMessage; print "</div>"; } print "<p>"; if ($highestAction == "Manage Expenses_all") { print _("This action allows you to manage all expenses for all budgets, regardless of your access rights to individual budgets.") . "<br/>"; } else { print _("This action allows you to manage expenses for the budgets in which you have relevant access rights.") . "<br/>"; } print "</p>"; //Check if have Full, Write or Read access in any budgets $budgetsAccess = FALSE; $budgets = getBudgetsByPerson($connection2, $_SESSION[$guid]["gibbonPersonID"]); $budgetsAll = NULL; if ($highestAction == "Manage Expenses_all") { $budgetsAll = getBudgets($connection2); $budgetsAccess = TRUE; } else { foreach ($budgets as $budget) { if ($budget[2] == "Full" or $budget[2] == "Write" or $budget[2] == "READ") { $budgetsAccess = TRUE; } } } if ($budgetsAccess == FALSE) { print "<div class='error'>"; print _("You do not have Full or Write access to any budgets."); print "</div>";
$URL .= "&addReturn=fail3"; header("Location: {$URL}"); } else { //Prepare approval settings $budgetLevelExpenseApproval = getSettingByScope($connection2, "Finance", "budgetLevelExpenseApproval"); if ($budgetLevelExpenseApproval == "") { //Fail2 $URL .= "&addReturn=fail2"; header("Location: {$URL}"); break; } else { if ($budgetLevelExpenseApproval == "N") { //Skip budget-level approval $statusApprovalBudgetCleared = "Y"; } else { $budgets = getBudgetsByPerson($connection2, $_SESSION[$guid]["gibbonPersonID"], $gibbonFinanceBudgetID); if (@$budgets[0][2] == "Full") { //I can self-approve budget-level, as have Full access $statusApprovalBudgetCleared = "Y"; } else { //I cannot self-approve budget-level $statusApprovalBudgetCleared = "N"; } } } //Write to database try { $data = array("gibbonFinanceBudgetCycleID" => $gibbonFinanceBudgetCycleID, "gibbonFinanceBudgetID" => $gibbonFinanceBudgetID, "title" => $title, "body" => $body, "status" => $status, "statusApprovalBudgetCleared" => $statusApprovalBudgetCleared, "cost" => $cost, "purchaseBy" => $purchaseBy, "purchaseDetails" => $purchaseDetails, "gibbonPersonIDCreator" => $_SESSION[$guid]["gibbonPersonID"]); $sql = "INSERT INTO gibbonFinanceExpense SET gibbonFinanceBudgetCycleID=:gibbonFinanceBudgetCycleID, gibbonFinanceBudgetID=:gibbonFinanceBudgetID, title=:title, body=:body, status=:status, statusApprovalBudgetCleared=:statusApprovalBudgetCleared, cost=:cost, purchaseBy=:purchaseBy, purchaseDetails=:purchaseDetails, gibbonPersonIDCreator=:gibbonPersonIDCreator, timestampCreator='" . date("Y-m-d H:i:s") . "'"; $result = $connection2->prepare($sql); $result->execute($data);