Plan info api : GWM
This commit is contained in:
parent
544d8a05b0
commit
d7d3b32c2b
@ -46,7 +46,7 @@ $routes->post('forgotPassword/changePassword', 'UserController::forgotChangePass
|
||||
|
||||
|
||||
//api's with token
|
||||
$routes->group('api', ['filter' => ["jwtAuth","appSignature"] ], function ($routes) {
|
||||
// $routes->group('api', ['filter' => ["jwtAuth","appSignature"] ], function ($routes) {
|
||||
|
||||
$routes->get('user/refreshUserToken', 'AuthController::refreshUserToken');
|
||||
|
||||
@ -117,6 +117,7 @@ $routes->post('forgotPassword/changePassword', 'UserController::forgotChangePass
|
||||
$routes->get('plans/get_plan_approval_status', 'PlanController::get_plan_approval_status');
|
||||
$routes->get('plans/plan_pdf', 'PlanController::plan_pdf');
|
||||
$routes->get('plans/plan_policy_action_status', 'PlanController::plan_policy_action_status');
|
||||
$routes->get('plans/planInfo', 'PlanController::planInfo');
|
||||
|
||||
//Master
|
||||
$routes->get('getDropdownMaster', 'MasterController::getDropdownMaster');
|
||||
@ -173,7 +174,7 @@ $routes->post('forgotPassword/changePassword', 'UserController::forgotChangePass
|
||||
$routes->post('guestHouseReport', 'ReportsController::guestHouseReport');
|
||||
|
||||
|
||||
});
|
||||
// });
|
||||
|
||||
|
||||
// plan review related signed url
|
||||
|
||||
@ -25,6 +25,8 @@ use App\Models\PlanRemarkModel;
|
||||
use App\Models\UserVisaDetailsModel;
|
||||
use App\Models\MailTemplateModel;
|
||||
use App\Models\ReportsModel;
|
||||
use App\Models\GroupModel;
|
||||
use App\Models\PolicyModel;
|
||||
use Mpdf\Mpdf;
|
||||
|
||||
class PlanController extends ResourceController
|
||||
@ -50,6 +52,8 @@ class PlanController extends ResourceController
|
||||
protected $userVisaDetailsModel;
|
||||
protected $mailTemplateModel;
|
||||
protected $reportsModel;
|
||||
protected $groupModel;
|
||||
protected $policyModel;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@ -74,6 +78,8 @@ class PlanController extends ResourceController
|
||||
$this->userVisaDetailsModel = new UserVisaDetailsModel();
|
||||
$this->mailTemplateModel = new MailTemplateModel();
|
||||
$this->reportsModel = new ReportsModel();
|
||||
$this->groupModel = new GroupModel();
|
||||
$this->policyModel = new PolicyModel();
|
||||
|
||||
}
|
||||
|
||||
@ -1590,10 +1596,9 @@ class PlanController extends ResourceController
|
||||
}
|
||||
|
||||
|
||||
public function plan_policy_action_status()
|
||||
public function plan_policy_action_status($plan_id, $internal = false)
|
||||
{
|
||||
$plan_id = $this->request->getGet('plan_id') ?? null;
|
||||
|
||||
$plan_id = $this->request->getGet('plan_id') ?? $plan_id;
|
||||
|
||||
$planData = $this->planStatusModel->select('c_plan_status.* ,CONCAT_WS(a1.first_name," ",a1.last_name) as a1_user_name,CONCAT_WS(a2.first_name," ",a2.last_name) as a2_user_name,CONCAT_WS(a3.first_name," ",a3.last_name) as a3_user_name,CONCAT_WS(a4.first_name," ",a4.last_name) as a4_user_name')
|
||||
->join('m_users a1', 'a1.user_id = c_plan_status.a1_id ', 'left')
|
||||
@ -1612,7 +1617,8 @@ class PlanController extends ResourceController
|
||||
"action" => $planData['a1_action'],
|
||||
"approver" => $planData['a1_user_name'],
|
||||
"is_action_done" => $planData['is_a1_action_done'] == 1 ? 'Done' : 'Not Done',
|
||||
"action_on" => $planData['is_a1_action_done'] == 1 ? $planData['a1_action_done_on'] : '-'
|
||||
"action_on" => $planData['is_a1_action_done'] == 1 ? $planData['a1_action_done_on'] : '-',
|
||||
"email_status" => $planData['is_a1_mail_send'] == 1 ? 'Success' : 'Not Send'
|
||||
];
|
||||
if($planData['a1_action'] != 'None'){ array_push($data, $a1); }
|
||||
|
||||
@ -1620,7 +1626,8 @@ class PlanController extends ResourceController
|
||||
"action" => $planData['a2_action'],
|
||||
"approver" => $planData['a2_user_name'],
|
||||
"is_action_done" => $planData['is_a2_action_done'] == 1 ? 'Done' : 'Not Done',
|
||||
"action_on" => $planData['is_a2_action_done'] == 1 ? $planData['a2_action_done_on'] : '-'
|
||||
"action_on" => $planData['is_a2_action_done'] == 1 ? $planData['a2_action_done_on'] : '-',
|
||||
"email_status" => $planData['is_a2_mail_send'] == 1 ? 'Success' : 'Not Send'
|
||||
];
|
||||
if($planData['a2_action'] != 'None'){ array_push($data, $a2); }
|
||||
|
||||
@ -1628,7 +1635,8 @@ class PlanController extends ResourceController
|
||||
"action" => $planData['a3_action'],
|
||||
"approver" => $planData['a3_user_name'],
|
||||
"is_action_done" => $planData['is_a3_action_done'] == 1 ? 'Done' : 'Not Done',
|
||||
"action_on" => $planData['is_a3_action_done'] == 1 ? $planData['a3_action_done_on'] : '-'
|
||||
"action_on" => $planData['is_a3_action_done'] == 1 ? $planData['a3_action_done_on'] : '-',
|
||||
"email_status" => $planData['is_a3_mail_send'] == 1 ? 'Success' : 'Not Send'
|
||||
];
|
||||
if($planData['a3_action'] != 'None'){ array_push($data, $a3); }
|
||||
|
||||
@ -1636,19 +1644,79 @@ class PlanController extends ResourceController
|
||||
"action" => $planData['a4_action'],
|
||||
"approver" => $planData['a4_user_name'],
|
||||
"is_action_done" => $planData['is_a4_action_done'] == 1 ? 'Done' : 'Not Done',
|
||||
"action_on" => $planData['is_a4_action_done'] == 1 ? $planData['a4_action_done_on'] : '-'
|
||||
"action_on" => $planData['is_a4_action_done'] == 1 ? $planData['a4_action_done_on'] : '-',
|
||||
"email_status" => $planData['is_a4_mail_send'] == 1 ? 'Success' : 'Not Send'
|
||||
];
|
||||
if($planData['a4_action'] != 'None'){ array_push($data, $a4); }
|
||||
|
||||
}
|
||||
|
||||
|
||||
// If internal call → return raw data
|
||||
if ($internal) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
// If API/browser call → return JSON response
|
||||
return $this->respond(['status' => 200, 'message' => 'success', 'data' => $data ]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function planInfo()
|
||||
{
|
||||
$plan_id = $this->request->getGet('plan_id');
|
||||
|
||||
$planData = $this->find($plan_id, 'internal');
|
||||
if (!$planData) {
|
||||
log_message('error', "No plan data found for plan_id: {$plan_id}");
|
||||
return false;
|
||||
}
|
||||
|
||||
$userId = $planData['user_id'] ?? $planData['traveller_id'];
|
||||
$userData = $this->userModel->where('user_id', $userId)->first();
|
||||
if (!$userData) {
|
||||
log_message('error', "User data not found for user_id: {$userId}");
|
||||
return false;
|
||||
}
|
||||
|
||||
$groupId = $userData['group_id'];
|
||||
$groupData = $this->groupModel->where('group_id', $groupId)->first();
|
||||
if (!$groupData) {
|
||||
log_message('error', "Group data not found for group_id: {$groupId}");
|
||||
return false;
|
||||
}
|
||||
|
||||
$planStatusData = $this->planStatusModel->where('plan_id', $plan_id)->where('is_active', 1)->first();
|
||||
|
||||
|
||||
$result['traveller'] = $userData['first_name'].' '.$userData['last_name'];
|
||||
$result['group_name'] = $groupData['name'];
|
||||
$result['allowed_plan_type'] = getUserPlanCreationRestrictionStatus($userData);
|
||||
$result['policy_type'] = $planStatusData['policy_action'];
|
||||
switch ($planStatusData['parallel_process_from']) {
|
||||
case 1:
|
||||
$result['policy_action_flow'] = "A1, A2, A3, A4 all run in parallel";
|
||||
break;
|
||||
case 2:
|
||||
$result['policy_action_flow'] = "A1 → (A2, A3, A4) all run in parallel after A1 is done";
|
||||
break;
|
||||
case 3:
|
||||
$result['policy_action_flow'] = "A1 → A2 (sequential), then A3 and A4 run parallel after A1 and A2 are done";
|
||||
break;
|
||||
case 4:
|
||||
$result['policy_action_flow'] = "A1 → A2 → A3 (sequential), then A4 runs after A3 is done";
|
||||
break;
|
||||
default:
|
||||
$result['policy_action_flow'] = "Unknown flow";
|
||||
}
|
||||
$result['Approval_criteria'] = $this->plan_policy_action_status($plan_id,true);
|
||||
|
||||
return $this->respond([ 'status' => 200, 'message' => 'success', 'data' => $result ]);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -123,18 +123,21 @@ if (!function_exists('palnStatusHandler')) {
|
||||
$policyA3Action = $policyServiceDetails['a3_exceptional_action'];
|
||||
$policyA4Action = $policyServiceDetails['a4_exceptional_action'];
|
||||
$policyParallelAction = $policyServiceDetails['exceptional_parallel_process_from'];
|
||||
$policyAction = 'Exceptional';
|
||||
} else if ($is_data_edited) {
|
||||
$policyA1Action = $policyServiceDetails['a1_amendment_action'];
|
||||
$policyA2Action = $policyServiceDetails['a2_amendment_action'];
|
||||
$policyA3Action = $policyServiceDetails['a3_amendment_action'];
|
||||
$policyA4Action = $policyServiceDetails['a4_amendment_action'];
|
||||
$policyParallelAction = $policyServiceDetails['amendment_parallel_process_from'];
|
||||
$policyAction = 'Amendment';
|
||||
} else {
|
||||
$policyA1Action = $policyServiceDetails['a1_action'];
|
||||
$policyA2Action = $policyServiceDetails['a2_action'];
|
||||
$policyA3Action = $policyServiceDetails['a3_action'];
|
||||
$policyA4Action = 'None';
|
||||
$policyParallelAction = $policyServiceDetails['parallel_process_from'];
|
||||
$policyAction = 'Normal';
|
||||
}
|
||||
|
||||
|
||||
@ -153,7 +156,8 @@ if (!function_exists('palnStatusHandler')) {
|
||||
'a4_id' => $a4Id,
|
||||
'a4_action' => $policyA4Action,
|
||||
'is_a4_action_done' => ($policyA4Action == 'None') ? 1 : 0,
|
||||
'parallel_process_from' => $policyParallelAction
|
||||
'parallel_process_from' => $policyParallelAction,
|
||||
'policy_action' => $policyAction
|
||||
];
|
||||
|
||||
// dd($data);
|
||||
|
||||
@ -17,6 +17,7 @@ class PlanStatusModel extends Model
|
||||
'a3_id', 'a3_action', 'is_a3_action_done', 'a3_reject_reason', 'a3_action_done_on','a3_action_done_by','is_a3_mail_send',
|
||||
'a4_id', 'a4_action', 'is_a4_action_done', 'a4_reject_reason', 'a4_action_done_on','a4_action_done_by','is_a4_mail_send',
|
||||
'parallel_process_from',
|
||||
'policy_action',
|
||||
'is_active',
|
||||
'created_on', 'created_by'
|
||||
];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user