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: allow to disable subscriptions #144

Merged
merged 1 commit into from
Feb 23, 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
2 changes: 1 addition & 1 deletion includes/i18n/de.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
'last_added' => "Zuletzt hinzugefügt",
'price' => "Preis",
'next_payment' => "Nächste Zahlung",
'inactive' => "Deaktiviertes Abonnement",
'inactive' => "Abonnement deaktivieren",
'member' => "Mitglied",
'category' => "Kategorie",
'payment_method' => "Zahlungsmethode",
Expand Down
2 changes: 1 addition & 1 deletion includes/i18n/el.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
'last_added' => "Τελευταία προσθήκη",
'price' => "Τιμή",
'next_payment' => "Επόμενη πληρωμή",
'inactive' => "Ανενεργή συνδρομή",
'inactive' => "Απενεργοποίηση συνδρομής",
'member' => "Χρήστης",
'category' => "Κατηγορία",
'payment_method' => "Τρόπος πληρωμής",
Expand Down
2 changes: 1 addition & 1 deletion includes/i18n/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
'last_added' => "Last Added",
'price' => "Price",
'next_payment' => "Next Payment",
'inactive' => "Disabled Subscription",
'inactive' => "Disable Subscription",
'member' => "Member",
'category' => "Category",
'payment_method' => "Payment Method",
Expand Down
2 changes: 1 addition & 1 deletion includes/i18n/es.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
'last_added' => "Última Añadida",
'price' => "Precio",
'next_payment' => "Próximo Pago",
'inactive' => "Suscripción desactivada",
'inactive' => "Desactivar Suscripción",
'member' => "Miembro",
'category' => "Categoría",
'payment_method' => "Método de Pago",
Expand Down
2 changes: 1 addition & 1 deletion includes/i18n/fr.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
'last_added' => "Dernier ajouté",
'price' => "Prix",
'next_payment' => "Prochain paiement",
'inactive' => "Abonnement désactivé",
'inactive' => "Désactiver l'abonnement",
'member' => "Membre",
'category' => "Catégorie",
'payment_method' => "Méthode de paiement",
Expand Down
2 changes: 1 addition & 1 deletion includes/i18n/jp.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
'last_added' => "最終追加日",
'price' => "金額",
'next_payment' => "次回支払い",
'inactive' => "無効なサブスクリプション",
'inactive' => "サブスクリプションを無効にする",
'member' => "メンバー",
'category' => "カテゴリ",
'payment_method' => "支払い方法",
Expand Down
2 changes: 1 addition & 1 deletion includes/i18n/pt.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
'last_added' => "Última Adicionada",
'price' => "Preço",
'next_payment' => "Próximo Pagamento",
'inactive' => "Subscrição desactivada",
'inactive' => "Desactivar Subscrição",
'member' => "Membro",
'category' => "Categoria",
'payment_method' => "Metodo de Pagamento",
Expand Down
2 changes: 2 additions & 0 deletions includes/i18n/tr.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
'last_added' => "Son Eklenen",
'price' => "Fiyat",
'next_payment' => "Sonraki Ödeme",
'inactive' => "Aboneliği Devre Dışı Bırak",
'member' => "Üye",
'category' => "Kategori",
'payment_method' => "Ödeme Yöntemi",
Expand Down Expand Up @@ -70,6 +71,7 @@
// Statistics page
'general_statistics' => "Genel İstatistikler",
'active_subscriptions' => "Aktif Abonelikler",
'inactive_subscriptions' => "Aktif Olmayan Abonelikler",
'monthly_cost' => "Aylık Maliyet",
'yearly_cost' => "Yıllık Maliyet",
'average_monthly' => "Ortalama Aylık Abonelik Maliyeti",
Expand Down
2 changes: 1 addition & 1 deletion includes/i18n/zh_cn.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
'last_added' => "创建时间",
'price' => "价格",
'next_payment' => "下次支付时间",
'inactive' => "禁用订阅",
'inactive' => "停用订阅",
'member' => "成员",
'category' => "分类",
'payment_method' => "支付方式",
Expand Down
2 changes: 2 additions & 0 deletions includes/i18n/zh_tw.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
'last_added' => "建立時間",
'price' => "價格",
'next_payment' => "下次付款時間",
'inactive' => "停用訂閱",
'member' => "成員",
'category' => "分類",
'payment_method' => "付款方式",
Expand Down Expand Up @@ -75,6 +76,7 @@
// 統計頁面
'general_statistics' => "整體統計",
'active_subscriptions' => "訂閱中",
'inactive_subscriptions' => "停用訂閱",
'monthly_cost' => "每月費用",
'yearly_cost' => "每年費用",
'average_monthly' => "平均每月訂閱費用",
Expand Down
7 changes: 0 additions & 7 deletions includes/list_subscriptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,6 @@ function printSubscriptions($subscriptions, $sort, $categories, $members, $i18n)
});
}

