1<?php
2require 'init.php';
3use WHMCS\Database\Capsule;
4
5// Ensure the user is logged in before processing
6if (!isset($_SESSION['uid'])) {
7 die("You must be logged in to modify this setting.");
8}
9
10if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['disableCC'])) {
11 $userId = $_SESSION['uid']; // Get the logged-in user's ID
12 $disableCC = $_POST['disableCC']; // 1 to disable, 0 to enable
13
14 // Update the 'DisableCC' setting for the user
15 Capsule::table('tblclients')
16 ->where('id', $userId)
17 ->update([
18 'disableautocc' => $disableCC,
19 'disableautocc_viewinvoice' => 0
20 ]);
21 $_SESSION['disableCCMessage'] = "Your changes have been made successfully.";
22
23 // Redirect back to the invoice page after updating
24 header("Location: " . $_SERVER['HTTP_REFERER']);
25 exit();
26}
27?>
28