1499 lines
56 KiB
PHP
Executable File
1499 lines
56 KiB
PHP
Executable File
<?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 CodeIgniter\Files\File;
|
|
|
|
use App\Helpers\DepositHelper;
|
|
use App\Helpers\MailHelper;
|
|
|
|
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\PolicyTypeModel;
|
|
use App\Models\CDMasterModel;
|
|
use App\Models\ClientDepositModel;
|
|
use App\Models\InsurerExcelExportTemplateModel;
|
|
|
|
class MasterController extends AdminController
|
|
{
|
|
use ResponseTrait;
|
|
|
|
protected $myLogger;
|
|
protected $insurerModel;
|
|
protected $userModel;
|
|
protected $insurerBranchModel;
|
|
protected $insurerKYCDocsModel;
|
|
protected $insurerPolicyModel;
|
|
protected $insurerRMModel;
|
|
protected $kycDocsModel;
|
|
protected $kycEntityTypeModel;
|
|
protected $levelContactModel;
|
|
protected $policesModel;
|
|
protected $tpaBranchModel;
|
|
protected $tpaModel;
|
|
protected $stateModel;
|
|
protected $policyTypeModel;
|
|
protected $CDMasterModel;
|
|
protected $clientModel;
|
|
protected $clientDepositModel;
|
|
protected $insurerTemplateModel;
|
|
|
|
|
|
|
|
public function __construct()
|
|
{
|
|
set_session_context('Master');
|
|
$this->myLogger = \Config\Services::mylogger();
|
|
|
|
// $this->insurerModel = new ClientModel();
|
|
$this->userModel = new UserModel();
|
|
// $this->insurerBranchModel = new ClientBranchModel();
|
|
$this->insurerKYCDocsModel = new ClientKYCDocsModel();
|
|
$this->insurerPolicyModel = new ClientPolicyModel();
|
|
$this->insurerRMModel = 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->policyTypeModel = new PolicyTypeModel();
|
|
$this->CDMasterModel = new CDMasterModel();
|
|
$this->clientModel = new ClientModel();
|
|
$this->clientDepositModel = new ClientDepositModel();
|
|
$this->insurerTemplateModel = new InsurerExcelExportTemplateModel();
|
|
|
|
}
|
|
|
|
|
|
//start insurer
|
|
public function insurerList()
|
|
{
|
|
$this->myLogger->logme('error','Insurer list function called');
|
|
$headerData['page_name'] = 'Insurer List';
|
|
$data['insurerList'] = $this->insurerModel->where('is_active',1)->findAll();
|
|
$data['insurer_rm'] = $this->insurerRMModel->getAllClientRM();
|
|
// echo '<pre>';
|
|
// print_r($data['insurerList']); die;
|
|
|
|
echo view('layout/header', $headerData);
|
|
echo view('insurer_list', $data);
|
|
echo view('layout/footer');
|
|
|
|
// $this->loadLayout('insurer_onboarding', $data);
|
|
}
|
|
|
|
public function insurerRemove($id = null)
|
|
{
|
|
$this->myLogger->logme('error','Insurer Remove function called');
|
|
// $id = $this->request->getPost('PrimaryKey');
|
|
// $data = $this->request->getPost();
|
|
$data['updated_by'] = get_session_userid();
|
|
$data['is_active'] = 0;
|
|
$update = $this->insurerModel->update($id,$data);
|
|
if($update){
|
|
return $this->respond(['status' => true,'code' => 200], 200);
|
|
}else{
|
|
return $this->respond(['status' => false,'code' => 404], 200);
|
|
}
|
|
}
|
|
|
|
public function removeInsurerBranch($id = null)
|
|
{
|
|
$this->myLogger->logme('error','Insurer Branch Remove function called');
|
|
// $id = $this->request->getPost('PrimaryKey');
|
|
// $data = $this->request->getPost();
|
|
$data['updated_by'] = get_session_userid();
|
|
$data['is_active'] = 0;
|
|
$update = $this->insurerBranchModel->update($id,$data);
|
|
if($update){
|
|
return $this->respond(['status' => true,'code' => 200], 200);
|
|
}else{
|
|
return $this->respond(['status' => false,'code' => 404], 200);
|
|
}
|
|
}
|
|
|
|
public function editInsurerOnboarding($id = null)
|
|
{
|
|
|
|
$this->myLogger->logme('error','Edit Insurer Onboarding function called');
|
|
$headerData['page_name'] = 'Edit Insurer Master';
|
|
|
|
$types = array(
|
|
(object) array('id' => 'pvt', 'name' => 'PVT'),
|
|
(object) array('id' => 'psu', 'name' => 'PSU')
|
|
);
|
|
|
|
$editData['types'] = $types;
|
|
$editData['RM'] = $this->userModel->findAll();
|
|
$editData['tpa'] = $this->tpaBranchModel ->getTpaBranchesWithTpaNames();
|
|
$editData['state'] = $this->stateModel->getAllStates();
|
|
$editData['insurer'] = $this->insurerBranchModel ->getInsurerBranchesWithInsurerNames();
|
|
|
|
|
|
$editData['insurer'] = $this->insurerModel->where(['id' => $id, 'is_active' => 1])->first();
|
|
$editData['insuer_branch'] = $this->insurerBranchModel->where(['insurer_id' => $id, 'is_active' => 1])->findAll();
|
|
$editData['insurer_templete_count'] = $this->insurerTemplateModel->where(['insurer_id' => $id, 'is_active' => 1])->countAllResults();
|
|
$editData['insurer_templete_list'] = $this->insurerModel->getInsurerTemplateByInsurerID($id);
|
|
|
|
|
|
$editData['policy_type'] = $this->policyTypeModel->whereIn('id', [1,2,6,7])->findAll();
|
|
$editData['events'] = ['inception' => 'Inception', 'addition' => 'Addition', 'dependent_addition' => 'Dependent Addition', 'deletion' => 'Deletion', 'correction' => 'Correction', 'si_enhancement' => 'SI Enhancement', 'all' => 'All'];
|
|
$editData['action'] = ['import' => 'Import', 'export' => 'Export'];
|
|
$editData['db_column_name'] = [
|
|
|
|
'Employee Name' => 'emp_name',
|
|
'Employee ID' => 'emp_code',
|
|
'Date of Birth' => 'emp_dob',
|
|
'Gender' => 'emp_gender',
|
|
'Change Event' => 'change_event',
|
|
'Relationship' => 'emp_relationship',
|
|
'Relationship Code' => 'emp_relationship_code',
|
|
'Event Type' => 'event_type_data',
|
|
'Date of Joining' => 'emp_doj',
|
|
'Mobile' => 'emp_mobile',
|
|
'Corporate Email' => 'emp_email_c',
|
|
'Personal Email' => 'emp_email_p',
|
|
'Grade' => 'emp_grade',
|
|
'Designation' => 'emp_designation',
|
|
'Basic Pay' => 'emp_basic_pay',
|
|
'Age' => 'emp_age',
|
|
'Employee Type' => 'emp_type',
|
|
'Primary Key' => 'primaryKey',
|
|
'TPA ID' => 'tpa_id',
|
|
'UHID' => 'uhid',
|
|
'Pre-existing Alignments' => 'pre_existing_alignments',
|
|
'Basic Cover SI' => 'basic_cover_si',
|
|
'Date of Coverage' => 'date_coverage',
|
|
'Policy End Date' => 'policy_end_date',
|
|
'Number of Days' => 'no_of_days',
|
|
'Premium' => 'premium',
|
|
'Pro Rata Premium' => 'pro_rata_premium',
|
|
'GST' => 'gst',
|
|
'Total' => 'total',
|
|
'Policy ID' => 'emp_policy_id',
|
|
'SEZ' => 'sez',
|
|
'Endorsement ID' => 'endorsement_id',
|
|
'Old Value' => 'old_value',
|
|
'New Value' => 'new_value',
|
|
'Field Name' => 'field_name',
|
|
'Remarks' => 'remarks',
|
|
'Actions' => 'actions',
|
|
'Date of Exit' => 'dateofexit',
|
|
'Reason for Exit' => 'reasonforexit',
|
|
'Status' => 'status',
|
|
'Old Basic Cover SI' => 'old_basic_cover_si',
|
|
'Old SI Premium' => 'old_si_premium',
|
|
'New Basic Cover SI' => 'new_basic_cover_si',
|
|
'New SI Premium' => 'new_si_premium',
|
|
'Date of Coverage' => 'date_of_coverage',
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
// echo "<pre>";
|
|
// print_r($editData); die;
|
|
|
|
echo view('layout/header', $headerData);
|
|
echo view('insurer_onboarding', $editData);
|
|
echo view('layout/footer');
|
|
|
|
}
|
|
|
|
public function insurerOnboarding()
|
|
{
|
|
|
|
$this->myLogger->logme('error','Insurer Onboarding function called');
|
|
$headerData['page_name'] = 'Insurer Master';
|
|
|
|
$types = array(
|
|
(object) array('id' => 'pvt', 'name' => 'PVT'),
|
|
(object) array('id' => 'psu', 'name' => 'PSU')
|
|
);
|
|
|
|
$data['types'] = $types;
|
|
// print_r($data['types']);die();
|
|
$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();
|
|
|
|
// echo "<pre>";
|
|
// print_r($data); die;
|
|
|
|
echo view('layout/header', $headerData);
|
|
echo view('insurer_onboarding', $data);
|
|
echo view('layout/footer');
|
|
|
|
}
|
|
|
|
public function createInsurerGeneralInfo()
|
|
{
|
|
|
|
$this->myLogger->logme('error','Insurer general info function called');
|
|
$uploadFilePath = ROOTPATH . 'public/uploads/logo/';
|
|
$file_name = file_Upload($this->request->getFile('insurer_logo'), $uploadFilePath);
|
|
$data = $this->request->getPost();
|
|
|
|
if($this->request->getPost('addition_add_day')){
|
|
$data['addition_add_day'] = 1;
|
|
}
|
|
|
|
if($this->request->getPost('deletion_add_day')){
|
|
$data['deletion_add_day'] = 1;
|
|
}
|
|
|
|
$data['created_by'] = get_session_userid();
|
|
$data['insurer_logo'] = $file_name;
|
|
|
|
$insert = $this->insurerModel->insert($data);
|
|
if($insert){
|
|
$insurer_data = $this->insurerModel->where(['id' => $insert, 'is_active' => 1])->first();
|
|
$insurer_templete_count = $this->insurerTemplateModel->where(['insurer_id' => $insert, 'is_active' => 1])->countAllResults();
|
|
echo json_encode(array("status" => true , 'data' => $insurer_data, 'templete_count' => $insurer_templete_count));
|
|
}else{
|
|
echo json_encode(array("status" => false));
|
|
}
|
|
}
|
|
|
|
public function createInsurerBranch()
|
|
{
|
|
|
|
$this->myLogger->logme('error','Client branch CREATE function called');
|
|
$data = $this->request->getPost();
|
|
$data['created_by'] = get_session_userid();
|
|
$insert = $this->insurerBranchModel->insert($data);
|
|
|
|
if($insert){
|
|
for ($i = 0; $i < count($this->request->getPost('name')); $i++) {
|
|
// Prepare data to insert
|
|
$data = [
|
|
'contact_type' => 'insurer',
|
|
'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->insurerBranchModel->where('insurer_id', $this->request->getPost('insurer_id'))->findAll();
|
|
echo json_encode(array("status" => true , 'data' => $branchData));
|
|
}else{
|
|
echo json_encode(array("status" => false));
|
|
}
|
|
}
|
|
|
|
public function insurerBranchList($id = null)
|
|
{
|
|
$this->myLogger->logme('error','Edit Insurer Onboarding function called');
|
|
|
|
$editData['insuer_branch'] = $this->insurerBranchModel->where(['insurer_id' => $id, 'is_active' => 1])->findAll();
|
|
|
|
// Return JSON response
|
|
header('Content-Type: application/json');
|
|
echo json_encode($editData);
|
|
exit();
|
|
}
|
|
|
|
public function editInsurerGeneralInfo()
|
|
{
|
|
$this->myLogger->logme('error','edit Insurer general info function called');
|
|
|
|
$uploadFilePath = ROOTPATH . 'public/uploads/logo/';
|
|
$file_name = file_Upload($this->request->getFile('insurer_logo'), $uploadFilePath);
|
|
|
|
$id = $this->request->getPost('PrimaryKey');
|
|
$data = $this->request->getPost();
|
|
$data['updated_by'] = get_session_userid();
|
|
|
|
if(!empty($file_name)){
|
|
$data['insurer_logo'] = $file_name;
|
|
}
|
|
|
|
if($this->request->getPost('addition_add_day')){
|
|
$data['addition_add_day'] = 1;
|
|
}else{
|
|
$data['addition_add_day'] = 0;
|
|
}
|
|
|
|
if($this->request->getPost('deletion_add_day')){
|
|
$data['deletion_add_day'] = 1;
|
|
}else{
|
|
$data['deletion_add_day'] = 0;
|
|
}
|
|
|
|
$update = $this->insurerModel->update($id,$data);
|
|
if($update){
|
|
echo json_encode(array("status" => true , 'data' => $data));
|
|
}else{
|
|
echo json_encode(array("status" => false));
|
|
}
|
|
}
|
|
|
|
public function editInsurerGet($id = null)
|
|
{
|
|
$this->myLogger->logme('error','Edit TPA Onboarding function called');
|
|
|
|
|
|
$editData['insurerbranch'] = $this->insurerBranchModel->where(['id' => $id, 'is_active' => 1])->first();
|
|
$editData['levelcontact'] = $this->levelContactModel->where(['ref_id' => $id, 'contact_type' => 'insurer' , 'is_active' => 1])->findAll();
|
|
// print_r($editData['tpa']);
|
|
// Return JSON response
|
|
header('Content-Type: application/json');
|
|
echo json_encode($editData);
|
|
exit();
|
|
}
|
|
|
|
public function editInsurerBranch()
|
|
{
|
|
$this->myLogger->logme('error','Insurer branch CREATE function called');
|
|
$id = $this->request->getPost('PrimaryKey');
|
|
$data = $this->request->getPost();
|
|
$update = $this->insurerBranchModel->update($id, $data);
|
|
|
|
if($update){
|
|
$contactsToDelete = $this->levelContactModel->where(['ref_id' => $id,'contact_type' => 'insurer', 'is_active' => 1])->get()->getResult();
|
|
foreach ($contactsToDelete as $contact) {
|
|
$this->levelContactModel->delete($contact->id);
|
|
}
|
|
for ($i = 0; $i < count($this->request->getPost('name')); $i++) {
|
|
// Prepare data to update
|
|
$data = [
|
|
'contact_type' => 'insurer',
|
|
'ref_id' => $id,
|
|
'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($update){
|
|
$branchData = $this->insurerBranchModel->where('insurer_id', $this->request->getPost('insurer_id'))->findAll();
|
|
echo json_encode(array("status" => true , 'data' => $branchData, 'edit'));
|
|
}else{
|
|
echo json_encode(array("status" => false, 'edit'));
|
|
}
|
|
}
|
|
|
|
public function getInsurerByExportTemplete()
|
|
{
|
|
$insurer_data = $this->insurerModel
|
|
->select('insurers.name as insurer_name, insurers.id, insurers.is_multi_event')
|
|
->join('insurer_excel_export_template', 'insurer_excel_export_template.insurer_id = insurers.id')
|
|
->where('insurer_excel_export_template.is_active', 1)
|
|
->where('insurers.is_active', 1)
|
|
->groupBy('insurers.id')
|
|
->findAll();
|
|
|
|
return $this->respond(['status' => true, 'code' => 200, 'data' => $insurer_data], 200);
|
|
}
|
|
|
|
public function copyInsurerTemplete($existing_insurer_id, $copy_insurer_id)
|
|
{
|
|
$insurer_templete_data = $this->insurerTemplateModel->where('insurer_id', $existing_insurer_id)->where('is_active', 1)->findAll();
|
|
$existing_insurer_templete_data = $this->insurerTemplateModel->where('insurer_id', $copy_insurer_id)->set('is_active', 0)->update();
|
|
|
|
$data_to_insert = [];
|
|
foreach ($insurer_templete_data as $value) {
|
|
$data_to_insert[] = [
|
|
"insurer_id" => $copy_insurer_id,
|
|
"policy_type_id" => $value['policy_type_id'],
|
|
"event_name" => $value['event_name'],
|
|
"type_name" => $value['type_name'],
|
|
"jsoncolumns" => $value['jsoncolumns'],
|
|
"created_by" => get_session_user(),
|
|
"is_active" => 1,
|
|
];
|
|
}
|
|
|
|
$insert_result = $this->insurerTemplateModel->insertBatch($data_to_insert);
|
|
|
|
if($insert_result){
|
|
return $this->respond(['status' => true, 'message' => 'Template added successfully', $insurer_templete_data]);
|
|
}else{
|
|
return $this->respond(['status' => false, 'message' => 'Failed to add template', $insurer_templete_data]);
|
|
}
|
|
}
|
|
|
|
public function getSingleExcelTemplate($id = null)
|
|
{
|
|
$insurer_templete_data = $this->insurerTemplateModel
|
|
->where('id', $id)
|
|
->where('is_active', 1)
|
|
->first();
|
|
|
|
if($insurer_templete_data){
|
|
|
|
return $this->respond(['status' => true, 'code' => 200, 'data' => $insurer_templete_data, 'message' => 'data found'], 200);
|
|
|
|
}else{
|
|
|
|
return $this->respond(['status' => false, 'code' => 404, 'message' => 'no data found'], 200);
|
|
}
|
|
|
|
}
|
|
// Insurer Ends
|
|
|
|
|
|
|
|
|
|
// TPA Start
|
|
public function tpaList()
|
|
{
|
|
$this->myLogger->logme('error','TPA list function called');
|
|
$headerData['page_name'] = 'TPA List';
|
|
$data['tpaList'] = $this->tpaModel->where('is_active',1)->findAll();
|
|
// $data['insurer_rm'] = $this->insurerRMModel->getAllClientRM();
|
|
// echo '<pre>';
|
|
// print_r($data['insurerList']); die;
|
|
|
|
echo view('layout/header', $headerData);
|
|
echo view('tpa_list', $data);
|
|
echo view('layout/footer');
|
|
|
|
// $this->loadLayout('insurer_onboarding', $data);
|
|
}
|
|
|
|
public function tpaRemove($id = null)
|
|
{
|
|
$this->myLogger->logme('error','TPA Remove function called');
|
|
$data = $this->request->getPost();
|
|
$data['updated_by'] = get_session_userid();
|
|
$data['is_active'] = 0;
|
|
$update = $this->tpaModel->update($id,$data);
|
|
if($update){
|
|
return $this->respond(['status' => true,'code' => 200], 200);
|
|
}else{
|
|
return $this->respond(['status' => false,'code' => 404], 200);
|
|
}
|
|
}
|
|
|
|
public function removeTPABranch($id = null)
|
|
{
|
|
$this->myLogger->logme('error','TPA Branch Remove function called');
|
|
// $id = $this->request->getPost('PrimaryKey');
|
|
// $data = $this->request->getPost();
|
|
$data['updated_by'] = get_session_userid();
|
|
$data['is_active'] = 0;
|
|
$update = $this->tpaBranchModel->update($id,$data);
|
|
if($update){
|
|
return $this->respond(['status' => true,'code' => 200], 200);
|
|
}else{
|
|
return $this->respond(['status' => false,'code' => 404], 200);
|
|
}
|
|
}
|
|
|
|
public function tpaOnboarding()
|
|
{
|
|
|
|
$this->myLogger->logme('error','TPA Onboarding function called');
|
|
$headerData['page_name'] = 'TPA Master';
|
|
|
|
|
|
// print_r($data['types']);die();
|
|
$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();
|
|
|
|
// echo "<pre>";
|
|
// print_r($data); die;
|
|
|
|
echo view('layout/header', $headerData);
|
|
echo view('tpa_onboarding', $data);
|
|
echo view('layout/footer');
|
|
|
|
}
|
|
|
|
public function createTPAGeneralInfo()
|
|
{
|
|
|
|
$this->myLogger->logme('error','TPA general info function called');
|
|
|
|
$uploadFilePath = ROOTPATH . 'public/uploads/logo/';
|
|
$file_name = file_Upload($this->request->getFile('tpa_logo'), $uploadFilePath);
|
|
|
|
$template_bg_path = ROOTPATH . 'public/uploads/template_bg';
|
|
$front_card_file_name = file_Upload($this->request->getFile('fc'), $template_bg_path);
|
|
$back_card_file_name = file_Upload($this->request->getFile('bc'), $template_bg_path);
|
|
|
|
|
|
$eCardTemplate = $this->request->getPost('ecard_content');
|
|
$data = $this->request->getPost();
|
|
$data['created_by'] = get_session_userid();
|
|
$data['tpa_logo'] = $file_name;
|
|
$data['front_card'] = $front_card_file_name;
|
|
$data['back_card'] = $back_card_file_name;
|
|
$data['network_hospitals'] = $this->request->getPost('network_hospitals');
|
|
|
|
$insert = $this->tpaModel->insert($data);
|
|
|
|
$tpa_name = (string) $this->request->getPost('name');
|
|
$short_name = (string) $this->request->getPost('short_name');
|
|
|
|
$filename = strtolower(str_replace(' ', '_', $short_name)) . '.html';
|
|
$file_directory = WRITEPATH . 'e_card_template/';
|
|
$file_path = $file_directory . $filename;
|
|
|
|
// Ensure that the directory exists, if not, create it
|
|
if (!is_dir($file_directory)) {
|
|
mkdir($file_directory, 0777, true);
|
|
}
|
|
|
|
// Set the appropriate content type
|
|
header('Content-type:text/html; charset=utf-8');
|
|
|
|
// Write the HTML content to the file
|
|
$data = file_put_contents($file_path, $eCardTemplate);
|
|
|
|
|
|
if ($data !== false) {
|
|
$this->myLogger->logme('error', 'TPA: {tpa}, e-Card HTML template file saved successfully: {data}, filepath is: {path}', ['data' => $filename, 'tpa' => $tpa_name, 'path' => $file_path]);
|
|
} else {
|
|
$this->myLogger->logme('error', 'TPA: {tpa}, e-Card HTML template file unable to save: {data}', ['data' => $filename, 'tpa' => $tpa_name]);
|
|
}
|
|
|
|
|
|
if($insert){
|
|
$tpa_data = $this->tpaModel->where(['id' => $insert, 'is_active' => 1])->first();
|
|
echo json_encode(array("status" => true , 'data' => $tpa_data));
|
|
}else{
|
|
echo json_encode(array("status" => false));
|
|
}
|
|
}
|
|
|
|
public function createTPABranch()
|
|
{
|
|
|
|
$this->myLogger->logme('error','TPA branch CREATE function called');
|
|
$data = $this->request->getPost();
|
|
$data['created_by'] = get_session_userid();
|
|
$insert = $this->tpaBranchModel->insert($data);
|
|
|
|
if($insert){
|
|
for ($i = 0; $i < count($this->request->getPost('name')); $i++) {
|
|
// Prepare data to insert
|
|
$data = [
|
|
'contact_type' => 'tpa',
|
|
'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->tpaBranchModel->where('tpa_id', $this->request->getPost('tpa_id'))->findAll();
|
|
echo json_encode(array("status" => true , 'data' => $branchData));
|
|
}else{
|
|
echo json_encode(array("status" => false));
|
|
}
|
|
}
|
|
|
|
public function editTPAOnboarding($id = null)
|
|
{
|
|
|
|
$this->myLogger->logme('error','Edit TPA Onboarding function called');
|
|
$headerData['page_name'] = 'Edit TPA Master';
|
|
|
|
$tpa_data = $this->tpaModel->where(['id' => $id, 'is_active' => 1])->first();
|
|
|
|
$editData['tpa'] = $tpa_data;
|
|
$editData['tpa_branch'] = $this->tpaBranchModel->where(['tpa_id' => $id, 'is_active' => 1])->findAll();
|
|
$editData['state'] = $this->stateModel->getAllStates();
|
|
|
|
$filename = strtolower(str_replace(' ', '_', $tpa_data['short_name'])) . '.html';
|
|
$template_data_path = WRITEPATH . 'e_card_template/';
|
|
$final_path = $template_data_path . $filename;
|
|
|
|
|
|
if (file_exists($final_path)) {
|
|
|
|
$tmplt_data = file_get_contents($final_path);
|
|
$editData['template_data'] = $tmplt_data;
|
|
}
|
|
|
|
// echo "<pre>";
|
|
// print_r($editData); die;
|
|
|
|
echo view('layout/header', $headerData);
|
|
echo view('tpa_onboarding', $editData);
|
|
echo view('layout/footer');
|
|
|
|
}
|
|
|
|
public function editTPAGeneralInfo()
|
|
{
|
|
$this->myLogger->logme('error','edit TPA general info function called');
|
|
|
|
$uploadFilePath = ROOTPATH . 'public/uploads/logo/';
|
|
$file_name = file_Upload($this->request->getFile('tpa_logo'), $uploadFilePath);
|
|
|
|
$template_bg_path = ROOTPATH . 'public/uploads/template_bg';
|
|
$front_card_file_name = file_Upload($this->request->getFile('fc'), $template_bg_path);
|
|
$back_card_file_name = file_Upload($this->request->getFile('bc'), $template_bg_path);
|
|
|
|
$id = $this->request->getPost('PrimaryKey');
|
|
$data = $this->request->getPost();
|
|
$data['updated_by'] = get_session_userid();
|
|
|
|
if(!empty($file_name)){
|
|
$data['tpa_logo'] = $file_name;
|
|
}
|
|
|
|
if(!empty($front_card_file_name)){
|
|
$data['front_card'] = $front_card_file_name;
|
|
}
|
|
|
|
if(!empty($back_card_file_name)){
|
|
$data['back_card'] = $back_card_file_name;
|
|
}
|
|
|
|
$data['network_hospitals'] = $this->request->getPost('network_hospitals');
|
|
$update = $this->tpaModel->update($id,$data);
|
|
|
|
|
|
$tpa_name = (string) $this->request->getPost('name');
|
|
$short_name = (string) $this->request->getPost('short_name');
|
|
$eCardTemplate = $this->request->getPost('ecard_content');
|
|
|
|
$filename = strtolower(str_replace(' ', '_', $short_name)) . '.html';
|
|
$file_directory = WRITEPATH . 'e_card_template/';
|
|
$file_path = $file_directory . $filename;
|
|
|
|
// Ensure that the directory exists, if not, create it
|
|
if (!is_dir($file_directory)) {
|
|
mkdir($file_directory, 0777, true);
|
|
}
|
|
|
|
// Set the appropriate content type
|
|
header('Content-type:text/html; charset=utf-8');
|
|
|
|
// Write the HTML content to the file
|
|
$data = file_put_contents($file_path, $eCardTemplate);
|
|
|
|
|
|
if ($data !== false) {
|
|
$this->myLogger->logme('error', 'TPA: {tpa}, e-Card HTML template file saved successfully: {data}, filepath is: {path}', ['data' => $filename, 'tpa' => $tpa_name, 'path' => $file_path]);
|
|
} else {
|
|
$this->myLogger->logme('error', 'TPA: {tpa}, e-Card HTML template file unable to save: {data}', ['data' => $filename, 'tpa' => $tpa_name]);
|
|
}
|
|
|
|
|
|
|
|
if($update){
|
|
echo json_encode(array("status" => true , 'data' => $data));
|
|
}else{
|
|
echo json_encode(array("status" => false));
|
|
}
|
|
}
|
|
|
|
public function editTPAGet($id = null)
|
|
{
|
|
$this->myLogger->logme('error','Edit TPA Onboarding function called');
|
|
|
|
|
|
$editData['tpabranch'] = $this->tpaBranchModel->where(['id' => $id, 'is_active' => 1])->first();
|
|
$editData['levelcontact'] = $this->levelContactModel->where(['ref_id' => $id, 'contact_type' => 'tpa' , 'is_active' => 1])->findAll();
|
|
// print_r($editData['tpa']);
|
|
// Return JSON response
|
|
header('Content-Type: application/json');
|
|
echo json_encode($editData);
|
|
exit();
|
|
}
|
|
|
|
public function editTPABranch()
|
|
{
|
|
$this->myLogger->logme('error','TPA branch CREATE function called');
|
|
$id = $this->request->getPost('PrimaryKey');
|
|
$data = $this->request->getPost();
|
|
$update = $this->tpaBranchModel->update($id, $data);
|
|
|
|
// print_r($this->request->getPost('name[]'));
|
|
// print_r($this->request->getPost('email[]'));
|
|
// print_r($this->request->getPost('mobile[]'));
|
|
// print_r($this->request->getPost('designation[]'));
|
|
|
|
if($update){
|
|
$contactsToDelete = $this->levelContactModel->where(['ref_id' => $id,'contact_type' => 'tpa', 'is_active' => 1])->get()->getResult();
|
|
foreach ($contactsToDelete as $contact) {
|
|
$this->levelContactModel->delete($contact->id);
|
|
}
|
|
for ($i = 0; $i < count($this->request->getPost('name')); $i++) {
|
|
// Prepare data to update
|
|
$data = [
|
|
'contact_type' => 'tpa',
|
|
'ref_id' => $id,
|
|
'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($update){
|
|
$branchData = $this->tpaBranchModel->where('tpa_id', $this->request->getPost('tpa_id'))->findAll();
|
|
echo json_encode(array("status" => true , 'data' => $branchData));
|
|
}else{
|
|
echo json_encode(array("status" => false));
|
|
}
|
|
}
|
|
|
|
public function tpaBranchList($id = null)
|
|
{
|
|
$this->myLogger->logme('error','TPA List function called');
|
|
|
|
$editData['tpa_branch'] = $this->tpaBranchModel->where(['tpa_id' => $id, 'is_active' => 1])->findAll();
|
|
|
|
// Return JSON response
|
|
header('Content-Type: application/json');
|
|
echo json_encode($editData);
|
|
exit();
|
|
}
|
|
//Ends TPA Models
|
|
|
|
|
|
|
|
|
|
|
|
//Start KYC
|
|
public function kycList()
|
|
{
|
|
$this->myLogger->logme('error','KYC list function called');
|
|
$headerData['page_name'] = 'KYC List';
|
|
$data['kycList'] = $this->kycEntityTypeModel->where('is_active',1)->findAll();
|
|
// $data['insurer_rm'] = $this->insurerRMModel->getAllClientRM();
|
|
// echo '<pre>';
|
|
// print_r($data['insurerList']); die;
|
|
|
|
echo view('layout/header', $headerData);
|
|
echo view('kyc_list', $data);
|
|
echo view('layout/footer');
|
|
|
|
// $this->loadLayout('insurer_onboarding', $data);
|
|
}
|
|
|
|
public function kycRemove($id = null)
|
|
{
|
|
$this->myLogger->logme('error','KYC Remove function called');
|
|
// $data = $this->request->getPost();
|
|
$data['updated_by'] = get_session_userid();
|
|
$data['is_active'] = 0;
|
|
$update = $this->kycEntityTypeModel->update($id,$data);
|
|
if($update){
|
|
return $this->respond(['status' => true,'code' => 200], 200);
|
|
}else{
|
|
return $this->respond(['status' => false,'code' => 404], 200);
|
|
}
|
|
}
|
|
|
|
public function removeKYCDocs($id = null)
|
|
{
|
|
$this->myLogger->logme('error','KYC Docs Remove function called');
|
|
// $id = $this->request->getPost('PrimaryKey');
|
|
// $data = $this->request->getPost();
|
|
$data['updated_by'] = get_session_userid();
|
|
$data['is_active'] = 0;
|
|
$update = $this->kycDocsModel->update($id,$data);
|
|
if($update){
|
|
return $this->respond(['status' => true,'code' => 200], 200);
|
|
}else{
|
|
return $this->respond(['status' => false,'code' => 404], 200);
|
|
}
|
|
}
|
|
|
|
public function kycOnboarding()
|
|
{
|
|
|
|
$this->myLogger->logme('error','KYC Onboarding function called');
|
|
$headerData['page_name'] = 'KYC Master';
|
|
|
|
|
|
// print_r($data['types']);die();
|
|
$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();
|
|
|
|
// echo "<pre>";
|
|
// print_r($data); die;
|
|
|
|
echo view('layout/header', $headerData);
|
|
echo view('kyc_onboarding', $data);
|
|
echo view('layout/footer');
|
|
|
|
}
|
|
|
|
public function createKYCInfo()
|
|
{
|
|
|
|
$this->myLogger->logme('error','KYC Entity Type general info function called');
|
|
$data = $this->request->getPost();
|
|
$data['created_by'] = get_session_userid();
|
|
|
|
$insert = $this->kycEntityTypeModel->insert($data);
|
|
if($insert){
|
|
$kyc_data = $this->kycEntityTypeModel->where(['id' => $insert, 'is_active' => 1])->first();
|
|
echo json_encode(array("status" => true , 'data' => $kyc_data));
|
|
}else{
|
|
echo json_encode(array("status" => false));
|
|
}
|
|
}
|
|
|
|
public function createKycDocs()
|
|
{
|
|
|
|
$this->myLogger->logme('error','Kyc Docs CREATE function called');
|
|
$data = $this->request->getPost();
|
|
// print_r($data);die;
|
|
|
|
if($data['kyc_type_id'] == ''){
|
|
// PrimaryKey
|
|
$data['kyc_type_id'] =$data['PrimaryKey'];
|
|
}
|
|
// print_r($data);die;
|
|
|
|
$data['created_by'] = get_session_userid();
|
|
$insert = $this->kycDocsModel->insert($data);
|
|
|
|
if($insert){
|
|
$kycDocsData = $this->kycDocsModel->where('kyc_type_id', $data['kyc_type_id'])->where('is_active',1)->findAll();
|
|
echo json_encode(array("status" => true , 'data' => $kycDocsData));
|
|
}else{
|
|
echo json_encode(array("status" => false));
|
|
}
|
|
}
|
|
|
|
public function editKYCOnboarding($id = null)
|
|
{
|
|
|
|
$this->myLogger->logme('error','Edit KYC Onboarding function called');
|
|
$headerData['page_name'] = 'Edit KYC Master';
|
|
|
|
$editData['kyc'] = $this->kycEntityTypeModel->where(['id' => $id, 'is_active' => 1])->first();
|
|
$editData['kyc_docs'] = $this->kycDocsModel->where(['kyc_type_id' => $id, 'is_active' => 1])->findAll();
|
|
|
|
|
|
// echo "<pre>";
|
|
// print_r($editData); die;
|
|
|
|
echo view('layout/header', $headerData);
|
|
echo view('kyc_onboarding', $editData);
|
|
echo view('layout/footer');
|
|
|
|
}
|
|
|
|
public function kycDocsList($id = null)
|
|
{
|
|
|
|
$this->myLogger->logme('error','Edit KYC Docs Onboarding function called');
|
|
|
|
|
|
$editData['kyc_docs'] = $this->kycDocsModel->where(['kyc_type_id' => $id, 'is_active' => 1])->findAll();
|
|
|
|
// Return JSON response
|
|
header('Content-Type: application/json');
|
|
echo json_encode($editData);
|
|
exit();
|
|
}
|
|
|
|
public function editKYCInfo()
|
|
{
|
|
$this->myLogger->logme('error','edit KYC general info function called');
|
|
$id = $this->request->getPost('PrimaryKey');
|
|
$data = $this->request->getPost();
|
|
$data['updated_by'] = get_session_userid();
|
|
$update = $this->kycEntityTypeModel->update($id,$data);
|
|
if($update){
|
|
echo json_encode(array("status" => true , 'data' => $data));
|
|
}else{
|
|
echo json_encode(array("status" => false));
|
|
}
|
|
}
|
|
|
|
public function editKYCGet($id = null)
|
|
{
|
|
$this->myLogger->logme('error','Edit KYC Onboarding function called');
|
|
|
|
$editData['policies'] = $this->kycDocsModel->where(['id' => $id, 'is_active' => 1])->first();
|
|
|
|
// Return JSON response
|
|
header('Content-Type: application/json');
|
|
echo json_encode($editData);
|
|
exit();
|
|
}
|
|
|
|
public function editKYCDocs()
|
|
{
|
|
$this->myLogger->logme('error','edit KYC Docs function called');
|
|
$id = $this->request->getPost('PrimaryKey');
|
|
$data['file_name'] = $this->request->getPost('file_name');
|
|
$data['updated_by'] = get_session_userid();
|
|
$update = $this->kycDocsModel->update($id,$data);
|
|
if($update){
|
|
echo json_encode(array("status" => true , 'data' => $data));
|
|
}else{
|
|
echo json_encode(array("status" => false));
|
|
}
|
|
}
|
|
//Ends KYC
|
|
|
|
|
|
|
|
|
|
|
|
//Start Policy
|
|
public function policyTypeList()
|
|
{
|
|
$this->myLogger->logme('error','Policy Type list function called');
|
|
$headerData['page_name'] = 'Policy Type List';
|
|
$data['policyList'] = $this->policyTypeModel->where('is_active',1)->findAll();
|
|
// $data['insurer_rm'] = $this->insurerRMModel->getAllClientRM();
|
|
// echo '<pre>';
|
|
// print_r($data['insurerList']); die;
|
|
|
|
echo view('layout/header', $headerData);
|
|
echo view('policy_type_list', $data);
|
|
echo view('layout/footer');
|
|
|
|
// $this->loadLayout('insurer_onboarding', $data);
|
|
}
|
|
|
|
public function policyTypeRemove($id = null)
|
|
{
|
|
$this->myLogger->logme('error','Policy Type Remove function called');
|
|
// $data = $this->request->getPost();
|
|
$data['updated_by'] = get_session_userid();
|
|
$data['is_active'] = 0;
|
|
$update = $this->policyTypeModel->update($id,$data);
|
|
if($update){
|
|
return $this->respond(['status' => true,'code' => 200], 200);
|
|
}else{
|
|
return $this->respond(['status' => false,'code' => 404], 200);
|
|
}
|
|
}
|
|
|
|
public function removePolicyPolicies($id = null)
|
|
{
|
|
$this->myLogger->logme('error','Policies Remove function called');
|
|
// $id = $this->request->getPost('PrimaryKey');
|
|
// $data = $this->request->getPost();
|
|
$data['updated_by'] = get_session_userid();
|
|
$data['is_active'] = 0;
|
|
$update = $this->policesModel->update($id,$data);
|
|
if($update){
|
|
return $this->respond(['status' => true,'code' => 200], 200);
|
|
}else{
|
|
return $this->respond(['status' => false,'code' => 404], 200);
|
|
}
|
|
}
|
|
|
|
public function policyTypeOnboarding()
|
|
{
|
|
|
|
$this->myLogger->logme('error','Policy Type Onboarding function called');
|
|
$headerData['page_name'] = 'Policy Type Master';
|
|
|
|
|
|
// print_r($data['types']);die();
|
|
$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['policy_type'] = $this->policyTypeModel->findAll();
|
|
$data['insurer'] = $this->insurerModel ->findAll();
|
|
// echo "<pre>";
|
|
|
|
echo view('layout/header', $headerData);
|
|
echo view('policy_type_onboarding', $data);
|
|
echo view('layout/footer');
|
|
|
|
}
|
|
|
|
public function createPolicies()
|
|
{
|
|
$this->myLogger->logme('error','Policies CREATE function called');
|
|
$data = $this->request->getPost();
|
|
// print_r($data);
|
|
// die();
|
|
$data['created_by'] = get_session_userid();
|
|
$insert = $this->policesModel->insert($data);
|
|
if($insert){
|
|
$policiesData = $this->policesModel->select('policies.*, insurers.name as insurer_name')
|
|
->join('insurers', 'insurers.id = policies.insurer_id')
|
|
->where('policies.policy_type_id', $this->request->getPost('policy_type_id'))
|
|
->where('policies.is_active', 1)
|
|
->findAll();
|
|
// $policiesData = $this->policesModel->where('policy_type_id', $this->request->getPost('policy_type_id'))->findAll();
|
|
echo json_encode(array("status" => true , 'data' => $policiesData));
|
|
}else{
|
|
echo json_encode(array("status" => false));
|
|
}
|
|
}
|
|
|
|
public function createPolicyType()
|
|
{
|
|
$this->myLogger->logme('error','Policy Type CREATE function called');
|
|
$data = $this->request->getPost();
|
|
|
|
$data['created_by'] = get_session_userid();
|
|
$insert = $this->policyTypeModel->insert($data);
|
|
|
|
if($insert){
|
|
$policyTypeData = $this->policyTypeModel->where('id', $insert)->first();
|
|
echo json_encode(array("status" => true , 'data' => $policyTypeData));
|
|
}else{
|
|
echo json_encode(array("status" => false));
|
|
}
|
|
}
|
|
|
|
public function editPolicyTypeOnboarding($id = null)
|
|
{
|
|
|
|
$this->myLogger->logme('error','Edit KYC Onboarding function called');
|
|
$headerData['page_name'] = 'Edit Policy Type';
|
|
|
|
$editData['policytype'] = $this->policyTypeModel->where(['id' => $id, 'is_active' => 1])->first();
|
|
$editData['policies'] = $this->policesModel->select('policies.*, insurers.name as insurer_name')
|
|
->join('insurers', 'insurers.id = policies.insurer_id')
|
|
->where('policies.policy_type_id', $id)
|
|
->where('policies.is_active', 1)
|
|
->findAll();
|
|
// $editData['policies'] = $this->policesModel->where(['policy_type_id' => $id, 'is_active' => 1])->findAll();
|
|
$editData['insurer'] = $this->insurerModel-> findAll();
|
|
echo view('layout/header', $headerData);
|
|
echo view('policy_type_onboarding', $editData);
|
|
echo view('layout/footer');
|
|
|
|
}
|
|
|
|
public function editPolicyType()
|
|
{
|
|
$this->myLogger->logme('error','edit Policy general info function called');
|
|
$id = $this->request->getPost('PrimaryKey');
|
|
$data = $this->request->getPost();
|
|
$data['updated_by'] = get_session_userid();
|
|
$update = $this->policyTypeModel->update($id,$data);
|
|
if($update){
|
|
echo json_encode(array("status" => true , 'data' => $data));
|
|
}else{
|
|
echo json_encode(array("status" => false));
|
|
}
|
|
}
|
|
|
|
public function policesList($id = null)
|
|
{
|
|
$this->myLogger->logme('error','Edit Policies Onboarding function called');
|
|
|
|
// $editData['policies'] = $this->policesModel->where(['policy_type_id' => $id, 'is_active' => 1])->findAll();
|
|
|
|
$policies = $this->policesModel->where(['policy_type_id' => $id, 'is_active' => 1])->findAll();
|
|
|
|
// print_r($id);die;
|
|
foreach ($policies as $policy) {
|
|
// Retrieve the insurer information
|
|
$insurer = $this->insurerModel->find($policy['insurer_id']);
|
|
|
|
// print_r($insurer);die;
|
|
// Add the insurer information to the editData array
|
|
if ($insurer) {
|
|
$editData['policies'][$policy['id']] = [
|
|
'policy' => $policy,
|
|
'insurer' => $insurer
|
|
];
|
|
}
|
|
}
|
|
|
|
|
|
// Return JSON response
|
|
// header('Content-Type: application/json');
|
|
// echo json_encode($editData);
|
|
exit();
|
|
}
|
|
|
|
public function editPoliciesGet($id = null)
|
|
{
|
|
$this->myLogger->logme('error','Edit Policies Onboarding function called');
|
|
$editData['policies'] = $this->policesModel->where(['id' => $id, 'is_active' => 1])->first();
|
|
// Return JSON response
|
|
header('Content-Type: application/json');
|
|
echo json_encode($editData);
|
|
exit();
|
|
}
|
|
|
|
public function editPolicies()
|
|
{
|
|
$this->myLogger->logme('error','edit Policy general info function called');
|
|
$id = $this->request->getPost('PrimaryKey');
|
|
$data = $this->request->getPost();
|
|
$data['updated_by'] = get_session_userid();
|
|
$update = $this->policesModel->update($id,$data);
|
|
if($update){
|
|
$policyData = $this->policesModel->where(['id' => $id, 'is_active' => 1])->findAll();
|
|
echo json_encode(array("status" => true , 'data' => $policyData));
|
|
}else{
|
|
echo json_encode(array("status" => false));
|
|
}
|
|
}
|
|
//end policies
|
|
|
|
|
|
|
|
|
|
//start CD Master list
|
|
public function CDMasterList()
|
|
{
|
|
$data['page_name'] = 'CD Master List';
|
|
$data['CD_Master_Data'] = $this->CDMasterModel->getCDMasterList();
|
|
$data['insurers'] = $this->insurerModel->where('is_active', 1)->findAll();
|
|
$data['clients'] = $this->clientModel->where('is_active', 1)->findAll();
|
|
$this->loadLayout('cd_master_list', $data);
|
|
}
|
|
|
|
public function createCDMasterData()
|
|
{
|
|
|
|
$data = $this->request->getPost();
|
|
$date = (string) $this->request->getPost('opening_date');
|
|
$data['opening_date'] = date('Y-m-d', strtotime($date));
|
|
|
|
// Prepare the array with data
|
|
$cd_tranction_data = [
|
|
'amount' => $data['opening_bal'],
|
|
'sub_type_id' => 7,
|
|
'client_id' => $data['client_id'],
|
|
'client_policy_id' => null,
|
|
'cd_ac_no' => $data['cd_ac_no'],
|
|
'endorsement_no' => null,
|
|
'insurer_id' => $data['insurer_id'],
|
|
'description' => 'opening Amount',
|
|
'transaction_type' => 'Credit',
|
|
'event_name' => null,
|
|
'updated_by' => 1,
|
|
];
|
|
|
|
$loggedInUserID = get_session_userid();
|
|
|
|
if ($data) {
|
|
|
|
$insert = $this->CDMasterModel->insert($data);
|
|
|
|
if ($insert) {
|
|
|
|
$response = DepositHelper::saveDeposit($cd_tranction_data, $loggedInUserID);
|
|
|
|
session()->setFlashdata('success', "Cash Deposite Master Added Successfully");
|
|
return redirect()->to(base_url('/master/cash_deposite/list'));
|
|
} else {
|
|
|
|
session()->setFlashdata('error', "Cash Deposite Master Added Failed");
|
|
return redirect()->to(base_url('/master/cash_deposite/list'));
|
|
}
|
|
} else {
|
|
|
|
session()->setFlashdata('error', "Cash Deposite Master Added Failed. Data Not Found");
|
|
return redirect()->to(base_url('/master/cash_deposite/list'));
|
|
}
|
|
}
|
|
|
|
public function editCDMasterData($id = null)
|
|
{
|
|
|
|
$id = $this->request->getPost('PrimaryKey');
|
|
$date = (string) $this->request->getPost('opening_date');
|
|
$data = $this->request->getPost();
|
|
$data['opening_date'] = date('Y-m-d', strtotime($date));
|
|
|
|
if ($data) {
|
|
|
|
$insert = $this->CDMasterModel->where('id', $id)->set($data)->update();
|
|
|
|
$cd_transaction_updated_data = [
|
|
'balance' => $data['opening_bal'],
|
|
'amount' => $data['opening_bal']
|
|
];
|
|
|
|
$cd_tranction = $this->clientDepositModel
|
|
->where('client_id', $data['client_id'])
|
|
->where('insurer_id', $data['insurer_id'])
|
|
->where('cd_ac_no', $data['cd_ac_no'])
|
|
->where('sub_type', 7)
|
|
->set($cd_transaction_updated_data)->update();
|
|
|
|
if ($insert) {
|
|
|
|
session()->setFlashdata('success', "Cash Deposite Master Updated Successfully");
|
|
return redirect()->to(base_url('/master/cash_deposite/list'));
|
|
} else {
|
|
|
|
session()->setFlashdata('error', "Cash Deposite Master Update Failed");
|
|
return redirect()->to(base_url('/master/cash_deposite/list'));
|
|
}
|
|
} else {
|
|
|
|
session()->setFlashdata('error', "Cash Deposite Master Update Failed. Data Not Found");
|
|
return redirect()->to(base_url('/master/cash_deposite/list'));
|
|
}
|
|
}
|
|
|
|
public function getCDMasterDataByID($id = null)
|
|
{
|
|
|
|
$cd_data = $this->CDMasterModel
|
|
->where('id', $id)
|
|
->where('is_active', 1)
|
|
->first();
|
|
|
|
// convert the date formate 2000-01-01 to 01-01-2000
|
|
$cd_data['opening_date'] = date('d-m-Y', strtotime($cd_data['opening_date']));
|
|
|
|
if ($cd_data) {
|
|
return $this->respond(['status' => true, 'code' => 200, 'data' => $cd_data], 200);
|
|
} else {
|
|
return $this->respond(['status' => false, 'code' => 404], 200);
|
|
}
|
|
}
|
|
|
|
public function checkUniqueCDAccountNumber($AccountNumber)
|
|
{
|
|
$uniqueAC = $this->CDMasterModel
|
|
->where('cd_ac_no', $AccountNumber)
|
|
->where('is_active', 1)
|
|
->findAll();
|
|
|
|
if($uniqueAC != null){
|
|
return $this->respond(['status' => true, 'message' => 'The CD Account Number is Already Exist', 'code' => 200], 200);
|
|
}else{
|
|
return $this->respond(['status' => false, 'code' => 404], 200);
|
|
}
|
|
}
|
|
|
|
public function removeCDMaster($id)
|
|
{
|
|
|
|
$this->myLogger->logme('error','CDMaster Remove function called');
|
|
$data['updated_by'] = get_session_userid();
|
|
$data['is_active'] = 0;
|
|
$cash_transaction_data = $this->CDMasterModel->where('id', $id)->first();
|
|
|
|
$update = $this->CDMasterModel->where('id', $id)->set($data)->update();
|
|
|
|
$cd_tranction_update = $this->clientDepositModel
|
|
->where('client_id', $cash_transaction_data['client_id'])
|
|
->where('insurer_id', $cash_transaction_data['insurer_id'])
|
|
->where('cd_ac_no', $cash_transaction_data['cd_ac_no'])
|
|
->where('sub_type', 7)
|
|
->set($data)
|
|
->update();
|
|
|
|
if($update){
|
|
return $this->respond(['status' => true,'code' => 200], 200);
|
|
}else{
|
|
return $this->respond(['status' => false,'code' => 404], 200);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//excel export template
|
|
public function createExcelTemplate()
|
|
{
|
|
// return $this->respond($this->request->getPost());
|
|
$template_id = $this->request->getPost('template_id');
|
|
|
|
$data = [
|
|
'insurer_id' => $this->request->getPost('insurer_id'),
|
|
'policy_type_id' => $this->request->getPost('policy_type'),
|
|
'event_name' => $this->request->getPost('event'),
|
|
'type_name' => 'export',
|
|
'jsoncolumns' => $this->request->getPost('json_data'),
|
|
'is_active' => 1,
|
|
'created_by' => get_session_userid(),
|
|
];
|
|
|
|
if($template_id){
|
|
|
|
$update = $this->insurerTemplateModel->where('id', $template_id)->set($data)->update();
|
|
|
|
if($update){
|
|
return $this->respond(['status' => true, 'message' => 'Template updated successfully', $data]);
|
|
}else{
|
|
return $this->respond(['status' => true, 'message' => 'Failed to update template', $data]);
|
|
}
|
|
|
|
}else{
|
|
|
|
$insert = $this->insurerTemplateModel->insert($data);
|
|
|
|
if($insert){
|
|
return $this->respond(['status' => true, 'message' => 'Template created successfully', $data]);
|
|
}else{
|
|
return $this->respond(['status' => true, 'message' => 'Failed to create template', $data]);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
public function duplicateTemplate($template_id, $event_name)
|
|
{
|
|
// Fetch the template data based on the provided ID and ensure it is active
|
|
$insurer_template_data = $this->insurerTemplateModel->where('id', $template_id)
|
|
->where('is_active', 1)
|
|
->first();
|
|
|
|
|
|
if ($insurer_template_data) {
|
|
|
|
// Check if the event name matches the existing template's event name
|
|
if ($insurer_template_data['event_name'] == $event_name) {
|
|
return $this->respond([
|
|
'status' => false,
|
|
'message' => 'Template with the same event already exists.',
|
|
'data' => $insurer_template_data
|
|
]);
|
|
}
|
|
|
|
// Prepare data for insertion as a duplicate
|
|
$data_to_insert = [
|
|
"insurer_id" => $insurer_template_data['insurer_id'],
|
|
"policy_type_id" => $insurer_template_data['policy_type_id'],
|
|
"event_name" => $event_name,
|
|
"type_name" => $insurer_template_data['type_name'],
|
|
"jsoncolumns" => $insurer_template_data['jsoncolumns'],
|
|
"created_by" => get_session_user(),
|
|
"is_active" => 1,
|
|
];
|
|
|
|
// Insert the duplicate template data
|
|
$insert_result = $this->insurerTemplateModel->insert($data_to_insert);
|
|
|
|
if ($insert_result) {
|
|
return $this->respond([
|
|
'status' => true,
|
|
'message' => 'Template duplicated successfully.',
|
|
'data' => $insurer_template_data
|
|
]);
|
|
} else {
|
|
return $this->respond([
|
|
'status' => false,
|
|
'message' => 'Failed to duplicate template.',
|
|
'data' => $insurer_template_data
|
|
]);
|
|
}
|
|
} else {
|
|
// No matching active template found
|
|
return $this->respond([
|
|
'status' => false,
|
|
'message' => 'No active template data found.',
|
|
'data' => null
|
|
]);
|
|
}
|
|
}
|
|
|
|
|
|
public function generateNewGmailAPIToken()
|
|
{
|
|
$gmailapi = \Config\Services::gmailapi();
|
|
$gmailapi->generateNewToken();
|
|
|
|
}
|
|
|
|
//testing a sample mail from front end
|
|
public function testGmailAPI()
|
|
{
|
|
|
|
if ($this->request->getMethod() == 'post') {
|
|
$gmailapi = \Config\Services::gmailapi();
|
|
|
|
$to = $this->request->getPost('to');
|
|
$subject = $this->request->getPost('subject');
|
|
$mail_content = $this->request->getPost('content');
|
|
|
|
/*****CHOOSE ANY ONE AT A TIME, COMMENT ANOTHER ONE******/
|
|
|
|
/*****CALLING DIRECLT USING LIB******/
|
|
// $res = $gmailapi->sendMessage($to, $subject, $mail_content, 'info@nhanceindia.in', 'info@nhanceindia.in', $cc = [], $bcc = []);
|
|
|
|
// if($res['status'])
|
|
// {
|
|
// return $this->respond(['status' => 'success','code' => 200,'data' => $res],200);
|
|
// }
|
|
// else
|
|
// {
|
|
// $this->respond(['status' => 'failed','code' => 500,'data' => $res],200);
|
|
// }
|
|
/*****CALLING DIRECLT USING LIB******/
|
|
|
|
/*****CALLING VIA MAIL HELPER******/
|
|
$res = MailHelper::send_email(['mail' => $to, 'subject' => $subject, 'message' => $mail_content]);
|
|
return $this->respond(['status' => 'success','code' => 200,'data' => $res],200);
|
|
/*****CALLING VIA MAIL HELPER******/
|
|
|
|
}
|
|
|
|
$this->loadLayout('mail_test');
|
|
|
|
}
|
|
|
|
|
|
//testing a sample mail from cli
|
|
public function testGmailAPIViaCLI()
|
|
{
|
|
$gmailapi = \Config\Services::gmailapi();
|
|
$res = MailHelper::send_email(['mail' => 'velmurugan.s@venbainfotech.com', 'subject' => 'Mail Via CLI', 'message' => 'This is sample mail sent via CLI mode']);
|
|
print_r($res);
|
|
|
|
}
|
|
} |