CHANGE_APIS
This commit is contained in:
parent
0093ed8ab3
commit
aeedae09fc
@ -2820,18 +2820,29 @@ class EmployeeRestController extends AdminController
|
|||||||
{
|
{
|
||||||
$policyGroup = 'gpa';
|
$policyGroup = 'gpa';
|
||||||
$data['ticket_type_id'] = 2;
|
$data['ticket_type_id'] = 2;
|
||||||
|
$data['claim_subject'] = "Claim GPA";
|
||||||
|
$data['sum_insured_label'] = "Sum Assured";
|
||||||
|
|
||||||
}else if($ClientPolicyValue['policy_type_id'] == 6)
|
}else if($ClientPolicyValue['policy_type_id'] == 6)
|
||||||
{
|
{
|
||||||
$policyGroup = 'gpa';
|
$policyGroup = 'gpa';
|
||||||
$data['ticket_type_id'] = 3;
|
$data['ticket_type_id'] = 3;
|
||||||
|
$data['claim_subject'] = "Claim EDLI";
|
||||||
|
$data['sum_insured_label'] = "Sum Assured";
|
||||||
|
|
||||||
}else if($ClientPolicyValue['policy_type_id'] == 7)
|
}else if($ClientPolicyValue['policy_type_id'] == 7)
|
||||||
{
|
{
|
||||||
$policyGroup = 'gpa';
|
$policyGroup = 'gpa';
|
||||||
$data['ticket_type_id'] = 4;
|
$data['ticket_type_id'] = 4;
|
||||||
|
$data['claim_subject'] = "Claim GTLI";
|
||||||
|
$data['sum_insured_label'] = "Sum Assured";
|
||||||
|
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
$policyGroup = 'gmc';
|
$policyGroup = 'gmc';
|
||||||
$data['ticket_type_id'] = 1;
|
$data['ticket_type_id'] = 1;
|
||||||
|
$data['claim_subject'] = "Claim GMC";
|
||||||
|
$data['sum_insured_label'] = "Sum Insured";
|
||||||
}
|
}
|
||||||
|
|
||||||
$terms = json_decode($ClientPolicyValue['policy_terms'] , true);
|
$terms = json_decode($ClientPolicyValue['policy_terms'] , true);
|
||||||
@ -3545,14 +3556,101 @@ class EmployeeRestController extends AdminController
|
|||||||
}
|
}
|
||||||
|
|
||||||
//department
|
//department
|
||||||
|
// public function get_ticket_type()
|
||||||
|
// {
|
||||||
|
// $ticket_type = $this->ticketController->ticketType;
|
||||||
|
// $ticket_type = array_map(fn($value, $key) => (object) ['id' => $key, 'name' => $value], array_values($ticket_type), array_keys($ticket_type));
|
||||||
|
// // print_r($ticket_type); die;
|
||||||
|
// return $this->response->setJSON(['ticket_type' => $ticket_type])->setStatusCode(200);
|
||||||
|
// }
|
||||||
|
|
||||||
public function get_ticket_type()
|
public function get_ticket_type()
|
||||||
{
|
{
|
||||||
$ticket_type = $this->ticketController->ticketType;
|
try {
|
||||||
$ticket_type = array_map(fn($value, $key) => (object) ['id' => $key, 'name' => $value], array_values($ticket_type), array_keys($ticket_type));
|
|
||||||
// print_r($ticket_type); die;
|
$client_id = $this->request->getGet('client_id');
|
||||||
return $this->response->setJSON(['ticket_type' => $ticket_type])->setStatusCode(200);
|
$emp_code = $this->request->getGet('emp_code');
|
||||||
|
|
||||||
|
if (empty($client_id) || empty($emp_code)) {
|
||||||
|
$this->myLogger->logme('error', "Missing required parameters: client_id={$client_id}, emp_code={$emp_code}");
|
||||||
|
return $this->response->setJSON([
|
||||||
|
'status' => false,
|
||||||
|
'code' => 400,
|
||||||
|
'message' => 'client_id and emp_code are required'
|
||||||
|
])->setStatusCode(400);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get policy type ids
|
||||||
|
$policy_type_ids = $this->employeePolicyModel
|
||||||
|
->select('client_policy.policy_type_id')
|
||||||
|
->join('employees', 'employee_polices.employee_id = employees.id')
|
||||||
|
->join('client_policy', 'employee_polices.client_policy_id = client_policy.id')
|
||||||
|
->where('employees.is_active', 1)
|
||||||
|
->whereIn('employees.emp_status', ['active', 'expired'])
|
||||||
|
->where('employee_polices.is_active', 1)
|
||||||
|
->whereIn('employee_polices.status', ['active', 'expired'])
|
||||||
|
->where('employees.client_id', $client_id)
|
||||||
|
->where('employees.emp_code', $emp_code)
|
||||||
|
->groupBy('employee_polices.client_policy_id')
|
||||||
|
->findAll();
|
||||||
|
|
||||||
|
if (!$policy_type_ids) {
|
||||||
|
$this->myLogger->logme('error', "No policy types found for client_id={$client_id}, emp_code={$emp_code}");
|
||||||
|
return $this->response->setJSON([
|
||||||
|
'status' => false,
|
||||||
|
'code' => 404,
|
||||||
|
'message' => 'No policy types found'
|
||||||
|
])->setStatusCode(404);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->myLogger->logme('info', "Policy type IDs fetched: " . json_encode($policy_type_ids));
|
||||||
|
|
||||||
|
$ticket_type = $this->ticketController->ticketType;
|
||||||
|
$filtered = [];
|
||||||
|
|
||||||
|
$mapping = [
|
||||||
|
2 => 1,
|
||||||
|
3 => 1,
|
||||||
|
4 => 1,
|
||||||
|
5 => 1,
|
||||||
|
1 => 2,
|
||||||
|
6 => 3,
|
||||||
|
7 => 4,
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($policy_type_ids as $value) {
|
||||||
|
$ticketTypeId = $value['policy_type_id'] ?? null;
|
||||||
|
|
||||||
|
if (isset($mapping[$ticketTypeId]) && isset($ticket_type[$mapping[$ticketTypeId]])) {
|
||||||
|
$mappedId = $mapping[$ticketTypeId];
|
||||||
|
$mappedName = $ticket_type[$mappedId];
|
||||||
|
|
||||||
|
// Use mappedId as key to avoid duplicates
|
||||||
|
$filtered[$mappedId] = [
|
||||||
|
'id' => $mappedId,
|
||||||
|
'name' => $mappedName
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->myLogger->logme('info', "Ticket type resolved: ID={$ticketTypeId}, Name={$mappedName}");
|
||||||
|
} else {
|
||||||
|
$this->myLogger->logme('warning', "No valid ticket type mapping for policy_type_id={$ticketTypeId}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$filtered = array_values($filtered);
|
||||||
|
return $this->response->setJSON(['status' => true,'code' => 200, 'ticket_type' => $filtered ])->setStatusCode(200);
|
||||||
|
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
$this->myLogger->logme('error', "Error in get_ticket_type: " . $e->getMessage() . " Trace: " . $e->getTraceAsString());
|
||||||
|
return $this->response->setJSON([
|
||||||
|
'status' => false,
|
||||||
|
'code' => 500,
|
||||||
|
'message' => 'Internal Server Error'
|
||||||
|
])->setStatusCode(500);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//ticket data
|
//ticket data
|
||||||
public function get_ticket_data()
|
public function get_ticket_data()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
namespace App\Controllers;
|
namespace App\Controllers;
|
||||||
|
|
||||||
use App\Controllers\BaseController;
|
use App\Controllers\BaseController;
|
||||||
|
use App\Models\EmployeePolicyModel;
|
||||||
use CodeIgniter\HTTP\ResponseInterface;
|
use CodeIgniter\HTTP\ResponseInterface;
|
||||||
use CodeIgniter\API\ResponseTrait;
|
use CodeIgniter\API\ResponseTrait;
|
||||||
use Dompdf\Dompdf;
|
use Dompdf\Dompdf;
|
||||||
@ -216,4 +217,23 @@ class TestingController extends BaseController
|
|||||||
'S' = return as string.
|
'S' = return as string.
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getEmployeePolicyTypes($client_id, $emp_code, $emp_id)
|
||||||
|
{
|
||||||
|
$employeePolicy = new EmployeePolicyModel();
|
||||||
|
|
||||||
|
$data = $employeePolicy
|
||||||
|
->select('client_policy.policy_type_id')
|
||||||
|
->join('employees', 'employee_polices.employee_id = employees.id')
|
||||||
|
->join('client_policy', 'employee_polices.client_policy_id = client_policy.id')
|
||||||
|
->where('employees.is_active', 1)
|
||||||
|
->where('employees.emp_status', ['active', 'expired'])
|
||||||
|
->where('employee_polices.is_active', 1)
|
||||||
|
->where('employee_polices.status', ['active', 'expired'])
|
||||||
|
->where('employees.client_id', $client_id)
|
||||||
|
->where('employees.emp_code', $emp_code)
|
||||||
|
->groupBy('employee_polices.client_policy_id')
|
||||||
|
->findAll();
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -336,8 +336,7 @@
|
|||||||
<label for="waiverof30dayswaitingperiod">Waiver of 30 days waiting period</label>
|
<label for="waiverof30dayswaitingperiod">Waiver of 30 days waiting period</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<input type="text" name="waiverof30dayswaitingperiod" class="form-control waiverof30dayswaitingperiod"
|
<input type="text" name="waiverof30dayswaitingperiod" class="form-control waiverof30dayswaitingperiod">
|
||||||
value="1">
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user