Add url field to subscription
This commit is contained in:
parent
2d7fb4bb6d
commit
f4da6b735e
@ -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";
|
||||
|
||||
@ -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');
|
||||
|
||||
@ -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);
|
||||
|
||||
BIN
images/siteicons/filter.png
Normal file
BIN
images/siteicons/filter.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 628 B |
BIN
images/siteicons/web.png
Normal file
BIN
images/siteicons/web.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
@ -101,6 +101,17 @@
|
||||
<span class="name"><img src="images/siteicons/subscription.png" alt="Subscription" /><?= $subscription['name'] ?></span>
|
||||
<span class="payer_user" title="Paid By"><img src="images/siteicons/payment.png" alt="Paid By" /><?= $members[$subscription['payer_user_id']]['name'] ?></span>
|
||||
<span class="category" title="Category" ><img src="images/siteicons/category.png" alt="Category" /><?= $categories[$subscription['category_id']]['name'] ?></span>
|
||||
<?php
|
||||
if ($subscription['url'] != "") {
|
||||
$url = $subscription['url'];
|
||||
if (!preg_match('/^https?:\/\//', $url)) {
|
||||
$url = "https://" . $url;
|
||||
}
|
||||
?>
|
||||
<span class="url" title="External Url"><a href="<?= $url ?>" target="_blank"><img src="images/siteicons/web.png" alt="URL" /></a></span>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
@ -80,6 +80,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);
|
||||
@ -233,6 +234,10 @@
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<input type="text" id="url" name="url" placeholder="URL">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<input type="text" id="notes" name="notes" placeholder="Notes">
|
||||
</div>
|
||||
|
||||
12
migrations/000004.php
Normal file
12
migrations/000004.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
// This migration adds a URL column to the subscriptions table.
|
||||
|
||||
/** @noinspection PhpUndefinedVariableInspection */
|
||||
$columnQuery = $db->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);');
|
||||
}
|
||||
|
||||
?>
|
||||
@ -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) {
|
||||
|
||||
@ -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%;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user