-
-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow sorting payment methods (#217)
feat: don't allow to change currency code if in use
- Loading branch information
Showing
6 changed files
with
108 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
require_once '../../includes/connect_endpoint.php'; | ||
|
||
session_start(); | ||
|
||
if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] === true) { | ||
$paymentMethods = $_POST['paymentMethodIds']; | ||
$order = 1; | ||
|
||
foreach ($paymentMethods as $paymentMethodId) { | ||
$sql = "UPDATE payment_methods SET `order` = :order WHERE id = :paymentMethodId"; | ||
$stmt = $db->prepare($sql); | ||
$stmt->bindParam(':order', $order, SQLITE3_INTEGER); | ||
$stmt->bindParam(':paymentMethodId', $paymentMethodId, 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(); | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<?php | ||
$version = "v1.15.3"; | ||
$version = "v1.16.0"; | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
// This migration adds a "order" column to the payment_methods table so that they can be sorted and initializes all values to their id. | ||
|
||
/** @noinspection PhpUndefinedVariableInspection */ | ||
$columnQuery = $db->query("SELECT * FROM pragma_table_info('payment_methods') WHERE name='order'"); | ||
$columnRequired = $columnQuery->fetchArray(SQLITE3_ASSOC) === false; | ||
|
||
if ($columnRequired) { | ||
$db->exec('ALTER TABLE payment_methods ADD COLUMN `order` INTEGER DEFAULT 0'); | ||
$db->exec('UPDATE payment_methods SET `order` = id'); | ||
} | ||
|
||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters