diff --git a/calendar.php b/calendar.php index f36dd7f..b424a3c 100644 --- a/calendar.php +++ b/calendar.php @@ -18,6 +18,14 @@ function getPriceConverted($price, $currency, $database, $userId) } } +// Get budget from user table +$query = "SELECT budget FROM user WHERE id = :userId"; +$stmt = $db->prepare($query); +$stmt->bindValue(':userId', $userId, SQLITE3_INTEGER); +$result = $stmt->execute(); +$row = $result->fetchArray(SQLITE3_ASSOC); +$budget = $row['budget']; + $currentMonth = date('m'); $currentYear = date('Y'); $sameAsCurrent = false; @@ -133,7 +141,7 @@ $yearsToLoad = $calendarYear - $currentYear + 1; - = translate('month-' . $calendarMonth, $i18n) ?> = $calendarYear ?> + = translate('month-' . $calendarMonth, $i18n) ?> = $calendarYear ?> @@ -336,6 +344,19 @@ $yearsToLoad = $calendarYear - $currentYear + 1; + $budget) { + $overBudgetAmount = $totalCostThisMonth - $budget; + $overBudgetAmount = CurrencyFormatter::format($overBudgetAmount, $code); + ?> +