-
-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add export subscriptions to JSON button
- Loading branch information
Showing
13 changed files
with
73 additions
and
1 deletion.
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,41 @@ | ||
<?php | ||
|
||
require_once '../../includes/connect_endpoint.php'; | ||
|
||
session_start(); | ||
|
||
require_once '../../includes/getdbkeys.php'; | ||
|
||
$query = "SELECT * FROM subscriptions"; | ||
|
||
$result = $db->query($query); | ||
if ($result) { | ||
$subscriptions = array(); | ||
while ($row = $result->fetchArray(SQLITE3_ASSOC)) { | ||
// Map foreign keys to their corresponding values | ||
$row['currency'] = $currencies[$row['currency_id']]; | ||
$row['payment_method'] = $payment_methods[$row['payment_method_id']]; | ||
$row['payer_user'] = $members[$row['payer_user_id']]; | ||
$row['category'] = $categories[$row['category_id']]; | ||
$row['cycle'] = $cycles[$row['cycle']]; | ||
$row['frequency'] = $frequencies[$row['frequency']]; | ||
|
||
$subscriptions[] = $row; | ||
} | ||
|
||
// Output JSON | ||
$json = json_encode($subscriptions, JSON_PRETTY_PRINT); | ||
|
||
// Set headers for file download | ||
header('Content-Type: application/json'); | ||
header('Content-Disposition: attachment; filename="subscriptions.json"'); | ||
header('Pragma: no-cache'); | ||
header('Expires: 0'); | ||
|
||
// Output JSON for download | ||
echo $json; | ||
} else { | ||
echo json_encode(array('error' => 'Failed to fetch subscriptions.')); | ||
} | ||
|
||
?> |
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
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
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
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.2.3"; | ||
$version = "v1.2.4"; | ||
?> |
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