From f4da6b735ef3db1b30caf23464e5a5596d308dfb Mon Sep 17 00:00:00 2001 From: ellite Date: Fri, 8 Dec 2023 22:33:24 +0100 Subject: [PATCH] Add url field to subscription --- endpoints/subscription/add.php | 10 ++++++---- endpoints/subscription/get.php | 1 + endpoints/subscriptions/get.php | 1 + images/siteicons/filter.png | Bin 0 -> 628 bytes images/siteicons/web.png | Bin 0 -> 1537 bytes includes/list_subscriptions.php | 11 +++++++++++ index.php | 5 +++++ migrations/000004.php | 12 ++++++++++++ scripts/dashboard.js | 2 ++ styles/styles.css | 10 ++++++++++ 10 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 images/siteicons/filter.png create mode 100644 images/siteicons/web.png create mode 100644 migrations/000004.php diff --git a/endpoints/subscription/add.php b/endpoints/subscription/add.php index 1071d83..ed6f92f 100644 --- a/endpoints/subscription/add.php +++ b/endpoints/subscription/add.php @@ -144,6 +144,7 @@ $payerUserId = $_POST["payer_user_id"]; $categoryId = $_POST['category_id']; $notes = $_POST["notes"]; + $url = $_POST['url']; $logoUrl = $_POST['logo-url']; $logo = ""; $notify = isset($_POST['notifications']) ? true : false; @@ -158,15 +159,15 @@ if (!$isEdit) { $sql = "INSERT INTO subscriptions (name, logo, price, currency_id, next_payment, cycle, frequency, notes, - payment_method_id, payer_user_id, category_id, notify) + payment_method_id, payer_user_id, category_id, notify, url) VALUES (:name, :logo, :price, :currencyId, :nextPayment, :cycle, :frequency, :notes, - :paymentMethodId, :payerUserId, :categoryId, :notify)"; + :paymentMethodId, :payerUserId, :categoryId, :notify, :url)"; } else { $id = $_POST['id']; if ($logo != "") { - $sql = "UPDATE subscriptions SET name = :name, logo = :logo, price = :price, currency_id = :currencyId, next_payment = :nextPayment, cycle = :cycle, frequency = :frequency, notes = :notes, payment_method_id = :paymentMethodId, payer_user_id = :payerUserId, category_id = :categoryId, notify = :notify WHERE id = :id"; + $sql = "UPDATE subscriptions SET name = :name, logo = :logo, price = :price, currency_id = :currencyId, next_payment = :nextPayment, cycle = :cycle, frequency = :frequency, notes = :notes, payment_method_id = :paymentMethodId, payer_user_id = :payerUserId, category_id = :categoryId, notify = :notify, url = :url WHERE id = :id"; } else { - $sql = "UPDATE subscriptions SET name = :name, price = :price, currency_id = :currencyId, next_payment = :nextPayment, cycle = :cycle, frequency = :frequency, notes = :notes, payment_method_id = :paymentMethodId, payer_user_id = :payerUserId, category_id = :categoryId, notify = :notify WHERE id = :id"; + $sql = "UPDATE subscriptions SET name = :name, price = :price, currency_id = :currencyId, next_payment = :nextPayment, cycle = :cycle, frequency = :frequency, notes = :notes, payment_method_id = :paymentMethodId, payer_user_id = :payerUserId, category_id = :categoryId, notify = :notify, url = :url WHERE id = :id"; } } @@ -188,6 +189,7 @@ $stmt->bindParam(':payerUserId', $payerUserId, SQLITE3_INTEGER); $stmt->bindParam(':categoryId', $categoryId, SQLITE3_INTEGER); $stmt->bindParam(':notify', $notify, SQLITE3_INTEGER); + $stmt->bindParam(':url', $url, SQLITE3_TEXT); if ($stmt->execute()) { $success['status'] = "Success"; diff --git a/endpoints/subscription/get.php b/endpoints/subscription/get.php index c0f29aa..1b9b112 100644 --- a/endpoints/subscription/get.php +++ b/endpoints/subscription/get.php @@ -25,6 +25,7 @@ $subscriptionData['payer_user_id'] = $row['payer_user_id']; $subscriptionData['category_id'] = $row['category_id']; $subscriptionData['notify'] = $row['notify']; + $subscriptionData['url'] = $row['url']; $subscriptionJson = json_encode($subscriptionData); header('Content-Type: application/json'); diff --git a/endpoints/subscriptions/get.php b/endpoints/subscriptions/get.php index bb6f256..d1eb682 100644 --- a/endpoints/subscriptions/get.php +++ b/endpoints/subscriptions/get.php @@ -53,6 +53,7 @@ $print[$id]['category_id'] = $subscription['category_id']; $print[$id]['payer_user_id'] = $subscription['payer_user_id']; $print[$id]['price'] = floatval($subscription['price']); + $print[$id]['url'] = $subscription['url']; if (isset($_COOKIE['convertCurrency']) && $_COOKIE['convertCurrency'] === 'true' && $currencyId != $mainCurrencyId) { $print[$id]['price'] = getPriceConverted($print[$id]['price'], $currencyId, $db); diff --git a/images/siteicons/filter.png b/images/siteicons/filter.png new file mode 100644 index 0000000000000000000000000000000000000000..5cbc991044929ab09a225d17cc1a8657bb34ec01 GIT binary patch literal 628 zcmV-)0*n2LP)0qH=jz*xb?4xj?D0_nh{0^JU<0<#quD%engln^Sw^DMdxv&iP-#gJLf z%$@rW?wJXB6HEi=D$qBtLtwkz#?*-H6OovNpd=O9XJck1eUbwKhJL0J?Zzd#EDG%; z3&d{e2Ob3&|AU&4A&?_6rFR01PbB>$L*hLWMQx5d@{3zUZ9qMgG8d;B{d@FWJCOtDO7{n0uB-pm6IEC4wl5nS9C3m zGzO7W;h&u{`4+AhA&U z+w3jl=X7gA2&8KNd&sQCb-z#F0#gKXx-}sL61D$J=7ZI|-~Wrg1>Tz3S{(=>FqZU- zG=}k=zrXVbI7n=%rmWZ>)13$lGri#fQae< O0000#=#=cNF2se8uArkE z9h}0#mTH+&=|buvS>eJWDbN{8r43XmbjmaerOgB4|B&3|o||hZ46SO+ma3u&Tq5_#o$}yHaNO??E`9%D=_y=VH&h$w zaQZFF4+2LAf4cF`-MbI+aEbEsx6$i|%1Lj?!8anmFGxRJnxKV+hxkUcb7$^SeccOP zkUb8Y-i=x@iVd7{`dd~h)Q%?1SBC$f;o(_g==C~!t7%`f^AgO&w`WJm?_a?;qU!2m zda?Q`C~|9wI*;4*Jy!7$ z<+=q$WH9K+-f{p+BIF^`IUKf}e#!!210Bwgi70RZ(n=hBr;J8DH8<^tlIP6XtF*Z2 zheAWC&AN!T)H`e%F9{%IfWK$^$%Ru&1CfMfzkphvufF~TpJCF3LK2Cg zckJj(_)JI0g8{lKRbtB+@H6D>rml|>u^H_lsNooRC}n5ii@9wN=K;Q zVKdZ2#F1nmJkGCPfJ_S?|7E552%%@8#BsT9B9s=OMDjo)IUiCO@ZG{?Gi5+o2Vy9@ z0U-~b!fuEt8k8sq9Xq8Nb$Iv$77KxR_z)CGWS&+ebT>taGthK$>b_2=H9=0)&^@!gsoe*%yhl`bO~h4 zz@}f!ZTjUjqv_<$`&ymG1epME(a4cmG7OB5~cQlaMvQ$dnI!9+=G=?08)QPr^=k35T*BC62^USmzfUxbs?j zy3R8)8eqVL1(l0Zm^j}z9({c(5=Q(}lRwpFF|VnU3mYB{iV%^+?uR^x5`~Xvwir|Y zk}q@-35z?QoUo}7HXsqsih-G=%cWm(T)Z5a(8nB6t zO-_;t)_FGRNv~rg|7!3JWH&nQMy(jt1`;{^=~NrSBQHm%si?9PPT&%axaZ1)E1_|O n+0ywB_H^RXy0PvC9yfmjN2e}cGYzIc00000NkvXXu0mjfRbk{b literal 0 HcmV?d00001 diff --git a/includes/list_subscriptions.php b/includes/list_subscriptions.php index feaf6d6..4144e74 100644 --- a/includes/list_subscriptions.php +++ b/includes/list_subscriptions.php @@ -101,6 +101,17 @@ Subscription Paid By Category + + URL + +
+ +
+
diff --git a/migrations/000004.php b/migrations/000004.php new file mode 100644 index 0000000..9f1ec44 --- /dev/null +++ b/migrations/000004.php @@ -0,0 +1,12 @@ +query("SELECT * FROM pragma_table_info('subscriptions') where name='url'"); + $columnRequired = $columnQuery->fetchArray(SQLITE3_ASSOC) === false; + + if ($columnRequired) { + $db->exec('ALTER TABLE subscriptions ADD COLUMN url VARCHAR(255);'); + } + +?> \ No newline at end of file diff --git a/scripts/dashboard.js b/scripts/dashboard.js index 150c6b0..b17e896 100644 --- a/scripts/dashboard.js +++ b/scripts/dashboard.js @@ -67,6 +67,8 @@ function fillEditFormFields(subscription) { nextPament.value = subscription.next_payment; const notes = document.querySelector("#notes"); notes.value = subscription.notes; + const url = document.querySelector("#url"); + url.value = subscription.url; const notifications = document.querySelector("#notifications"); if (notifications) { diff --git a/styles/styles.css b/styles/styles.css index f738cf0..03185a3 100644 --- a/styles/styles.css +++ b/styles/styles.css @@ -283,6 +283,12 @@ main > .contain { flex-basis: 33%; } +.subscription-secondary > .url { + flex-basis: 20px; + margin-left: auto; + cursor: pointer; +} + @media (max-width: 768px) { .subscription-main > .name { display: none; @@ -308,6 +314,10 @@ main > .contain { margin-right: 10px; } +.subscription-secondary .url img { + margin-right: 0px;; +} + .empty-page { display: block; max-width: 90%;