Skip to content

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

feat: allow sorting of categories in settings

Miguel Ribeiro83234ab8cd18
diff --git a/endpoints/categories/sort.php b/endpoints/categories/sort.php
new file mode 100644
index 0000000..9552226
--- /dev/null
+++ b/endpoints/categories/sort.php
@@ -0,0 +1,34 @@
+<?php
+
+require_once '../../includes/connect_endpoint.php';
+
+session_start();
+
+if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] === true) {
+ $categories = $_POST['categoryIds'];
+ $order = 2;
+
+ foreach ($categories as $categoryId) {
+ $sql = "UPDATE categories SET `order` = :order WHERE id = :categoryId";
+ $stmt = $db->prepare($sql);
+ $stmt->bindParam(':order', $order, SQLITE3_INTEGER);
+ $stmt->bindParam(':categoryId', $categoryId, SQLITE3_INTEGER);
+ $result = $stmt->execute();
+ $order++;
+ }
+
+ $response = [
+ "success" => true,
+ "message" => translate("sort_order_saved", $i18n)
+ ];
+ echo json_encode($response);
+} else {
+ $response = [
+ "success" => false,
+ "errorMessage" => translate("session_expired", $i18n)
+ ];
+ echo json_encode($response);
+ die();
+}
+
+?>
\ No newline at end of file
diff --git a/endpoints/payments/get.php b/endpoints/payments/get.php
index fdd5f4e..902c645 100644
--- a/endpoints/payments/get.php
+++ b/endpoints/payments/get.php
@@ -39,7 +39,7 @@ if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] === true) {
<?= $payment['name'] ?>
</span>
<?php
- if ($payment['id'] > 31 && !$inUse) {
+ if (!$inUse) {
?>
<div class="delete-payment-method" title="<?= translate('delete', $i18n) ?>" data-paymentid="<?= $payment['id'] ?>" onclick="deletePaymentMethod(<?= $payment['id'] ?>)">
x
diff --git a/endpoints/payments/rename.php b/endpoints/payments/rename.php
new file mode 100644
index 0000000..f7ba250
--- /dev/null
+++ b/endpoints/payments/rename.php
@@ -0,0 +1,41 @@
+<?php
+
+require_once '../../includes/connect_endpoint.php';
+session_start();
+
+if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) {
+ die(json_encode([
+ "success" => false,
+ "message" => translate('session_expired', $i18n)
+ ]));
+}
+
+if (!isset($_POST['paymentId']) || !isset($_POST['name']) || $_POST['paymentId'] === '' || $_POST['name'] === '') {
+ die(json_encode([
+ "success" => false,
+ "message" => translate('fields_missing', $i18n)
+ ]));
+}
+
+$paymentId = $_POST['paymentId'];
+$name = $_POST['name'];
+
+$sql = "UPDATE payment_methods SET name = :name WHERE id = :paymentId";
+$stmt = $db->prepare($sql);
+$stmt->bindParam(':name', $name, SQLITE3_TEXT);
+$stmt->bindParam(':paymentId', $paymentId, SQLITE3_INTEGER);
+$result = $stmt->execute();
+
+if ($result) {
+ echo json_encode([
+ "success" => true,
+ "message" => translate('payment_renamed', $i18n)
+ ]);
+} else {
+ echo json_encode([
+ "success" => false,
+ "message" => translate('payment_not_renamed', $i18n)
+ ]);
+}
+
+?>
\ No newline at end of file
diff --git a/images/siteicons/draggable.png b/images/siteicons/draggable.png
new file mode 100644
index 0000000..55d8da3
Binary files /dev/null and b/images/siteicons/draggable.png differ
diff --git a/includes/getdbkeys.php b/includes/getdbkeys.php
index 0f0a874..6caaff1 100644
--- a/includes/getdbkeys.php
+++ b/includes/getdbkeys.php
@@ -26,7 +26,7 @@
}
$categories = array();
- $query = "SELECT * FROM categories";
+ $query = "SELECT * FROM categories ORDER BY `order` ASC";
$result = $db->query($query);
while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
$categoryId = $row['id'];
diff --git a/includes/i18n/de.php b/includes/i18n/de.php
index 632ed1a..82edb03 100644
--- a/includes/i18n/de.php
+++ b/includes/i18n/de.php
@@ -136,17 +136,24 @@ $i18n = [
"experimental_info" => "Experimentelle Einstellungen funktionieren möglicherweise nicht perfekt.",
"payment_methods" => "Zahlungsmethoden",
"payment_methods_info" => "Zahlungsmethode zum (de-)aktivieren anklicken.",
+ "rename_payment_methods_info" => "Klicken Sie auf den Namen einer Zahlungsmethode, um sie umzubenennen",
"cant_delete_payment_method_in_use" => "Genutzte Zahlungsmethoden können nicht deaktiviert werden",
"add_custom_payment" => "Eigene Zahlungsmethode hinzufügen",
"payment_method_name" => "Name der Zahlungsmethode",
"payment_method_added_successfuly" => "Zahlungsmethode erfolgreich hinzugefügt",
"disable" => "Deaktivieren",
"enable" => "Aktivieren",
+ "rename_payment_method" => "Zahlungsmethode umbenennen",
+ "payment_renamed" => "Zahlungsmethode umbenannt",
+ "payment_not_renamed" => "Zahlungsmethode konnte nicht umbenannt werden",
"test" => "Test",
"add" => "Hinzufügen",
"save" => "Speichern",
"export_subscriptions" => "Abonnements exportieren",
"export_to_json" => "Nach JSON exportieren",
+ // Filters menu
+ "filter" => "Filter",
+ "clear" => "Leeren",
// Toast
"success" => "Erfolgreich",
// Endpoint responses
@@ -162,6 +169,7 @@ $i18n = [
"failed_remove_category" => "Kategorie konnte nicht gelöscht werden",
"category_saved" => "Kategorie gespeichert",
"category_removed" => "Kategorie gelöscht",
+ "sort_order_saved" => "Sortierung gespeichert",
// Currency
"currency_saved" => "wurde gespeichert.",
"error_adding_currency" => "Fehler beim hinzufügen der Währung.",
diff --git a/includes/i18n/el.php b/includes/i18n/el.php
index f73753f..c4234c5 100644
--- a/includes/i18n/el.php
+++ b/includes/i18n/el.php
@@ -136,17 +136,24 @@ $i18n = [
"experimental_info" => "Οι πειραματικές ρυθμίσεις πιθανότατα δεν θα λειτουργούν τέλεια.",
"payment_methods" => "Τρόποι πληρωμής",
"payment_methods_info" => "Κάνε κλικ σε μια μέθοδο πληρωμής για να την απενεργοποιήσεις/ενεργοποιήσεις.",
+ "rename_payment_methods_info" => "Κάντε κλικ στο όνομα μιας μεθόδου πληρωμής για να τη μετονομάσετε.",
"cant_delete_payment_method_in_use" => "Δεν είναι εφικτό να απενεργοποιηθεί η χρησιμοποιούμενη μέθοδο πληρωμής",
"add_custom_payment" => "Προσθήκη προσαρμοσμένης μεθόδου πληρωμής",
"payment_method_name" => "Όνομα μεθόδου πληρωμής",
"payment_method_added_successfuly" => "Η μέθοδος πληρωμής προστέθηκε με επιτυχία",
"disable" => "Ανενεργό",
"enable" => "Ενεργό",
+ "rename_payment_method" => "Μετονομασία μεθόδου πληρωμής",
+ "payment_renamed" => "Η μέθοδος πληρωμής μετονομάστηκε",
+ "payment_not_renamed" => "Η μέθοδος πληρωμής δεν μετονομάστηκε",
"test" => "Δοκιμή",
"add" => "Προσθήκη",
"save" => "Αποθήκευση",
"export_subscriptions" => "Εξαγωγή συνδρομών",
"export_to_json" => "Εξαγωγή σε JSON",
+ // Filters menu
+ "filter" => "Φίλτρο",
+ "clear" => "Καθαρισμός",
// Toast
"success" => "Επιτυχία",
// Endpoint responses
@@ -162,6 +169,7 @@ $i18n = [
"failed_remove_category" => "Απέτυχε η διαγραφή κατηγορίας",
"category_saved" => "Αποθήκευση κατηγορίας",
"category_removed" => "Διαγραφή κατηγορίας",
+ "sort_order_saved" => "Η ταξινόμηση αποθηκεύτηκε",
// Currency
"currency_saved" => "αποθηκεύτηκε.",
"error_adding_currency" => "Error adding currency entry.",
diff --git a/includes/i18n/en.php b/includes/i18n/en.php
index b6d0692..cfcc650 100644
--- a/includes/i18n/en.php
+++ b/includes/i18n/en.php
@@ -136,17 +136,24 @@ $i18n = [
"experimental_info" => "Experimental settings will probably not work perfectly.",
"payment_methods" => "Payment Methods",
"payment_methods_info" => "Click a payment method to disable / enable it.",
+ "rename_payment_methods_info" => "Click the name on a payment method to rename it.",
"cant_delete_payment_method_in_use" => "Can't disable used payment method",
"add_custom_payment" => "Add Custom Payment Method",
"payment_method_name" => "Payment Method Name",
"payment_method_added_successfuly" => "Payment method added successfully",
"disable" => "Disable",
"enable" => "Enable",
+ "rename_payment_method" => "Rename Payment Method",
+ "payment_renamed" => "Payment method renamed",
+ "payment_not_renamed" => "Payment method not renamed",
"test" => "Test",
"add" => "Add",
"save" => "Save",
"export_subscriptions" => "Export Subscriptions",
"export_to_json" => "Export to JSON",
+ // Filters menu
+ "filter" => "Filter",
+ "clear" => "Clear",
// Toast
"success" => "Success",
// Endpoint responses
@@ -162,6 +169,7 @@ $i18n = [
"failed_remove_category" => "Failed to remove category",
"category_saved" => "Category saved",
"category_removed" => "Category removed",
+ "sort_order_saved" => "Sort order saved",
// Currency
"currency_saved" => "was saved.",
"error_adding_currency" => "Error adding currency entry.",
diff --git a/includes/i18n/es.php b/includes/i18n/es.php
index c0f60f8..44ee4e2 100644
--- a/includes/i18n/es.php
+++ b/includes/i18n/es.php
@@ -136,17 +136,24 @@ $i18n = [
"experimental_info" => "Las configuraciones experimentales probablemente no funcionarán perfectamente.",
"payment_methods" => "Métodos de Pago",
"payment_methods_info" => "Haz clic en un método de pago para deshabilitarlo/habilitarlo.",
+ "rename_payment_methods_info" => "Haz clic en el nombre de un método de pago para cambiarle el nombre.",
"cant_delete_payment_method_in_use" => "No se puede desactivar el método de pago utilizado",
"add_custom_payment" => "Añadir método de pago personalizado",
"payment_method_name" => "Nombre del método de pago",
"payment_method_added_successfuly" => "Método de pago añadido con éxito",
"disable" => "Desactivar",
"enable" => "Activar",
+ "rename_payment_method" => "Renombrar método de pago",
+ "payment_renamed" => "Método de pago renombrado",
+ "payment_not_renamed" => "Error al renombrar el método de pago",
"test" => "Probar",
"add" => "Agregar",
"save" => "Guardar",
"export_subscriptions" => "Exportar suscripciones",
"export_to_json" => "Exportar a JSON",
+ // Filters menu
+ "filter" => "Filtrar",
+ "clear" => "Limpiar",
// Toast
"success" => "Éxito",
// Endpoint responses
@@ -162,6 +169,7 @@ $i18n = [
"failed_remove_category" => "Error al eliminar la categoría",
"category_saved" => "Categoría guardada",
"category_removed" => "Categoría eliminada",
+ "sort_order_saved" => "Orden de clasificación guardado",
// Currency
"currency_saved" => "fue guardada.",
"error_adding_currency" => "Error al añadir la entrada de la moneda.",
diff --git a/includes/i18n/fr.php b/includes/i18n/fr.php
index ba844e3..e53ba7f 100644
--- a/includes/i18n/fr.php
+++ b/includes/i18n/fr.php
@@ -136,17 +136,24 @@ $i18n = [
"experimental_info" => "Les paramètres expérimentaux ne fonctionneront probablement pas parfaitement.",
"payment_methods" => "Méthodes de paiement",
"payment_methods_info" => "Cliquez sur une méthode de paiement pour la désactiver / l'activer.",
+ "rename_payment_methods_info" => "Cliquez sur le nom d'un mode de paiement pour le renommer.",
"cant_delete_payment_method_in_use" => "Impossible de désactiver la méthode de paiement utilisée",
"add_custom_payment" => "Ajouter un paiement personnalisé",
"payment_method_name" => "Nom de la méthode de paiement",
"payment_method_added_successfuly" => "Méthode de paiement ajoutée avec succès",
"disable" => "Désactiver",
"enable" => "Activer",
+ "rename_payment_method" => "Renommer la méthode de paiement",
+ "payment_renamed" => "Méthode de paiement renommée",
+ "payment_not_renamed" => "La méthode de paiement n'a pas été renommée",
"test" => "Test",
"add" => "Ajouter",
"save" => "Enregistrer",
"export_subscriptions" => "Exporter les abonnements",
"export_to_json" => "Exporter en JSON",
+ // Menu des filtes
+ "filter" => "Filtre",
+ "clear" => "Effacer",
// Toast
"success" => "Succès",
// Réponses de l'API
@@ -162,6 +169,7 @@ $i18n = [
"failed_remove_category" => "Échec de la suppression de la catégorie",
"category_saved" => "Catégorie enregistrée",
"category_removed" => "Catégorie supprimée",
+ "sort_order_saved" => "L'ordre de tri a été enregistré",
// Devise
"currency_saved" => "a été enregistrée.",
"error_adding_currency" => "Erreur lors de l'ajout de l'entrée de devise.",
diff --git a/includes/i18n/jp.php b/includes/i18n/jp.php
index d0d0b4a..ec3afd0 100644
--- a/includes/i18n/jp.php
+++ b/includes/i18n/jp.php
@@ -136,17 +136,24 @@ $i18n = [
"experimental_info" => "実験的な設定は、おそらく完全には機能しません。",
"payment_methods" => "支払い方法",
"payment_methods_info" => "支払い方法をクリックして無効/有効を切り替えます。",
+ "rename_payment_methods_info" => "支払い方法の名前をクリックして、名前を変更します。",
"cant_delete_payment_method_in_use" => "支払い方法が使用中のため無効にできません。",
"add_custom_payment" => "カスタム支払い方法を追加",
"payment_method_name" => "支払い方法名",
"payment_method_added_successfuly" => "支払い方法が追加されました",
"disable" => "無効",
"enable" => "有効",
+ "rename_payment_method" => "支払い方法の名前を変更",
+ "payment_renamed" => "支払い方法が変更されました",
+ "payment_not_renamed" => "支払い方法が変更されませんでした",
"test" => "テスト",
"add" => "追加",
"save" => "保存",
"export_subscriptions" => "購読をエクスポート",
"export_to_json" => "JSONにエクスポート",
+ // Filters menu
+ "filter" => "フィルタ",
+ "clear" => "クリア",
// Toast
"success" => "成功",
// Endpoint responses
@@ -162,6 +169,7 @@ $i18n = [
"failed_remove_category" => "カテゴリの削除に失敗",
"category_saved" => "カテゴリの保存",
"category_removed" => "カテゴリの削除",
+ "sort_order_saved" => "並べ替え順が保存されました",
// Currency
"currency_saved" => "通貨を保存",
"error_adding_currency" => "通貨エントリの追加エラー.",
diff --git a/includes/i18n/pt.php b/includes/i18n/pt.php
index 3f82490..3f5f584 100644
--- a/includes/i18n/pt.php
+++ b/includes/i18n/pt.php
@@ -136,17 +136,24 @@ $i18n = [
"experimental_info" => "Definições experimentais provavelmente não funcionarão correctamente.",
"payment_methods" => "Métodos de Pagamento",
"payment_methods_info" => "Clique num método de pagamento para o activar / desactivar.",
+ "rename_payment_methods_info" => "Clique no nome do método de pagamento para o renomear.",
"cant_delete_payment_method_in_use" => "Não pode desactivar metodo de pagamento em uso",
"add_custom_payment" => "Adicionar método de pagamento personalizado",
"payment_method_name" => "Nome do método de pagamento",
"payment_method_added_successfuly" => "Método de pagamento adicionado com sucesso",
"disable" => "Desactivar",
"enable" => "Activar",
+ "rename_payment_method" => "Renomear método de pagamento",
+ "payment_renamed" => "Método de pagamento renomeado",
+ "payment_not_renamed" => "Método de pagamento não renomeado",
"test" => "Testar",
"add" => "Adicionar",
"save" => "Guardar",
"export_subscriptions" => "Exportar Subscrições",
"export_to_json" => "Exportar para JSON",
+ // Filters menu
+ "filter" => "Filtro",
+ "clear" => "Limpar",
// Toast
"success" => "Sucesso",
// Endpoint responses
@@ -162,6 +169,7 @@ $i18n = [
"failed_remove_category" => "Erro ao remover categoria",
"category_saved" => "Categoria guardada",
"category_removed" => "Categoria removida",
+ "sort_order_saved" => "Ordenação guardada",
// Currency
"currency_saved" => "guardada.",
"error_adding_currency" => "Erro ao adicionar moeda.",
diff --git a/includes/i18n/tr.php b/includes/i18n/tr.php
index 15a7c90..8d05ede 100644
--- a/includes/i18n/tr.php
+++ b/includes/i18n/tr.php
@@ -136,17 +136,24 @@ $i18n = [
"experimental_info" => "Deneysel ayarlar muhtemelen mükemmel çalışmayacak.",
"payment_methods" => "Ödeme Yöntemleri",
"payment_methods_info" => "Bir ödeme yöntemini devre dışı bırakmak / etkinleştirmek için tıklayın.",
+ "rename_payment_methods_info" => "Yeniden adlandırmak için bir ödeme yönteminin adına tıklayın.",
"cant_delete_payment_method_in_use" => "Kullanımda olan ödeme yöntemini devre dışı bırakamazsınız",
"add_custom_payment" => "Özel ödeme yöntemi ekle",
"payment_method_name" => "Ödeme Yöntemi Adı",
"payment_method_added_successfuly" => "Ödeme yöntemi başarıyla eklendi",
"disable" => "Devre Dışı Bırak",
"enable" => "Etkinleştir",
+ "rename_payment_method" => "Ödeme yöntemi adını değiştir",
+ "payment_renamed" => "Ödeme yöntemi adı değiştirildi",
+ "payment_not_renamed" => "Ödeme yöntemi adı değiştirilemedi",
"test" => "Test Et",
"add" => "Ekle",
"save" => "Kaydet",
"export_subscriptions" => "Abonelikleri Dışa Aktar",
"export_to_json" => "JSON'a dışa aktar",
+ // Filters menu
+ "filter" => "Filtre",
+ "clear" => "Temizle",
// Toast
"success" => "Başarılı",
// Endpoint responses
@@ -162,6 +169,7 @@ $i18n = [
"failed_remove_category" => "Kategori kaldırılamadı",
"category_saved" => "Kategori kaydedildi",
"category_removed" => "Kategori kaldırıldı",
+ "sort_order_saved" => "Sıralama düzeni kaydedildi",
// Currency
"currency_saved" => "kaydedildi.",
"error_adding_currency" => "Para birimi girişi eklenirken hata oluştu.",
diff --git a/includes/i18n/zh_cn.php b/includes/i18n/zh_cn.php
index 859d7cb..405125c 100644
--- a/includes/i18n/zh_cn.php
+++ b/includes/i18n/zh_cn.php
@@ -143,17 +143,25 @@ $i18n = [
"experimental_info" => "实验性设置,可能存在问题。",
"payment_methods" => "支付方式",
"payment_methods_info" => "点击支付方式以禁用/启用。",
+ "rename_payment_methods_info" => "点击付款方式名称,重新命名该付款方式。"
"cant_delete_payment_method_in_use" => "不能禁用正在使用的支付方式",
"add_custom_payment" => "添加自定义支付方式",
"payment_method_name" => "支付方式名称",
"payment_method_added_successfuly" => "支付方式已成功添加",
"disable" => "禁用",
"enable" => "启用",
+ "rename_payment_method" => "重命名支付方式",
+ "payment_renamed" => "支付方式已重命名",
+ "payment_not_renamed" => "支付方式未重命名",
"test" => "测试",
"add" => "添加",
"save" => "保存",
"export_subscriptions" => "导出订阅",
"export_to_json" => "导出为 JSON",
+
+ // Filters menu
+ "filter" => "筛选",
+ "clear" => "清除",
// Toast
"success" => "成功",
@@ -172,6 +180,7 @@ $i18n = [
"failed_remove_category" => "移除分类失败",
"category_saved" => "分类已保存",
"category_removed" => "分类已移除",
+ "sort_order_saved" => "排序顺序已保存",
// Currency
"currency_saved" => "货币已保存。",
diff --git a/includes/i18n/zh_tw.php b/includes/i18n/zh_tw.php
index 5cb2332..6838f4b 100644
--- a/includes/i18n/zh_tw.php
+++ b/includes/i18n/zh_tw.php
@@ -136,17 +136,24 @@ $i18n = [
"experimental_info" => "實驗性設定,可能存在問題。",
"payment_methods" => "付款方式",
"payment_methods_info" => "點選付款方式以停用/啟用。",
+ "rename_payment_methods_info" => "點選付款方式的名稱可對其進行重新命名。",
"cant_delete_payment_method_in_use" => "無法停用正在使用的付款方式",
"add_custom_payment" => "新增自訂付款方式",
"payment_method_name" => "付款方式名稱",
"payment_method_added_successfuly" => "付款方式已成功新增",
"disable" => "停用",
"enable" => "啟用",
+ "rename_payment_method" => "更改付款方式名稱",
+ "payment_renamed" => "付款方式名稱已更改",
+ "payment_not_renamed" => "付款方式名稱未更改",
"test" => "測試",
"add" => "新增",
"save" => "儲存",
"export_subscriptions" => "匯出訂閱",
"export_to_json" => "匯出為 JSON 檔案",
+ // Filters menu
+ "filter" => "篩選",
+ "clear" => "清除",
// Toast
"success" => "成功",
// Endpoint responses
@@ -162,6 +169,7 @@ $i18n = [
"failed_remove_category" => "移除分類失敗",
"category_saved" => "分類已儲存",
"category_removed" => "分類已移除",
+ "sort_order_saved" => "排序順序已儲存",
// Currency
"currency_saved" => "已儲存。",
"error_adding_currency" => "新增貨幣時發生錯誤。",
diff --git a/includes/version.php b/includes/version.php
index ee4e48b..4a16bfe 100644
--- a/includes/version.php
+++ b/includes/version.php
@@ -1,3 +1,3 @@
<?php
- $version = "v1.11.3";
+ $version = "v1.12.0";
?>
\ No newline at end of file
diff --git a/migrations/000010.php b/migrations/000010.php
new file mode 100644
index 0000000..5c65e19
--- /dev/null
+++ b/migrations/000010.php
@@ -0,0 +1,14 @@
+<?php
+ // This migration adds a "order" column to the categories table so that they can be sorted and initializes all values to their id.
+
+ /** @noinspection PhpUndefinedVariableInspection */
+ $columnQuery = $db->query("SELECT * FROM pragma_table_info('categories') WHERE name='order'");
+ $columnRequired = $columnQuery->fetchArray(SQLITE3_ASSOC) === false;
+
+ if ($columnRequired) {
+ $db->exec('ALTER TABLE categories ADD COLUMN `order` INTEGER DEFAULT 0');
+ $db->exec('UPDATE categories SET `order` = id');
+ }
+
+
+?>
\ No newline at end of file
diff --git a/scripts/libs/sortable.min.js b/scripts/libs/sortable.min.js
new file mode 100644
index 0000000..bb99533
--- /dev/null
+++ b/scripts/libs/sortable.min.js
@@ -0,0 +1,2 @@
+/*! Sortable 1.15.2 - MIT | git://github.com/SortableJS/Sortable.git */
+!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).Sortable=e()}(this,function(){"use strict";function e(e,t){var n,o=Object.keys(e);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(e),t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),o.push.apply(o,n)),o}function I(o){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?e(Object(i),!0).forEach(function(t){var e,n;e=o,t=i[n=t],n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(i)):e(Object(i)).forEach(function(t){Object.defineProperty(o,t,Object.getOwnPropertyDescriptor(i,t))})}return o}function o(t){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function a(){return(a=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n,o=arguments[e];for(n in o)Object.prototype.hasOwnProperty.call(o,n)&&(t[n]=o[n])}return t}).apply(this,arguments)}function i(t,e){if(null==t)return{};var n,o=function(t,e){if(null==t)return{};for(var n,o={},i=Object.keys(t),r=0;r<i.length;r++)n=i[r],0<=e.indexOf(n)||(o[n]=t[n]);return o}(t,e);if(Object.getOwnPropertySymbols)for(var i=Object.getOwnPropertySymbols(t),r=0;r<i.length;r++)n=i[r],0<=e.indexOf(n)||Object.prototype.propertyIsEnumerable.call(t,n)&&(o[n]=t[n]);return o}function r(t){return function(t){if(Array.isArray(t))return l(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return l(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?l(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,o=new Array(e);n<e;n++)o[n]=t[n];return o}function t(t){if("undefined"!=typeof window&&window.navigator)return!!navigator.userAgent.match(t)}var y=t(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),w=t(/Edge/i),s=t(/firefox/i),u=t(/safari/i)&&!t(/chrome/i)&&!t(/android/i),n=t(/iP(ad|od|hone)/i),c=t(/chrome/i)&&t(/android/i),d={capture:!1,passive:!1};function h(t,e,n){t.addEventListener(e,n,!y&&d)}function f(t,e,n){t.removeEventListener(e,n,!y&&d)}function p(t,e){if(e&&(">"===e[0]&&(e=e.substring(1)),t))try{if(t.matches)return t.matches(e);if(t.msMatchesSelector)return t.msMatchesSelector(e);if(t.webkitMatchesSelector)return t.webkitMatchesSelector(e)}catch(t){return}}function P(t,e,n,o){if(t){n=n||document;do{if(null!=e&&(">"!==e[0]||t.parentNode===n)&&p(t,e)||o&&t===n)return t}while(t!==n&&(t=(i=t).host&&i!==document&&i.host.nodeType?i.host:i.parentNode))}var i;return null}var g,m=/\s+/g;function k(t,e,n){var o;t&&e&&(t.classList?t.classList[n?"add":"remove"](e):(o=(" "+t.className+" ").replace(m," ").replace(" "+e+" "," "),t.className=(o+(n?" "+e:"")).replace(m," ")))}function R(t,e,n){var o=t&&t.style;if(o){if(void 0===n)return document.defaultView&&document.defaultView.getComputedStyle?n=document.defaultView.getComputedStyle(t,""):t.currentStyle&&(n=t.currentStyle),void 0===e?n:n[e];o[e=!(e in o||-1!==e.indexOf("webkit"))?"-webkit-"+e:e]=n+("string"==typeof n?"":"px")}}function v(t,e){var n="";if("string"==typeof t)n=t;else do{var o=R(t,"transform")}while(o&&"none"!==o&&(n=o+" "+n),!e&&(t=t.parentNode));var i=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return i&&new i(n)}function b(t,e,n){if(t){var o=t.getElementsByTagName(e),i=0,r=o.length;if(n)for(;i<r;i++)n(o[i],i);return o}return[]}function O(){var t=document.scrollingElement;return t||document.documentElement}function X(t,e,n,o,i){if(t.getBoundingClientRect||t===window){var r,a,l,s,c,u,d=t!==window&&t.parentNode&&t!==O()?(a=(r=t.getBoundingClientRect()).top,l=r.left,s=r.bottom,c=r.right,u=r.height,r.width):(l=a=0,s=window.innerHeight,c=window.innerWidth,u=window.innerHeight,window.innerWidth);if((e||n)&&t!==window&&(i=i||t.parentNode,!y))do{if(i&&i.getBoundingClientRect&&("none"!==R(i,"transform")||n&&"static"!==R(i,"position"))){var h=i.getBoundingClientRect();a-=h.top+parseInt(R(i,"border-top-width")),l-=h.left+parseInt(R(i,"border-left-width")),s=a+r.height,c=l+r.width;break}}while(i=i.parentNode);return o&&t!==window&&(o=(e=v(i||t))&&e.a,t=e&&e.d,e&&(s=(a/=t)+(u/=t),c=(l/=o)+(d/=o))),{top:a,left:l,bottom:s,right:c,width:d,height:u}}}function Y(t,e,n){for(var o=M(t,!0),i=X(t)[e];o;){var r=X(o)[n];if(!("top"===n||"left"===n?r<=i:i<=r))return o;if(o===O())break;o=M(o,!1)}return!1}function B(t,e,n,o){for(var i=0,r=0,a=t.children;r<a.length;){if("none"!==a[r].style.display&&a[r]!==Ft.ghost&&(o||a[r]!==Ft.dragged)&&P(a[r],n.draggable,t,!1)){if(i===e)return a[r];i++}r++}return null}function F(t,e){for(var n=t.lastElementChild;n&&(n===Ft.ghost||"none"===R(n,"display")||e&&!p(n,e));)n=n.previousElementSibling;return n||null}function j(t,e){var n=0;if(!t||!t.parentNode)return-1;for(;t=t.previousElementSibling;)"TEMPLATE"===t.nodeName.toUpperCase()||t===Ft.clone||e&&!p(t,e)||n++;return n}function E(t){var e=0,n=0,o=O();if(t)do{var i=v(t),r=i.a,i=i.d}while(e+=t.scrollLeft*r,n+=t.scrollTop*i,t!==o&&(t=t.parentNode));return[e,n]}function M(t,e){if(!t||!t.getBoundingClientRect)return O();var n=t,o=!1;do{if(n.clientWidth<n.scrollWidth||n.clientHeight<n.scrollHeight){var i=R(n);if(n.clientWidth<n.scrollWidth&&("auto"==i.overflowX||"scroll"==i.overflowX)||n.clientHeight<n.scrollHeight&&("auto"==i.overflowY||"scroll"==i.overflowY)){if(!n.getBoundingClientRect||n===document.body)return O();if(o||e)return n;o=!0}}}while(n=n.parentNode);return O()}function D(t,e){return Math.round(t.top)===Math.round(e.top)&&Math.round(t.left)===Math.round(e.left)&&Math.round(t.height)===Math.round(e.height)&&Math.round(t.width)===Math.round(e.width)}function S(e,n){return function(){var t;g||(1===(t=arguments).length?e.call(this,t[0]):e.apply(this,t),g=setTimeout(function(){g=void 0},n))}}function H(t,e,n){t.scrollLeft+=e,t.scrollTop+=n}function _(t){var e=window.Polymer,n=window.jQuery||window.Zepto;return e&&e.dom?e.dom(t).cloneNode(!0):n?n(t).clone(!0)[0]:t.cloneNode(!0)}function C(t,e){R(t,"position","absolute"),R(t,"top",e.top),R(t,"left",e.left),R(t,"width",e.width),R(t,"height",e.height)}function T(t){R(t,"position",""),R(t,"top",""),R(t,"left",""),R(t,"width",""),R(t,"height","")}function L(n,o,i){var r={};return Array.from(n.children).forEach(function(t){var e;P(t,o.draggable,n,!1)&&!t.animated&&t!==i&&(e=X(t),r.left=Math.min(null!==(t=r.left)&&void 0!==t?t:1/0,e.left),r.top=Math.min(null!==(t=r.top)&&void 0!==t?t:1/0,e.top),r.right=Math.max(null!==(t=r.right)&&void 0!==t?t:-1/0,e.right),r.bottom=Math.max(null!==(t=r.bottom)&&void 0!==t?t:-1/0,e.bottom))}),r.width=r.right-r.left,r.height=r.bottom-r.top,r.x=r.left,r.y=r.top,r}var K="Sortable"+(new Date).getTime();function x(){var e,o=[];return{captureAnimationState:function(){o=[],this.options.animation&&[].slice.call(this.el.children).forEach(function(t){var e,n;"none"!==R(t,"display")&&t!==Ft.ghost&&(o.push({target:t,rect:X(t)}),e=I({},o[o.length-1].rect),!t.thisAnimationDuration||(n=v(t,!0))&&(e.top-=n.f,e.left-=n.e),t.fromRect=e)})},addAnimationState:function(t){o.push(t)},removeAnimationState:function(t){o.splice(function(t,e){for(var n in t)if(t.hasOwnProperty(n))for(var o in e)if(e.hasOwnProperty(o)&&e[o]===t[n][o])return Number(n);return-1}(o,{target:t}),1)},animateAll:function(t){var c=this;if(!this.options.animation)return clearTimeout(e),void("function"==typeof t&&t());var u=!1,d=0;o.forEach(function(t){var e=0,n=t.target,o=n.fromRect,i=X(n),r=n.prevFromRect,a=n.prevToRect,l=t.rect,s=v(n,!0);s&&(i.top-=s.f,i.left-=s.e),n.toRect=i,n.thisAnimationDuration&&D(r,i)&&!D(o,i)&&(l.top-i.top)/(l.left-i.left)==(o.top-i.top)/(o.left-i.left)&&(t=l,s=r,r=a,a=c.options,e=Math.sqrt(Math.pow(s.top-t.top,2)+Math.pow(s.left-t.left,2))/Math.sqrt(Math.pow(s.top-r.top,2)+Math.pow(s.left-r.left,2))*a.animation),D(i,o)||(n.prevFromRect=o,n.prevToRect=i,e=e||c.options.animation,c.animate(n,l,i,e)),e&&(u=!0,d=Math.max(d,e),clearTimeout(n.animationResetTimer),n.animationResetTimer=setTimeout(function(){n.animationTime=0,n.prevFromRect=null,n.fromRect=null,n.prevToRect=null,n.thisAnimationDuration=null},e),n.thisAnimationDuration=e)}),clearTimeout(e),u?e=setTimeout(function(){"function"==typeof t&&t()},d):"function"==typeof t&&t(),o=[]},animate:function(t,e,n,o){var i,r;o&&(R(t,"transition",""),R(t,"transform",""),i=(r=v(this.el))&&r.a,r=r&&r.d,i=(e.left-n.left)/(i||1),r=(e.top-n.top)/(r||1),t.animatingX=!!i,t.animatingY=!!r,R(t,"transform","translate3d("+i+"px,"+r+"px,0)"),this.forRepaintDummy=t.offsetWidth,R(t,"transition","transform "+o+"ms"+(this.options.easing?" "+this.options.easing:"")),R(t,"transform","translate3d(0,0,0)"),"number"==typeof t.animated&&clearTimeout(t.animated),t.animated=setTimeout(function(){R(t,"transition",""),R(t,"transform",""),t.animated=!1,t.animatingX=!1,t.animatingY=!1},o))}}}var A=[],N={initializeByDefault:!0},W={mount:function(e){for(var t in N)!N.hasOwnProperty(t)||t in e||(e[t]=N[t]);A.forEach(function(t){if(t.pluginName===e.pluginName)throw"Sortable: Cannot mount plugin ".concat(e.pluginName," more than once")}),A.push(e)},pluginEvent:function(e,n,o){var t=this;this.eventCanceled=!1,o.cancel=function(){t.eventCanceled=!0};var i=e+"Global";A.forEach(function(t){n[t.pluginName]&&(n[t.pluginName][i]&&n[t.pluginName][i](I({sortable:n},o)),n.options[t.pluginName]&&n[t.pluginName][e]&&n[t.pluginName][e](I({sortable:n},o)))})},initializePlugins:function(n,o,i,t){for(var e in A.forEach(function(t){var e=t.pluginName;(n.options[e]||t.initializeByDefault)&&((t=new t(n,o,n.options)).sortable=n,t.options=n.options,n[e]=t,a(i,t.defaults))}),n.options){var r;n.options.hasOwnProperty(e)&&(void 0!==(r=this.modifyOption(n,e,n.options[e]))&&(n.options[e]=r))}},getEventProperties:function(e,n){var o={};return A.forEach(function(t){"function"==typeof t.eventProperties&&a(o,t.eventProperties.call(n[t.pluginName],e))}),o},modifyOption:function(e,n,o){var i;return A.forEach(function(t){e[t.pluginName]&&t.optionListeners&&"function"==typeof t.optionListeners[n]&&(i=t.optionListeners[n].call(e[t.pluginName],o))}),i}};function z(t){var e=t.sortable,n=t.rootEl,o=t.name,i=t.targetEl,r=t.cloneEl,a=t.toEl,l=t.fromEl,s=t.oldIndex,c=t.newIndex,u=t.oldDraggableIndex,d=t.newDraggableIndex,h=t.originalEvent,f=t.putSortable,p=t.extraEventProperties;if(e=e||n&&n[K]){var g,m=e.options,t="on"+o.charAt(0).toUpperCase()+o.substr(1);!window.CustomEvent||y||w?(g=document.createEvent("Event")).initEvent(o,!0,!0):g=new CustomEvent(o,{bubbles:!0,cancelable:!0}),g.to=a||n,g.from=l||n,g.item=i||n,g.clone=r,g.oldIndex=s,g.newIndex=c,g.oldDraggableIndex=u,g.newDraggableIndex=d,g.originalEvent=h,g.pullMode=f?f.lastPutMode:void 0;var v,b=I(I({},p),W.getEventProperties(o,e));for(v in b)g[v]=b[v];n&&n.dispatchEvent(g),m[t]&&m[t].call(e,g)}}function G(t,e){var n=(o=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{}).evt,o=i(o,U);W.pluginEvent.bind(Ft)(t,e,I({dragEl:V,parentEl:Z,ghostEl:$,rootEl:Q,nextEl:J,lastDownEl:tt,cloneEl:et,cloneHidden:nt,dragStarted:gt,putSortable:st,activeSortable:Ft.active,originalEvent:n,oldIndex:ot,oldDraggableIndex:rt,newIndex:it,newDraggableIndex:at,hideGhostForTarget:Rt,unhideGhostForTarget:Xt,cloneNowHidden:function(){nt=!0},cloneNowShown:function(){nt=!1},dispatchSortableEvent:function(t){q({sortable:e,name:t,originalEvent:n})}},o))}var U=["evt"];function q(t){z(I({putSortable:st,cloneEl:et,targetEl:V,rootEl:Q,oldIndex:ot,oldDraggableIndex:rt,newIndex:it,newDraggableIndex:at},t))}var V,Z,$,Q,J,tt,et,nt,ot,it,rt,at,lt,st,ct,ut,dt,ht,ft,pt,gt,mt,vt,bt,yt,wt=!1,Et=!1,Dt=[],St=!1,_t=!1,Ct=[],Tt=!1,xt=[],Ot="undefined"!=typeof document,Mt=n,At=w||y?"cssFloat":"float",Nt=Ot&&!c&&!n&&"draggable"in document.createElement("div"),It=function(){if(Ot){if(y)return!1;var t=document.createElement("x");return t.style.cssText="pointer-events:auto","auto"===t.style.pointerEvents}}(),Pt=function(t,e){var n=R(t),o=parseInt(n.width)-parseInt(n.paddingLeft)-parseInt(n.paddingRight)-parseInt(n.borderLeftWidth)-parseInt(n.borderRightWidth),i=B(t,0,e),r=B(t,1,e),a=i&&R(i),l=r&&R(r),s=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+X(i).width,t=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+X(r).width;if("flex"===n.display)return"column"===n.flexDirection||"column-reverse"===n.flexDirection?"vertical":"horizontal";if("grid"===n.display)return n.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(i&&a.float&&"none"!==a.float){e="left"===a.float?"left":"right";return!r||"both"!==l.clear&&l.clear!==e?"horizontal":"vertical"}return i&&("block"===a.display||"flex"===a.display||"table"===a.display||"grid"===a.display||o<=s&&"none"===n[At]||r&&"none"===n[At]&&o<s+t)?"vertical":"horizontal"},kt=function(t){function l(r,a){return function(t,e,n,o){var i=t.options.group.name&&e.options.group.name&&t.options.group.name===e.options.group.name;if(null==r&&(a||i))return!0;if(null==r||!1===r)return!1;if(a&&"clone"===r)return r;if("function"==typeof r)return l(r(t,e,n,o),a)(t,e,n,o);e=(a?t:e).options.group.name;return!0===r||"string"==typeof r&&r===e||r.join&&-1<r.indexOf(e)}}var e={},n=t.group;n&&"object"==o(n)||(n={name:n}),e.name=n.name,e.checkPull=l(n.pull,!0),e.checkPut=l(n.put),e.revertClone=n.revertClone,t.group=e},Rt=function(){!It&&$&&R($,"display","none")},Xt=function(){!It&&$&&R($,"display","")};Ot&&!c&&document.addEventListener("click",function(t){if(Et)return t.preventDefault(),t.stopPropagation&&t.stopPropagation(),t.stopImmediatePropagation&&t.stopImmediatePropagation(),Et=!1},!0);function Yt(t){if(V){t=t.touches?t.touches[0]:t;var e=(i=t.clientX,r=t.clientY,Dt.some(function(t){var e=t[K].options.emptyInsertThreshold;if(e&&!F(t)){var n=X(t),o=i>=n.left-e&&i<=n.right+e,e=r>=n.top-e&&r<=n.bottom+e;return o&&e?a=t:void 0}}),a);if(e){var n,o={};for(n in t)t.hasOwnProperty(n)&&(o[n]=t[n]);o.target=o.rootEl=e,o.preventDefault=void 0,o.stopPropagation=void 0,e[K]._onDragOver(o)}}var i,r,a}function Bt(t){V&&V.parentNode[K]._isOutsideThisEl(t.target)}function Ft(t,e){if(!t||!t.nodeType||1!==t.nodeType)throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(t));this.el=t,this.options=e=a({},e),t[K]=this;var n,o,i={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(t.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return Pt(t,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(t,e){t.setData("Text",e.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:!1!==Ft.supportPointer&&"PointerEvent"in window&&!u,emptyInsertThreshold:5};for(n in W.initializePlugins(this,t,i),i)n in e||(e[n]=i[n]);for(o in kt(e),this)"_"===o.charAt(0)&&"function"==typeof this[o]&&(this[o]=this[o].bind(this));this.nativeDraggable=!e.forceFallback&&Nt,this.nativeDraggable&&(this.options.touchStartThreshold=1),e.supportPointer?h(t,"pointerdown",this._onTapStart):(h(t,"mousedown",this._onTapStart),h(t,"touchstart",this._onTapStart)),this.nativeDraggable&&(h(t,"dragover",this),h(t,"dragenter",this)),Dt.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[]),a(this,x())}function jt(t,e,n,o,i,r,a,l){var s,c,u=t[K],d=u.options.onMove;return!window.CustomEvent||y||w?(s=document.createEvent("Event")).initEvent("move",!0,!0):s=new CustomEvent("move",{bubbles:!0,cancelable:!0}),s.to=e,s.from=t,s.dragged=n,s.draggedRect=o,s.related=i||e,s.relatedRect=r||X(e),s.willInsertAfter=l,s.originalEvent=a,t.dispatchEvent(s),c=d?d.call(u,s,a):c}function Ht(t){t.draggable=!1}function Lt(){Tt=!1}function Kt(t){return setTimeout(t,0)}function Wt(t){return clearTimeout(t)}Ft.prototype={constructor:Ft,_isOutsideThisEl:function(t){this.el.contains(t)||t===this.el||(mt=null)},_getDirection:function(t,e){return"function"==typeof this.options.direction?this.options.direction.call(this,t,e,V):this.options.direction},_onTapStart:function(e){if(e.cancelable){var n=this,o=this.el,t=this.options,i=t.preventOnFilter,r=e.type,a=e.touches&&e.touches[0]||e.pointerType&&"touch"===e.pointerType&&e,l=(a||e).target,s=e.target.shadowRoot&&(e.path&&e.path[0]||e.composedPath&&e.composedPath()[0])||l,c=t.filter;if(!function(t){xt.length=0;var e=t.getElementsByTagName("input"),n=e.length;for(;n--;){var o=e[n];o.checked&&xt.push(o)}}(o),!V&&!(/mousedown|pointerdown/.test(r)&&0!==e.button||t.disabled)&&!s.isContentEditable&&(this.nativeDraggable||!u||!l||"SELECT"!==l.tagName.toUpperCase())&&!((l=P(l,t.draggable,o,!1))&&l.animated||tt===l)){if(ot=j(l),rt=j(l,t.draggable),"function"==typeof c){if(c.call(this,e,l,this))return q({sortable:n,rootEl:s,name:"filter",targetEl:l,toEl:o,fromEl:o}),G("filter",n,{evt:e}),void(i&&e.cancelable&&e.preventDefault())}else if(c=c&&c.split(",").some(function(t){if(t=P(s,t.trim(),o,!1))return q({sortable:n,rootEl:t,name:"filter",targetEl:l,fromEl:o,toEl:o}),G("filter",n,{evt:e}),!0}))return void(i&&e.cancelable&&e.preventDefault());t.handle&&!P(s,t.handle,o,!1)||this._prepareDragStart(e,a,l)}}},_prepareDragStart:function(t,e,n){var o,i=this,r=i.el,a=i.options,l=r.ownerDocument;n&&!V&&n.parentNode===r&&(o=X(n),Q=r,Z=(V=n).parentNode,J=V.nextSibling,tt=n,lt=a.group,ct={target:Ft.dragged=V,clientX:(e||t).clientX,clientY:(e||t).clientY},ft=ct.clientX-o.left,pt=ct.clientY-o.top,this._lastX=(e||t).clientX,this._lastY=(e||t).clientY,V.style["will-change"]="all",o=function(){G("delayEnded",i,{evt:t}),Ft.eventCanceled?i._onDrop():(i._disableDelayedDragEvents(),!s&&i.nativeDraggable&&(V.draggable=!0),i._triggerDragStart(t,e),q({sortable:i,name:"choose",originalEvent:t}),k(V,a.chosenClass,!0))},a.ignore.split(",").forEach(function(t){b(V,t.trim(),Ht)}),h(l,"dragover",Yt),h(l,"mousemove",Yt),h(l,"touchmove",Yt),h(l,"mouseup",i._onDrop),h(l,"touchend",i._onDrop),h(l,"touchcancel",i._onDrop),s&&this.nativeDraggable&&(this.options.touchStartThreshold=4,V.draggable=!0),G("delayStart",this,{evt:t}),!a.delay||a.delayOnTouchOnly&&!e||this.nativeDraggable&&(w||y)?o():Ft.eventCanceled?this._onDrop():(h(l,"mouseup",i._disableDelayedDrag),h(l,"touchend",i._disableDelayedDrag),h(l,"touchcancel",i._disableDelayedDrag),h(l,"mousemove",i._delayedDragTouchMoveHandler),h(l,"touchmove",i._delayedDragTouchMoveHandler),a.supportPointer&&h(l,"pointermove",i._delayedDragTouchMoveHandler),i._dragStartTimer=setTimeout(o,a.delay)))},_delayedDragTouchMoveHandler:function(t){t=t.touches?t.touches[0]:t;Math.max(Math.abs(t.clientX-this._lastX),Math.abs(t.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){V&&Ht(V),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var t=this.el.ownerDocument;f(t,"mouseup",this._disableDelayedDrag),f(t,"touchend",this._disableDelayedDrag),f(t,"touchcancel",this._disableDelayedDrag),f(t,"mousemove",this._delayedDragTouchMoveHandler),f(t,"touchmove",this._delayedDragTouchMoveHandler),f(t,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(t,e){e=e||"touch"==t.pointerType&&t,!this.nativeDraggable||e?this.options.supportPointer?h(document,"pointermove",this._onTouchMove):h(document,e?"touchmove":"mousemove",this._onTouchMove):(h(V,"dragend",this),h(Q,"dragstart",this._onDragStart));try{document.selection?Kt(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch(t){}},_dragStarted:function(t,e){var n;wt=!1,Q&&V?(G("dragStarted",this,{evt:e}),this.nativeDraggable&&h(document,"dragover",Bt),n=this.options,t||k(V,n.dragClass,!1),k(V,n.ghostClass,!0),Ft.active=this,t&&this._appendGhost(),q({sortable:this,name:"start",originalEvent:e})):this._nulling()},_emulateDragOver:function(){if(ut){this._lastX=ut.clientX,this._lastY=ut.clientY,Rt();for(var t=document.elementFromPoint(ut.clientX,ut.clientY),e=t;t&&t.shadowRoot&&(t=t.shadowRoot.elementFromPoint(ut.clientX,ut.clientY))!==e;)e=t;if(V.parentNode[K]._isOutsideThisEl(t),e)do{if(e[K])if(e[K]._onDragOver({clientX:ut.clientX,clientY:ut.clientY,target:t,rootEl:e})&&!this.options.dragoverBubble)break}while(e=(t=e).parentNode);Xt()}},_onTouchMove:function(t){if(ct){var e=this.options,n=e.fallbackTolerance,o=e.fallbackOffset,i=t.touches?t.touches[0]:t,r=$&&v($,!0),a=$&&r&&r.a,l=$&&r&&r.d,e=Mt&&yt&&E(yt),a=(i.clientX-ct.clientX+o.x)/(a||1)+(e?e[0]-Ct[0]:0)/(a||1),l=(i.clientY-ct.clientY+o.y)/(l||1)+(e?e[1]-Ct[1]:0)/(l||1);if(!Ft.active&&!wt){if(n&&Math.max(Math.abs(i.clientX-this._lastX),Math.abs(i.clientY-this._lastY))<n)return;this._onDragStart(t,!0)}$&&(r?(r.e+=a-(dt||0),r.f+=l-(ht||0)):r={a:1,b:0,c:0,d:1,e:a,f:l},r="matrix(".concat(r.a,",").concat(r.b,",").concat(r.c,",").concat(r.d,",").concat(r.e,",").concat(r.f,")"),R($,"webkitTransform",r),R($,"mozTransform",r),R($,"msTransform",r),R($,"transform",r),dt=a,ht=l,ut=i),t.cancelable&&t.preventDefault()}},_appendGhost:function(){if(!$){var t=this.options.fallbackOnBody?document.body:Q,e=X(V,!0,Mt,!0,t),n=this.options;if(Mt){for(yt=t;"static"===R(yt,"position")&&"none"===R(yt,"transform")&&yt!==document;)yt=yt.parentNode;yt!==document.body&&yt!==document.documentElement?(yt===document&&(yt=O()),e.top+=yt.scrollTop,e.left+=yt.scrollLeft):yt=O(),Ct=E(yt)}k($=V.cloneNode(!0),n.ghostClass,!1),k($,n.fallbackClass,!0),k($,n.dragClass,!0),R($,"transition",""),R($,"transform",""),R($,"box-sizing","border-box"),R($,"margin",0),R($,"top",e.top),R($,"left",e.left),R($,"width",e.width),R($,"height",e.height),R($,"opacity","0.8"),R($,"position",Mt?"absolute":"fixed"),R($,"zIndex","100000"),R($,"pointerEvents","none"),Ft.ghost=$,t.appendChild($),R($,"transform-origin",ft/parseInt($.style.width)*100+"% "+pt/parseInt($.style.height)*100+"%")}},_onDragStart:function(t,e){var n=this,o=t.dataTransfer,i=n.options;G("dragStart",this,{evt:t}),Ft.eventCanceled?this._onDrop():(G("setupClone",this),Ft.eventCanceled||((et=_(V)).removeAttribute("id"),et.draggable=!1,et.style["will-change"]="",this._hideClone(),k(et,this.options.chosenClass,!1),Ft.clone=et),n.cloneId=Kt(function(){G("clone",n),Ft.eventCanceled||(n.options.removeCloneOnHide||Q.insertBefore(et,V),n._hideClone(),q({sortable:n,name:"clone"}))}),e||k(V,i.dragClass,!0),e?(Et=!0,n._loopId=setInterval(n._emulateDragOver,50)):(f(document,"mouseup",n._onDrop),f(document,"touchend",n._onDrop),f(document,"touchcancel",n._onDrop),o&&(o.effectAllowed="move",i.setData&&i.setData.call(n,o,V)),h(document,"drop",n),R(V,"transform","translateZ(0)")),wt=!0,n._dragStartId=Kt(n._dragStarted.bind(n,e,t)),h(document,"selectstart",n),gt=!0,u&&R(document.body,"user-select","none"))},_onDragOver:function(n){var o,i,r,t,e,a=this.el,l=n.target,s=this.options,c=s.group,u=Ft.active,d=lt===c,h=s.sort,f=st||u,p=this,g=!1;if(!Tt){if(void 0!==n.preventDefault&&n.cancelable&&n.preventDefault(),l=P(l,s.draggable,a,!0),O("dragOver"),Ft.eventCanceled)return g;if(V.contains(n.target)||l.animated&&l.animatingX&&l.animatingY||p._ignoreWhileAnimating===l)return A(!1);if(Et=!1,u&&!s.disabled&&(d?h||(i=Z!==Q):st===this||(this.lastPutMode=lt.checkPull(this,u,V,n))&&c.checkPut(this,u,V,n))){if(r="vertical"===this._getDirection(n,l),o=X(V),O("dragOverValid"),Ft.eventCanceled)return g;if(i)return Z=Q,M(),this._hideClone(),O("revert"),Ft.eventCanceled||(J?Q.insertBefore(V,J):Q.appendChild(V)),A(!0);var m=F(a,s.draggable);if(m&&(S=n,c=r,x=X(F((D=this).el,D.options.draggable)),D=L(D.el,D.options,$),!(c?S.clientX>D.right+10||S.clientY>x.bottom&&S.clientX>x.left:S.clientY>D.bottom+10||S.clientX>x.right&&S.clientY>x.top)||m.animated)){if(m&&(t=n,e=r,C=X(B((_=this).el,0,_.options,!0)),_=L(_.el,_.options,$),e?t.clientX<_.left-10||t.clientY<C.top&&t.clientX<C.right:t.clientY<_.top-10||t.clientY<C.bottom&&t.clientX<C.left)){var v=B(a,0,s,!0);if(v===V)return A(!1);if(E=X(l=v),!1!==jt(Q,a,V,o,l,E,n,!1))return M(),a.insertBefore(V,v),Z=a,N(),A(!0)}else if(l.parentNode===a){var b,y,w,E=X(l),D=V.parentNode!==a,S=(S=V.animated&&V.toRect||o,x=l.animated&&l.toRect||E,_=(e=r)?S.left:S.top,t=e?S.right:S.bottom,C=e?S.width:S.height,v=e?x.left:x.top,S=e?x.right:x.bottom,x=e?x.width:x.height,!(_===v||t===S||_+C/2===v+x/2)),_=r?"top":"left",C=Y(l,"top","top")||Y(V,"top","top"),v=C?C.scrollTop:void 0;if(mt!==l&&(y=E[_],St=!1,_t=!S&&s.invertSwap||D),0!==(b=function(t,e,n,o,i,r,a,l){var s=o?t.clientY:t.clientX,c=o?n.height:n.width,t=o?n.top:n.left,o=o?n.bottom:n.right,n=!1;if(!a)if(l&&bt<c*i){if(St=!St&&(1===vt?t+c*r/2<s:s<o-c*r/2)?!0:St)n=!0;else if(1===vt?s<t+bt:o-bt<s)return-vt}else if(t+c*(1-i)/2<s&&s<o-c*(1-i)/2)return function(t){return j(V)<j(t)?1:-1}(e);if((n=n||a)&&(s<t+c*r/2||o-c*r/2<s))return t+c/2<s?1:-1;return 0}(n,l,E,r,S?1:s.swapThreshold,null==s.invertedSwapThreshold?s.swapThreshold:s.invertedSwapThreshold,_t,mt===l)))for(var T=j(V);(w=Z.children[T-=b])&&("none"===R(w,"display")||w===$););if(0===b||w===l)return A(!1);vt=b;var x=(mt=l).nextElementSibling,D=!1,S=jt(Q,a,V,o,l,E,n,D=1===b);if(!1!==S)return 1!==S&&-1!==S||(D=1===S),Tt=!0,setTimeout(Lt,30),M(),D&&!x?a.appendChild(V):l.parentNode.insertBefore(V,D?x:l),C&&H(C,0,v-C.scrollTop),Z=V.parentNode,void 0===y||_t||(bt=Math.abs(y-X(l)[_])),N(),A(!0)}}else{if(m===V)return A(!1);if((l=m&&a===n.target?m:l)&&(E=X(l)),!1!==jt(Q,a,V,o,l,E,n,!!l))return M(),m&&m.nextSibling?a.insertBefore(V,m.nextSibling):a.appendChild(V),Z=a,N(),A(!0)}if(a.contains(V))return A(!1)}return!1}function O(t,e){G(t,p,I({evt:n,isOwner:d,axis:r?"vertical":"horizontal",revert:i,dragRect:o,targetRect:E,canSort:h,fromSortable:f,target:l,completed:A,onMove:function(t,e){return jt(Q,a,V,o,t,X(t),n,e)},changed:N},e))}function M(){O("dragOverAnimationCapture"),p.captureAnimationState(),p!==f&&f.captureAnimationState()}function A(t){return O("dragOverCompleted",{insertion:t}),t&&(d?u._hideClone():u._showClone(p),p!==f&&(k(V,(st||u).options.ghostClass,!1),k(V,s.ghostClass,!0)),st!==p&&p!==Ft.active?st=p:p===Ft.active&&st&&(st=null),f===p&&(p._ignoreWhileAnimating=l),p.animateAll(function(){O("dragOverAnimationComplete"),p._ignoreWhileAnimating=null}),p!==f&&(f.animateAll(),f._ignoreWhileAnimating=null)),(l===V&&!V.animated||l===a&&!l.animated)&&(mt=null),s.dragoverBubble||n.rootEl||l===document||(V.parentNode[K]._isOutsideThisEl(n.target),t||Yt(n)),!s.dragoverBubble&&n.stopPropagation&&n.stopPropagation(),g=!0}function N(){it=j(V),at=j(V,s.draggable),q({sortable:p,name:"change",toEl:a,newIndex:it,newDraggableIndex:at,originalEvent:n})}},_ignoreWhileAnimating:null,_offMoveEvents:function(){f(document,"mousemove",this._onTouchMove),f(document,"touchmove",this._onTouchMove),f(document,"pointermove",this._onTouchMove),f(document,"dragover",Yt),f(document,"mousemove",Yt),f(document,"touchmove",Yt)},_offUpEvents:function(){var t=this.el.ownerDocument;f(t,"mouseup",this._onDrop),f(t,"touchend",this._onDrop),f(t,"pointerup",this._onDrop),f(t,"touchcancel",this._onDrop),f(document,"selectstart",this)},_onDrop:function(t){var e=this.el,n=this.options;it=j(V),at=j(V,n.draggable),G("drop",this,{evt:t}),Z=V&&V.parentNode,it=j(V),at=j(V,n.draggable),Ft.eventCanceled||(St=_t=wt=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),Wt(this.cloneId),Wt(this._dragStartId),this.nativeDraggable&&(f(document,"drop",this),f(e,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),u&&R(document.body,"user-select",""),R(V,"transform",""),t&&(gt&&(t.cancelable&&t.preventDefault(),n.dropBubble||t.stopPropagation()),$&&$.parentNode&&$.parentNode.removeChild($),(Q===Z||st&&"clone"!==st.lastPutMode)&&et&&et.parentNode&&et.parentNode.removeChild(et),V&&(this.nativeDraggable&&f(V,"dragend",this),Ht(V),V.style["will-change"]="",gt&&!wt&&k(V,(st||this).options.ghostClass,!1),k(V,this.options.chosenClass,!1),q({sortable:this,name:"unchoose",toEl:Z,newIndex:null,newDraggableIndex:null,originalEvent:t}),Q!==Z?(0<=it&&(q({rootEl:Z,name:"add",toEl:Z,fromEl:Q,originalEvent:t}),q({sortable:this,name:"remove",toEl:Z,originalEvent:t}),q({rootEl:Z,name:"sort",toEl:Z,fromEl:Q,originalEvent:t}),q({sortable:this,name:"sort",toEl:Z,originalEvent:t})),st&&st.save()):it!==ot&&0<=it&&(q({sortable:this,name:"update",toEl:Z,originalEvent:t}),q({sortable:this,name:"sort",toEl:Z,originalEvent:t})),Ft.active&&(null!=it&&-1!==it||(it=ot,at=rt),q({sortable:this,name:"end",toEl:Z,originalEvent:t}),this.save())))),this._nulling()},_nulling:function(){G("nulling",this),Q=V=Z=$=J=et=tt=nt=ct=ut=gt=it=at=ot=rt=mt=vt=st=lt=Ft.dragged=Ft.ghost=Ft.clone=Ft.active=null,xt.forEach(function(t){t.checked=!0}),xt.length=dt=ht=0},handleEvent:function(t){switch(t.type){case"drop":case"dragend":this._onDrop(t);break;case"dragenter":case"dragover":V&&(this._onDragOver(t),function(t){t.dataTransfer&&(t.dataTransfer.dropEffect="move");t.cancelable&&t.preventDefault()}(t));break;case"selectstart":t.preventDefault()}},toArray:function(){for(var t,e=[],n=this.el.children,o=0,i=n.length,r=this.options;o<i;o++)P(t=n[o],r.draggable,this.el,!1)&&e.push(t.getAttribute(r.dataIdAttr)||function(t){var e=t.tagName+t.className+t.src+t.href+t.textContent,n=e.length,o=0;for(;n--;)o+=e.charCodeAt(n);return o.toString(36)}(t));return e},sort:function(t,e){var n={},o=this.el;this.toArray().forEach(function(t,e){e=o.children[e];P(e,this.options.draggable,o,!1)&&(n[t]=e)},this),e&&this.captureAnimationState(),t.forEach(function(t){n[t]&&(o.removeChild(n[t]),o.appendChild(n[t]))}),e&&this.animateAll()},save:function(){var t=this.options.store;t&&t.set&&t.set(this)},closest:function(t,e){return P(t,e||this.options.draggable,this.el,!1)},option:function(t,e){var n=this.options;if(void 0===e)return n[t];var o=W.modifyOption(this,t,e);n[t]=void 0!==o?o:e,"group"===t&&kt(n)},destroy:function(){G("destroy",this);var t=this.el;t[K]=null,f(t,"mousedown",this._onTapStart),f(t,"touchstart",this._onTapStart),f(t,"pointerdown",this._onTapStart),this.nativeDraggable&&(f(t,"dragover",this),f(t,"dragenter",this)),Array.prototype.forEach.call(t.querySelectorAll("[draggable]"),function(t){t.removeAttribute("draggable")}),this._onDrop(),this._disableDelayedDragEvents(),Dt.splice(Dt.indexOf(this.el),1),this.el=t=null},_hideClone:function(){nt||(G("hideClone",this),Ft.eventCanceled||(R(et,"display","none"),this.options.removeCloneOnHide&&et.parentNode&&et.parentNode.removeChild(et),nt=!0))},_showClone:function(t){"clone"===t.lastPutMode?nt&&(G("showClone",this),Ft.eventCanceled||(V.parentNode!=Q||this.options.group.revertClone?J?Q.insertBefore(et,J):Q.appendChild(et):Q.insertBefore(et,V),this.options.group.revertClone&&this.animate(V,et),R(et,"display",""),nt=!1)):this._hideClone()}},Ot&&h(document,"touchmove",function(t){(Ft.active||wt)&&t.cancelable&&t.preventDefault()}),Ft.utils={on:h,off:f,css:R,find:b,is:function(t,e){return!!P(t,e,t,!1)},extend:function(t,e){if(t&&e)for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t},throttle:S,closest:P,toggleClass:k,clone:_,index:j,nextTick:Kt,cancelNextTick:Wt,detectDirection:Pt,getChild:B},Ft.get=function(t){return t[K]},Ft.mount=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];(e=e[0].constructor===Array?e[0]:e).forEach(function(t){if(!t.prototype||!t.prototype.constructor)throw"Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(t));t.utils&&(Ft.utils=I(I({},Ft.utils),t.utils)),W.mount(t)})},Ft.create=function(t,e){return new Ft(t,e)};var zt,Gt,Ut,qt,Vt,Zt,$t=[],Qt=!(Ft.version="1.15.2");function Jt(){$t.forEach(function(t){clearInterval(t.pid)}),$t=[]}function te(){clearInterval(Zt)}var ee,ne=S(function(n,t,e,o){if(t.scroll){var i,r=(n.touches?n.touches[0]:n).clientX,a=(n.touches?n.touches[0]:n).clientY,l=t.scrollSensitivity,s=t.scrollSpeed,c=O(),u=!1;Gt!==e&&(Gt=e,Jt(),zt=t.scroll,i=t.scrollFn,!0===zt&&(zt=M(e,!0)));var d=0,h=zt;do{var f=h,p=X(f),g=p.top,m=p.bottom,v=p.left,b=p.right,y=p.width,w=p.height,E=void 0,D=void 0,S=f.scrollWidth,_=f.scrollHeight,C=R(f),T=f.scrollLeft,p=f.scrollTop,D=f===c?(E=y<S&&("auto"===C.overflowX||"scroll"===C.overflowX||"visible"===C.overflowX),w<_&&("auto"===C.overflowY||"scroll"===C.overflowY||"visible"===C.overflowY)):(E=y<S&&("auto"===C.overflowX||"scroll"===C.overflowX),w<_&&("auto"===C.overflowY||"scroll"===C.overflowY)),T=E&&(Math.abs(b-r)<=l&&T+y<S)-(Math.abs(v-r)<=l&&!!T),p=D&&(Math.abs(m-a)<=l&&p+w<_)-(Math.abs(g-a)<=l&&!!p);if(!$t[d])for(var x=0;x<=d;x++)$t[x]||($t[x]={});$t[d].vx==T&&$t[d].vy==p&&$t[d].el===f||($t[d].el=f,$t[d].vx=T,$t[d].vy=p,clearInterval($t[d].pid),0==T&&0==p||(u=!0,$t[d].pid=setInterval(function(){o&&0===this.layer&&Ft.active._onTouchMove(Vt);var t=$t[this.layer].vy?$t[this.layer].vy*s:0,e=$t[this.layer].vx?$t[this.layer].vx*s:0;"function"==typeof i&&"continue"!==i.call(Ft.dragged.parentNode[K],e,t,n,Vt,$t[this.layer].el)||H($t[this.layer].el,e,t)}.bind({layer:d}),24))),d++}while(t.bubbleScroll&&h!==c&&(h=M(h,!1)));Qt=u}},30),c=function(t){var e=t.originalEvent,n=t.putSortable,o=t.dragEl,i=t.activeSortable,r=t.dispatchSortableEvent,a=t.hideGhostForTarget,t=t.unhideGhostForTarget;e&&(i=n||i,a(),e=e.changedTouches&&e.changedTouches.length?e.changedTouches[0]:e,e=document.elementFromPoint(e.clientX,e.clientY),t(),i&&!i.el.contains(e)&&(r("spill"),this.onSpill({dragEl:o,putSortable:n})))};function oe(){}function ie(){}oe.prototype={startIndex:null,dragStart:function(t){t=t.oldDraggableIndex;this.startIndex=t},onSpill:function(t){var e=t.dragEl,n=t.putSortable;this.sortable.captureAnimationState(),n&&n.captureAnimationState();t=B(this.sortable.el,this.startIndex,this.options);t?this.sortable.el.insertBefore(e,t):this.sortable.el.appendChild(e),this.sortable.animateAll(),n&&n.animateAll()},drop:c},a(oe,{pluginName:"revertOnSpill"}),ie.prototype={onSpill:function(t){var e=t.dragEl,t=t.putSortable||this.sortable;t.captureAnimationState(),e.parentNode&&e.parentNode.removeChild(e),t.animateAll()},drop:c},a(ie,{pluginName:"removeOnSpill"});var re,ae,le,se,ce,ue=[],de=[],he=!1,fe=!1,pe=!1;function ge(n,o){de.forEach(function(t,e){e=o.children[t.sortableIndex+(n?Number(e):0)];e?o.insertBefore(t,e):o.appendChild(t)})}function me(){ue.forEach(function(t){t!==le&&t.parentNode&&t.parentNode.removeChild(t)})}return Ft.mount(new function(){function t(){for(var t in this.defaults={scroll:!0,forceAutoScrollFallback:!1,scrollSensitivity:30,scrollSpeed:10,bubbleScroll:!0},this)"_"===t.charAt(0)&&"function"==typeof this[t]&&(this[t]=this[t].bind(this))}return t.prototype={dragStarted:function(t){t=t.originalEvent;this.sortable.nativeDraggable?h(document,"dragover",this._handleAutoScroll):this.options.supportPointer?h(document,"pointermove",this._handleFallbackAutoScroll):t.touches?h(document,"touchmove",this._handleFallbackAutoScroll):h(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(t){t=t.originalEvent;this.options.dragOverBubble||t.rootEl||this._handleAutoScroll(t)},drop:function(){this.sortable.nativeDraggable?f(document,"dragover",this._handleAutoScroll):(f(document,"pointermove",this._handleFallbackAutoScroll),f(document,"touchmove",this._handleFallbackAutoScroll),f(document,"mousemove",this._handleFallbackAutoScroll)),te(),Jt(),clearTimeout(g),g=void 0},nulling:function(){Vt=Gt=zt=Qt=Zt=Ut=qt=null,$t.length=0},_handleFallbackAutoScroll:function(t){this._handleAutoScroll(t,!0)},_handleAutoScroll:function(e,n){var o,i=this,r=(e.touches?e.touches[0]:e).clientX,a=(e.touches?e.touches[0]:e).clientY,t=document.elementFromPoint(r,a);Vt=e,n||this.options.forceAutoScrollFallback||w||y||u?(ne(e,this.options,t,n),o=M(t,!0),!Qt||Zt&&r===Ut&&a===qt||(Zt&&te(),Zt=setInterval(function(){var t=M(document.elementFromPoint(r,a),!0);t!==o&&(o=t,Jt()),ne(e,i.options,t,n)},10),Ut=r,qt=a)):this.options.bubbleScroll&&M(t,!0)!==O()?ne(e,this.options,M(t,!1),!1):Jt()}},a(t,{pluginName:"scroll",initializeByDefault:!0})}),Ft.mount(ie,oe),Ft.mount(new function(){function t(){this.defaults={swapClass:"sortable-swap-highlight"}}return t.prototype={dragStart:function(t){t=t.dragEl;ee=t},dragOverValid:function(t){var e=t.completed,n=t.target,o=t.onMove,i=t.activeSortable,r=t.changed,a=t.cancel;i.options.swap&&(t=this.sortable.el,i=this.options,n&&n!==t&&(t=ee,ee=!1!==o(n)?(k(n,i.swapClass,!0),n):null,t&&t!==ee&&k(t,i.swapClass,!1)),r(),e(!0),a())},drop:function(t){var e,n,o=t.activeSortable,i=t.putSortable,r=t.dragEl,a=i||this.sortable,l=this.options;ee&&k(ee,l.swapClass,!1),ee&&(l.swap||i&&i.options.swap)&&r!==ee&&(a.captureAnimationState(),a!==o&&o.captureAnimationState(),n=ee,t=(e=r).parentNode,l=n.parentNode,t&&l&&!t.isEqualNode(n)&&!l.isEqualNode(e)&&(i=j(e),r=j(n),t.isEqualNode(l)&&i<r&&r++,t.insertBefore(n,t.children[i]),l.insertBefore(e,l.children[r])),a.animateAll(),a!==o&&o.animateAll())},nulling:function(){ee=null}},a(t,{pluginName:"swap",eventProperties:function(){return{swapItem:ee}}})}),Ft.mount(new function(){function t(o){for(var t in this)"_"===t.charAt(0)&&"function"==typeof this[t]&&(this[t]=this[t].bind(this));o.options.avoidImplicitDeselect||(o.options.supportPointer?h(document,"pointerup",this._deselectMultiDrag):(h(document,"mouseup",this._deselectMultiDrag),h(document,"touchend",this._deselectMultiDrag))),h(document,"keydown",this._checkKeyDown),h(document,"keyup",this._checkKeyUp),this.defaults={selectedClass:"sortable-selected",multiDragKey:null,avoidImplicitDeselect:!1,setData:function(t,e){var n="";ue.length&&ae===o?ue.forEach(function(t,e){n+=(e?", ":"")+t.textContent}):n=e.textContent,t.setData("Text",n)}}}return t.prototype={multiDragKeyDown:!1,isMultiDrag:!1,delayStartGlobal:function(t){t=t.dragEl;le=t},delayEnded:function(){this.isMultiDrag=~ue.indexOf(le)},setupClone:function(t){var e=t.sortable,t=t.cancel;if(this.isMultiDrag){for(var n=0;n<ue.length;n++)de.push(_(ue[n])),de[n].sortableIndex=ue[n].sortableIndex,de[n].draggable=!1,de[n].style["will-change"]="",k(de[n],this.options.selectedClass,!1),ue[n]===le&&k(de[n],this.options.chosenClass,!1);e._hideClone(),t()}},clone:function(t){var e=t.sortable,n=t.rootEl,o=t.dispatchSortableEvent,t=t.cancel;this.isMultiDrag&&(this.options.removeCloneOnHide||ue.length&&ae===e&&(ge(!0,n),o("clone"),t()))},showClone:function(t){var e=t.cloneNowShown,n=t.rootEl,t=t.cancel;this.isMultiDrag&&(ge(!1,n),de.forEach(function(t){R(t,"display","")}),e(),ce=!1,t())},hideClone:function(t){var e=this,n=(t.sortable,t.cloneNowHidden),t=t.cancel;this.isMultiDrag&&(de.forEach(function(t){R(t,"display","none"),e.options.removeCloneOnHide&&t.parentNode&&t.parentNode.removeChild(t)}),n(),ce=!0,t())},dragStartGlobal:function(t){t.sortable;!this.isMultiDrag&&ae&&ae.multiDrag._deselectMultiDrag(),ue.forEach(function(t){t.sortableIndex=j(t)}),ue=ue.sort(function(t,e){return t.sortableIndex-e.sortableIndex}),pe=!0},dragStarted:function(t){var e,n=this,t=t.sortable;this.isMultiDrag&&(this.options.sort&&(t.captureAnimationState(),this.options.animation&&(ue.forEach(function(t){t!==le&&R(t,"position","absolute")}),e=X(le,!1,!0,!0),ue.forEach(function(t){t!==le&&C(t,e)}),he=fe=!0)),t.animateAll(function(){he=fe=!1,n.options.animation&&ue.forEach(function(t){T(t)}),n.options.sort&&me()}))},dragOver:function(t){var e=t.target,n=t.completed,t=t.cancel;fe&&~ue.indexOf(e)&&(n(!1),t())},revert:function(t){var n,o,e=t.fromSortable,i=t.rootEl,r=t.sortable,a=t.dragRect;1<ue.length&&(ue.forEach(function(t){r.addAnimationState({target:t,rect:fe?X(t):a}),T(t),t.fromRect=a,e.removeAnimationState(t)}),fe=!1,n=!this.options.removeCloneOnHide,o=i,ue.forEach(function(t,e){e=o.children[t.sortableIndex+(n?Number(e):0)];e?o.insertBefore(t,e):o.appendChild(t)}))},dragOverCompleted:function(t){var e,n=t.sortable,o=t.isOwner,i=t.insertion,r=t.activeSortable,a=t.parentEl,l=t.putSortable,t=this.options;i&&(o&&r._hideClone(),he=!1,t.animation&&1<ue.length&&(fe||!o&&!r.options.sort&&!l)&&(e=X(le,!1,!0,!0),ue.forEach(function(t){t!==le&&(C(t,e),a.appendChild(t))}),fe=!0),o||(fe||me(),1<ue.length?(o=ce,r._showClone(n),r.options.animation&&!ce&&o&&de.forEach(function(t){r.addAnimationState({target:t,rect:se}),t.fromRect=se,t.thisAnimationDuration=null})):r._showClone(n)))},dragOverAnimationCapture:function(t){var e=t.dragRect,n=t.isOwner,t=t.activeSortable;ue.forEach(function(t){t.thisAnimationDuration=null}),t.options.animation&&!n&&t.multiDrag.isMultiDrag&&(se=a({},e),e=v(le,!0),se.top-=e.f,se.left-=e.e)},dragOverAnimationComplete:function(){fe&&(fe=!1,me())},drop:function(t){var e=t.originalEvent,n=t.rootEl,o=t.parentEl,i=t.sortable,r=t.dispatchSortableEvent,a=t.oldIndex,l=t.putSortable,s=l||this.sortable;if(e){var c,u,d,h=this.options,f=o.children;if(!pe)if(h.multiDragKey&&!this.multiDragKeyDown&&this._deselectMultiDrag(),k(le,h.selectedClass,!~ue.indexOf(le)),~ue.indexOf(le))ue.splice(ue.indexOf(le),1),re=null,z({sortable:i,rootEl:n,name:"deselect",targetEl:le,originalEvent:e});else{if(ue.push(le),z({sortable:i,rootEl:n,name:"select",targetEl:le,originalEvent:e}),e.shiftKey&&re&&i.el.contains(re)){var p=j(re),t=j(le);if(~p&&~t&&p!==t)for(var g,m=p<t?(g=p,t):(g=t,p+1);g<m;g++)~ue.indexOf(f[g])||(k(f[g],h.selectedClass,!0),ue.push(f[g]),z({sortable:i,rootEl:n,name:"select",targetEl:f[g],originalEvent:e}))}else re=le;ae=s}pe&&this.isMultiDrag&&(fe=!1,(o[K].options.sort||o!==n)&&1<ue.length&&(c=X(le),u=j(le,":not(."+this.options.selectedClass+")"),!he&&h.animation&&(le.thisAnimationDuration=null),s.captureAnimationState(),he||(h.animation&&(le.fromRect=c,ue.forEach(function(t){var e;t.thisAnimationDuration=null,t!==le&&(e=fe?X(t):c,t.fromRect=e,s.addAnimationState({target:t,rect:e}))})),me(),ue.forEach(function(t){f[u]?o.insertBefore(t,f[u]):o.appendChild(t),u++}),a===j(le)&&(d=!1,ue.forEach(function(t){t.sortableIndex!==j(t)&&(d=!0)}),d&&(r("update"),r("sort")))),ue.forEach(function(t){T(t)}),s.animateAll()),ae=s),(n===o||l&&"clone"!==l.lastPutMode)&&de.forEach(function(t){t.parentNode&&t.parentNode.removeChild(t)})}},nullingGlobal:function(){this.isMultiDrag=pe=!1,de.length=0},destroyGlobal:function(){this._deselectMultiDrag(),f(document,"pointerup",this._deselectMultiDrag),f(document,"mouseup",this._deselectMultiDrag),f(document,"touchend",this._deselectMultiDrag),f(document,"keydown",this._checkKeyDown),f(document,"keyup",this._checkKeyUp)},_deselectMultiDrag:function(t){if(!(void 0!==pe&&pe||ae!==this.sortable||t&&P(t.target,this.options.draggable,this.sortable.el,!1)||t&&0!==t.button))for(;ue.length;){var e=ue[0];k(e,this.options.selectedClass,!1),ue.shift(),z({sortable:this.sortable,rootEl:this.sortable.el,name:"deselect",targetEl:e,originalEvent:t})}},_checkKeyDown:function(t){t.key===this.options.multiDragKey&&(this.multiDragKeyDown=!0)},_checkKeyUp:function(t){t.key===this.options.multiDragKey&&(this.multiDragKeyDown=!1)}},a(t,{pluginName:"multiDrag",utils:{select:function(t){var e=t.parentNode[K];e&&e.options.multiDrag&&!~ue.indexOf(t)&&(ae&&ae!==e&&(ae.multiDrag._deselectMultiDrag(),ae=e),k(t,e.options.selectedClass,!0),ue.push(t))},deselect:function(t){var e=t.parentNode[K],n=ue.indexOf(t);e&&e.options.multiDrag&&~n&&(k(t,e.options.selectedClass,!1),ue.splice(n,1))}},eventProperties:function(){var n=this,o=[],i=[];return ue.forEach(function(t){var e;o.push({multiDragElement:t,index:t.sortableIndex}),e=fe&&t!==le?-1:fe?j(t,":not(."+n.options.selectedClass+")"):j(t),i.push({multiDragElement:t,index:e})}),{items:r(ue),clones:[].concat(de),oldIndicies:o,newIndicies:i}},optionListeners:{multiDragKey:function(t){return"ctrl"===(t=t.toLowerCase())?t="Control":1<t.length&&(t=t.charAt(0).toUpperCase()+t.substr(1)),t}}})}),Ft});
\ No newline at end of file
diff --git a/scripts/settings.js b/scripts/settings.js
index 57ae7b2..e6a50cb 100644
--- a/scripts/settings.js
+++ b/scripts/settings.js
@@ -165,9 +165,12 @@ function addCategoryButton(categoryId) {
if(responseData.success) {
const newCategoryId = responseData.categoryId;;
let container = document.getElementById("categories");
- let div = document.createElement("div");
- div.className = "form-group-inline";
- div.dataset.categoryid = newCategoryId;
+ let row = document.createElement("li");
+ row.className = "form-group-inline";
+ row.dataset.categoryid = newCategoryId;
+
+ let dragIcon = document.createElement("div");
+ dragIcon.className = "drag-icon";
let input = document.createElement("input");
input.type = "text";
@@ -201,11 +204,12 @@ function addCategoryButton(categoryId) {
deleteLink.appendChild(deleteImage);
- div.appendChild(input);
- div.appendChild(editLink);
- div.appendChild(deleteLink);
+ row.appendChild(dragIcon);
+ row.appendChild(input);
+ row.appendChild(editLink);
+ row.appendChild(deleteLink);
- container.appendChild(div);
+ container.appendChild(row);
} else {
showErrorMessage(responseData.errorMessage);
}
@@ -246,6 +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) {
@@ -424,7 +429,7 @@ function togglePayment(paymentId) {
const element = document.querySelector(`div[data-paymentid="${paymentId}"]`);
if (element.dataset.inUse === 'yes') {
- return showErrorMessage(translate(cant_disable_payment_in_use));
+ return showErrorMessage(translate('cant_disable_payment_in_use'));
}
const newEnabledState = element.dataset.enabled === '1' ? '0' : '1';
@@ -449,6 +454,69 @@ function togglePayment(paymentId) {
});
}
+document.body.addEventListener('click', function(e) {
+ let targetElement = e.target;
+ do {
+ if (targetElement.classList && targetElement.classList.contains('payments-payment')) {
+ let targetChild = e.target;
+ do {
+ if (targetChild.classList && targetChild.classList.contains('payment-name')) {
+ return;
+ }
+ targetChild = targetChild.parentNode;
+ } while (targetChild && targetChild !== targetElement);
+
+ const paymentId = targetElement.dataset.paymentid;
+ togglePayment(paymentId);
+ return;
+ }
+ targetElement = targetElement.parentNode;
+ } while (targetElement);
+});
+
+document.body.addEventListener('blur', function(e) {
+ let targetElement = e.target;
+ if (targetElement.classList && targetElement.classList.contains('payment-name')) {
+ const paymentId = targetElement.closest('.payments-payment').dataset.paymentid;
+ const newName = targetElement.textContent;
+ renamePayment(paymentId, newName);
+ }
+}, true);
+
+function renamePayment(paymentId, newName) {
+ const name = newName.trim();
+ const formData = new FormData();
+ formData.append('paymentId', paymentId);
+ formData.append('name', name);
+ fetch('endpoints/payments/rename.php', {
+ method: 'POST',
+ body: formData
+ }).then(response => {
+ if (!response.ok) {
+ throw new Error(translate('network_response_error'));
+ }
+ return response.json();
+ }).then(data => {
+ if (data.success) {
+ showSuccessMessage(`${newName} ${data.message}`);
+ } else {
+ showErrorMessage(data.message);
+ }
+ }).catch(error => {
+ showErrorMessage(translate('unknown_error'));
+ });
+}
+
+document.body.addEventListener('keypress', function(e) {
+ let targetElement = e.target;
+ if (targetElement.classList && targetElement.classList.contains('payment-name')) {
+ if (e.key === 'Enter') {
+ e.preventDefault();
+ targetElement.blur();
+ }
+ }
+});
+
function handleFileSelect(event) {
const fileInput = event.target;
const iconPreview = document.querySelector('.icon-preview');
@@ -843,3 +911,41 @@ function setRemoveBackground() {
function exportToJson() {
window.location.href = "endpoints/subscriptions/export.php";
}
+
+function saveCategorySorting() {
+ const categories = document.getElementById('categories');
+ const categoryIds = Array.from(categories.children).map(category => category.dataset.categoryid);
+
+ const formData = new FormData();
+ categoryIds.forEach(categoryId => {
+ formData.append('categoryIds[]', categoryId);
+ });
+
+ fetch('endpoints/categories/sort.php', {
+ method: 'POST',
+ body: formData
+ })
+ .then(response => response.json())
+ .then(data => {
+ if (data.success) {
+ showSuccessMessage(data.message);
+ } else {
+ showErrorMessage(data.errorMessage);
+ }
+ })
+ .catch(error => {
+ showErrorMessage(translate('unknown_error'));
+ });
+}
+
+var el = document.getElementById('categories');
+var sortable = Sortable.create(el, {
+ handle: '.drag-icon',
+ ghostClass: 'sortable-ghost',
+ delay: 500,
+ delayOnTouchOnly: true,
+ touchStartThreshold: 5,
+ onEnd: function (evt) {
+ saveCategorySorting();
+ },
+});
\ No newline at end of file
diff --git a/scripts/stats.js b/scripts/stats.js
index d67db30..cc8160e 100644
--- a/scripts/stats.js
+++ b/scripts/stats.js
@@ -25,3 +25,91 @@ function loadGraph(container, dataPoints, currency, run) {
});
}
}
+
+function closeSubMenus() {
+ var subMenus = document.querySelectorAll('.filtermenu-submenu-content');
+ subMenus.forEach(subMenu => {
+ subMenu.classList.remove('is-open');
+ });
+
+}
+
+document.addEventListener("DOMContentLoaded", function() {
+ var filtermenu = document.querySelector('#filtermenu-button');
+ filtermenu.addEventListener('click', function() {
+ this.parentElement.querySelector('.filtermenu-content').classList.toggle('is-open');
+ closeSubMenus();
+ });
+
+ document.addEventListener('click', function(e) {
+ var filtermenuContent = document.querySelector('.filtermenu-content');
+ if (filtermenuContent.classList.contains('is-open')) {
+ var subMenus = document.querySelectorAll('.filtermenu-submenu');
+ var clickedInsideSubmenu = Array.from(subMenus).some(subMenu => subMenu.contains(e.target) || subMenu === e.target);
+
+ if (!filtermenu.contains(e.target) && !clickedInsideSubmenu) {
+ closeSubMenus();
+ filtermenuContent.classList.remove('is-open');
+ }
+ }
+ });
+});
+
+function toggleSubMenu(subMenu) {
+ var subMenu = document.getElementById("filter-" + subMenu);
+ if (subMenu.classList.contains("is-open")) {
+ closeSubMenus();
+ } else {
+ closeSubMenus();
+ subMenu.classList.add("is-open");
+ }
+}
+
+document.querySelectorAll('.filter-item').forEach(function(item) {
+ item.addEventListener('click', function(e) {
+ if (this.hasAttribute('data-categoryid')) {
+ const categoryId = this.getAttribute('data-categoryid');
+ const urlParams = new URLSearchParams(window.location.search);
+ let newUrl = 'stats.php?';
+
+ if (urlParams.get('category') === categoryId) {
+ urlParams.delete('category');
+ } else {
+ urlParams.set('category', categoryId);
+ }
+
+ newUrl += urlParams.toString();
+ window.location.href = newUrl;
+ } else if (this.hasAttribute('data-memberid')) {
+ const memberId = this.getAttribute('data-memberid');
+ const urlParams = new URLSearchParams(window.location.search);
+ let newUrl = 'stats.php?';
+
+ if (urlParams.get('member') === memberId) {
+ urlParams.delete('member');
+ } else {
+ urlParams.set('member', memberId);
+ }
+
+ newUrl += urlParams.toString();
+ window.location.href = newUrl;
+ } else if (this.hasAttribute('data-paymentid')) {
+ const paymentId = this.getAttribute('data-paymentid');
+ const urlParams = new URLSearchParams(window.location.search);
+ let newUrl = 'stats.php?';
+
+ if (urlParams.get('payment') === paymentId) {
+ urlParams.delete('payment');
+ } else {
+ urlParams.set('payment', paymentId);
+ }
+
+ newUrl += urlParams.toString();
+ window.location.href = newUrl;
+ }
+ });
+});
+
+function clearFilters() {
+ window.location.href = 'stats.php';
+}
\ No newline at end of file
diff --git a/service-worker.js b/service-worker.js
index 8fb587b..ec834cd 100644
--- a/service-worker.js
+++ b/service-worker.js
@@ -33,6 +33,7 @@ self.addEventListener('install', function(event) {
'scripts/i18n/zh_tw.js',
'scripts/i18n/getlang.js',
'scripts/libs/chart.js',
+ 'scripts/libs/sortable.min.js',
'images/icon/favicon.ico',
'images/wallossolid.png',
'images/wallossolidwhite.png',
diff --git a/settings.php b/settings.php
index 20f7a70..c5a67fa 100644
--- a/settings.php
+++ b/settings.php
@@ -2,6 +2,7 @@
require_once 'includes/header.php';
?>
+<script src="scripts/libs/sortable.min.js"></script>
<style>
.logo-preview:after {
content: '<?= translate('upload_logo', $i18n) ?>';
@@ -238,7 +239,7 @@
</section>
<?php
- $sql = "SELECT * FROM categories";
+ $sql = "SELECT * FROM categories ORDER BY `order` ASC";
$result = $db->query($sql);
if ($result) {
@@ -254,7 +255,7 @@
<h2><?= translate('categories', $i18n) ?></h2>
</header>
<div class="account-categories">
- <div id="categories">
+ <div id="categories" class="sortable-list">
<?php
foreach ($categories as $category) {
if ($category['id'] != 1) {
@@ -272,6 +273,7 @@
}
?>
<div class="form-group-inline" data-categoryid="<?= $category['id'] ?>">
+ <div class="drag-icon"></div>
<input type="text" name="category" value="<?= $category['name'] ?>" placeholder="Category">
<button class="image-button medium" onClick="editCategory(<?= $category['id'] ?>)" name="save">
<img src="images/siteicons/save.png" title="<?= translate('save_category', $i18n) ?>">
@@ -497,14 +499,11 @@
data-enabled="<?= $payment['enabled']; ?>"
data-in-use="<?= $inUse ? 'yes' : 'no' ?>"
data-paymentid="<?= $payment['id'] ?>"
- title="<?= $inUse ? translate('cant_delete_payment_method_in_use', $i18n) : ($payment['enabled'] ? translate('disable', $i18n) : translate('enable', $i18n)) ?>"
- onClick="togglePayment(<?= $payment['id'] ?>)">
+ title="<?= $inUse ? translate('cant_delete_payment_method_in_use', $i18n) : ($payment['enabled'] ? translate('disable', $i18n) : translate('enable', $i18n)) ?>">
<img src="<?= $paymentIconFolder.$payment['icon'] ?>" alt="Logo" />
- <span class="payment-name">
- <?= $payment['name'] ?>
- </span>
+ <span class="payment-name" contenteditable="true" title="<?= translate("rename_payment_method", $i18n) ?>"><?= $payment['name'] ?></span>
<?php
- if ($payment['id'] > 31 && !$inUse) {
+ if (!$inUse) {
?>
<div class="delete-payment-method" title="<?= translate('delete', $i18n) ?>" data-paymentid="<?= $payment['id'] ?>">x</div>
<?php
@@ -520,6 +519,10 @@
<i class="fa-solid fa-circle-info"></i>
<?= translate('payment_methods_info', $i18n) ?>
</p>
+ <p>
+ <i class="fa-solid fa-circle-info"></i>
+ <?= translate('rename_payment_methods_info', $i18n) ?>
+ </p>
</div>
<header>
<h2 class="second-header"><?= translate("add_custom_payment", $i18n) ?></h2>
diff --git a/stats.php b/stats.php
index 3a90c5c..c0425c0 100644
--- a/stats.php
+++ b/stats.php
@@ -51,7 +51,7 @@ while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
// Get categories
$categories = array();
-$query = "SELECT * FROM categories";
+$query = "SELECT * FROM categories ORDER BY 'order' ASC";
$result = $db->query($query);
while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
$categoryId = $row['id'];
@@ -61,7 +61,7 @@ while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
}
// Get payment methods
-$categories = array();
+$paymentMethodCount = array();
$query = "SELECT * FROM payment_methods WHERE enabled = 1";
$result = $db->query($query);
while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
@@ -89,8 +89,41 @@ $amountDueThisMonth = 0;
$totalCostPerMonth = 0;
$totalSavingsPerMonth = 0;
+$statsSubtitleParts = [];
$query = "SELECT name, price, frequency, cycle, currency_id, next_payment, payer_user_id, category_id, payment_method_id, inactive FROM subscriptions";
-$result = $db->query($query);
+$conditions = [];
+$params = [];
+
+if (isset($_GET['member'])) {
+ $conditions[] = "payer_user_id = :member";
+ $params[':member'] = $_GET['member'];
+ $statsSubtitleParts[] = $members[$_GET['member']]['name'];
+}
+
+if (isset($_GET['category'])) {
+ $conditions[] = "category_id = :category";
+ $params[':category'] = $_GET['category'];
+ $statsSubtitleParts[] = $categories[$_GET['category']]['name'];
+}
+
+if (isset($_GET['payment'])) {
+ $conditions[] = "payment_method_id = :payment";
+ $params[':payment'] = $_GET['payment'];
+ $statsSubtitleParts[] = $paymentMethodCount[$_GET['payment']]['name'];
+}
+
+if (!empty($conditions)) {
+ $query .= " WHERE " . implode(' AND ', $conditions);
+}
+
+$stmt = $db->prepare($query);
+$statsSubtitle = !empty($statsSubtitleParts) ? '(' . implode(', ', $statsSubtitleParts) . ')' : "";
+
+foreach ($params as $key => $value) {
+ $stmt->bindValue($key, $value, SQLITE3_INTEGER);
+}
+
+$result = $stmt->execute();
if ($result) {
while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
$subscriptions[] = $row;
@@ -160,7 +193,97 @@ if ($result) {
$numberOfElements = 6;
?>
<section class="contain">
- <h2><?= translate('general_statistics', $i18n) ?></h2>
+ <div class="split-header">
+ <h2>
+ <?= translate('general_statistics', $i18n) ?> <span class="header-subtitle"><?= $statsSubtitle ?></span>
+ </h2>
+ <div class="filtermenu">
+ <button class="button" id="filtermenu-button">
+ <i class="fa-solid fa-filter"></i>
+ <?= translate("filter", $i18n) ?>
+ </button>
+ <div class="filtermenu-content">
+ <?php
+ if (count($members) > 1) {
+ ?>
+ <div class="filtermenu-submenu">
+ <div class="filter-title" onClick="toggleSubMenu('member')"><?= translate("member", $i18n) ?></div>
+ <div class="filtermenu-submenu-content" id="filter-member">
+ <?php
+ foreach ($members as $member) {
+ $selectedClass = '';
+ if (isset($_GET['member']) && $_GET['member'] == $member['id']) {
+ $selectedClass = 'selected';
+ }
+ ?>
+ <div class="filter-item <?= $selectedClass ?>" data-memberid="<?= $member['id'] ?>"><?= $member['name'] ?></div>
+ <?php
+ }
+ ?>
+ </div>
+ </div>
+ <?php
+ }
+ ?>
+ <?php
+ if (count($categories) > 1) {
+ ?>
+ <div class="filtermenu-submenu">
+ <div class="filter-title" onClick="toggleSubMenu('category')"><?= translate("category", $i18n) ?></div>
+ <div class="filtermenu-submenu-content" id="filter-category">
+ <?php
+ foreach ($categories as $category) {
+ $selectedClass = '';
+ if (isset($_GET['category']) && $_GET['category'] == $category['id']) {
+ $selectedClass = 'selected';
+ }
+ ?>
+ <div class="filter-item <?= $selectedClass ?>" data-categoryid="<?= $category['id'] ?>"><?= $category['name'] ?></div>
+ <?php
+ }
+ ?>
+ </div>
+ </div>
+ <?php
+ }
+ ?>
+ <?php
+ if (count($paymentMethodCount) > 1) {
+ ?>
+ <div class="filtermenu-submenu">
+ <div class="filter-title" onClick="toggleSubMenu('payment')"><?= translate("payment_method", $i18n) ?></div>
+ <div class="filtermenu-submenu-content" id="filter-payment">
+ <?php
+ foreach ($paymentMethodCount as $payment) {
+ $selectedClass = '';
+ if (isset($_GET['payment']) && $_GET['payment'] == $payment['id']) {
+ $selectedClass = 'selected';
+ }
+ ?>
+ <div class="filter-item <?= $selectedClass ?>" data-paymentid="<?= $payment['id'] ?>"><?= $payment['name'] ?></div>
+ <?php
+ }
+ ?>
+ </div>
+ </div>
+ <?php
+ }
+ ?>
+ <?php
+ if (isset($_GET['member']) || isset($_GET['category']) || isset($_GET['payment'])) {
+ ?>
+ <div class="filtermenu-submenu">
+ <div class="filter-title filter-clear" onClick="clearFilters()">
+ <i class="fa-solid fa-times-circle"></i> <?= translate("clear", $i18n) ?>
+ </div>
+ </div>
+ <?php
+ }
+ ?>
+ </div>
+ </div>
+</div>
+ </div>
<div class="statistics">
<div class="statistic">
<span><?= $activeSubscriptions ?></span>
@@ -208,86 +331,92 @@ $numberOfElements = 6;
}
?>
</div>
- <h2><?= translate('split_views', $i18n) ?></h2>
- <div class="graphs">
- <?php
- $categoryDataPoints = [];
- foreach ($categoryCost as $category) {
- if ($category['cost'] != 0) {
- $categoryDataPoints[] = [
- "label" => $category['name'],
- "y" => $category["cost"],
- ];
- }
- }
-
- $showCategoryCostGraph = count($categoryDataPoints) > 1;
+ <?php
+ $categoryDataPoints = [];
+ foreach ($categoryCost as $category) {
+ if ($category['cost'] != 0) {
+ $categoryDataPoints[] = [
+ "label" => $category['name'],
+ "y" => $category["cost"],
+ ];
+ }
+ }
- $memberDataPoints = [];
- foreach ($memberCost as $member) {
- if ($member['cost'] != 0) {
- $memberDataPoints[] = [
- "label" => $member['name'],
- "y" => $member["cost"],
- ];
-
- }
- }
+ $showCategoryCostGraph = count($categoryDataPoints) > 1;
- $showMemberCostGraph = count($memberDataPoints) > 1;
+ $memberDataPoints = [];
+ foreach ($memberCost as $member) {
+ if ($member['cost'] != 0) {
+ $memberDataPoints[] = [
+ "label" => $member['name'],
+ "y" => $member["cost"],
+ ];
+
+ }
+ }
- $paymentMethodDataPoints = [];
- foreach ($paymentMethodCount as $paymentMethod) {
- if ($paymentMethod['count'] != 0) {
- $paymentMethodDataPoints[] = [
- "label" => $paymentMethod['name'],
- "y" => $paymentMethod["count"],
- ];
- }
- }
+ $showMemberCostGraph = count($memberDataPoints) > 1;
- $showPaymentMethodCountGraph = count($paymentMethodDataPoints) > 1;
+ $paymentMethodDataPoints = [];
+ foreach ($paymentMethodCount as $paymentMethod) {
+ if ($paymentMethod['count'] != 0) {
+ $paymentMethodDataPoints[] = [
+ "label" => $paymentMethod['name'],
+ "y" => $paymentMethod["count"],
+ ];
+ }
+ }
- if ($showMemberCostGraph) {
- ?>
- <section class="graph">
- <header>
- <?= translate('household_split', $i18n) ?>
- <div class="sub-header">(<?= translate('monthly_cost', $i18n) ?>)</div>
- </header>
- <canvas id="memberSplitChart"></canvas>
- </section>
- <?php
- }
-
- if ($showCategoryCostGraph) {
- ?>
- <section class="graph">
- <header>
- <?= translate('category_split', $i18n) ?>
- <div class="sub-header">(<?= translate('monthly_cost', $i18n) ?>)</div>
- </header>
- <canvas id="categorySplitChart" style="height: 370px; width: 100%;"></canvas>
- </section>
- <?php
- }
+ $showPaymentMethodCountGraph = count($paymentMethodDataPoints) > 1;
+ if ($showCategoryCostGraph || $showMemberCostGraph || $showPaymentMethodCountGraph) {
+ ?>
+ <h2><?= translate('split_views', $i18n) ?></h2>
+ <div class="graphs">
+ <?php
+ if ($showMemberCostGraph) {
+ ?>
+ <section class="graph">
+ <header>
+ <?= translate('household_split', $i18n) ?>
+ <div class="sub-header">(<?= translate('monthly_cost', $i18n) ?>)</div>
+ </header>
+ <canvas id="memberSplitChart"></canvas>
+ </section>
+ <?php
+ }
+
+ if ($showCategoryCostGraph) {
+ ?>
+ <section class="graph">
+ <header>
+ <?= translate('category_split', $i18n) ?>
+ <div class="sub-header">(<?= translate('monthly_cost', $i18n) ?>)</div>
+ </header>
+ <canvas id="categorySplitChart" style="height: 370px; width: 100%;"></canvas>
+ </section>
+ <?php
+ }
- if ($showPaymentMethodCountGraph) {
- ?>
- <section class="graph">
- <header>
- <?= translate('payment_method_split', $i18n) ?>
- </header>
- <canvas id="paymentMethidSplitChart" style="height: 370px; width: 100%;"></canvas>
- </section>
- <?php
- }
+ if ($showPaymentMethodCountGraph) {
+ ?>
+ <section class="graph">
+ <header>
+ <?= translate('payment_method_split', $i18n) ?>
+ </header>
+ <canvas id="paymentMethidSplitChart" style="height: 370px; width: 100%;"></canvas>
+ </section>
+ <?php
+ }
- ?>
- </div>
+ ?>
+ </div>
+ <?php
+ }
+ ?>
+
</section>
<?php
- if ($showCategoryCostGraph || $showMemberCostGraph) {
+ if ($showCategoryCostGraph || $showMemberCostGraph || $showPaymentMethodCountGraph) {
?>
<script src="scripts/libs/chart.js"></script>
<script type="text/javascript">
diff --git a/styles/dark-theme.css b/styles/dark-theme.css
index cb0ee62..ec8abbe 100644
--- a/styles/dark-theme.css
+++ b/styles/dark-theme.css
@@ -11,15 +11,21 @@ header .logo .logo-image {
background-image: url("../images/wallossolidwhite.png");
}
+.split-header > h2 .header-subtitle {
+ color: #A9A9A9;
+ }
+
.subscription,
.subscription-form,
.account-section,
.avatar-select,
.logo-search,
+.icon-search,
.dropdown-content,
.sort-options,
.statistic,
-.graph {
+.graph,
+.filtermenu-content {
background-color: #222;
border: 1px solid #333;
box-shadow: 0 2px 5px rgba(120, 120, 120, 0.1);
@@ -37,6 +43,11 @@ header .logo .logo-image {
background-color: #333333;
}
+.filtermenu-content .filter-item:hover,
+.filtermenu-content .filter-title:hover {
+ background-color: #333333;
+}
+
.subscription-form h3 {
color: #FFF;
border-bottom: 1px solid #EEE;
diff --git a/styles/styles.css b/styles/styles.css
index bbc6e2a..8b34737 100644
--- a/styles/styles.css
+++ b/styles/styles.css
@@ -21,10 +21,34 @@ h2, h3 {
box-sizing: border-box;
}
+.split-header {
+ display: flex;
+ flex-direction: row;
+ align-items: center;
+ justify-content: space-between;
+ margin-bottom: 10px;
+}
+
+.split-header h2 {
+ margin-right: 20px;
+}
+
+.split-header > h2 .header-subtitle {
+ font-size: 22px;
+ font-weight: 400;
+ color: #666666;
+ margin-left: 10px;
+}
+
@media (max-width: 768px) {
.contain.settings {
padding: 20px 0px;
}
+
+ .split-header > h2 .header-subtitle {
+ margin-left: 0px;
+ font-size: 18px;
+ }
}
body > header {
@@ -96,7 +120,7 @@ header .logo .logo-image {
.dropdown-content a {
color: black;
- padding: 12px 16px;
+ padding: 14px 18px;
text-decoration: none;
display: block;
}
@@ -593,6 +617,10 @@ main > .contain {
object-fit: contain;
}
+.payments-list .payments-payment > .payment-name {
+ cursor: text;
+}
+
.payments-list .payments-payment .delete-payment-method {
padding: 5px;
font-weight: bold;
@@ -817,7 +845,7 @@ input[type="checkbox"] {
}
.icon-search {
- width: 100px;
+ width: 112px;
height: 224px;
top: 50px;
right: 0px;
@@ -1047,7 +1075,7 @@ input[type="checkbox"] {
.sort-options > ul > li {
list-style: none;
- padding: 10px 35px 10px 10px;
+ padding: 14px 35px 14px 18px;
border-bottom: 1px solid #DDD;
cursor: pointer;
}
@@ -1283,4 +1311,122 @@ input[type="checkbox"] {
flex-basis: 100%;
max-width: 100%;
}
+}
+
+/* Settings sort category */
+
+.sortable-list {
+ margin: 0px;
+ padding: 0px;
+ -webkit-touch-callout: none;
+ -webkit-user-select: none;
+ -khtml-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+}
+
+.drag-icon {
+ width: 28px;
+ height: 50px;
+ cursor: grab;
+ background-image: url(../images/siteicons/draggable.png);
+ background-repeat: no-repeat;
+ background-position: center;
+ background-size: 14px auto;
+}
+
+.sortable-list .sortable-ghost {
+ border-radius: 16px;
+ background-color: #c1d9f7;
+ border: 1px solid #8FBFFA;
+}
+
+/* Fitler dropdown */
+
+.filtermenu {
+ position: relative;
+ display: inline-block;
+}
+
+.filtermenu-content {
+ display: none;
+ position: absolute;
+ background-color: #f9f9f9;
+ left: auto;
+ right: 0;
+ width: 220px;
+ background-color: #fff;
+ border: 1px solid #eee;
+ border-radius: 8px;
+ box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
+ z-index: 3;
+ overflow: hidden;
+ margin-top: 4px;
+}
+
+.filtermenu-content.is-open {
+ display: block;
+}
+
+.filtermenu-content .filter-title {
+ padding: 14px 18px;
+ text-decoration: none;
+ display: block;
+ cursor: pointer;
+ font-weight: 500;
+ border-bottom: 1px solid #DDD;
+ user-select: none;
+}
+
+.filtermenu-content .filtermenu-submenu:last-of-type .filter-title {
+ border-bottom: none;
+}
+
+.filtermenu-content .filtermenu-submenu:last-of-type .filter-item:first-of-type {
+ border-top: 1px solid #DDD;
+}
+
+.filtermenu-content .filtermenu-submenu:last-of-type .filter-item:last-of-type {
+ border-bottom: none;
+}
+
+.filtermenu-content .filter-item {
+ padding: 14px 24px;
+ text-decoration: none;
+ display: block;
+ cursor: pointer;
+ border-bottom: 1px solid #DDD;
+ user-select: none;
+ font-size: 16px;
+}
+
+.filtermenu-content .filter-item.selected {
+ background-image: url(../images/siteicons/check.png);
+ background-size: 16px;
+ background-repeat: no-repeat;
+ background-position: center right 10px;
+}
+
+.filtermenu-content .filter-title.filter-clear {
+ color: #0056b3;
+ font-weight: normal;
+ border-bottom: none;
+}
+
+.filtermenu-content .filter-title.filter-clear > i {
+ margin-right: 8px;
+}
+
+.filtermenu-content .filter-item:hover,
+.filtermenu-content .filter-title:hover {
+ background-color: #f1f1f1;
+}
+
+.filtermenu-submenu-content {
+ display: none;
+}
+
+.filtermenu-submenu-content.is-open {
+ display: block;
}
\ No newline at end of file