1) user invitation 2) app access control 3) txn quota guard

This commit is contained in:
Thanakorn S
2026-05-21 11:42:47 +07:00
parent 8ec2e89f79
commit 6eeebfeacb
50 changed files with 1062 additions and 113 deletions
+9 -3
View File
@@ -191,11 +191,17 @@ try {
// ── Step 11: Map user as company owner ───────────────────────────────────
// company_map_user is the many-to-many table between users and companies.
// 'owner' role grants full admin access within the company.
// app_access mirrors the owner's license (user.app_access) so the column
// is never NULL and switch_branch reads consistent data.
$sth = $pdo1->prepare("SELECT app_access FROM user WHERE user_id = :u LIMIT 1");
$sth->execute([':u' => $user_id]);
$owner_app_access = $sth->fetchColumn() ?: 'wms';
$sth = $pdo1->prepare("
INSERT INTO company_map_user (company_id, user_id, role, created_at)
VALUES (:company_id, :user_id, 'owner', NOW())
INSERT INTO company_map_user (company_id, user_id, role, app_access, created_at)
VALUES (:company_id, :user_id, 'owner', :app_access, NOW())
");
$sth->execute([':company_id' => $company_id, ':user_id' => $user_id]);
$sth->execute([':company_id' => $company_id, ':user_id' => $user_id, ':app_access' => $owner_app_access]);
db_check($sth, $answer);
// ── Step 12: Activate user account and set default company ───────────────