fix: company save — cast int fields, fix error redirect URL
- Cast erp_active_users (and requires_approval, is_active) to int before INSERT/UPDATE so empty string '' doesn't fail the INT column - Fix error redirect for new company: was /admin/companies/new (404), now /admin/company/edit (the actual new-company route) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
b25126e52b
commit
cb348bd602
+1
-1
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user