Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add monthly budget field and statistics #329

Merged
merged 1 commit into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions endpoints/user/budget.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

require_once '../../includes/connect_endpoint.php';
require_once '../../includes/inputvalidation.php';

session_start();


if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) {
die(json_encode([
"success" => false,
"message" => translate('session_expired', $i18n)
]));
}

if ($_SERVER["REQUEST_METHOD"] === "POST") {
$postData = file_get_contents("php://input");
$data = json_decode($postData, true);

if (
!isset($data["budget"]) || $data["budget"] == ""
) {
$response = [
"success" => false,
"message" => translate('fill_mandatory_fields', $i18n)
];
echo json_encode($response);
} else {
$budget = $data["budget"];

$userId = $_SESSION['userId'];

$sql = "UPDATE user SET budget = :budget WHERE id = :userId";
$stmt = $db->prepare($sql);
$stmt->bindValue(':budget', $budget, SQLITE3_TEXT);
$stmt->bindValue(':userId', $userId, SQLITE3_TEXT);
$result = $stmt->execute();

if ($result) {
$response = [
"success" => true,
"message" => translate('user_details_saved', $i18n)
];
echo json_encode($response);
} else {
$response = [
"success" => false,
"message" => translate('error_updating_user_data', $i18n)
];
echo json_encode($response);
}

}
}


?>
3 changes: 3 additions & 0 deletions includes/checksession.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
if ($userData === false) {
header('Location: logout.php');
exit();
} else {
$_SESSION['userId'] = $userData['id'];
}

