Send the chosen company when switching branch
This commit is contained in:
@@ -3,7 +3,11 @@
|
||||
* switch_branch.php — Switch the active company for the current session.
|
||||
*
|
||||
* action: 'read' → return list of companies the user belongs to
|
||||
* action: 'update' → switch to the requested company_id
|
||||
* action: 'update' → switch to target_company_id
|
||||
*
|
||||
* The target is read from target_company_id, not company_id: every request
|
||||
* carries company_id = the CURRENT company (prepare_form_data in custom.js),
|
||||
* so reading it made a switch silently re-select the company already active.
|
||||
*/
|
||||
session_start();
|
||||
require_once '../../../assets/utils/db_auth.php';
|
||||
@@ -20,7 +24,7 @@ if ($action === 'read') {
|
||||
}
|
||||
|
||||
if ($action === 'update') {
|
||||
$target_company_id = (int)($data['company_id'] ?? 0);
|
||||
$target_company_id = (int)($data['target_company_id'] ?? 0);
|
||||
|
||||
if (!$target_company_id) {
|
||||
$answer['message'] = 'Invalid company.';
|
||||
|
||||
Reference in New Issue
Block a user