diff --git a/calendar.php b/calendar.php new file mode 100644 index 0000000..61bc0eb --- /dev/null +++ b/calendar.php @@ -0,0 +1,224 @@ +prepare($query); +$stmt->bindValue(':user_id', $userId, SQLITE3_INTEGER); +$result = $stmt->execute(); +$subscriptions = []; +while ($row = $result->fetchArray(SQLITE3_ASSOC)) { + $subscriptions[] = $row; +} + +$yearsToLoad = $calendarYear - $currentYear + 1; +?> + +
+
+

Calendar

+
+ + + + + + +
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+   +
+
+
+ +
+
+ +
+
+ +
+ +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ +
+ +
+
+ +
+
+   +
+
+
+ +
+
+
+
+ +
+ +
+ + + \ No newline at end of file diff --git a/endpoints/subscription/getcalendar.php b/endpoints/subscription/getcalendar.php new file mode 100644 index 0000000..493dd17 --- /dev/null +++ b/endpoints/subscription/getcalendar.php @@ -0,0 +1,50 @@ + false, + "message" => translate('session_expired', $i18n) + ])); +} + +if ($_SERVER["REQUEST_METHOD"] === "POST") { + $postData = file_get_contents("php://input"); + $data = json_decode($postData, true); + + $id = $data['id']; + + $stmt = $db->prepare('SELECT * FROM subscriptions WHERE id = :id AND user_id = :userId'); + $stmt->bindParam(':id', $id, SQLITE3_INTEGER); + $stmt->bindParam(':userId', $_SESSION['userId'], SQLITE3_INTEGER); // Assuming $_SESSION['userId'] holds the logged-in user's ID + $result = $stmt->execute(); + + if ($result === false) { + die(json_encode([ + 'success' => false, + 'message' => "Subscription not found" + ])); + } + + $subscription = $result->fetchArray(SQLITE3_ASSOC); // Fetch the subscription details as an associative array + + if ($subscription) { + // get payer name from household object + $subscription['payer_user'] = $members[$subscription['payer_user_id']]['name']; + $subscription['category'] = $categories[$subscription['category_id']]['name']; + $subscription['payment_method'] = $payment_methods[$subscription['payment_method_id']]['name']; + $subscription['currency'] = $currencies[$subscription['currency_id']]['symbol']; + + echo json_encode([ + 'success' => true, + 'data' => $subscription + ]); + } else { + echo json_encode([ + 'success' => false, + 'message' => "Subscription not found" + ]); + } +} +?> \ No newline at end of file diff --git a/includes/header.php b/includes/header.php index 77c945a..e066be9 100644 --- a/includes/header.php +++ b/includes/header.php @@ -95,6 +95,7 @@