903 lines
40 KiB
PHP
903 lines
40 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers;
|
|
|
|
use CodeIgniter\HTTP\IncomingRequest;
|
|
use CodeIgniter\HTTP\RequestInterface;
|
|
use CodeIgniter\HTTP\ResponseInterface;
|
|
use Psr\Log\LoggerInterface;
|
|
use CodeIgniter\API\ResponseTrait;
|
|
|
|
use App\Models\UserModel;
|
|
use App\Models\ClientModel;
|
|
use App\Models\ClientBranchModel;
|
|
use App\Models\ClientKYCDocsModel;
|
|
use App\Models\ClientPolicyModel;
|
|
use App\Models\ClientRMModel;
|
|
use App\Models\InsurerBranchModel;
|
|
use App\Models\InsurerModel;
|
|
use App\Models\KYCDocsModel;
|
|
use App\Models\KYCEntityTypeModel;
|
|
use App\Models\LevelContactModel;
|
|
use App\Models\PolicesModel;
|
|
use App\Models\TPABranchModel;
|
|
use App\Models\TPAModel;
|
|
use App\Models\StateModel;
|
|
use App\Models\PolicyGridModel;
|
|
use App\Models\PolicyPremium1Model;
|
|
use App\Models\PolicyPremium2Model;
|
|
use App\Models\EmployeeModel;
|
|
|
|
class ClientController extends AdminController
|
|
{
|
|
use ResponseTrait;
|
|
|
|
protected $myLogger;
|
|
protected $clientModel;
|
|
protected $userModel;
|
|
protected $clientBranchModel;
|
|
protected $clientKYCDocsModel;
|
|
protected $clientPolicyModel;
|
|
protected $clientRMModel;
|
|
protected $insurerBranchModel;
|
|
protected $insurerModel;
|
|
protected $kycDocsModel;
|
|
protected $kycEntityTypeModel;
|
|
protected $levelContactModel;
|
|
protected $policesModel;
|
|
protected $tpaBranchModel;
|
|
protected $tpaModel;
|
|
protected $stateModel;
|
|
protected $policyGridModel;
|
|
protected $policyPremium1Model;
|
|
protected $policyPremium2Model;
|
|
protected $employeeModel;
|
|
|
|
public function __construct()
|
|
{
|
|
set_session_context('Client');
|
|
$this->myLogger = \Config\Services::mylogger();
|
|
|
|
$this->clientModel = new ClientModel();
|
|
$this->userModel = new UserModel();
|
|
$this->clientBranchModel = new ClientBranchModel();
|
|
$this->clientKYCDocsModel = new ClientKYCDocsModel();
|
|
$this->clientPolicyModel = new ClientPolicyModel();
|
|
$this->clientRMModel = new ClientRMModel();
|
|
$this->insurerBranchModel = new InsurerBranchModel();
|
|
$this->insurerModel = new InsurerModel();
|
|
$this->kycDocsModel = new KYCDocsModel();
|
|
$this->kycEntityTypeModel = new KYCEntityTypeModel();
|
|
$this->levelContactModel = new LevelContactModel();
|
|
$this->policesModel = new PolicesModel();
|
|
$this->tpaBranchModel = new TPABranchModel();
|
|
$this->tpaModel = new TPAModel();
|
|
$this->stateModel = new StateModel();
|
|
$this->policyGridModel = new PolicyGridModel();
|
|
$this->policyPremium1Model = new PolicyPremium1Model();
|
|
$this->policyPremium2Model = new PolicyPremium2Model();
|
|
$this->employeeModel = new EmployeeModel();
|
|
|
|
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
$this->myLogger->logme('error','Client list function called');
|
|
$headerData['page_name'] = 'Client List';
|
|
$data['clientList'] = $this->clientModel->getCreatedByUserName();
|
|
$data['client_rm'] = $this->clientRMModel->getAllClientRM();
|
|
// echo '<pre>';
|
|
// print_r($data); die;
|
|
echo view('layout/header', $headerData);
|
|
echo view('client_list', $data);
|
|
echo view('layout/footer');
|
|
|
|
// $this->loadLayout('client_onboarding', $data);
|
|
}
|
|
|
|
public function clientOnboarding()
|
|
{
|
|
|
|
$this->myLogger->logme('error','Client Onboarding function called');
|
|
$headerData['page_name'] = 'Client Onboarding';
|
|
|
|
$data['entity'] = $this->kycEntityTypeModel->findAll();
|
|
$data['kyc_docs'] = $this->kycDocsModel->findAll();
|
|
$data['police'] = $this->policesModel->findAll();
|
|
$data['insurer'] = $this->insurerBranchModel ->getInsurerBranchesWithInsurerNames();
|
|
$data['tpa'] = $this->tpaBranchModel ->getTpaBranchesWithTpaNames();
|
|
$data['state'] = $this->stateModel->getAllStates();
|
|
$data['RM'] = $this->userModel->findAll();
|
|
$data['policyGridData'] = $this->policyGridModel->findAll();
|
|
|
|
// echo "<pre>";
|
|
// print_r($data); die;
|
|
|
|
echo view('layout/header', $headerData);
|
|
echo view('client_onboarding', $data);
|
|
echo view('layout/footer');
|
|
|
|
}
|
|
|
|
public function editClientOnboarding($id = null)
|
|
{
|
|
|
|
$this->myLogger->logme('error','Edit Client Onboarding function called');
|
|
$headerData['page_name'] = 'Edit Client Onboarding';
|
|
|
|
$editData['RM'] = $this->userModel->findAll();
|
|
$editData['tpa'] = $this->tpaBranchModel ->getTpaBranchesWithTpaNames();
|
|
$editData['state'] = $this->stateModel->getAllStates();
|
|
$editData['police'] = $this->policesModel->findAll();
|
|
$editData['entity'] = $this->kycEntityTypeModel->findAll();
|
|
$editData['insurer'] = $this->insurerBranchModel ->getInsurerBranchesWithInsurerNames();
|
|
$editData['kyc_docs'] = $this->kycDocsModel->findAll();
|
|
$editData['policyGridData'] = $this->policyGridModel->findAll();
|
|
|
|
|
|
$editData['client'] = $this->clientModel->where(['id' => $id, 'is_active' => 1])->first();
|
|
$editData['client_kyc'] = $this->clientKYCDocsModel->where('client_id', $id)->findAll();
|
|
$editData['client_branch'] = $this->clientBranchModel->where(['client_id' => $id, 'is_active' => 1])->findAll();
|
|
$editData['client_relation'] = $this->clientRMModel->where(['client_id' => $id, 'is_active' => 1])->findAll();
|
|
$editData['client_policy'] = $this->clientPolicyModel->getClientPolicyByClientId($id);
|
|
|
|
// echo "<pre>";
|
|
// print_r($editData); die;
|
|
|
|
echo view('layout/header', $headerData);
|
|
echo view('client_onboarding', $editData);
|
|
echo view('layout/footer');
|
|
|
|
}
|
|
|
|
public function createClientGeneralInfo()
|
|
{
|
|
|
|
$this->myLogger->logme('error','Client general info function called');
|
|
$data = $this->request->getPost();
|
|
$data['created_by'] = get_session_userid();
|
|
$insert = $this->clientModel->insert($data);
|
|
if($insert){
|
|
$client_data = $this->clientModel->where(['id' => $insert, 'is_active' => 1])->first();
|
|
echo json_encode(array("status" => true , 'data' => $client_data));
|
|
}else{
|
|
echo json_encode(array("status" => false));
|
|
}
|
|
}
|
|
|
|
public function editClientGeneralInfo()
|
|
{
|
|
$this->myLogger->logme('error','edit client general info function called');
|
|
$id = $this->request->getPost('PrimaryKey');
|
|
$data = $this->request->getPost();
|
|
$data['updated_by'] = get_session_userid();
|
|
$update = $this->clientModel->update($id,$data);
|
|
if($update){
|
|
echo json_encode(array("status" => true , 'data' => $data));
|
|
}else{
|
|
echo json_encode(array("status" => false));
|
|
}
|
|
}
|
|
|
|
public function createClientKYCInfo()
|
|
{
|
|
$this->myLogger->logme('error','create Client kyc function called');
|
|
$data = $this->request->getPost();
|
|
unset($data['file_name']);
|
|
$File = file_Upload($this->request->getFile('file_name'));
|
|
if(!empty($File)){
|
|
$data['file_name'] = $File;
|
|
}
|
|
|
|
$data['created_by'] = get_session_userid();
|
|
$insert = $this->clientKYCDocsModel->insert($data);
|
|
if($insert){
|
|
|
|
$kycDocs = $this->clientKYCDocsModel->where('client_id',$this->request->getPost('client_id'))->findAll();
|
|
echo json_encode(array("status" => true , 'data' => $kycDocs, 'file_name' => $File));
|
|
}else{
|
|
echo json_encode(array("status" => false));
|
|
}
|
|
}
|
|
|
|
public function editClientKYCInfo()
|
|
{
|
|
|
|
$this->myLogger->logme('error','edit client kyc function called');
|
|
$File = file_Upload($this->request->getFile('file_name'));
|
|
if(!empty($File)){
|
|
$data['file_name'] = $File;
|
|
}
|
|
$id = $this->request->getPost('PrimaryKey');
|
|
$data['client_id'] = $id;
|
|
$data['kyc_doc_type_id'] = $this->request->getPost('kyc_doc_id');
|
|
$data['updated_by'] = get_session_userid();
|
|
$insert = $this->clientKYCDocsModel->insert($data);
|
|
if($insert){
|
|
$kycDocs = $this->clientKYCDocsModel->getKycDocsName($id);
|
|
echo json_encode(array("status" => true , 'data' => $kycDocs));
|
|
}else{
|
|
echo json_encode(array());
|
|
}
|
|
}
|
|
|
|
public function deleteClientKycDocs($id=null)
|
|
{
|
|
|
|
$delete = $this->clientKYCDocsModel->where('kyc_doc_type_id', $id)->delete();
|
|
if($delete){
|
|
echo json_encode(array("status" => true, 'id' => $id ));
|
|
}else{
|
|
echo json_encode(array("status" => false));
|
|
}
|
|
}
|
|
|
|
public function deleteClientKycOtherDocs($id=null)
|
|
{
|
|
|
|
$delete = $this->clientKYCDocsModel->where('id', $id)->delete();
|
|
if($delete){
|
|
echo json_encode(array("status" => true, 'id' => $id ));
|
|
}else{
|
|
echo json_encode(array("status" => false));
|
|
}
|
|
}
|
|
|
|
public function createClientRelation()
|
|
{
|
|
|
|
$this->myLogger->logme('error','Client relation function called');
|
|
|
|
$data['client_id'] = $this->request->getPost('client_id');
|
|
$data['created_by'] = get_session_userid();
|
|
$inserted = false;
|
|
|
|
if ($this->request->getPost('head')) {
|
|
$data['level'] = "1";
|
|
$data['user_id'] = $this->request->getPost('head');
|
|
$inserted = $this->clientRMModel->insert($data);
|
|
}
|
|
|
|
if ($this->request->getPost('manager')) {
|
|
$data['level'] = "2";
|
|
$data['user_id'] = $this->request->getPost('manager');
|
|
$inserted = $this->clientRMModel->insert($data);
|
|
}
|
|
|
|
if ($this->request->getPost('account_manager')) {
|
|
$data['level'] = "3";
|
|
foreach ($this->request->getPost('account_manager') as $value) {
|
|
$data['user_id'] = $value;
|
|
$inserted = $this->clientRMModel->insert($data);
|
|
}
|
|
}
|
|
|
|
if ($inserted) {
|
|
echo json_encode(array("status" => true, 'data' => $this->request->getPost()));
|
|
} else {
|
|
echo json_encode(array("status" => false));
|
|
}
|
|
}
|
|
|
|
public function editClientRelation()
|
|
{
|
|
$this->myLogger->logme('error','Client relation function called');
|
|
|
|
$id = $this->request->getPost('PrimaryKey');
|
|
$data['client_id'] = $this->request->getPost('client_id');
|
|
$data['updated_by'] = get_session_userid();
|
|
$inserted = false;
|
|
|
|
if ($this->request->getPost('head')) {
|
|
$data['user_id'] = $this->request->getPost('head');
|
|
$checkHead = $this->clientRMModel->checkExistenceOfClientRelation($id, $this->request->getPost('head'), 1);
|
|
if($checkHead){
|
|
$inserted = $this->clientRMModel->where('client_id', $id )->where('level', 1)->set($data)->update();
|
|
}else{
|
|
$data['level'] = "1";
|
|
$data['user_id'] = $this->request->getPost('head');
|
|
$inserted = $this->clientRMModel->insert($data);
|
|
}
|
|
}
|
|
|
|
if ($this->request->getPost('manager')) {
|
|
$data['user_id'] = $this->request->getPost('manager');
|
|
$checkHead = $this->clientRMModel->checkExistenceOfClientRelation($id, $this->request->getPost('manager'), 2);
|
|
if($checkHead){
|
|
$inserted = $this->clientRMModel->where('client_id', $id )->where('level', 2)->set($data)->update();
|
|
}else{
|
|
$data['level'] = "2";
|
|
$data['user_id'] = $this->request->getPost('manager');
|
|
$inserted = $this->clientRMModel->insert($data);
|
|
}
|
|
}
|
|
|
|
if ($this->request->getPost('account_manager')) {
|
|
|
|
$this->clientRMModel->where('client_id', $id)->where('level', 3)->delete();
|
|
$data['level'] = "3";
|
|
foreach ($this->request->getPost('account_manager') as $value) {
|
|
$data['user_id'] = $value;
|
|
$inserted = $this->clientRMModel->insert($data);
|
|
}
|
|
}
|
|
|
|
$lastQuery = $this->clientRMModel->getLastQuery();
|
|
|
|
if ($inserted) {
|
|
echo json_encode(array("status" => true, 'data' => $this->request->getPost(), "place" => 'edit'));
|
|
} else {
|
|
echo json_encode(array("status" => false, "place" => 'edit'));
|
|
}
|
|
}
|
|
|
|
public function createClientBranch()
|
|
{
|
|
|
|
$this->myLogger->logme('error','Client branch CREATE function called');
|
|
$data = $this->request->getPost();
|
|
$data['created_by'] = get_session_userid();
|
|
$insert = $this->clientBranchModel->insert($data);
|
|
|
|
if($insert){
|
|
for ($i = 0; $i < count($this->request->getPost('name')); $i++) {
|
|
// Prepare data to insert
|
|
$data = [
|
|
'contact_type' => 'client',
|
|
'ref_id' => $insert,
|
|
'created_by' => get_session_userid(),
|
|
'name' => $this->request->getPost('name')[$i],
|
|
'email' => $this->request->getPost('email')[$i],
|
|
'mobile' => $this->request->getPost('mobile')[$i],
|
|
'designation' => $this->request->getPost('designation')[$i]
|
|
];
|
|
$contacts = $this->levelContactModel->insert($data);
|
|
}
|
|
}
|
|
|
|
if($insert){
|
|
$branchData = $this->clientBranchModel->where('client_id', $this->request->getPost('client_id'))->findAll();
|
|
echo json_encode(array("status" => true , 'data' => $branchData));
|
|
}else{
|
|
echo json_encode(array("status" => false));
|
|
}
|
|
}
|
|
|
|
public function editClientBranch()
|
|
{
|
|
|
|
$this->myLogger->logme('error','Client branch EDIT function called');
|
|
$id = $this->request->getPost('PrimaryKey');
|
|
$client_id = $this->request->getPost('client_id');
|
|
$data = $this->request->getPost();
|
|
$data['updated_by'] = get_session_userid();
|
|
$insert = $this->clientBranchModel->update($id, $data);
|
|
$this->myLogger->logme('error','Client branch EDITED by {data}', ['data' => get_session_userid()]);
|
|
|
|
|
|
if($insert){
|
|
|
|
$this->levelContactModel->where('ref_id', $id)->where('contact_type', 'client')->delete();
|
|
for ($i = 0; $i < count($this->request->getPost('name')); $i++) {
|
|
$data = [
|
|
'contact_type' => 'client',
|
|
'ref_id' => $id,
|
|
'updated_by' => get_session_userid(),
|
|
'name' => $this->request->getPost('name')[$i],
|
|
'email' => $this->request->getPost('email')[$i],
|
|
'mobile' => $this->request->getPost('mobile')[$i],
|
|
'designation' => $this->request->getPost('designation')[$i]
|
|
];
|
|
$contacts = $this->levelContactModel->insert($data);
|
|
}
|
|
}
|
|
|
|
if($insert){
|
|
$branchData = $this->clientBranchModel->where('client_id', $client_id)->findAll();
|
|
echo json_encode(array("status" => true , 'data' => $branchData));
|
|
}else{
|
|
echo json_encode(array("status" => false));
|
|
}
|
|
}
|
|
|
|
public function createClientPolicy()
|
|
{
|
|
|
|
$this->myLogger->logme('error','Client policy CREATE function called');
|
|
|
|
$insurerValue = (string) $this->request->getPost('insurer');
|
|
list($insurerBranchId, $insurerId) = explode('-', $insurerValue);
|
|
|
|
$data['insurer_branch_id'] = $insurerBranchId;
|
|
$data['insurer_id'] = $insurerId;
|
|
|
|
$tpaValue = (string) $this->request->getPost('tpa');
|
|
list($tpaBranchId, $tpaId) = explode('-', $tpaValue);
|
|
|
|
$data['tpa_branch_id'] = $tpaBranchId;
|
|
$data['tpa_id'] = $tpaId;
|
|
$data['policy_id'] = $this->request->getPost('policy_id');
|
|
$data['policy_type_id'] = $this->request->getPost('policy_type_id');
|
|
$data['client_id'] = $this->request->getPost('client_id');
|
|
|
|
|
|
$data['no_of_lives'] = $this->request->getPost('no_of_lives');
|
|
$data['policy_status'] = $this->request->getPost('policy_status');
|
|
$data['no_of_employees'] = $this->request->getPost('no_of_employees');
|
|
$data['earned_premium_date'] = change_date_format($this->request->getPost('earned_premium_date'), 'd-m-Y', 'Y-m-d');
|
|
$data['claims_incurred_date'] = change_date_format($this->request->getPost('claims_incurred_date'), 'd-m-Y', 'Y-m-d');
|
|
$data['incurred_claims_ratio'] = $this->request->getPost('incurred_claims_ratio');
|
|
$data['no_lives_at_inception'] = $this->request->getPost('no_lives_at_inception');
|
|
$data['premium_paid_at_inception'] = $this->request->getPost('premium_paid_at_inception');
|
|
$data['claims_experience_for_last_3_years'] = $this->request->getPost('claims_experience_for_last_3_years');
|
|
$data['earned_premium_amount'] = $this->request->getPost('earned_premium_amount');
|
|
$data['claims_incurred_amount'] = $this->request->getPost('claims_incurred_amount');
|
|
|
|
|
|
|
|
$data['policy_start_date'] = change_date_format($this->request->getPost('policy_start_date'), 'd-m-Y', 'Y-m-d');
|
|
$data['policy_end_date'] = change_date_format($this->request->getPost('policy_end_date'), 'd-m-Y', 'Y-m-d');
|
|
|
|
|
|
$data['created_by'] = get_session_userid();
|
|
|
|
$insert = $this->clientPolicyModel->insert($data);
|
|
if($insert){
|
|
$clientPoliceData = $this->clientPolicyModel->getClientPolicyByClientId($this->request->getPost('client_id'));
|
|
echo json_encode(array("status" => true , 'data' => $clientPoliceData, 'method' => 'CERATE'));
|
|
}else{
|
|
echo json_encode(array("status" => false));
|
|
}
|
|
}
|
|
|
|
public function editClientPolicy()
|
|
{
|
|
|
|
$this->myLogger->logme('error','Client policy function called');
|
|
|
|
$id = $this->request->getPost('PrimaryKey');
|
|
$client_id = $this->request->getPost('client_id');
|
|
|
|
$insurerValue = (string) $this->request->getPost('insurer');
|
|
list($insurerBranchId, $insurerId) = explode('-', $insurerValue);
|
|
|
|
$data['insurer_branch_id'] = $insurerBranchId;
|
|
$data['insurer_id'] = $insurerId;
|
|
|
|
$tpaValue = (string) $this->request->getPost('tpa');
|
|
list($tpaBranchId, $tpaId) = explode('-', $tpaValue);
|
|
|
|
$data['tpa_branch_id'] = $tpaBranchId;
|
|
$data['tpa_id'] = $tpaId;
|
|
$data['policy_id'] = $this->request->getPost('policy_id');
|
|
$data['policy_type_id'] = $this->request->getPost('policy_type_id');
|
|
$data['policy_start_date'] = change_date_format($this->request->getPost('policy_start_date'), 'd-m-Y', 'Y-m-d');
|
|
$data['policy_end_date'] = change_date_format($this->request->getPost('policy_end_date'), 'd-m-Y', 'Y-m-d');
|
|
|
|
$data['insured'] = $this->request->getPost('insured');
|
|
$data['no_of_lives'] = $this->request->getPost('no_of_lives');
|
|
$data['policy_status'] = $this->request->getPost('policy_status');
|
|
$data['no_of_employees'] = $this->request->getPost('no_of_employees');
|
|
$data['earned_premium_date'] = change_date_format($this->request->getPost('earned_premium_date'), 'd-m-Y', 'Y-m-d');
|
|
$data['claims_incurred_date'] = change_date_format($this->request->getPost('claims_incurred_date'), 'd-m-Y', 'Y-m-d');
|
|
$data['incurred_claims_ratio'] = $this->request->getPost('incurred_claims_ratio');
|
|
$data['no_lives_at_inception'] = $this->request->getPost('no_lives_at_inception');
|
|
$data['premium_paid_at_inception'] = $this->request->getPost('premium_paid_at_inception');
|
|
$data['claims_experience_for_last_3_years'] = $this->request->getPost('claims_experience_for_last_3_years');
|
|
$data['earned_premium_amount'] = $this->request->getPost('earned_premium_amount');
|
|
$data['claims_incurred_amount'] = $this->request->getPost('claims_incurred_amount');
|
|
|
|
$data['updated_by'] = get_session_userid();
|
|
$insert = $this->clientPolicyModel->update($id,$data);
|
|
$lastQuery = $this->clientPolicyModel->getLastQuery();
|
|
|
|
// echo '<pre>';
|
|
// print_r($lastQuery); die;
|
|
|
|
if($insert){
|
|
$clientPoliceData = $this->clientPolicyModel->getClientPolicyByClientId($client_id);
|
|
echo json_encode(array("status" => true , 'data' => $clientPoliceData , 'method' => 'EDIT'));
|
|
}else{
|
|
echo json_encode(array("status" => false));
|
|
}
|
|
}
|
|
|
|
public function createClientPolicyPremium()
|
|
{
|
|
$policy_type = $this->request->getPost('policy_type');
|
|
$client_id = $this->request->getPost('client_id');
|
|
$client_policy_id = $this->request->getPost('client_policy_id');
|
|
$policy_grid_id = $this->request->getPost('policy_grid_id');
|
|
|
|
if($policy_type !== null && $policy_type !== ''){
|
|
|
|
$data = $this->request->getPost();
|
|
$data['created_by'] = get_session_userid();
|
|
$this->policyPremium1Model->where('client_id', $client_id)->where('client_policy_id', $client_policy_id)->set('is_active', 0)->update();
|
|
$insert = $this->policyPremium1Model->insert($data);
|
|
|
|
}else{
|
|
|
|
$this->policyPremium2Model->where('client_id', $client_id)->where('client_policy_id', $client_policy_id)->set('is_active', 0)->update();
|
|
$premiumData = $this->request->getPost('premium');
|
|
for ($i = 0; $i < count($premiumData); $i++) {
|
|
|
|
$data = [
|
|
'client_id' => $client_id,
|
|
'client_policy_id' => $client_policy_id,
|
|
'policy_grid_id' => $policy_grid_id,
|
|
'created_by' => get_session_userid(),
|
|
|
|
];
|
|
|
|
if(is_array($this->request->getPost('si'))){
|
|
$si = isset($this->request->getPost('si')[$i]) ? $this->request->getPost('si')[$i] : null;
|
|
}else{
|
|
$si = $this->request->getPost('si');
|
|
}
|
|
$age_from = isset($this->request->getPost('age_from')[$i]) ? $this->request->getPost('age_from')[$i] : null;
|
|
$age_to = isset($this->request->getPost('age_to')[$i]) ? $this->request->getPost('age_to')[$i] : null;
|
|
$premium = isset($premiumData[$i]) ? $premiumData[$i] : null;
|
|
$grade = isset($this->request->getPost('grade')[$i]) ? $this->request->getPost('grade')[$i] : null;
|
|
$max_si = isset($this->request->getPost('max_si')[$i]) ? $this->request->getPost('max_si')[$i] : null;
|
|
$created_by = get_session_userid();
|
|
|
|
if ($si !== null) {
|
|
$data['si'] = $si;
|
|
}
|
|
|
|
if ($age_from !== null) {
|
|
$data['age_from'] = $age_from;
|
|
}
|
|
|
|
if ($age_to !== null) {
|
|
$data['age_to'] = $age_to;
|
|
}
|
|
|
|
if ($premium !== null) {
|
|
$data['premium'] = $premium;
|
|
}
|
|
|
|
if ($max_si !== null) {
|
|
$data['max_si'] = $max_si;
|
|
}
|
|
|
|
if ($grade !== null) {
|
|
$data['grade'] = $grade;
|
|
}
|
|
|
|
$this->policyPremium2Model->insert($data);
|
|
}
|
|
$data = $this->request->getPost();
|
|
$insert = true;
|
|
}
|
|
|
|
if($insert){
|
|
echo json_encode(array("status" => true , 'data' => $data));
|
|
}else{
|
|
echo json_encode(array("status" => false , 'data' => $data));
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getKycDocsById($id=null)
|
|
{
|
|
|
|
$this->myLogger->logme('error','getKycDocsById function called');
|
|
if($id){
|
|
$kyc_docs_data = $this->kycDocsModel->where(['kyc_type_id' => $id, 'is_active' => 1])->findAll();
|
|
echo json_encode(array("status" => true , 'data' => $kyc_docs_data));
|
|
$this->myLogger->logme('error','getKycDocs status TRUE');
|
|
}else{
|
|
echo json_encode(array("status" => false));
|
|
$this->myLogger->logme('error','getKycDocs status FALSE');
|
|
}
|
|
}
|
|
|
|
public function getPolicesByInsurerId($id = null)
|
|
{
|
|
$this->myLogger->logme('error','getPolicesByInsurerId function called');
|
|
if($id){
|
|
$police_data = $this->policesModel->where(['insurer_id' => $id, 'is_active' => 1])->findAll();
|
|
echo json_encode(array("status" => true , 'data' => $police_data));
|
|
}else{
|
|
echo json_encode(array("status" => false));
|
|
}
|
|
}
|
|
|
|
public function getSingleBranchDataById($id=null)
|
|
{
|
|
|
|
$this->myLogger->logme('error','getSingleBranchDataById function called');
|
|
if($id){
|
|
$branch_data = $this->clientBranchModel->where(['id' => $id, 'is_active' => 1])->first();
|
|
$branch_contact_data = $this->levelContactModel->where(['ref_id' => $id, 'contact_type'=>'client', 'is_active' => 1])->findAll();
|
|
echo json_encode(array("status" => true , 'data' => $branch_data, 'contact' => $branch_contact_data));
|
|
}else{
|
|
echo json_encode(array("status" => false));
|
|
}
|
|
|
|
}
|
|
|
|
public function getClientPolicyById($id=null)
|
|
{
|
|
$this->myLogger->logme('error','getClientPolicyById function called');
|
|
if($id){
|
|
$client_policy_data = $this->clientPolicyModel->where(['id' => $id, 'is_active' => 1])->first();
|
|
$insurer_id = $client_policy_data['insurer_id'];
|
|
$polices = $this->policesModel->where(['insurer_id' => $insurer_id, 'is_active' => 1])->findAll();
|
|
echo json_encode(array("insurer_id" => $client_policy_data['insurer_id'], "status" => true , 'data' => $client_policy_data, 'policy' => $polices));
|
|
}else{
|
|
echo json_encode(array("status" => false));
|
|
}
|
|
|
|
}
|
|
|
|
public function getpolicyGridData()
|
|
{
|
|
|
|
$policy_id = $this->request->getGet('policy_id');
|
|
$client_id = $this->request->getGet('client_id');
|
|
|
|
$data = $this->policesModel->getPolicyPremium($policy_id);
|
|
$pattern = '/gmc/i';
|
|
$subject = $data[0]->policy_type;
|
|
if (preg_match($pattern, $subject)) {
|
|
$search_term = 'GMC';
|
|
} else {
|
|
$search_term = 'GPA';
|
|
}
|
|
$results = $this->policyGridModel->like('policy_type', $search_term)->findAll();
|
|
|
|
if($search_term === 'GPA'){
|
|
$premiumData = $this->policyPremium1Model->where(['client_id' => $client_id, 'client_policy_id' => $policy_id, 'is_active' => 1])->findAll();
|
|
}else{
|
|
$premiumData = $this->policyPremium2Model->where(['client_id' => $client_id, 'client_policy_id' => $policy_id, 'is_active' => 1])->findAll();
|
|
}
|
|
|
|
echo json_encode(array("status" => true , 'data' => $results, 'premiumData' => $premiumData));
|
|
|
|
}
|
|
|
|
public function policyGMCTerms()
|
|
{
|
|
|
|
try {
|
|
$this->myLogger->logme('error','Terms CREATE function called');
|
|
// print_r($this->request->getPost());
|
|
$client_id = $this->request->getPost("client_id");
|
|
$policy_id = $this->request->getPost("policy_id");
|
|
$data['sum_insured'] =$this->request->getPost("sum_insured");
|
|
$data['family_floater'] =$this->request->getPost("family_floater");
|
|
// print_r($data['familyfloater']);
|
|
if (!$data['family_floater'] || $data['family_floater'] == 0) {
|
|
$data['corporatebuffer'] = "";
|
|
$data['family_floaters'] = "";
|
|
}else{
|
|
$data['corporatebuffer'] = $this->request->getPost("corporatebuffer");
|
|
$data['family_floaters'] = $this->request->getPost("family_floaters") ?? [];
|
|
}
|
|
|
|
$data['waiverofpreexistingdiseases'] =$this->request->getPost("waiverofpreexistingdiseases");
|
|
if ($data['waiverofpreexistingdiseases'] == 1) {
|
|
$data['maternitycoverage'] =$this->request->getPost("maternitycoverage");
|
|
$data['twindelivery'] =$this->request->getPost("twindelivery");
|
|
$data['preandpostnatal'] =$this->request->getPost("preandpostnatal");
|
|
$data['babyday1cover'] =$this->request->getPost("babyday1cover");
|
|
}else{
|
|
$data['maternitycoverage'] ="";
|
|
$data['twindelivery'] ="";
|
|
$data['preandpostnatal'] ="";
|
|
$data['babyday1cover'] ="";
|
|
}
|
|
$data['9monthwaitingperiodwaived'] =$this->request->getPost("9monthwaitingperiodwaived");
|
|
$data['coverfromthedateofjoining'] =$this->request->getPost("coverfromthedateofjoining");
|
|
$data['waiverof1,2,3&4thyearexclusions'] =$this->request->getPost("waiverof1,2,3&4thyearexclusions");
|
|
$data['waiverof30dayswaitingperiod'] =$this->request->getPost("waiverof30dayswaitingperiod");
|
|
$data['prehospitalizationcover'] =$this->request->getPost("prehospitalizationcover");
|
|
// $data['posthospitalizationcover'] =$this->request->getPost("posthospitalizationcover");
|
|
$data['congenitaldiseasesinternal'] =$this->request->getPost("congenitaldiseasesinternal");
|
|
// $data['congenitaldiseasesexternal'] =$this->request->getPost("congenitaldiseasesexternal");
|
|
$data['copayzonewisecopay'] =$this->request->getPost("copayzonewisecopay");
|
|
$data['bioabsorbablestenttoriclensmultifocallens'] =$this->request->getPost("bioabsorbablestenttoriclensmultifocallens");
|
|
$data['roomrentlimit'] =$this->request->getPost("roomrentlimit");
|
|
$data['proportionatedeductionclause'] =$this->request->getPost("proportionatedeductionclause");
|
|
$data['nursingallowance'] =$this->request->getPost("nursingallowance");
|
|
$data['ailmentcapping'] =$this->request->getPost("ailmentcapping");
|
|
$data['ambulancecharges'] =$this->request->getPost("ambulancecharges");
|
|
$data['airambulance'] =$this->request->getPost("airambulance");
|
|
$data['familytransportationbenefit'] =$this->request->getPost("familytransportationbenefit");
|
|
$data['reasonableandcustomarycharges'] =$this->request->getPost("reasonableandcustomarycharges");
|
|
$data['ayudhtreatmentcover'] =$this->request->getPost("ayudhtreatmentcover");
|
|
$data['armdcovered'] =$this->request->getPost("armdcovered");
|
|
$data['suminsuredenhancement'] =$this->request->getPost("suminsuredenhancement");
|
|
$data['automaticsuminsuredreinstatement'] =$this->request->getPost("automaticsuminsuredreinstatement");
|
|
$data['additionalsicknessbenefit'] =$this->request->getPost("additionalsicknessbenefit");
|
|
$data['lasiksurgery'] =$this->request->getPost("lasiksurgery");
|
|
$data['midterminclusion'] =$this->request->getPost("midterminclusion");
|
|
$data['capd'] =$this->request->getPost("capd");
|
|
$data['organdonorexpenses'] =$this->request->getPost("organdonorexpenses");
|
|
$data['moderntreatmentsasperirdai'] =$this->request->getPost("moderntreatmentsasperirdai");
|
|
$data['Wellness'] =$this->request->getPost("Wellness");
|
|
$data['days_of_discharge'] =$this->request->getPost("days_of_discharge");
|
|
$data['days_from_dod'] =$this->request->getPost("days_from_dod");
|
|
$data['special_condition_label'] = $this->request->getPost("special_condition_label") ?? [];
|
|
$data['special_condition_input'] = $this->request->getPost("special_condition_input") ?? [];
|
|
|
|
|
|
$jsonData = json_encode($data);
|
|
$dataa = array(
|
|
'policy_terms' => $jsonData,
|
|
'client_id' => $client_id,
|
|
'policy_id' => $policy_id
|
|
);
|
|
|
|
$record = $this->clientPolicyModel->where(['client_id' => $client_id, 'policy_id' => $policy_id])->first();
|
|
|
|
if ($record) {
|
|
$update = $this->clientPolicyModel->update($record['id'], $dataa);
|
|
if ($update) {
|
|
echo json_encode(array('message' => 'Data updated successfully'));
|
|
} else {
|
|
echo json_encode(array('message' => 'Failed to update data'));
|
|
}
|
|
}else{
|
|
$insert = $this->clientPolicyModel->insert($dataa);
|
|
if ($insert) {
|
|
echo json_encode(array('message' => 'Data stored successfully'));
|
|
} else {
|
|
echo json_encode(array('message' => 'Failed to store data'));
|
|
}
|
|
}
|
|
} catch (\Exception $e) {
|
|
|
|
echo "Failed to insert data: " . $e->getMessage();
|
|
// Log the error
|
|
log_message('error', 'Failed to insert data: ' . $e->getMessage());
|
|
}
|
|
|
|
}
|
|
|
|
public function getterms()
|
|
{
|
|
$client_id = $this->request->getVar('client_id');
|
|
$policy_id = $this->request->getVar('policy_id');
|
|
$record = $this->clientPolicyModel->where(['client_id' => $client_id, 'policy_id' => $policy_id])->first();
|
|
$emp_count = $this->employeeModel ->join('client_policy cp',"employees.client_id = cp.client_id")
|
|
->join('employee_polices ep',"cp.id = ep.client_policy_id AND employees.id = ep.employee_id")
|
|
->where("employees.client_id",$client_id)
|
|
->where("employees.emp_status",'active')
|
|
->countAllResults();
|
|
if($emp_count = 0){
|
|
$emp_count = true;
|
|
}else{
|
|
$emp_count = false;
|
|
}
|
|
|
|
if ($record) {
|
|
return $this->respond(['Status' => true,'code' => 200,'data' => $record['policy_terms'], 'count' => $emp_count], 200);
|
|
} else {
|
|
return $this->respond(['Status' => false,'code' => 200,'message' => 'Record not found.', 'count' => $emp_count], 200);
|
|
}
|
|
|
|
}
|
|
|
|
public function policyGPATerms()
|
|
{
|
|
|
|
try {
|
|
$this->myLogger->logme('error','Policy GPA Terms CREATE function called');
|
|
|
|
// print_r($this->request->getPost());
|
|
$client_id = $this->request->getPost("client_id");
|
|
$policy_id = $this->request->getPost("policy_id");
|
|
|
|
$data['sumInsured2'] =$this->request->getPost("sumInsured2");
|
|
$data['totalSumInsured'] =$this->request->getPost("totalSumInsured");
|
|
$data['accidentalDeathBenefit'] =$this->request->getPost("accidentalDeathBenefit");
|
|
$data['permanentTotalDisablement'] =$this->request->getPost("permanentTotalDisablement");
|
|
$data['permanentPartialDisablement'] =$this->request->getPost("permanentPartialDisablement");
|
|
$data['temporaryTotalDisablementBenefit'] =$this->request->getPost("temporaryTotalDisablementBenefit");
|
|
$data['accidentalHospitalizationExpenses'] =$this->request->getPost("accidentalHospitalizationExpenses");
|
|
$data['childrenEducationWelfareFund'] =$this->request->getPost("childrenEducationWelfareFund");
|
|
|
|
$data['compassionateVisitExpenses'] =$this->request->getPost("compassionateVisitExpenses");
|
|
if ($data['compassionateVisitExpenses'] == 1) {
|
|
$data['compassionateVisitExpensesData'] =$this->request->getPost("compassionateVisitExpensesData");
|
|
}else{
|
|
$data['compassionateVisitExpensesData'] ="";
|
|
}
|
|
|
|
$data['brokenBoneExpenses'] = $this->request->getPost("brokenBoneExpenses");
|
|
if ($data['brokenBoneExpenses'] == 1) {
|
|
$data['brokenBoneExpensesData'] = $this->request->getPost("brokenBoneExpensesData");
|
|
}else{
|
|
$data['brokenBoneExpensesData'] ="";
|
|
}
|
|
|
|
$data['ambulanceCharges'] =$this->request->getPost("ambulanceCharges");
|
|
if ($data['ambulanceCharges'] == 1) {
|
|
$data['ambulanceChargesData'] =$this->request->getPost("ambulanceChargesData");
|
|
}else{
|
|
$data['ambulanceChargesData'] ="";
|
|
}
|
|
|
|
$data['burnExpenses'] = $this->request->getPost("burnExpenses");
|
|
if ($data['burnExpenses'] == 1) {
|
|
$data['burnExpensesData'] = $this->request->getPost("burnExpensesData");
|
|
}else{
|
|
$data['burnExpensesData'] = "";
|
|
}
|
|
|
|
$data['carriageOfDeadBody'] = $this->request->getPost("carriageOfDeadBody");
|
|
if ($data['carriageOfDeadBody'] == 1) {
|
|
$data['carriageOfDeadBodyData'] = $this->request->getPost("carriageOfDeadBodyData");
|
|
}else{
|
|
$data['carriageOfDeadBodyData'] = "";
|
|
}
|
|
|
|
$data['animalSnakeInsectBite'] = $this->request->getPost("animalSnakeInsectBite");
|
|
$data['terrorism'] = $this->request->getPost("terrorism");
|
|
$data['worldwideCover'] = $this->request->getPost("worldwideCover");
|
|
|
|
|
|
print_r($data);
|
|
|
|
// print_r($this->request->getPost());
|
|
// die();
|
|
|
|
$jsonData = json_encode($data);
|
|
$dataa = array(
|
|
'policy_terms' => $jsonData,
|
|
'client_id' => $client_id,
|
|
'policy_id' => $policy_id
|
|
);
|
|
$record = $this->clientPolicyModel->where(['client_id' => $client_id, 'policy_id' => $policy_id])->first();
|
|
if ($record) {
|
|
$update = $this->clientPolicyModel->update($record['id'], $dataa);
|
|
if ($update) {
|
|
$response = array('message' => 'Data updated successfully');
|
|
header('Content-Type: application/json');
|
|
echo json_encode($response);
|
|
} else {
|
|
echo json_encode(array('message' => 'Failed to update data'));
|
|
}
|
|
}else{
|
|
$insert = $this->clientPolicyModel->insert($dataa);
|
|
if ($insert) {
|
|
echo json_encode(array('message' => 'Data stored successfully'));
|
|
} else {
|
|
echo json_encode(array('message' => 'Failed to store data'));
|
|
}
|
|
}
|
|
} catch (\Exception $e) {
|
|
// Handle the exception
|
|
echo "Failed to insert data: " . $e->getMessage();
|
|
// Log the error
|
|
log_message('error', 'Failed to insert data: ' . $e->getMessage());
|
|
}
|
|
|
|
}
|
|
|
|
public function getPolicyGPATerms(){
|
|
|
|
$client_id = $this->request->getVar('client_id');
|
|
$policy_id = $this->request->getVar('policy_id');
|
|
$record = $this->clientPolicyModel->where(['client_id' => $client_id, 'policy_id' => $policy_id])->first();
|
|
|
|
if ($record) {
|
|
echo $record['policy_terms'];
|
|
|
|
} else {
|
|
echo "Record not found.";
|
|
}
|
|
|
|
}
|
|
|
|
} |