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'; +?> + +
+
+
+
+
+

Company Preferences

+

Manage your business identity and application-wide settings.

+
+ + Back to Settings + +
+ + + + + + + + + +
+ + + +
+
+
+
Company Identity
+
+
+
+
+
+ + +
+
+
+ + +
+
+ + +
+
+
+
+ +
+ + Logo + +
+ +
+ +
+ +

Recommended: PNG or SVG with transparent background.

+
+
+
+
+
+ + +
+
+
+
Address & Contact Info
+
+
+
+ + +
+
+ + +
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+ + +
+
+
+
Operations
+
+
+
+ + +

Important: This date is used for tax reporting and financial summaries.

+
+
+ + +
+
+ > + +

Global toggle for email alerts and system notifications.

+
+
+
+ +
+ +
+
+
+
+
+
+ + diff --git a/db/migrations/004_company_settings.sql b/db/migrations/004_company_settings.sql new file mode 100644 index 0000000..f6f5fa9 --- /dev/null +++ b/db/migrations/004_company_settings.sql @@ -0,0 +1,24 @@ +CREATE TABLE IF NOT EXISTS company_settings ( + id INT PRIMARY KEY DEFAULT 1, + company_name VARCHAR(255), + address_1 VARCHAR(255), + address_2 VARCHAR(255), + city VARCHAR(100), + province VARCHAR(100), + postal_code VARCHAR(20), + phone VARCHAR(20), + phone_2 VARCHAR(20), + email VARCHAR(255), + website VARCHAR(255), + fiscal_year_end DATE, + business_number VARCHAR(100), + timezone VARCHAR(100), + sector VARCHAR(100), + notifications_enabled TINYINT(1) DEFAULT 1, + logo_path VARCHAR(255), + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + CONSTRAINT single_row CHECK (id = 1) +) ENGINE=InnoDB; + +-- Initialize with default values if not exists +INSERT IGNORE INTO company_settings (id, company_name) VALUES (1, 'My ERP Company'); diff --git a/includes/header.php b/includes/header.php index d3d4a35..17cf347 100644 --- a/includes/header.php +++ b/includes/header.php @@ -67,11 +67,12 @@ $currentPage = basename($_SERVER['PHP_SELF']);