Skip to content

Wallos: Open-source, self-hostable personal subscription tracker. Visualize your recurring expenses, manage your budget, and save money.

fix: rename category after adding and sort order of categories

Miguel Ribeiroae73db779077
diff --git a/endpoints/categories/category.php b/endpoints/categories/category.php
index 97b5b3c..21ac2ac 100644
--- a/endpoints/categories/category.php
+++ b/endpoints/categories/category.php
@@ -6,10 +6,22 @@ session_start();
if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] === true) {
if (isset($_GET['action']) && $_GET['action'] == "add") {
+ $stmt = $db->prepare('SELECT MAX("order") as maxOrder FROM categories');
+ $result = $stmt->execute();
+ $row = $result->fetchArray(SQLITE3_ASSOC);
+ $maxOrder = $row['maxOrder'];
+
+ if ($maxOrder === NULL) {
+ $maxOrder = 0;
+ }
+
+ $order = $maxOrder + 1;
+
$categoryName = "Category";
- $sqlInsert = "INSERT INTO categories (name) VALUES (:name)";
+ $sqlInsert = 'INSERT INTO categories ("name", "order") VALUES (:name, :order)';
$stmtInsert = $db->prepare($sqlInsert);
$stmtInsert->bindParam(':name', $categoryName, SQLITE3_TEXT);
+ $stmtInsert->bindParam(':order', $order, SQLITE3_INTEGER);
$resultInsert = $stmtInsert->execute();
if ($resultInsert) {
diff --git a/endpoints/logos/search.php b/endpoints/logos/search.php
index 4df345d..f5f5854 100644
--- a/endpoints/logos/search.php
+++ b/endpoints/logos/search.php
@@ -30,6 +30,7 @@
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $backupUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$envVars = array_change_key_case($_SERVER, CASE_LOWER);
$httpProxy = isset($envVars['http_proxy']) ? $envVars['http_proxy'] : null;
$httpsProxy = isset($envVars['https_proxy']) ? $envVars['https_proxy'] : null;
diff --git a/endpoints/payments/search.php b/endpoints/payments/search.php
index 602adea..8deb47f 100644
--- a/endpoints/payments/search.php
+++ b/endpoints/payments/search.php
@@ -8,6 +8,7 @@
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
// Convert all environment variable keys to lowercase
$envVars = array_change_key_case($_SERVER, CASE_LOWER);
@@ -29,6 +30,7 @@
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $backupUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$envVars = array_change_key_case($_SERVER, CASE_LOWER);
$httpProxy = isset($envVars['http_proxy']) ? $envVars['http_proxy'] : null;
$httpsProxy = isset($envVars['https_proxy']) ? $envVars['https_proxy'] : null;
diff --git a/includes/version.php b/includes/version.php
index 4b78b7b..a413fd9 100644
--- a/includes/version.php
+++ b/includes/version.php
@@ -1,3 +1,3 @@
<?php
- $version = "v1.16.2";
+ $version = "v1.16.3";
?>
\ No newline at end of file
diff --git a/scripts/settings.js b/scripts/settings.js
index 44da72b..cd89e4b 100644
--- a/scripts/settings.js
+++ b/scripts/settings.js
@@ -165,7 +165,7 @@ function addCategoryButton(categoryId) {
if(responseData.success) {
const newCategoryId = responseData.categoryId;;
let container = document.getElementById("categories");
- let row = document.createElement("li");
+ let row = document.createElement("div");
row.className = "form-group-inline";
row.dataset.categoryid = newCategoryId;
@@ -250,7 +250,7 @@ function removeCategory(categoryId) {
function editCategory(categoryId) {
var saveButton = document.querySelector(`div[data-categoryid="${categoryId}"] button[name="save"]`);
var inputElement = document.querySelector(`div[data-categoryid="${categoryId}"] input[name="category"]`);
- console.log(saveButton);
+
saveButton.classList.add("disabled");
saveButton.disabled = true;
if (inputElement) {