usort($subscriptions, function ($a, $b) {
if ($a['inactive'] == $b['inactive']) {
return 0;
}
return $a['inactive'] ? 1 : -1;
});

$currentCategory = 0;
$currentPayerUserId = 0;
$currentPaymentMethodId = 0;
Expand Down
2 changes: 1 addition & 1 deletion includes/version.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php
$version = "v1.4.1";
$version = "v1.5.0";
?>
10 changes: 5 additions & 5 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,6 @@
</div>
</div>

<div class="form-group-inline">
<input type="checkbox" id="inactive" name="inactive">
<label for="inactive"><?= translate('inactive', $i18n) ?></label>
</div>

<div class="form-group">
<label for="payment_method"><?= translate('payment_method', $i18n) ?></label>
<select id="payment_method" name="payment_method_id">
Expand Down Expand Up @@ -252,6 +247,11 @@
<input type="text" id="notes" name="notes" placeholder="<?= translate('notes', $i18n) ?>">
</div>

<div class="form-group-inline">
<input type="checkbox" id="inactive" name="inactive">
<label for="inactive"><?= translate('inactive', $i18n) ?></label>
</div>

<?php
if ($notificationsEnabled) {
?>
Expand Down
19 changes: 1 addition & 18 deletions stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,6 @@ function getPriceConverted($price, $currency, $database) {
$row = $result->fetchArray(SQLITE3_ASSOC);
$activeSubscriptions = $row['active_subscriptions'];

// Calculate inactive subscriptions
$query = "SELECT COUNT(*) AS inactive_subscriptions FROM subscriptions WHERE inactive = 1";
$stmt = $db->prepare($query);
$stmt->bindParam(':inactive', $inactive, SQLITE3_INTEGER);
$result = $stmt->execute();
$row = $result->fetchArray(SQLITE3_ASSOC);
$inactiveSubscriptions = $row['inactive_subscriptions'];

// Calculate total monthly price
$mostExpensiveSubscription = 0;
$amountDueThisMonth = 0;
Expand Down Expand Up @@ -163,6 +155,7 @@ function getPriceConverted($price, $currency, $database) {
}
}

$numberOfElements = 6;
?>
<section class="contain">
<h2><?= translate('general_statistics', $i18n) ?></h2>
Expand All @@ -171,15 +164,6 @@ function getPriceConverted($price, $currency, $database) {
<span><?= $activeSubscriptions ?></span>
<div class="title"><?= translate('active_subscriptions', $i18n) ?></div>
</div>
<?php if ($inactiveSubscriptions > 0) {
?>
<div class="statistic">
<span><?= $inactiveSubscriptions ?></span>
<div class="title"><?= translate('inactive_subscriptions', $i18n) ?></div>
</div>
<?php
}
?>
<div class="statistic">
<span><?= CurrencyFormatter::format($totalCostPerMonth, $code) ?></span>
<div class="title"><?= translate('monthly_cost', $i18n) ?></div>
Expand All @@ -201,7 +185,6 @@ function getPriceConverted($price, $currency, $database) {
<div class="title"><?= translate('amount_due', $i18n) ?></div>
</div>
<?php
$numberOfElements = 6;
if (($numberOfElements + 1) % 3 == 0) {
?>
<div class="statistic empty"></div>
Expand Down
8 changes: 5 additions & 3 deletions styles/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,11 @@ main > .contain {
}

.subscription.inactive {
color: #808080;
opacity: 0.6;
}

.subscription.inactive span.price {
text-decoration: line-through;
font-style: italic;
background-color: #F8F8FF;
}

.subscription-main {
Expand Down Expand Up @@ -955,6 +956,7 @@ input[type="checkbox"] {
display: none;
width: 144px;
width: max-content;
z-index: 2;
}

@media (max-width: 380px) {
Expand Down