diff --git a/company_settings.php b/company_settings.php new file mode 100644 index 0000000..1113c65 --- /dev/null +++ b/company_settings.php @@ -0,0 +1,264 @@ + 'Alberta', 'BC' => 'British Columbia', 'MB' => 'Manitoba', + 'NB' => 'New Brunswick', 'NL' => 'Newfoundland and Labrador', 'NS' => 'Nova Scotia', + 'ON' => 'Ontario', 'PE' => 'Prince Edward Island', 'QC' => 'Quebec', + 'SK' => 'Saskatchewan', 'NT' => 'Northwest Territories', 'NU' => 'Nunavut', 'YT' => 'Yukon' +]; + +// Business Sectors +$sectors = [ + 'Telecommunications', 'Information Technology', 'Professional Services', + 'Manufacturing', 'Construction', 'Retail', 'Healthcare', 'Energy', 'Other' +]; + +// Handle Form Submission +if ($_SERVER['REQUEST_METHOD'] === 'POST') { + $company_name = $_POST['company_name'] ?? ''; + $address_1 = $_POST['address_1'] ?? ''; + $address_2 = $_POST['address_2'] ?? ''; + $city = $_POST['city'] ?? ''; + $province = $_POST['province'] ?? ''; + $postal_code = $_POST['postal_code'] ?? ''; + $phone = $_POST['phone'] ?? ''; + $phone_2 = $_POST['phone_2'] ?? ''; + $email = $_POST['email'] ?? ''; + $website = $_POST['website'] ?? ''; + $fiscal_year_end = $_POST['fiscal_year_end'] ?: null; + $business_number = $_POST['business_number'] ?? ''; + $timezone = $_POST['timezone'] ?? ''; + $sector = $_POST['sector'] ?? ''; + $notifications_enabled = isset($_POST['notifications_enabled']) ? 1 : 0; + + // Handle Logo Upload + $logo_path = $_POST['current_logo'] ?? ''; + if (isset($_FILES['logo']) && $_FILES['logo']['error'] === UPLOAD_ERR_OK) { + $upload_dir = __DIR__ . '/assets/images/logo/'; + if (!is_dir($upload_dir)) { + mkdir($upload_dir, 0775, true); + } + $ext = pathinfo($_FILES['logo']['name'], PATHINFO_EXTENSION); + $filename = 'company_logo_' . time() . '.' . $ext; + $target = $upload_dir . $filename; + + if (move_uploaded_file($_FILES['logo']['tmp_name'], $target)) { + $logo_path = 'assets/images/logo/' . $filename; + } + } + + try { + $stmt = db()->prepare(" + UPDATE company_settings + SET company_name = ?, address_1 = ?, address_2 = ?, city = ?, province = ?, + postal_code = ?, phone = ?, phone_2 = ?, email = ?, website = ?, + fiscal_year_end = ?, business_number = ?, timezone = ?, sector = ?, + notifications_enabled = ?, logo_path = ? + WHERE id = 1 + "); + $stmt->execute([ + $company_name, $address_1, $address_2, $city, $province, + $postal_code, $phone, $phone_2, $email, $website, + $fiscal_year_end, $business_number, $timezone, $sector, + $notifications_enabled, $logo_path + ]); + $success = true; + } catch (PDOException $e) { + $error = "Error updating settings: " . $e->getMessage(); + } +} + +// Fetch Current Settings +$settings = db()->query("SELECT * FROM company_settings WHERE id = 1")->fetch(); + +$pageTitle = "SR&ED Manager - Company Preferences"; +include __DIR__ . '/includes/header.php'; +?> + +
Manage your business identity and application-wide settings.
+