Wallos: Open-source, self-hostable personal subscription tracker. Visualize your recurring expenses, manage your budget, and save money.
feat: add some leeway for totp codes
Miguel Ribeiro6e44a2670348
diff --git a/api/subscriptions/get_subscriptions.php b/api/subscriptions/get_subscriptions.phpindex 96fbeb2..fc11866 100644--- a/api/subscriptions/get_subscriptions.php+++ b/api/subscriptions/get_subscriptions.php@@ -28,9 +28,11 @@ Example response:"logo": "example.png","price": 10.00,"currency_id": 1,+ "start_date": "2024-09-01","next_payment": "2024-09-01","cycle": 1,"frequency": 1,+ "auto_renew": 1,"notes": "Example note","payment_method_id": 1,"payer_user_id": 1,@@ -52,9 +54,11 @@ Example response:"logo": "another.png","price": 15.00,"currency_id": 2,+ "start_date": "2024-09-02","next_payment": "2024-09-02","cycle": 1,"frequency": 1,+ "auto_renew": 0,"notes": "","payment_method_id": 2,"payer_user_id": 2,diff --git a/endpoints/admin/deleteuser.php b/endpoints/admin/deleteuser.phpindex c00b876..b137f50 100644--- a/endpoints/admin/deleteuser.php+++ b/endpoints/admin/deleteuser.php@@ -115,6 +115,16 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {$stmt->bindValue(':id', $userId, SQLITE3_INTEGER);$result = $stmt->execute();+ // Delete totp+ $stmt = $db->prepare('DELETE FROM totp WHERE user_id = :id');+ $stmt->bindValue(':id', $userId, SQLITE3_INTEGER);+ $result = $stmt->execute();++ // Delete total yearly cost+ $stmt = $db->prepare('DELETE FROM total_yearly_cost WHERE user_id = :id');+ $stmt->bindValue(':id', $userId, SQLITE3_INTEGER);+ $result = $stmt->execute();+die(json_encode(["success" => true,"message" => translate('success', $i18n)diff --git a/endpoints/cronjobs/updatenextpayment.php b/endpoints/cronjobs/updatenextpayment.phpindex 308b862..6013103 100644--- a/endpoints/cronjobs/updatenextpayment.php+++ b/endpoints/cronjobs/updatenextpayment.php@@ -19,7 +19,7 @@ while ($row = $result->fetchArray(SQLITE3_ASSOC)) {$cycles[$cycleId] = $row;}-$query = "SELECT id, next_payment, frequency, cycle FROM subscriptions WHERE next_payment < :currentDate";+$query = "SELECT id, next_payment, frequency, cycle FROM subscriptions WHERE next_payment < :currentDate AND auto_renew = 1";$stmt = $db->prepare($query);$stmt->bindValue(':currentDate', $currentDate->format('Y-m-d'));$result = $stmt->execute();diff --git a/endpoints/settings/deleteaccount.php b/endpoints/settings/deleteaccount.phpindex 9c5c72f..9b46268 100644--- a/endpoints/settings/deleteaccount.php+++ b/endpoints/settings/deleteaccount.php@@ -107,6 +107,16 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {$stmt->bindValue(':id', $userIdToDelete, SQLITE3_INTEGER);$result = $stmt->execute();+ // Delete totp+ $stmt = $db->prepare('DELETE FROM totp WHERE user_id = :id');+ $stmt->bindValue(':id', $userIdToDelete, SQLITE3_INTEGER);+ $result = $stmt->execute();++ // Delete total yearly cost+ $stmt = $db->prepare('DELETE FROM total_yearly_cost WHERE user_id = :id');+ $stmt->bindValue(':id', $userIdToDelete, SQLITE3_INTEGER);+ $result = $stmt->execute();+die(json_encode(["success" => true,"message" => translate('success', $i18n)diff --git a/endpoints/subscription/add.php b/endpoints/subscription/add.phpindex 4d7d550..66f7c36 100644--- a/endpoints/subscription/add.php+++ b/endpoints/subscription/add.php@@ -167,6 +167,8 @@ if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] === true) {$frequency = $_POST["frequency"];$cycle = $_POST["cycle"];$nextPayment = $_POST["next_payment"];+ $autoRenew = isset($_POST['auto_renew']) ? true : false;+ $startDate = $_POST["start_date"];$paymentMethodId = $_POST["payment_method_id"];$payerUserId = $_POST["payer_user_id"];$categoryId = $_POST['category_id'];@@ -201,11 +203,13 @@ if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] === true) {$sql = "INSERT INTO subscriptions (name, logo, price, currency_id, next_payment, cycle, frequency, notes,payment_method_id, payer_user_id, category_id, notify, inactive, url,- notify_days_before, user_id, cancellation_date, replacement_subscription_id+ notify_days_before, user_id, cancellation_date, replacement_subscription_id,+ auto_renew, start_date) VALUES (:name, :logo, :price, :currencyId, :nextPayment, :cycle, :frequency, :notes,:paymentMethodId, :payerUserId, :categoryId, :notify, :inactive, :url,- :notifyDaysBefore, :userId, :cancellationDate, :replacement_subscription_id+ :notifyDaysBefore, :userId, :cancellationDate, :replacement_subscription_id,+ :autoRenew, :startDate)";} else {$id = $_POST['id'];@@ -214,6 +218,8 @@ if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] === true) {price = :price,currency_id = :currencyId,next_payment = :nextPayment,+ auto_renew = :autoRenew,+ start_date = :startDate,cycle = :cycle,frequency = :frequency,notes = :notes,@@ -242,6 +248,8 @@ if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] === true) {$stmt->bindParam(':price', $price, SQLITE3_FLOAT);$stmt->bindParam(':currencyId', $currencyId, SQLITE3_INTEGER);$stmt->bindParam(':nextPayment', $nextPayment, SQLITE3_TEXT);+ $stmt->bindParam(':autoRenew', $autoRenew, SQLITE3_INTEGER);+ $stmt->bindParam(':startDate', $startDate, SQLITE3_TEXT);$stmt->bindParam(':cycle', $cycle, SQLITE3_INTEGER);$stmt->bindParam(':frequency', $frequency, SQLITE3_INTEGER);$stmt->bindParam(':notes', $notes, SQLITE3_TEXT);diff --git a/endpoints/subscription/clone.php b/endpoints/subscription/clone.phpindex e143fb6..567d9f0 100644--- a/endpoints/subscription/clone.php+++ b/endpoints/subscription/clone.php@@ -24,6 +24,8 @@$cloneStmt->bindValue(':price', $subscriptionToClone['price'], SQLITE3_TEXT);$cloneStmt->bindValue(':currency_id', $subscriptionToClone['currency_id'], SQLITE3_INTEGER);$cloneStmt->bindValue(':next_payment', $subscriptionToClone['next_payment'], SQLITE3_TEXT);+ $cloneStmt->bindValue(':auto_renew', $subscriptionToClone['auto_renew'], SQLITE3_INTEGER);+ $cloneStmt->bindValue(':start_date', $subscriptionToClone['start_date'], SQLITE3_TEXT);$cloneStmt->bindValue(':cycle', $subscriptionToClone['cycle'], SQLITE3_TEXT);$cloneStmt->bindValue(':frequency', $subscriptionToClone['frequency'], SQLITE3_INTEGER);$cloneStmt->bindValue(':notes', $subscriptionToClone['notes'], SQLITE3_TEXT);diff --git a/endpoints/subscription/get.php b/endpoints/subscription/get.phpindex 0668139..31bd2bf 100644--- a/endpoints/subscription/get.php+++ b/endpoints/subscription/get.php@@ -18,6 +18,8 @@ if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] === true) {$subscriptionData['logo'] = $row['logo'];$subscriptionData['price'] = $row['price'];$subscriptionData['currency_id'] = $row['currency_id'];+ $subscriptionData['auto_renew'] = $row['auto_renew'];+ $subscriptionData['start_date'] = $row['start_date'];$subscriptionData['next_payment'] = $row['next_payment'];$subscriptionData['frequency'] = $row['frequency'];$subscriptionData['cycle'] = $row['cycle'];diff --git a/endpoints/subscription/renew.php b/endpoints/subscription/renew.phpnew file mode 100644index 0000000..174fd6c--- /dev/null+++ b/endpoints/subscription/renew.php@@ -0,0 +1,89 @@+<?php+require_once '../../includes/connect_endpoint.php';++if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] === true) {+ if ($_SERVER["REQUEST_METHOD"] === "GET") {+ $currentDate = new DateTime();+ $currentDateString = $currentDate->format('Y-m-d');++ $cycles = array();+ $query = "SELECT * FROM cycles";+ $result = $db->query($query);+ while ($row = $result->fetchArray(SQLITE3_ASSOC)) {+ $cycleId = $row['id'];+ $cycles[$cycleId] = $row;+ }++ $subscriptionId = $_GET["id"];+ $query = "SELECT * FROM subscriptions WHERE id = :id AND user_id = :user_id AND auto_renew = 0";+ $stmt = $db->prepare($query);+ $stmt->bindValue(':id', $subscriptionId, SQLITE3_INTEGER);+ $stmt->bindValue(':user_id', $userId, SQLITE3_INTEGER);+ $result = $stmt->execute();+ $subscriptionToRenew = $result->fetchArray(SQLITE3_ASSOC);+ if ($subscriptionToRenew === false) {+ die(json_encode([+ "success" => false,+ "message" => translate("error", $i18n)+ ]));+ }++ $nextPaymentDate = new DateTime($subscriptionToRenew['next_payment']);+ $frequency = $subscriptionToRenew['frequency'];+ $cycle = $cycles[$subscriptionToRenew['cycle']]['name'];++ // Calculate the interval to add based on the cycle+ $intervalSpec = "P";+ if ($cycle == 'Daily') {+ $intervalSpec .= "{$frequency}D";+ } elseif ($cycle === 'Weekly') {+ $intervalSpec .= "{$frequency}W";+ } elseif ($cycle === 'Monthly') {+ $intervalSpec .= "{$frequency}M";+ } elseif ($cycle === 'Yearly') {+ $intervalSpec .= "{$frequency}Y";+ }++ $interval = new DateInterval($intervalSpec);++ // Add intervals until the next payment date is in the future and after current next payment date+ while ($nextPaymentDate < $currentDate || $nextPaymentDate == new DateTime($subscriptionToRenew['next_payment'])) {+ $nextPaymentDate->add($interval);+ }++ // Update the subscription's next_payment date+ $updateQuery = "UPDATE subscriptions SET next_payment = :nextPaymentDate WHERE id = :subscriptionId";+ $updateStmt = $db->prepare($updateQuery);+ $updateStmt->bindValue(':nextPaymentDate', $nextPaymentDate->format('Y-m-d'));+ $updateStmt->bindValue(':subscriptionId', $subscriptionId);+ $updateStmt->execute();++ if ($updateStmt->execute()) {+ $response = [+ "success" => true,+ "message" => translate('success', $i18n),+ "id" => $subscriptionId+ ];+ echo json_encode($response);+ } else {+ die(json_encode([+ "success" => false,+ "message" => translate("error", $i18n)+ ]));+ }+ } else {+ $db->close();+ die(json_encode([+ "success" => false,+ "message" => translate('invalid_request_method', $i18n)+ ]));+ }+} else {+ $db->close();+ die(json_encode([+ "success" => false,+ "message" => translate('session_expired', $i18n)+ ]));+}++?>\ No newline at end of filediff --git a/endpoints/subscriptions/export.php b/endpoints/subscriptions/export.phpindex b005756..86f633d 100644--- a/endpoints/subscriptions/export.php+++ b/endpoints/subscriptions/export.php@@ -21,6 +21,7 @@ while ($row = $result->fetchArray(SQLITE3_ASSOC)) {$subscriptionDetails = array('Name' => str_replace(',', ' ', $row['name']),'Next Payment' => $row['next_payment'],+ 'Renewal' => $row['auto_renew'] ? 'Automatic' : 'Manual','Category' => str_replace(',', ' ', $categories[$row['category_id']]['name']),'Payment Method' => str_replace(',', ' ', $payment_methods[$row['payment_method_id']]['name']),'Paid By' => str_replace(',', ' ', $members[$row['payer_user_id']]['name']),diff --git a/endpoints/subscriptions/get.php b/endpoints/subscriptions/get.phpindex 10c1cc5..9a9cfba 100644--- a/endpoints/subscriptions/get.php+++ b/endpoints/subscriptions/get.php@@ -156,6 +156,7 @@ if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] === true) {$next_payment_timestamp = strtotime($subscription['next_payment']);$formatted_date = $formatter->format($next_payment_timestamp);$print[$id]['next_payment'] = $formatted_date;+ $print[$id]['auto_renew'] = $subscription['auto_renew'];$paymentIconFolder = (strpos($payment_methods[$paymentMethodId]['icon'], 'images/uploads/icons/') !== false) ? "" : "images/uploads/logos/";$print[$id]['payment_method_icon'] = $paymentIconFolder . $payment_methods[$paymentMethodId]['icon'];$print[$id]['payment_method_name'] = $payment_methods[$paymentMethodId]['name'];diff --git a/endpoints/user/disable_totp.php b/endpoints/user/disable_totp.phpindex d093652..a376bd7 100644--- a/endpoints/user/disable_totp.php+++ b/endpoints/user/disable_totp.php@@ -68,8 +68,9 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {$clock = new OTPHP\InternalClock();$totp = OTPHP\TOTP::createFromSecret($secret, $clock);+ $totp->setPeriod(30);- if ($totp->verify($totp_code)) {+ if ($totp->verify($totp_code, null, 15)) {$statement = $db->prepare('UPDATE user SET totp_enabled = 0 WHERE id = :id');$statement->bindValue(':id', $userId, SQLITE3_INTEGER);$statement->execute();diff --git a/endpoints/user/enable_totp.php b/endpoints/user/enable_totp.phpindex 8e0bbdb..0e77307 100644--- a/endpoints/user/enable_totp.php+++ b/endpoints/user/enable_totp.php@@ -86,9 +86,11 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {}$clock = new OTPHP\InternalClock();+$totp = OTPHP\TOTP::createFromSecret($secret, $clock);+ $totp->setPeriod(30);- if ($totp->verify($totp_code)) {+ if ($totp->verify($totp_code, null, 15)) {// Generate 10 backup codes$backupCodes = [];for ($i = 0; $i < 10; $i++) {diff --git a/images/siteicons/svg/automatic.php b/images/siteicons/svg/automatic.phpnew file mode 100644index 0000000..67b1f4a--- /dev/null+++ b/images/siteicons/svg/automatic.php@@ -0,0 +1,3 @@+<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="100" height="100" viewBox="0 0 50 50">+<path fill="currentColor" d="M 25 5 C 13.964844 5 5 13.964844 5 25 C 4.996094 25.359375 5.183594 25.695313 5.496094 25.878906 C 5.808594 26.058594 6.191406 26.058594 6.503906 25.878906 C 6.816406 25.695313 7.003906 25.359375 7 25 C 7 15.046875 15.046875 7 25 7 C 31.246094 7 36.726563 10.179688 39.957031 15 L 33 15 C 32.640625 14.996094 32.304688 15.183594 32.121094 15.496094 C 31.941406 15.808594 31.941406 16.191406 32.121094 16.503906 C 32.304688 16.816406 32.640625 17.003906 33 17 L 43 17 L 43 7 C 43.003906 6.730469 42.898438 6.46875 42.707031 6.277344 C 42.515625 6.085938 42.253906 5.980469 41.984375 5.984375 C 41.433594 5.996094 40.992188 6.449219 41 7 L 41 13.011719 C 37.347656 8.148438 31.539063 5 25 5 Z M 43.984375 23.984375 C 43.433594 23.996094 42.992188 24.449219 43 25 C 43 34.953125 34.953125 43 25 43 C 18.753906 43 13.269531 39.820313 10.042969 35 L 17 35 C 17.359375 35.007813 17.695313 34.816406 17.878906 34.507813 C 18.058594 34.195313 18.058594 33.808594 17.878906 33.496094 C 17.695313 33.1875 17.359375 32.996094 17 33 L 8.445313 33 C 8.316406 32.976563 8.1875 32.976563 8.058594 33 L 7 33 L 7 43 C 6.996094 43.359375 7.183594 43.695313 7.496094 43.878906 C 7.808594 44.058594 8.191406 44.058594 8.503906 43.878906 C 8.816406 43.695313 9.003906 43.359375 9 43 L 9 36.984375 C 12.648438 41.847656 18.460938 45 25 45 C 36.035156 45 45 36.035156 45 25 C 45.003906 24.730469 44.898438 24.46875 44.707031 24.277344 C 44.515625 24.085938 44.253906 23.980469 43.984375 23.984375 Z"></path>+</svg>\ No newline at end of filediff --git a/images/siteicons/svg/manual.php b/images/siteicons/svg/manual.phpnew file mode 100644index 0000000..78db52d--- /dev/null+++ b/images/siteicons/svg/manual.php@@ -0,0 +1,3 @@+<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="100" height="100" viewBox="0 0 50 50">+<path fill="currentColor" d="M 32 1 C 31.0625 1 30.085938 1.324219 29.3125 2 C 28.539063 2.675781 28 3.734375 28 5 L 28 5.40625 C 27.519531 5.1875 27.0625 5 26.5 5 C 24.578125 5 23 6.578125 23 8.5 C 23 10.421875 24.578125 12 26.5 12 C 27.089844 12 27.625 11.824219 28.25 11.625 C 28.875 11.425781 29.539063 11.195313 30.15625 10.9375 C 31 10.585938 31.605469 10.28125 32 10.09375 C 32.394531 10.28125 33 10.585938 33.84375 10.9375 C 34.460938 11.195313 35.125 11.425781 35.75 11.625 C 36.375 11.824219 36.910156 12 37.5 12 C 39.421875 12 41 10.421875 41 8.5 C 41 6.578125 39.421875 5 37.5 5 C 36.9375 5 36.480469 5.1875 36 5.40625 L 36 4.90625 C 36 3.675781 35.429688 2.625 34.65625 1.96875 C 33.882813 1.3125 32.9375 1 32 1 Z M 32 3 C 32.460938 3 33 3.179688 33.375 3.5 C 33.75 3.820313 34 4.238281 34 4.90625 L 34 6.46875 C 33.894531 6.53125 33.789063 6.59375 33.6875 6.65625 C 32.984375 7.09375 32.421875 7.488281 32 7.78125 C 31.578125 7.488281 31.015625 7.09375 30.3125 6.65625 C 30.210938 6.59375 30.105469 6.53125 30 6.46875 L 30 5 C 30 4.265625 30.25 3.824219 30.625 3.5 C 31 3.175781 31.539063 3 32 3 Z M 26.5 7 C 26.492188 7 26.972656 7.121094 27.5 7.375 C 28.027344 7.628906 28.667969 7.980469 29.25 8.34375 C 29.621094 8.574219 29.625 8.605469 29.9375 8.8125 C 29.671875 8.929688 29.675781 8.9375 29.375 9.0625 C 28.789063 9.304688 28.195313 9.574219 27.65625 9.75 C 27.117188 9.925781 26.613281 10 26.5 10 C 25.625 10 25 9.375 25 8.5 C 25 7.625 25.625 7 26.5 7 Z M 37.5 7 C 38.375 7 39 7.625 39 8.5 C 39 9.375 38.375 10 37.5 10 C 37.386719 10 36.882813 9.925781 36.34375 9.75 C 35.804688 9.574219 35.210938 9.304688 34.625 9.0625 C 34.324219 8.9375 34.328125 8.929688 34.0625 8.8125 C 34.375 8.605469 34.378906 8.574219 34.75 8.34375 C 35.332031 7.980469 35.972656 7.628906 36.5 7.375 C 37.027344 7.121094 37.507813 7 37.5 7 Z M 30 12.1875 L 28 13 L 28 15.5 C 27.398438 15.199219 26.800781 15 26 15 C 24.398438 15 23.292969 15.710938 22.59375 16.8125 C 21.992188 16.3125 21.101563 16 20 16 C 18.601563 16 17.011719 16.488281 16.3125 18.6875 C 15.511719 18.085938 14.699219 18 14 18 C 12.5 18 10 18.601563 10 23 L 10 41 C 10 46 14 50 19 50 L 28.09375 50 C 31.492188 50 34.59375 48.101563 36.09375 45 L 39 39.5 C 39.101563 39.199219 40.09375 37.207031 40.09375 34.90625 C 40.09375 31.007813 37.792969 29.011719 36.09375 28.3125 L 36.09375 13 L 34.09375 12.1875 L 34.09375 28.90625 C 34.09375 29.40625 34.507813 29.804688 34.90625 29.90625 C 35.007813 29.90625 38.09375 30.8125 38.09375 34.8125 C 38.09375 36.3125 37.488281 37.898438 37.1875 38.5 L 34.40625 44.09375 C 33.207031 46.492188 30.792969 48 28.09375 48 L 19 48 C 15.101563 48 12 44.898438 12 41 L 12 23 C 12 20.398438 13 20 14 20 C 15 20 16 20.398438 16 23 C 16 23.601563 16.398438 24 17 24 C 17.601563 24 18 23.601563 18 23 L 18 21 C 18 18.199219 19 18 20 18 C 21.699219 18 22 19.101563 22 20 L 22 22 C 22 22.601563 22.398438 23 23 23 C 23.601563 23 24 22.601563 24 22 L 24 19 C 24 18.199219 24.5 17 26 17 C 27.5 17 28 18.199219 28 19 L 28 23 C 28 23.601563 28.398438 24 29 24 C 29.601563 24 30 23.601563 30 23 Z"></path>+</svg>\ No newline at end of filediff --git a/images/siteicons/svg/mobile-menu/renew.php b/images/siteicons/svg/mobile-menu/renew.phpnew file mode 100644index 0000000..3bacc09--- /dev/null+++ b/images/siteicons/svg/mobile-menu/renew.php@@ -0,0 +1,3 @@+<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="100" height="100" viewBox="0 0 50 50">+ <path fill="currentColor" d="M 8.8125 2 C 8.335938 2.089844 7.992188 2.511719 8 3 L 8 11 C 8 11.03125 8 11.0625 8 11.09375 L 8 36 C 8 37.65625 6.65625 39 5 39 C 4.96875 39 4.9375 39 4.90625 39 C 3.296875 38.949219 2 37.621094 2 36 L 2 14 L 6 14 L 6 12 L 1 12 C 0.449219 12 0 12.449219 0 13 L 0 36 C 0 38.628906 2.074219 40.785156 4.65625 40.96875 C 4.667969 40.96875 4.675781 40.96875 4.6875 40.96875 C 4.707031 40.980469 4.730469 40.992188 4.75 41 C 4.835938 41.003906 4.914063 41 5 41 L 25 41 C 25.359375 41.003906 25.695313 40.816406 25.878906 40.503906 C 26.058594 40.191406 26.058594 39.808594 25.878906 39.496094 C 25.695313 39.183594 25.359375 38.996094 25 39 L 8.96875 39 C 9.609375 38.160156 10 37.128906 10 36 L 10 11.15625 C 10.003906 11.105469 10.003906 11.050781 10 11 L 10 4 L 44 4 L 44 25 C 43.996094 25.359375 44.183594 25.695313 44.496094 25.878906 C 44.808594 26.058594 45.191406 26.058594 45.503906 25.878906 C 45.816406 25.695313 46.003906 25.359375 46 25 L 46 3 C 46 2.449219 45.550781 2 45 2 L 9 2 C 8.96875 2 8.9375 2 8.90625 2 C 8.875 2 8.84375 2 8.8125 2 Z M 16 10 L 16 12 L 38 12 L 38 10 Z M 16 14 L 16 16 L 38 16 L 38 14 Z M 16 22 L 16 24 L 26 24 L 26 22 Z M 28 22 L 28 24 L 38 24 L 38 22 Z M 16 26 L 16 28 L 26 28 L 26 26 Z M 28 26 L 28 28 L 30 28 L 33 26 Z M 39 27 C 32.953125 27 28 31.953125 28 38 C 28 44.046875 32.953125 49 39 49 L 39 47 C 34.046875 47 30 42.953125 30 38 C 30 33.046875 34.046875 29 39 29 C 43.953125 29 48 33.046875 48 38 C 48 40.660156 46.851563 43 45 44.625 L 45 41 L 43 41 L 43 48 L 50 48 L 50 46 L 46.4375 46 C 48.621094 44.011719 50 41.171875 50 38 C 50 31.953125 45.046875 27 39 27 Z M 16 30 L 16 32 L 26 32 L 26 30 Z M 16 34 L 16 36 L 26 36 L 26 34 Z"></path>+</svg>\ No newline at end of filediff --git a/images/siteicons/svg/renew.php b/images/siteicons/svg/renew.phpnew file mode 100644index 0000000..c548c0d--- /dev/null+++ b/images/siteicons/svg/renew.php@@ -0,0 +1,5 @@+<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 48 48" id="Rotate-Left--Streamline-Plump" height="48" width="48">+ <g id="rotate-left">+ <path id="Union" class="accent-color" fill-rule="evenodd" d="M46.002 24.252C46.002 12.235 36.277 2 24.282 2c-6.843 0 -13.34 2.924 -17.495 7.768A73.686 73.686 0 0 0 4.274 8.47c-1.207 -0.59 -2.41 0.295 -2.262 1.632 0.58 5.209 1.925 8.672 2.66 10.248 0.289 0.62 0.912 0.98 1.594 0.92 1.73 -0.15 5.397 -0.715 10.19 -2.817 1.23 -0.54 1.396 -2.022 0.283 -2.774a71.485 71.485 0 0 0 -2.14 -1.383c2.48 -2.629 5.77 -4.384 9.682 -4.384 8.18 0 14.81 6.147 14.81 14.34 0 3.568 -1.258 6.842 -3.354 9.401 -0.626 0.765 -0.74 1.858 -0.167 2.664l1.758 2.474c0.687 0.967 2.067 1.13 2.874 0.26a21.7 21.7 0 0 0 5.8 -14.8ZM20.105 43.407c-0.165 1.149 -1.276 1.925 -2.377 1.558a19.778 19.778 0 0 1 -7.423 -4.488c-0.798 -0.763 -0.698 -2.034 0.138 -2.755l1.74 -1.501c0.738 -0.636 1.82 -0.638 2.63 -0.095A17.801 17.801 0 0 0 19 38.193c0.99 0.335 1.668 1.298 1.52 2.332l-0.415 2.882ZM8.891 35.146c-0.92 0.793 -2.335 0.591 -2.885 -0.492a23.216 23.216 0 0 1 -1.433 -3.517c-0.473 -1.499 0.722 -2.93 2.294 -2.93 1.132 0 2.102 0.77 2.573 1.8 0.223 0.489 0.48 0.965 0.765 1.426 0.573 0.927 0.485 2.16 -0.34 2.873l-0.974 0.84Zm25.595 8.315c0.998 -0.53 1.232 -1.82 0.578 -2.74l-1.711 -2.408c-0.618 -0.87 -1.806 -1.088 -2.772 -0.634a14.894 14.894 0 0 1 -5.063 1.354c-1.019 0.086 -1.907 0.81 -2.053 1.823l-0.427 2.972c-0.165 1.148 0.681 2.205 1.841 2.171a21.847 21.847 0 0 0 9.607 -2.538Z" clip-rule="evenodd" stroke-width="1"></path>+ </g>+</svg>\ No newline at end of filediff --git a/includes/i18n/de.php b/includes/i18n/de.phpindex 8f243eb..1dc631f 100644--- a/includes/i18n/de.php+++ b/includes/i18n/de.php@@ -48,6 +48,10 @@ $i18n = ["last_added" => "Zuletzt hinzugefügt","price" => "Preis","next_payment" => "Nächste Zahlung",+ "auto_renewal" => "Automatische Verlängerung",+ "automatically_renews" => "Automatisch verlängert",+ "manual_renewal" => "Manuelle Verlängerung",+ "start_date" => "Startdatum","inactive" => "Abonnement deaktivieren","replaced_with" => "Ersetzt durch","none" => "Keine",@@ -71,6 +75,7 @@ $i18n = ["clear_filters" => "Filter zurücksetzen","no_matching_subscriptions" => "Keine passenden Abonnements gefunden","clone" => "Klonen",+ "renew" => "Verlängern",// Subscription form"add_subscription" => "Abonnement hinzufügen","edit_subscription" => "Abonnement editieren",diff --git a/includes/i18n/el.php b/includes/i18n/el.phpindex fd40334..17f75d2 100644--- a/includes/i18n/el.php+++ b/includes/i18n/el.php@@ -48,6 +48,10 @@ $i18n = ["last_added" => "Τελευταία προσθήκη","price" => "Τιμή","next_payment" => "Επόμενη πληρωμή",+ "auto_renewal" => "Αυτόματη ανανέωση",+ "automatically_renews" => "Ανανεώνεται αυτόματα",+ "manual_renewal" => "Χειροκίνητη ανανέωση",+ "start_date" => "Ημερομηνία έναρξης","inactive" => "Απενεργοποίηση συνδρομής","replaced_with" => "Αντικαταστάθηκε με","none" => "Κανένα",@@ -71,6 +75,7 @@ $i18n = ["clear_filters" => "Καθαρισμός φίλτρων","no_matching_subscriptions" => "Δεν υπάρχουν συνδρομές που ταιριάζουν με τα φίλτρα σου","clone" => "Κλώνος",+ "renew" => "Ανανέωση",// Subscription form"add_subscription" => "Προσθήκη συνδρομής","edit_subscription" => "Επεξεργασία συνδρομής",diff --git a/includes/i18n/en.php b/includes/i18n/en.phpindex 6cefaff..ced6613 100644--- a/includes/i18n/en.php+++ b/includes/i18n/en.php@@ -48,6 +48,10 @@ $i18n = ["last_added" => "Last Added","price" => "Price","next_payment" => "Next Payment",+ "auto_renewal" => "Auto Renewal",+ "automatically_renews" => "Automatically renews",+ "manual_renewal" => "Manual Renewal",+ "start_date" => "Start Date","inactive" => "Disable Subscription","replaced_with" => "Replaced with","none" => "None",@@ -71,6 +75,7 @@ $i18n = ["clear_filters" => "Clear Filters","no_matching_subscriptions" => "No matching subscriptions","clone" => "Clone",+ "renew" => "Renew",// Subscription form"add_subscription" => "Add subscription","edit_subscription" => "Edit subscription",diff --git a/includes/i18n/es.php b/includes/i18n/es.phpindex ede2b40..7be4e44 100644--- a/includes/i18n/es.php+++ b/includes/i18n/es.php@@ -48,6 +48,10 @@ $i18n = ["last_added" => "Última Añadida","price" => "Precio","next_payment" => "Próximo Pago",+ "auto_renewal" => "Renovación Automática",+ "automatically_renews" => "Renovación Automática",+ "manual_renewal" => "Renovación Manual",+ "start_date" => "Fecha de Inicio","inactive" => "Desactivar Suscripción","replaced_with" => "Reemplazada con","none" => "Ninguna",@@ -71,6 +75,7 @@ $i18n = ["clear_filters" => "Limpiar Filtros","no_matching_subscriptions" => "No hay suscripciones que coincidan con los filtros","clone" => "Clonar",+ "renew" => "Renovar",// Subscription form"add_subscription" => "Añadir suscripción","edit_subscription" => "Editar suscripción",diff --git a/includes/i18n/fr.php b/includes/i18n/fr.phpindex 5da586e..52eb81d 100644--- a/includes/i18n/fr.php+++ b/includes/i18n/fr.php@@ -48,6 +48,10 @@ $i18n = ["last_added" => "Dernier ajouté","price" => "Prix","next_payment" => "Prochain paiement",+ "auto_renewal" => "Renouvellement automatique",+ "automatically_renews" => "Renouvellement automatique",+ "manual_renewal" => "Renouvellement manuel",+ "start_date" => "Date de début","inactive" => "Désactiver l'abonnement","replaced_with" => "Remplacé par","none" => "Aucun",@@ -71,6 +75,7 @@ $i18n = ["clear_filters" => "Effacer les filtres","no_matching_subscriptions" => "Aucun abonnement ne correspond à vos critères de recherche","clone" => "Cloner",+ "renew" => "Renouveler",// Formulaire d'abonnement"add_subscription" => "Ajouter un abonnement","edit_subscription" => "Modifier l'abonnement",diff --git a/includes/i18n/it.php b/includes/i18n/it.phpindex a35731a..f483ea1 100644--- a/includes/i18n/it.php+++ b/includes/i18n/it.php@@ -52,6 +52,10 @@ $i18n = ["last_added" => 'Ultimo aggiunto',"price" => 'Prezzo',"next_payment" => 'Prossimo pagamento',+ "auto_renewal" => 'Rinnovo automatico',+ "automatically_renews" => 'Si rinnova automaticamente',+ "manual_renewal" => "Rinnovo manuale",+ "start_date" => 'Data di inizio',"inactive" => 'Disattiva abbonamento',"replaced_with" => 'Sostituito con',"none" => 'Nessuno',@@ -75,6 +79,7 @@ $i18n = ["clear_filters" => 'Pulisci filtri',"no_matching_subscriptions" => 'Nessun abbonamento corrispondente',"clone" => "Clona",+ "renew" => "Rinnova",// Add/Edit Subscription"add_subscription" => 'Aggiungi abbonamento',diff --git a/includes/i18n/jp.php b/includes/i18n/jp.phpindex 003bfcc..775bb21 100644--- a/includes/i18n/jp.php+++ b/includes/i18n/jp.php@@ -48,6 +48,10 @@ $i18n = ["last_added" => "最終追加日","price" => "金額","next_payment" => "次回支払い",+ "auto_renewal" => "自動更新",+ "automatically_renews" => "自動更新",+ "manual_renewal" => "手動更新",+ "start_date" => "開始日","inactive" => "サブスクリプションを無効にする","replaced_with" => "置き換えられた","none" => "なし",@@ -71,6 +75,7 @@ $i18n = ["clear_filters" => "フィルタをクリア","no_matching_subscriptions" => "一致する定期購入がありません","clone" => "複製",+ "renew" => "更新",// Subscription form"add_subscription" => "定期購入の追加","edit_subscription" => "定期購入の編集",diff --git a/includes/i18n/ko.php b/includes/i18n/ko.phpindex 29cebd3..092d7f2 100644--- a/includes/i18n/ko.php+++ b/includes/i18n/ko.php@@ -48,6 +48,10 @@ $i18n = ["last_added" => "최근 등록","price" => "가격","next_payment" => "다음 결제일",+ "auto_renewal" => "자동 갱신",+ "automatically_renews" => "자동 갱신",+ "manual_renewal" => "수동 갱신",+ "start_date" => "시작일","inactive" => "구독 비활성화","replaced_with" => "다음 구독으로 대체됨","none" => "없음",@@ -71,6 +75,7 @@ $i18n = ["clear_filters" => "필터 제거","no_matching_subscriptions" => "해당하는 구독이 없습니다.","clone" => "복제",+ "renew" => "갱신",// Subscription form"add_subscription" => "구독 추가","edit_subscription" => "구독 편집",diff --git a/includes/i18n/pl.php b/includes/i18n/pl.phpindex 26bd40b..4541d76 100644--- a/includes/i18n/pl.php+++ b/includes/i18n/pl.php@@ -48,6 +48,10 @@ $i18n = ["last_added" => "Ostatnio dodane","price" => "Cena","next_payment" => "Następna płatność",+ "auto_renewal" => "Automatyczne odnawianie",+ "automatically_renews" => "Automatycznie odnawia się",+ "manual_renewal" => "Ręczne odnawianie",+ "start_date" => "Data rozpoczęcia","inactive" => "Wyłącz subskrypcję","replaced_with" => "Zastąpione przez","none" => "Brak",@@ -71,6 +75,7 @@ $i18n = ["clear_filters" => "Wyczyść filtry","no_matching_subscriptions" => "Brak pasujących subskrypcji","clone" => "Klonuj",+ "renew" => "Odnów",// Subscription form"add_subscription" => "Dodaj subskrypcję","edit_subscription" => "Edytuj subskrypcję",diff --git a/includes/i18n/pt.php b/includes/i18n/pt.phpindex 2d6b658..dd252e0 100644--- a/includes/i18n/pt.php+++ b/includes/i18n/pt.php@@ -48,6 +48,10 @@ $i18n = ["last_added" => "Última Adicionada","price" => "Preço","next_payment" => "Próximo Pagamento",+ "auto_renewal" => "Renovação Automática",+ "automatically_renews" => "Renova automaticamente",+ "manual_renewal" => "Renovação Manual",+ "start_date" => "Data de Início","inactive" => "Desactivar Subscrição","replaced_with" => "Substituída por","none" => "Nenhuma",@@ -71,6 +75,7 @@ $i18n = ["clear_filters" => "Limpar Filtros","no_matching_subscriptions" => "Sem subscrições correspondentes","clone" => "Clonar",+ "renew" => "Renovar",// Subscription form"add_subscription" => "Adicionar subscrição","edit_subscription" => "Modificar subscrição",diff --git a/includes/i18n/pt_br.php b/includes/i18n/pt_br.phpindex 0bac791..5bb6c71 100644--- a/includes/i18n/pt_br.php+++ b/includes/i18n/pt_br.php@@ -48,6 +48,10 @@ $i18n = ["last_added" => "Última adicionada","price" => "Preço","next_payment" => "Próximo pagamento",+ "auto_renewal" => "Renovação automática",+ "automatically_renews" => "Renova automaticamente",+ "manual_renewal" => "Renovação manual",+ "start_date" => "Data de início","inactive" => "Assinatura inativa","replaced_with" => "Substituída por","none" => "Nenhuma",@@ -71,6 +75,7 @@ $i18n = ["clear_filters" => "Limpar filtros","no_matching_subscriptions" => "Nenhuma assinatura encontrada","clone" => "Clonar",+ "renew" => "Renovar",// Subscription form"add_subscription" => "Adicionar assinatura","edit_subscription" => "Editar assinatura",diff --git a/includes/i18n/ru.php b/includes/i18n/ru.phpindex 3c792b1..f2a0a57 100644--- a/includes/i18n/ru.php+++ b/includes/i18n/ru.php@@ -48,6 +48,10 @@ $i18n = ["last_added" => "Дата создания","price" => "Стоимость","next_payment" => "Следующий платеж",+ "auto_renewal" => "Автоматическое продление",+ "automatically_renews" => "Автоматическое продление",+ "manual_renewal" => "Ручное продление",+ "start_date" => "Дата начала","inactive" => "Отключить подписку","replaced_with" => "Заменена на","none" => "Нет",@@ -71,6 +75,7 @@ $i18n = ["clear_filters" => "Очистить фильтры","no_matching_subscriptions" => "Нет подходящих подписок","clone" => "Клонировать",+ "renew" => "Продлить",// Subscription form"add_subscription" => "Добавить подписку","edit_subscription" => "Изменить подписку",diff --git a/includes/i18n/sl.php b/includes/i18n/sl.phpindex eaf4cd3..ee88930 100644--- a/includes/i18n/sl.php+++ b/includes/i18n/sl.php@@ -48,6 +48,10 @@ $i18n = ["last_added" => "Zadnje dodano","price" => "Cena","next_payment" => "Naslednje plačilo",+ "auto_renewal" => "Samodejno obnavljanje",+ "automatically_renews" => "Se samodejno obnavlja",+ "manual_renewal" => "Ročno obnavljanje",+ "start_date" => "Datum začetka","inactive" => "Onemogoči naročnino","replaced_with" => "Zamenjano z","none" => "brez",@@ -71,6 +75,7 @@ $i18n = ["clear_filters" => "Počisti filter","no_matching_subscriptions" => "Ni ustreznih naročnin","clone" => "Klon",+ "renew" => "Obnovi",// Subscription form"add_subscription" => "Dodaj naročnino","edit_subscription" => "Uredi naročnino",diff --git a/includes/i18n/sr.php b/includes/i18n/sr.phpindex d03c5bc..4fe9f7c 100644--- a/includes/i18n/sr.php+++ b/includes/i18n/sr.php@@ -48,6 +48,10 @@ $i18n = ["last_added" => "Последње додато","price" => "Цена","next_payment" => "Следећа уплата",+ "auto_renewal" => "Аутоматско обновљење",+ "automatically_renews" => "Аутоматски обновља",+ "manual_renewal" => "Ручно обновљење",+ "start_date" => "Датум почетка","inactive" => "Онемогући претплату","replaced_with" => "Замењено са","none" => "Ништа",@@ -71,6 +75,7 @@ $i18n = ["clear_filters" => "Очисти филтере","no_matching_subscriptions" => "Нема подударајућих претплата","clone" => "Клонирај",+ "renew" => "Обнови",// Форма за претплату"add_subscription" => "Додај претплату","edit_subscription" => "Уреди претплату",diff --git a/includes/i18n/sr_lat.php b/includes/i18n/sr_lat.phpindex 66bc650..6ca48c5 100644--- a/includes/i18n/sr_lat.php+++ b/includes/i18n/sr_lat.php@@ -48,6 +48,10 @@ $i18n = ["last_added" => "Poslednje dodato","price" => "Cena","next_payment" => "Sledeća uplata",+ "auto_renewal" => "Automatsko obnavljanje",+ "automatically_renews" => "Automatsko obnavljanje",+ "manual_renewal" => "Ručno obnavljanje",+ "start_date" => "Datum početka","inactive" => "Onemogući pretplatu","replaced_with" => "Zamenjeno sa","none" => "Nijedna",@@ -71,6 +75,7 @@ $i18n = ["clear_filters" => "Očisti filtere","no_matching_subscriptions" => "Nema podudarajućih pretplata","clone" => "Kloniraj",+ "renew" => "Obnovi",// Forma za pretplatu"add_subscription" => "Dodaj pretplatu","edit_subscription" => "Uredi pretplatu",diff --git a/includes/i18n/tr.php b/includes/i18n/tr.phpindex f8dc9bc..5f50e3e 100644--- a/includes/i18n/tr.php+++ b/includes/i18n/tr.php@@ -48,6 +48,10 @@ $i18n = ["last_added" => "Son Eklenen","price" => "Fiyat","next_payment" => "Sonraki Ödeme",+ "auto_renewal" => "Otomatik Yenileme",+ "automatically_renews" => "Otomatik Yenileme",+ "manual_renewal" => "Manuel Yenileme",+ "start_date" => "Başlangıç Tarihi","inactive" => "Aboneliği Devre Dışı Bırak","replaced_with" => "Şununla değiştirildi","none" => "Yok",@@ -71,6 +75,7 @@ $i18n = ["clear_filters" => "Filtreleri Temizle","no_matching_subscriptions" => "Eşleşen abonelik bulunamadı","clone" => "Kopyala",+ "renew" => "Yenile",// Subscription form"add_subscription" => "Abonelik ekle","edit_subscription" => "Aboneliği düzenle",diff --git a/includes/i18n/vi.php b/includes/i18n/vi.phpindex 8e7c983..439245c 100644--- a/includes/i18n/vi.php+++ b/includes/i18n/vi.php@@ -48,6 +48,10 @@ $i18n = ["last_added" => "Thêm gần đây","price" => "Giá","next_payment" => "Thanh toán tiếp theo",+ "auto_renewal" => "Tự động gia hạn",+ "automatically_renews" => "Tự động gia hạn",+ "manual_renewal" => "Gia hạn thủ công",+ "start_date" => "Ngày bắt đầu","inactive" => "Vô hiệu hóa đăng ký","replaced_with" => "Thay thế bằng","none" => "Không",@@ -71,6 +75,7 @@ $i18n = ["clear_filters" => "Xóa bộ lọc","no_matching_subscriptions" => "Không có đăng ký phù hợp","clone" => "Nhân bản",+ "renew" => "Gia hạn",// Subscription form"add_subscription" => "Thêm đăng ký","edit_subscription" => "Chỉnh sửa đăng ký",diff --git a/includes/i18n/zh_cn.php b/includes/i18n/zh_cn.phpindex d3dd630..2041184 100644--- a/includes/i18n/zh_cn.php+++ b/includes/i18n/zh_cn.php@@ -52,6 +52,10 @@ $i18n = ["last_added" => "创建时间","price" => "价格","next_payment" => "下次支付时间",+ "auto_renewal" => "自动续订",+ "automatically_renews" => "自动续订",+ "manual_renewal" => "手动续订",+ "start_date" => "开始日期","inactive" => "停用订阅","replaced_with" => "替换为","none" => "无",@@ -75,6 +79,7 @@ $i18n = ["clear_filters" => "清除筛选","no_matching_subscriptions" => "没有匹配的订阅","clone" => "克隆",+ "renew" => "续订",// 订阅表单"add_subscription" => "添加订阅",diff --git a/includes/i18n/zh_tw.php b/includes/i18n/zh_tw.phpindex 8ab6eae..c58fc39 100644--- a/includes/i18n/zh_tw.php+++ b/includes/i18n/zh_tw.php@@ -48,6 +48,10 @@ $i18n = ["last_added" => "建立時間","price" => "價格","next_payment" => "下次付款時間",+ "auto_renewal" => "自動續訂",+ "automatically_renews" => "自動續訂",+ "manual_renewal" => "手動續訂",+ "start_date" => "開始日期","inactive" => "停用訂閱","replaced_with" => "替換為","none" => "無",@@ -71,6 +75,7 @@ $i18n = ["clear_filters" => "清除篩選","no_matching_subscriptions" => "沒有符合的訂閱","clone" => "複製",+ "renew" => "續訂",// 訂閱表單"add_subscription" => "新增訂閱","edit_subscription" => "編輯訂閱",diff --git a/includes/list_subscriptions.php b/includes/list_subscriptions.phpindex a9b74f3..23a271b 100644--- a/includes/list_subscriptions.php+++ b/includes/list_subscriptions.php@@ -104,25 +104,43 @@ function printSubscriptions($subscriptions, $sort, $categories, $members, $i18n,if ($mobileNavigation === 'true') {?><div class="mobile-actions" data-id="<?= $subscription['id'] ?>">- <button class="mobile-action-edit"></button>- <button class="mobile-action-edit" onClick="openEditSubscription(event, <?= $subscription['id'] ?>)">- <?php include $imagePath . "images/siteicons/svg/mobile-menu/edit.php"; ?>- Edit+ <button class="mobile-action-clone"></button>+ <button class="mobile-action-clone" onClick="cloneSubscription(event, <?= $subscription['id'] ?>)">+ <?php include $imagePath . "images/siteicons/svg/mobile-menu/clone.php"; ?>+ Clone</button><button class="mobile-action-delete" onClick="deleteSubscription(event, <?= $subscription['id'] ?>)"><?php include $imagePath . "images/siteicons/svg/mobile-menu/delete.php"; ?>Delete</button>- <button class="mobile-action-clone" onClick="cloneSubscription(event, <?= $subscription['id'] ?>)">- <?php include $imagePath . "images/siteicons/svg/mobile-menu/clone.php"; ?>- Clone+ <?php+ if ($subscription['auto_renew'] != 1) {+ ?>+ <button class="mobile-action-renew" onClick="renewSubscription(event, <?= $subscription['id'] ?>)">+ <?php include $imagePath . "images/siteicons/svg/mobile-menu/renew.php"; ?>+ Renew+ </button>+ <?php+ }+ ?>+ <button class="mobile-action-edit" onClick="openEditSubscription(event, <?= $subscription['id'] ?>)">+ <?php include $imagePath . "images/siteicons/svg/mobile-menu/edit.php"; ?>+ Edit</button></div><?php++ $subscriptionExtraClasses = "";+ if ($subscription['inactive']) {+ $subscriptionExtraClasses .= " inactive";+ }+ if ($subscription['auto_renew'] != 1) {+ $subscriptionExtraClasses .= " manual";+ }}?>- <div class="subscription<?= $subscription['inactive'] ? ' inactive' : '' ?>"+ <div class="subscription<?= $subscriptionExtraClasses ?>"onClick="toggleOpenSubscription(<?= $subscription['id'] ?>)" data-id="<?= $subscription['id'] ?>"data-name="<?= $subscription['name'] ?>"><div class="subscription-main">@@ -138,7 +156,17 @@ function printSubscriptions($subscriptions, $sort, $categories, $members, $i18n,?></span><span class="name"><?= $subscription['name'] ?></span>- <span class="cycle"><?= $subscription['billing_cycle'] ?></span>+ <span class="cycle"+ title="<?= $subscription['auto_renew'] ? translate("automatically_renews", $i18n) : translate("manual_renewal", $i18n) ?>">+ <?php+ if ($subscription['auto_renew']) {+ include $imagePath . "images/siteicons/svg/automatic.php";+ } else {+ include $imagePath . "images/siteicons/svg/manual.php";+ }+ ?>+ <?= $subscription['billing_cycle'] ?>+ </span><span class="next"><?= $subscription['next_payment'] ?></span><span class="price"><span class="payment_method">@@ -158,10 +186,11 @@ function printSubscriptions($subscriptions, $sort, $categories, $members, $i18n,</span></span><?php- $desktopMenuButtonClass = "";- if ($mobileNavigation === "true") {- $desktopMenuButtonClass = "mobileNavigationHideOnMobile";- }+ $desktopMenuButtonClass = ""; {+ }+ if ($mobileNavigation === "true") {+ $desktopMenuButtonClass = "mobileNavigationHideOnMobile";+ }?><button type="button" class="actions-expand <?= $desktopMenuButtonClass ?>"onClick="expandActions(event, <?= $subscription['id'] ?>)">@@ -183,6 +212,17 @@ function printSubscriptions($subscriptions, $sort, $categories, $members, $i18n,<?php include $imagePath . "images/siteicons/svg/clone.php"; ?><?= translate('clone', $i18n) ?></li>+ <?php+ if ($subscription['auto_renew'] != 1) {+ ?>+ <li class="renew" title="<?= translate('renew', $i18n) ?>"+ onClick="renewSubscription(event, <?= $subscription['id'] ?>)">+ <?php include $imagePath . "images/siteicons/svg/renew.php"; ?>+ <?= translate('renew', $i18n) ?>+ </li>+ <?php+ }+ ?></ul></div><div class="subscription-secondary">diff --git a/includes/version.php b/includes/version.phpindex 887077e..8f8f1dc 100644--- a/includes/version.php+++ b/includes/version.php@@ -1,3 +1,3 @@<?php-$version = "v2.37.1";+$version = "v2.38.0";?>\ No newline at end of filediff --git a/index.php b/index.phpindex cf71f21..37e3cb2 100644--- a/index.php+++ b/index.php@@ -356,6 +356,7 @@ $headerClass = count($subscriptions) > 0 ? "main-actions" : "main-actions hidden$paymentMethodId = $subscription['payment_method_id'];$print[$id]['currency_code'] = $currencies[$subscription['currency_id']]['code'];$currencyId = $subscription['currency_id'];+ $print[$id]['auto_renew'] = $subscription['auto_renew'];$next_payment_timestamp = strtotime($subscription['next_payment']);$formatted_date = $formatter->format($next_payment_timestamp);$print[$id]['next_payment'] = $formatted_date;@@ -490,6 +491,22 @@ $headerClass = count($subscriptions) > 0 ? "main-actions" : "main-actions hidden</div></div><div class="split33">+ <label><?= translate('auto_renewal', $i18n) ?></label>+ <div class="inline height50">+ <input type="checkbox" id="auto_renew" name="auto_renew" checked>+ <label for="auto_renew"><?= translate('automatically_renews', $i18n) ?></label>+ </div>+ </div>+ </div>+ </div>++ <div class="form-group">+ <div class="inline">+ <div class="split50">+ <label for="start_date"><?= translate('start_date', $i18n) ?></label>+ <input type="date" id="start_date" name="start_date">+ </div>+ <div class="split50"><label for="next_payment"><?= translate('next_payment', $i18n) ?></label><input type="date" id="next_payment" name="next_payment" required></div>diff --git a/migrations/000032.php b/migrations/000032.phpnew file mode 100644index 0000000..e747d51--- /dev/null+++ b/migrations/000032.php@@ -0,0 +1,35 @@+<?php+// This migration adds a total_yearly_cost table to store the total yearly cost of all subscriptions over time+// This migration adds a start_date column to the subscriptions table to store the start date of the subscription+// This migration adds a auto_renew column to the subscriptions table to store if the subscription renews automatically or needs manual renewal++/** @noinspection PhpUndefinedVariableInspection */+$tableQuery = $db->query("SELECT name FROM sqlite_master WHERE type='table' AND name='total_yearly_cost'");+$tableRequired = $tableQuery->fetchArray(SQLITE3_ASSOC) === false;++if ($tableRequired) {+ $db->exec('CREATE TABLE total_yearly_cost (+ id INTEGER PRIMARY KEY AUTOINCREMENT,+ user_id INTEGER NOT NULL,+ date INTEGER NOT NULL,+ cost REAL NOT NULL,+ currency TEXT NOT NULL+ )');+}++/** @noinspection PhpUndefinedVariableInspection */+$columnQuery = $db->query("PRAGMA table_info(subscriptions)");+$columns = [];+while ($column = $columnQuery->fetchArray(SQLITE3_ASSOC)) {+ $columns[] = $column['name'];+}++if (!in_array('start_date', $columns)) {+ $db->exec('ALTER TABLE subscriptions ADD COLUMN start_date INTEGER DEFAULT NULL');+}++if (!in_array('auto_renew', $columns)) {+ $db->exec('ALTER TABLE subscriptions ADD COLUMN auto_renew INTEGER DEFAULT 1');+}++?>\ No newline at end of filediff --git a/scripts/dashboard.js b/scripts/dashboard.jsindex 8fb2ae1..ea0bbf1 100644--- a/scripts/dashboard.js+++ b/scripts/dashboard.js@@ -33,6 +33,10 @@ function resetForm() {logoSearchButton.classList.add("disabled");const submitButton = document.querySelector("#save-button");submitButton.disabled = false;+ const autoRenew = document.querySelector("#auto_renew");+ autoRenew.checked = true;+ const startDate = document.querySelector("#start_date");+ startDate.value = new Date().toISOString().split('T')[0];const notifyDaysBefore = document.querySelector("#notify_days_before");notifyDaysBefore.disabled = true;const replacementSubscriptionIdSelect = document.querySelector("#replacement_subscription_id");@@ -78,6 +82,8 @@ function fillEditFormFields(subscription) {const payerSelect = document.querySelector("#payer_user");payerSelect.value = subscription.payer_user_id;+ const startDate = document.querySelector("#start_date");+ startDate.value = subscription.start_date;const nextPament = document.querySelector("#next_payment");nextPament.value = subscription.next_payment;const cancellationDate = document.querySelector("#cancellation_date");@@ -90,6 +96,11 @@ function fillEditFormFields(subscription) {const url = document.querySelector("#url");url.value = subscription.url;+ const autoRenew = document.querySelector("#auto_renew");+ if (autoRenew) {+ autoRenew.checked = subscription.auto_renew;+ }+const notifications = document.querySelector("#notifications");if (notifications) {notifications.checked = subscription.notify;@@ -142,6 +153,7 @@ function openEditSubscription(event, id) {}}).catch((error) => {+ console.log(error);showErrorMessage(translate('failed_to_load_subscription'));});}@@ -233,6 +245,33 @@ function cloneSubscription(event, id) {});}+function renewSubscription(event, id) {+ event.stopPropagation();+ event.preventDefault();++ const url = `endpoints/subscription/renew.php?id=${id}`;++ fetch(url)+ .then(response => {+ if (!response.ok) {+ throw new Error(translate('network_response_error'));+ }+ return response.json();+ })+ .then(data => {+ if (data.success) {+ const id = data.id;+ fetchSubscriptions(id, event, "renew");+ showSuccessMessage(decodeURI(data.message));+ } else {+ showErrorMessage(data.message || translate('error'));+ }+ })+ .catch(error => {+ showErrorMessage(error.message || translate('error'));+ });+}+function setSearchButtonStatus() {const nameInput = document.querySelector("#name");@@ -479,9 +518,9 @@ function searchSubscriptions() {subscriptions.forEach(subscription => {const name = subscription.getAttribute('data-name').toLowerCase();if (!name.includes(searchTerm)) {- subscription.classList.add("hide");+ subscription.parentElement.classList.add("hide");} else {- subscription.classList.remove("hide");+ subscription.parentElement.classList.remove("hide");}});}@@ -511,7 +550,7 @@ function setSwipeElements() {let currentX = 0;let currentY = 0;let translateX = 0;- const maxTranslateX = -180;+ const maxTranslateX = element.classList.contains('manual') ? -240 : -180;element.addEventListener('touchstart', (e) => {startX = e.touches[0].clientX;diff --git a/scripts/profile.js b/scripts/profile.jsindex 5ca60ba..04501de 100644--- a/scripts/profile.js+++ b/scripts/profile.js@@ -180,7 +180,6 @@ function submitTotp() {totpBackupCodes.classList.remove('hide');} else {showErrorMessage(data.message);- console.log(error);}}).catch(error => {diff --git a/styles/styles.css b/styles/styles.cssindex 8277d2f..6d1fe8c 100644--- a/styles/styles.css+++ b/styles/styles.css@@ -384,6 +384,10 @@ button.mobile-action-clone {background-color: #2da7f3}+button.mobile-action-renew {+ background-color: #188823;+}+.subscription-container>.mobile-actions>button>svg {width: 25px;height: 25px;@@ -405,7 +409,7 @@ button.mobile-action-clone {transition: transform 0.2s;}-.subscription.hide {+.subscription-container.hide {display: none;}@@ -553,6 +557,15 @@ button.mobile-action-clone {.subscription .cycle {flex-basis: 16%;flex-grow: 1;+ flex-direction: row;+ align-items: center;+}++.subscription .cycle > svg {+ width: 15px;+ height: 15px;+ margin-right: 3px;+ margin-top: 2px;}.subscription .next {@@ -1175,6 +1188,10 @@ header #avatar {display: none;}+.height50 {+ height: 50px;+}+.inline-row {display: flex;flex-direction: row;diff --git a/totp.php b/totp.phpindex 94106c0..047b3cd 100644--- a/totp.php+++ b/totp.php@@ -71,7 +71,8 @@ if (isset($_POST['one-time-code'])) {$clock = new OTPHP\InternalClock();$totp = OTPHP\TOTP::createFromSecret($totp_secret, $clock);- $valid = $totp->verify($totp_code);+ $totp->setPeriod(30);+ $valid = $totp->verify($totp_code, null, 15);// If totp is not valid check backup codesif (!$valid) {