Allow to disable notifications
This commit is contained in:
@@ -30,7 +30,7 @@
|
||||
$currencies[$currencyId] = $row;
|
||||
}
|
||||
|
||||
$querySubscriptions = "SELECT * FROM subscriptions WHERE notify = 1";
|
||||
$querySubscriptions = "SELECT * FROM subscriptions WHERE notify = 1 AND inactive = 0";
|
||||
$resultSubscriptions = $db->query($querySubscriptions);
|
||||
|
||||
$notify = []; $i = 0;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
$cycles[$cycleId] = $row;
|
||||
}
|
||||
|
||||
$query = "SELECT id, next_payment, frequency, cycle FROM subscriptions WHERE next_payment < :currentDate";
|
||||
$query = "SELECT id, next_payment, frequency, cycle FROM subscriptions WHERE inactive = 0 AND next_payment < :currentDate";
|
||||
$stmt = $db->prepare($query);
|
||||
$stmt->bindValue(':currentDate', $currentDate->format('Y-m-d'));
|
||||
$result = $stmt->execute();
|
||||
|
||||
@@ -151,6 +151,7 @@
|
||||
$logoUrl = validate($_POST['logo-url']);
|
||||
$logo = "";
|
||||
$notify = isset($_POST['notifications']) ? true : false;
|
||||
$inactive = isset($_POST['inactive']) ? true : false;
|
||||
|
||||
if($logoUrl !== "") {
|
||||
$logo = getLogoFromUrl($logoUrl, '../../images/uploads/logos/', $name);
|
||||
@@ -162,15 +163,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, url)
|
||||
payment_method_id, payer_user_id, category_id, notify, inactive, url)
|
||||
VALUES (:name, :logo, :price, :currencyId, :nextPayment, :cycle, :frequency, :notes,
|
||||
:paymentMethodId, :payerUserId, :categoryId, :notify, :url)";
|
||||
:paymentMethodId, :payerUserId, :categoryId, :notify, :inactive, :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, url = :url 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, inactive = :inactive, 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, url = :url 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, inactive = :inactive, url = :url WHERE id = :id";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,6 +193,7 @@
|
||||
$stmt->bindParam(':payerUserId', $payerUserId, SQLITE3_INTEGER);
|
||||
$stmt->bindParam(':categoryId', $categoryId, SQLITE3_INTEGER);
|
||||
$stmt->bindParam(':notify', $notify, SQLITE3_INTEGER);
|
||||
$stmt->bindParam(':inactive', $inactive, SQLITE3_INTEGER);
|
||||
$stmt->bindParam(':url', $url, SQLITE3_TEXT);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
$subscriptionData['payer_user_id'] = $row['payer_user_id'];
|
||||
$subscriptionData['category_id'] = $row['category_id'];
|
||||
$subscriptionData['notify'] = $row['notify'];
|
||||
$subscriptionData['inactive'] = $row['inactive'];
|
||||
$subscriptionData['url'] = $row['url'];
|
||||
|
||||
$subscriptionJson = json_encode($subscriptionData);
|
||||
|
||||
@@ -56,6 +56,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]['inactive'] = $subscription['inactive'];
|
||||
$print[$id]['url'] = $subscription['url'];
|
||||
$print[$id]['notes'] = $subscription['notes'];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user