fix all issues

This commit is contained in:
root
2026-03-24 01:02:36 -04:00
parent 0f8a1fa0b1
commit 58445b2a48
19 changed files with 674 additions and 167 deletions
+29 -1
View File
@@ -421,17 +421,45 @@ class FlagController extends Controller
log_message('debug', 'Flag state: ' . $this->request->getPost('flag_state'));
$currentFlagModel = new CurrentFlagModel();
$userId = session()->get('user_id');
// Get the new flag state from the form
$newState = $this->request->getPost('flag_state');
$stateDescription = (string) ($this->request->getPost('state_description') ?? '');
$actionTaken = (string) ($this->request->getPost('action_taken') ?? '');
if (!$newState) {
session()->setFlashdata('error', 'incident state not provided.');
return $this->index();
}
$update = ['flag_state' => $newState];
if ($newState === 'Closed') {
$update['updated_by_closed'] = $userId;
if ($stateDescription !== '') {
$update['close_description'] = $stateDescription;
}
if ($actionTaken !== '') {
$update['action_taken'] = $actionTaken;
}
} elseif ($newState === 'Canceled') {
$update['updated_by_canceled'] = $userId;
if ($stateDescription !== '') {
$update['cancel_description'] = $stateDescription;
}
if ($actionTaken !== '') {
$update['action_taken'] = $actionTaken;
}
}
// Update the flag state in the database
if ($currentFlagModel->update($id, ['flag_state' => $newState])) {
if ($currentFlagModel->update($id, $update)) {
if ($newState === 'Closed' || $newState === 'Canceled') {
$flagData = $currentFlagModel->find($id);
if ($flagData) {
return $this->moveToHistory($flagData);
}
}
session()->setFlashdata('success', 'Incident state updated successfully!');
} else {
$errors = $currentFlagModel->errors();