if ($userData['avatar'] == "") {
Expand Down Expand Up @@ -55,6 +57,7 @@
$_SESSION['token'] = $token;
$_SESSION['loggedin'] = true;
$_SESSION['main_currency'] = $main_currency;
$_SESSION['userId'] = $userId;
} else {
$db->close();
header("Location: logout.php");
Expand Down
8 changes: 7 additions & 1 deletion includes/i18n/de.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@
'average_monthly' => "Durchschnittliche monatliche Kosten",
'most_expensive' => "Kosten des teuersten Abonnements",
'amount_due' => "Diesen Monat fällige Summe",
'percentage_budget_used' => "Prozentualer Anteil des Budgets genutzt",
'budget_remaining' => "Verbleibendes Budget",
'amount_over_budget' => "Überzogenes Budget",
'monthly_savings' => "Monatliche Ersparnisse (bei inaktiven Abonnements)",
'yearly_savings' => "Jährliche Ersparnisse (bei inaktiven Abonnements)",
'split_views' => "Aufgeteilte Ansichten",
'category_split' => "Kategorien",
'household_split' => "Haushalt",
Expand All @@ -101,7 +105,9 @@
'upload_avatar' => "Avatar hochladen",
'file_type_error' => "Dateityp nicht unterstützt",
'user_details' => "Benutzerdetails",
"household" => "Haushalt",
"monthly_budget" => "Monatliches Budget",
"budget_info" => "Das monatliche Budget wird für die Berechnung der Statistiken verwendet.",
"household" => "Haushalt",
"save_member" => "Mitglied speichern",
"delete_member" => "Mitglied löschen",
"cant_delete_member" => "Hauptmitglied kann nicht gelöscht werden",
Expand Down
8 changes: 7 additions & 1 deletion includes/i18n/el.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@
'average_monthly' => "Μέσο μηνιαίο κόστος συνδρομής",
'most_expensive' => "Πιο ακριβό κόστος συνδρομής",
'amount_due' => "Ποσό που οφείλεται αυτόν τον μήνα",
'percentage_budget_used' => "Ποσοστό προϋπολογισμού που χρησιμοποιείται",
'budget_remaining' => "Υπόλοιπο προϋπολογισμού",
'amount_over_budget' => "Ποσό πάνω από τον προϋπολογισμό",
'monthly_savings' => "Μηνιαίες εξοικονομήσεις (σε ανενεργές συνδρομές)",
'yearly_savings' => "Ετήσιες εξοικονομήσεις (σε ανενεργές συνδρομές)",
'split_views' => "Διαχωρισμένες προβολές",
'category_split' => "Διαχωρισμός κατηγορίας",
'household_split' => "Διαχωρισμός νοικοκυριού",
Expand All @@ -101,7 +105,9 @@
'upload_avatar' => "μεταφόρτωση άβαταρ",
'file_type_error' => "Το αρχείο πρέπει να είναι τύπου jpg, jpeg, png, webp ή gif",
'user_details' => "Λεπτομέρειες χρήστη",
"household" => "Νοικοκυριό",
"monthly_budget" => "Μηνιαίος προϋπολογισμός",
"budget_info" => "Ο μηνιαίος προϋπολογισμός χρησιμοποιείται για τον υπολογισμό των στατιστικών",
"household" => "Νοικοκυριό",
"save_member" => "Αποθήκευση μέλους",
"delete_member" => "Διαγραφή μέλους",
"cant_delete_member" => "Δεν ειναι δυνατή η διαγραφή του βασικού μέλους",
Expand Down
8 changes: 7 additions & 1 deletion includes/i18n/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@
'average_monthly' => "Average Monthly Subscription Cost",
'most_expensive' => "Most Expensive Subscription Cost",
'amount_due' => "Amount due this month",
'percentage_budget_used' => "Percentage of budget used",
'budget_remaining' => "Budget Remaining",
'amount_over_budget' => "Amount over budget",
'monthly_savings' => "Monthly Savings (on inactive subscriptions)",
'yearly_savings' => "Yearly Savings (on inactive subscriptions)",
'split_views' => "Split Views",
'category_split' => "Category Split",
'household_split' => "Household Split",
Expand All @@ -101,7 +105,9 @@
'upload_avatar' => "Upload Avatar",
'file_type_error' => "The file type supplied is not supported.",
'user_details' => "User Details",
"household" => "Household",
"monthly_budget" => "Monthly Budget",
"budget_info" => "Monthly budget is used to calculate statistics",
"household" => "Household",
"save_member" => "Save Member",
"delete_member" => "Delete Member",
"cant_delete_member" => "Can't delete main member",
Expand Down
8 changes: 7 additions & 1 deletion includes/i18n/es.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@
'average_monthly' => "Costo Promedio Mensual de Suscripción",
'most_expensive' => "Costo de Suscripción Más Caro",
'amount_due' => "Monto a pagar este mes",
'percentage_budget_used' => "Porcentaje del presupuesto utilizado",
'budget_remaining' => "Presupuesto Restante",
'amount_over_budget' => "Monto sobre el presupuesto",
'monthly_savings' => "Ahorro Mensual (en suscripciones inactivas)",
'yearly_savings' => "Ahorro Anual (en suscripciones inactivas)",
'split_views' => "Vistas Divididas",
'category_split' => "División por Categoría",
'household_split' => "División por Hogar",
Expand All @@ -101,7 +105,9 @@
'upload_avatar' => "Subir avatar",
'file_type_error' => "El archivo debe ser una imagen en formato PNG, JPG, WEBP o SVG",
'user_details' => "Detalles del Usuario",
"household" => "Hogar",
"monthly_budget" => "Presupuesto Mensual",
"budget_info" => "El presupuesto mensual se utiliza para calcular las estadísticas. Si no deseas utilizar esta función, déjalo en 0.",
"household" => "Hogar",
"save_member" => "Guardar Miembro",
"delete_member" => "Eliminar Miembro",
"cant_delete_member" => "No se puede eliminar el miembro principal",
Expand Down
6 changes: 6 additions & 0 deletions includes/i18n/fr.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@
'average_monthly' => "Coût moyen mensuel de l'abonnement",
'most_expensive' => "Coût d'abonnement le plus élevé",
'amount_due' => "Montant dû ce mois-ci",
'percentage_budget_used' => "Pourcentage du budget utilisé",
'budget_remaining' => "Budget restant",
'amount_over_budget' => "Montant dépassant le budget",
'monthly_savings' => "Économies mensuelles (sur les abonnements inactifs)",
'yearly_savings' => "Économies annuelles (sur les abonnements inactifs)",
'split_views' => "Vues partagées",
'category_split' => "Répartition par catégorie",
'household_split' => "Répartition du ménage",
Expand All @@ -101,6 +105,8 @@
'upload_avatar' => "Télécharger un Avatar",
'file_type_error' => "Le type de fichier n'est pas pris en charge",
'user_details' => "Détails de l'utilisateur",
"monthly_budget" => "Budget mensuel",
"budget_info" => "Le budget mensuel est utilisé pour calculer les statistiques. Laissez vide pour désactiver.",
"household" => "Ménage",
"save_member" => "Enregistrer le membre",
"delete_member" => "Supprimer le membre",
Expand Down
6 changes: 6 additions & 0 deletions includes/i18n/it.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@
'average_monthly' => "Costo medio mensile dell'abbonamento",
'most_expensive' => "Costo dell'abbonamento più elevato",
'amount_due' => 'Importo dovuto questo mese',
'percentage_budget_used' => 'Percentuale del budget utilizzata',
'budget_remaining' => 'Budget rimanente',
'amount_over_budget' => 'Importo oltre il budget',
'monthly_savings' => 'Risparmi mensili (su abbonamenti inattivi)',
'yearly_savings' => 'Risparmi annuali (su abbonamenti inattivi)',
'split_views' => 'Visualizzazioni con grafici',
'category_split' => 'Suddivisione per categoria',
'household_split' => 'Suddivisione per nucleo familiare',
Expand All @@ -106,6 +110,8 @@
'upload_avatar' => 'Carica avatar',
'file_type_error' => 'Il tipo di file fornito non è supportato.',
'user_details' => 'Dettagli utente',
"monthly_budget" => "Budget mensile",
"budget_info" => "Il budget mensile viene utilizzato per calcolare le statistiche. Se non si desidera utilizzare questa funzionalità, impostare il budget su 0.",
'household' => 'Nucleo familiare',
'save_member' => 'Salva membro',
'delete_member' => 'Elimina membro',
Expand Down
8 changes: 7 additions & 1 deletion includes/i18n/jp.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@
'average_monthly' => "月額平均費用",
'most_expensive' => "最も高額な定期購入費用",
'amount_due' => "今月の支払額",
'percentage_budget_used' => "予算使用率",
'budget_remaining' => "予算残高",
'amount_over_budget' => "予算オーバー",
'monthly_savings' => "月間節約 (非アクティブな定期購入)",
'yearly_savings' => "年間節約 (非アクティブな定期購入)",
'split_views' => "分割表示",
'category_split' => "カテゴリ別",
'household_split' => "世帯別",
Expand All @@ -101,7 +105,9 @@
'upload_avatar' => "アバターをアップロードする",
'file_type_error' => "ファイルタイプが許可されていません",
'user_details' => "ユーザー詳細",
"household" => "世帯",
"monthly_budget" => "月間予算",
"budget_info" => "予算を設定すると、統計ページで予算と実際の支出を比較できます。",
"household" => "世帯",
"save_member" => "世帯員を保存",
"delete_member" => "世帯員を削除",
"cant_delete_member" => "世帯主は削除出ません",
Expand Down
8 changes: 7 additions & 1 deletion includes/i18n/ko.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@
'average_monthly' => "월별 평균 구독 비용",
'most_expensive' => "최고가 구독 비용",
'amount_due' => "이달의 결제 비용",
'percentage_budget_used' => "예산 사용률",
'budget_remaining' => "남은 예산",
'amount_over_budget' => "예산 초과",
'monthly_savings' => "월간 절약 (비활성 구독)",
'yearly_savings' => "연간 절약 (비활성 구독)",
'split_views' => "분할 표시",
'category_split' => "카테고리별",
'household_split' => "가구별",
Expand All @@ -101,7 +105,9 @@
'upload_avatar' => "아바타 업로드",
'file_type_error' => "제공된 파일이 지원하지 않는 타입입니다.",
'user_details' => "유저 상세",
"household" => "가구",
"monthly_budget" => "월간 예산",
"budget_info" => "예산을 설정하면 통계 페이지에서 예산과 실제 지출을 비교할 수 있습니다.",
"household" => "가구",
"save_member" => "구성원 저장",
"delete_member" => "구성원 삭제",
"cant_delete_member" => "메인 구성원은 삭제할 수 없습니다",
Expand Down
8 changes: 7 additions & 1 deletion includes/i18n/pl.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@
'average_monthly' => "Średni miesięczny koszt subskrypcji",
'most_expensive' => "Najdroższy koszt subskrypcji",
'amount_due' => "Kwota należna w tym miesiącu",
'percentage_budget_used' => "Procent wykorzystania budżetu",
'budget_remaining' => "Pozostały budżet",
'amount_over_budget' => "Kwota przekraczająca budżet",
'monthly_savings' => "Miesięczne oszczędności (w przypadku nieaktywnych subskrypcji)",
'yearly_savings' => "Roczne oszczędności (w przypadku nieaktywnych subskrypcji)",
'split_views' => "Podziel widoki",
'category_split' => "Podział kategorii",
'household_split' => "Podział gospodarstwa domowego",
Expand All @@ -101,7 +105,9 @@
'upload_avatar' => "Prześlij awatar",
'file_type_error' => "Podany typ pliku nie jest obsługiwany.",
'user_details' => "Szczegóły użytkownika",
"household" => "Gospodarstwo domowe",
"monthly_budget" => "Miesięczny budżet",
"budget_info" => "Jeśli ustawisz budżet, zobaczysz pasek postępu na stronie głównej.",
"household" => "Gospodarstwo domowe",
"save_member" => "Zapisz użytkownika",
"delete_member" => "Usuń użytkownika",
"cant_delete_member" => "Nie można usunąć głównego użytkownika",
Expand Down
8 changes: 7 additions & 1 deletion includes/i18n/pt.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@
'average_monthly' => "Custo Mensal Médio das Subscrições",
'most_expensive' => "Custo da Subscrição Mais Cara",
'amount_due' => "Quantia em dívida este mês",
'percentage_budget_used' => "Percentagem do orçamento usada",
'budget_remaining' => "Orçamento Restante",
'amount_over_budget' => "Quantia acima do orçamento",
'monthly_savings' => "Poupança Mensal (em subscrições inactivas)",
'yearly_savings' => "Poupança Anual (em subscrições inactivas)",
'split_views' => "Vistas Divididas",
'category_split' => "Por Categoria",
'household_split' => "Por Membro",
Expand All @@ -101,7 +105,9 @@
'upload_avatar' => "Enviar avatar",
'file_type_error' => "Tipo de ficheiro não permitido",
'user_details' => "Detalhes do utilizador",
"household" => "Agregado",
"monthly_budget" => "Orçamento Mensal",
"budget_info" => "Ao definir um orçamento pode comparar com os gastos reais na página de estatísticas.",
"household" => "Agregado",
"save_member" => "Guardar Membro",
"delete_member" => "Apagar Membro",
"cant_delete_member" => "Não pode apagar o membro principal",
Expand Down
8 changes: 7 additions & 1 deletion includes/i18n/pt_br.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@
'average_monthly' => "Custom médio mensal",
'most_expensive' => "Assinatura mais cara",
'amount_due' => "Valor devido nesse mês",
'percentage_budget_used' => "Porcentagem do orçamento utilizado",
'budget_remaining' => "Orçamento restante",
'amount_over_budget' => "Valor acima do orçamento",
'monthly_savings' => "Economia mensal (em assinaturas inativas)",
'yearly_savings' => "Economia anual (em assinaturas inativas)",
'split_views' => "Visualizações",
'category_split' => "Por categoria",
'household_split' => "Por membro",
Expand All @@ -99,7 +103,9 @@
'upload_avatar' => "Carregar avatar",
'file_type_error' => "Tipo de arquivo não permitido",
'user_details' => "Informações do Usuário",
"household" => "Membros",
"monthly_budget" => "Orçamento mensal",
"budget_info" => "O orçamento mensal é usado para calcular estatísticas",
"household" => "Membros",
"save_member" => "Salvar membro",
"delete_member" => "Excluir membro",
"cant_delete_member" => "Não é possível excluir o membro principal",
Expand Down
8 changes: 7 additions & 1 deletion includes/i18n/ru.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@
'average_monthly' => "Средняя ежемесячная стоимость подписки",
'most_expensive' => "Самая дорогая стоимость подписки",
'amount_due' => "Сумма к оплате в этом месяце",
'percentage_budget_used' => "Процент использования бюджета",
'budget_remaining' => "Оставшийся бюджет",
'amount_over_budget' => "Сумма превышения бюджета",
'monthly_savings' => "Ежемесячная экономия (при неактивных подписках)",
'yearly_savings' => "Годовая экономия (при неактивных подписках)",
'split_views' => "Подробная статистика",
'category_split' => "По категориям",
'household_split' => "По членам семьи",
Expand All @@ -101,7 +105,9 @@
'upload_avatar' => "Загрузить аватар",
'file_type_error' => "Указанный тип файла не поддерживается.",
'user_details' => "Данные пользователя",
"household" => "Семья",
"monthly_budget" => "Ежемесячный бюджет",
"budget_info" => "Если вы укажете бюджет, Wallos будет отображать вашу текущую стоимость подписок в сравнении с вашим бюджетом.",
"household" => "Семья",
"save_member" => "Сохранить члена семьи",
"delete_member" => "Удалить члена семьи",
"cant_delete_member" => "Не могу удалить основного члена семьи",
Expand Down
8 changes: 7 additions & 1 deletion includes/i18n/sr.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@
'average_monthly' => "Просечни месечни трошак претплате",
'most_expensive' => "Најскупља претплата",
'amount_due' => "Износ за уплату овог месеца",
'percentage_budget_used' => "Проценат искоришћеног буџета",
'budget_remaining' => "Преостали буџет",
'amount_over_budget' => "Износ преко буџета",
'monthly_savings' => "Месечне уштеде (на неактивним претплатама)",
'yearly_savings' => "Годишње уштеде (на неактивним претплатама)",
'split_views' => "Подељени прикази",
'category_split' => "Подела по категоријама",
'household_split' => "Подела по домаћинству",
Expand All @@ -101,7 +105,9 @@
'upload_avatar' => "Постави аватар",
'file_type_error' => "Датотека није у подржаном формату.",
'user_details' => "Кориснички детаљи",
"household" => "Домаћинство",
"monthly_budget" => "Месечни буџет",
"budget_info" => "Унесите месечни буџет да бисте видели препоручену максималну цену претплате на почетној страници.",
"household" => "Домаћинство",
"save_member" => "Сачувај члана",
"delete_member" => "Обриши члана",
"cant_delete_member" => "Главни члан не може бити обрисан",
Expand Down
Loading