exec(" CREATE TABLE IF NOT EXISTS company_settings ( id INT AUTO_INCREMENT PRIMARY KEY, setting_key VARCHAR(100) UNIQUE NOT NULL, setting_value TEXT, updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ) "); } catch (Exception $e) { // Table might already exist } // Handle form submission if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['save_settings'])) { try { $fields = [ 'company_name', 'company_address', 'company_city', 'company_state', 'company_country', 'company_pincode', 'company_phone', 'company_email', 'company_website', 'tax_gst', 'tax_pan', 'tax_cin', 'tax_sac_code', 'bank_name', 'bank_account_name', 'bank_account_number', 'bank_ifsc', 'bank_branch', 'bank_swift', 'invoice_prefix', 'invoice_terms', 'invoice_notes', 'invoice_footer' ]; $stmt = $pdo->prepare(" INSERT INTO company_settings (setting_key, setting_value, updated_at) VALUES (?, ?, NOW()) ON DUPLICATE KEY UPDATE setting_value = VALUES(setting_value), updated_at = NOW() "); foreach ($fields as $field) { $value = trim($_POST[$field] ?? ''); $stmt->execute([$field, $value]); } $success = 'Company settings saved successfully!'; $mode = 'view'; logActivity($_SESSION['admin_id'], 'update', 'Updated company invoicing settings', 'settings', null); } catch (Exception $e) { $error = 'Error saving settings: ' . $e->getMessage(); $mode = 'edit'; } } // Load current settings $settings = []; try { $result = $pdo->query("SELECT setting_key, setting_value FROM company_settings"); while ($row = $result->fetch()) { $settings[$row['setting_key']] = $row['setting_value']; } } catch (Exception $e) {} function getSetting($key, $default = '') { global $settings; return $settings[$key] ?? $default; } $hasData = !empty(array_filter($settings)); include 'includes/header.php'; ?>

Company Settings

Manage your company details used in client invoicing

📋

No Company Details Saved Yet

Add your company information for invoicing by switching to Edit mode.

✏ Add Company Details

🏢 Company Information

Basic company details that appear on invoices and official documents.

— Not set

📋 Tax & Registration

Tax identification numbers and registration details.

💳 Bank Details

Banking information displayed on invoices for client payments.

📄 Invoice Preferences

Default text and formatting for generated invoices.

🏢 Company Information

Basic company details that appear on invoices and official documents.

📋 Tax & Registration

Tax identification numbers and registration details for invoicing compliance.

GST Identification Number or equivalent Tax ID
Permanent Account Number
Corporate Identification Number
Service Accounting Code for your services

💳 Bank Details

Banking information displayed on invoices for client payments.

Required for international payments

📄 Invoice Preferences

Default text and formatting preferences for generated invoices.

e.g. RR-INV-001, RR-INV-002 ...
Cancel