diff --git a/public/index.php b/public/index.php index 46ed24d..0d4283e 100644 --- a/public/index.php +++ b/public/index.php @@ -249,7 +249,7 @@ $routes = [ } catch (\RuntimeException $e) { $errMsg = urlencode($e->getMessage()); $redirect = $isNew - ? '/admin/companies/new?error=' . $errMsg + ? '/admin/company/edit?error=' . $errMsg : '/admin/company/edit?id=' . (int)$data['id'] . '&error=' . $errMsg; header('Location: ' . $redirect); } diff --git a/services/CompanyRepository.php b/services/CompanyRepository.php index 4cece14..5563250 100644 --- a/services/CompanyRepository.php +++ b/services/CompanyRepository.php @@ -50,6 +50,13 @@ class CompanyRepository } } + // Integer fields: cast so empty string '' doesn't fail the INT column + foreach (['requires_approval', 'is_active', 'erp_active_users'] as $f) { + if (array_key_exists($f, $data)) { + $data[$f] = (int)$data[$f]; + } + } + $params = []; $sets = []; foreach ($fields as $f) {