beginTransaction(); // 1. Create Company $stmt = db()->prepare("INSERT INTO companies (name, uprn_required) VALUES (?, ?)"); $stmt->execute([$companyName, $uprnRequired]); $companyId = db()->lastInsertId(); // 2. Insert Statuses $stmt = db()->prepare("INSERT INTO job_statuses (company_id, name, is_default, sort_order) VALUES (?, ?, ?, ?)"); foreach ($statuses as $index => $statusName) { if (trim($statusName) === '') continue; $isDefault = ($index === $defaultStatusIndex) ? 1 : 0; $stmt->execute([$companyId, $statusName, $isDefault, $index]); } // 3. Insert Folders $stmt = db()->prepare("INSERT INTO required_folders (company_id, name) VALUES (?, ?)"); foreach ($folders as $folderName) { if (trim($folderName) === '') continue; $stmt->execute([$companyId, $folderName]); } // 4. Create first Admin user (simplified for demo) $stmt = db()->prepare("INSERT INTO users (company_id, name, email, password, role) VALUES (?, ?, ?, ?, ?)"); $stmt->execute([$companyId, 'Admin User', 'admin@' . strtolower(str_replace(' ', '', $companyName)) . '.com', password_hash('password123', PASSWORD_DEFAULT), 'admin']); db()->commit(); $success = "Company setup successfully! You can now log in."; header('Refresh: 2; URL=index.php'); } catch (Exception $e) { db()->rollBack(); $error = "Database error: " . $e->getMessage(); } } } ?> Company Onboarding - RepairsPro

Company Onboarding

If enabled, every job must have a unique UPRN.

Define the workflow stages for your jobs.


These folders will appear on every job automatically.