Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev

This commit is contained in:
aadhavan valli 2024-06-28 17:02:19 +05:30
commit 437cf99db4
51 changed files with 5370 additions and 1724 deletions

View File

@ -36,6 +36,24 @@ Options -Indexes
# Ensure Authorization header is passed along
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/js "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/javascript "access 1 month"
ExpiresByType application/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
<IfModule !mod_rewrite.c>

View File

@ -42,6 +42,9 @@ class App extends BaseConfig
*/
public string $indexPage = 'index.php';
public $compressOutput = true;
/**
* --------------------------------------------------------------------------
* URI PROTOCOL

View File

@ -122,6 +122,7 @@ $routes->group("/client", ["filter" => "authMVC"], function ($routes) {
$routes->group("terms", ["filter" => "authMVC"], function ($routes) {
$routes->post("gpa_create", "ClientController::policyGPATerms");
$routes->post("edit", "ClientController::editClientPolicyPremium");
$routes->post("other_terms", "ClientController::otherPolicyTermsFormSubmit");
});
});
@ -214,6 +215,14 @@ $routes->group("/master", ["filter" => "authMVC"], function ($routes) {
$routes->get("remove/(:any)", "MasterController::removePolicyPolicies/$1");
});
});
$routes->group("cash_deposite", ["filter" => "authMVC"], function ($routes) {
$routes->get("list", "MasterController::CDMasterList");
$routes->post("create", "MasterController::createCDMasterData");
$routes->post("edit", "MasterController::editCDMasterData");
$routes->get("list/(:any)", "MasterController::getCDMasterDataByID/$1");
$routes->get("remove/(:any)", "MasterController::removeCDMaster/$1");
});
});
@ -242,6 +251,12 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
$routes->get("get-client-branch/(:any)", "ClientController::getClientBranch/$1");
$routes->get("get-client-details/(:any)", "ClientController::getClientAllDetailsByUsingClientID/$1");
$routes->get("delete-additional-rack-rate/(:any)", "ClientController::deleteAdditionalRackRate/$1");
$routes->get("check_cd_ac_no/(:any)", "MasterController::checkUniqueCDAccountNumber/$1");
$routes->get("get_cd_ac/(:any)", "ClientController::get_cd_ac/$1");
$routes->get("check_policy_type/(:any)", "ClientController::checkPolicyType/$1");
$routes->get("getPolicyTerms/(:any)", "ClientController::getPolicyTerms/$1");
$routes->get("getPolicyTermsFormJson/(:any)", "ClientController::getPolicyTermsFormJson/$1");
$routes->get("checkHRNumber/(:any)", "ClientController::checkHRNumber/$1");
});
$routes->cli('cli/processjob', 'JobWorker::processJob');
@ -265,9 +280,9 @@ $routes->group("/api", ["filter" => "authJWT"], function ($routes) {
$routes->get("getChatResponse", "ChatBotController::getChatResponse");
$routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
$routes->get("getChatResponse", "ChatBotController::getChatResponse");
$routes->get("getEmployeeProfile", "EmployeeRestController::getEmployeeProfile");
$routes->post("employeeUpload", "EmployeeRestController::employeeUpload");
$routes->get("relationshipList", "EmployeeRestController::relationshipList");
@ -298,6 +313,9 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
$routes->get("getAdvertisementImage", "EmployeeRestController::getAdvertisementImage");
});
$routes->post("sendEmail", "EmployeeRestController::send_email");

View File

@ -0,0 +1,118 @@
<?php
namespace App\Controllers;
use App\Helpers\MailHelper;
use App\Helpers\sendMailNotification;
use App\Models\EmployeeModel;
use App\Models\EmployeePolicyModel;
use App\Models\ClientModel;
use App\Models\ClientRMModel;
use App\Models\PolicesModel;
use App\Models\RelationshipModel;
use App\Models\FileModel;
use App\Models\ClientPolicyModel;
use App\Models\PolicyPremium1Model;
use App\Models\PolicyPremium2Model;
use App\Models\PolicyTypeModel;
use App\Models\NotificationModel;
use App\Models\UserModel;
use App\Models\FEContentModel;
use App\Models\AddImgModel;
use App\Models\ChatBotModel;
use CodeIgniter\API\ResponseTrait;
class ChatBotController extends AdminController
{
use ResponseTrait;
protected $myLogger;
protected $employeeModel;
protected $employeePolicyModel;
protected $clientModel;
protected $clientRMModel;
protected $fileModel;
protected $policesModel;
protected $relationshipModel;
protected $clientPolicyModel;
protected $policyPremium1Model;
protected $policyPremium2Model;
protected $policyTypeModel;
protected $notificationModel;
protected $userModel;
protected $feContentModel;
protected $addImgModel;
protected $ChatBotModel;
public function __construct()
{
set_session_context('Employee');
$this->myLogger = \Config\Services::mylogger();
$this->employeeModel = new EmployeeModel();
$this->employeePolicyModel = new EmployeePolicyModel();
$this->clientModel = new ClientModel();
$this->clientRMModel = new ClientRMModel();
$this->policesModel = new PolicesModel();
$this->relationshipModel = new RelationshipModel();
$this->fileModel= new FileModel();
$this->clientPolicyModel = new ClientPolicyModel();
$this->policyPremium1Model = new PolicyPremium1Model();
$this->policyPremium2Model = new PolicyPremium2Model();
$this->policyTypeModel = new PolicyTypeModel();
$this->notificationModel = new NotificationModel();
$this->userModel = new UserModel();
$this->feContentModel = new FEContentModel();
$this->addImgModel = new AddImgModel();
$this->ChatBotModel = new ChatBotModel();
}
public function getChatResponse()
{
// try {
$request_for = $this->request->getGet('request_for');
$option = $this->request->getGet('option');
$requestData = $this->ChatBotModel->where('request', $request_for)
->where('is_active', 1 )
->first();
if ($requestData) {
if($option != 0){
$decodedData = json_decode($requestData['options'],true);
$requestFor = $decodedData[$request_for][$option];
$requestData = $this->ChatBotModel->where('request', $requestFor)
->where('is_active', 1 )
->first();
}
$result = ['request_for'=>$requestData['request'],'options'=>json_decode($requestData['options'],true)];
return $this->respond(['status' => 'success','code' => 200,'data' => $result ],200);
} else {
return $this->respond(['status' => 'failed','code' => 404,'data' => 'No Data'],404);
}
// } catch (\Throwable $th) {
// return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
// }
}
}

View File

@ -31,6 +31,10 @@ use App\Models\PolicyPremium2Model;
use App\Models\EmployeeModel;
use App\Models\EmployeePolicyModel;
use App\Models\NotificationModel;
use App\Models\CDMasterModel;
use App\Models\PolicyTypeModel;
@ -62,12 +66,15 @@ class ClientController extends AdminController
protected $employeeModel;
protected $employeePolicyModel;
protected $notificationModel;
protected $CDMasterModel;
protected $policyTypeModel;
public function __construct()
{
set_session_context('Client');
$this->myLogger = \Config\Services::mylogger();
$this->clientModel = new ClientModel();
$this->userModel = new UserModel();
$this->clientBranchModel = new ClientBranchModel();
@ -89,7 +96,11 @@ class ClientController extends AdminController
$this->policyPremium2Model = new PolicyPremium2Model();
$this->employeeModel = new EmployeeModel();
$this->employeePolicyModel = new EmployeePolicyModel();
$this->notificationModel = new NotificationModel();
$this->notificationModel = new NotificationModel();
$this->CDMasterModel = new CDMasterModel();
$this->policyTypeModel = new PolicyTypeModel();
@ -200,13 +211,21 @@ class ClientController extends AdminController
public function view_Deposit($insurerId)
{
// Load your model to fetch data based on $clientId and $insurerId
// $subTypeOptions = [
// 1 => 'Deposit',
// 2 => 'Adjustment',
// 3 => 'Refund',
// 4 => 'Debit',
// ];
$subTypeOptions = [
1 => 'Deposit',
1 => 'Replenishment',
2 => 'Adjustment',
3 => 'Refund',
3 => 'Refund From Deletion',
4 => 'Debit',
// Add more options as needed
5 => 'Asset Policy',
];
$data['subTypeOptions'] = $subTypeOptions;
$headerData['page_name'] = 'Client Deposit';
$data['insurerName']= $this->insurerModel->getInsurerName($insurerId);
@ -231,20 +250,33 @@ class ClientController extends AdminController
// Retrieve form data from POST request
$loggedInUserID = get_session_userid();
$client_id = $this->request->getPost('client_id');
$insurer_id = $this->request->getPost('insurer_id');
$CD_Account_Number = $this->CDMasterModel
->where('client_id', $client_id)
->where('insurer_id', $insurer_id)
->first();
// Prepare the array with data
$data = [
'amount' => $this->request->getPost('amount'),
'sub_type_id' => $this->request->getPost('sub_type_id'),
'client_id' => $this->request->getPost('client_id'),
'client_policy_id' => null,
'cd_ac_no' => $CD_Account_Number['cd_ac_no'] ?? null,
'endorsement_no' => null,
'insurer_id' => $this->request->getPost('insurer_id'),
'description' => $this->request->getPost('description'),
'transaction_type' => $this->request->getPost('transaction_type') ?: 'Credit',
'updated_by' => 1, // You need to set the correct value for updated_by
'updated_by' => 1,
];
// Call the saveDeposit function from DepositHelper
$response = DepositHelper::saveDeposit($data, $loggedInUserID);
// Return a boolean value based on success
return $this->response->setJSON(['success' => $response['success']]);
}
@ -271,9 +303,9 @@ class ClientController extends AdminController
$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();
// dd('Hi');
$editData['client_branch']['role'] = get_role_id();
$clientPoliceData = $this->clientPolicyModel->getClientPolicyByClientId($id);
// dd($this->clientPolicyModel->getLastQuery());
foreach ($clientPoliceData as $key => $value) {
$clientPoliceData[$key]->policy_start_date = date('d-M-Y', strtotime($value->policy_start_date));
@ -281,12 +313,10 @@ class ClientController extends AdminController
}
$editData['client_policy'] = $clientPoliceData;
$editData['notification'] =$this->notificationModel->select('template_name,enabled')->where('client_id',$id)->findAll();
$editData['placeHolders'] = ['member_name','nhance_logo','tpa_id','ecard_download_link', 'client_logo', 'policy_no', 'member_summary', 'app_link', 'post_enrollment_app_link', 'client_name'];
// dd($editData);
echo view('layout/header', $headerData);
echo view('client_onboarding', $editData);
echo view('layout/footer');
@ -535,6 +565,7 @@ class ClientController extends AdminController
if($insert){
$branchData = $this->clientBranchModel->where('client_id', $this->request->getPost('client_id'))->findAll();
$branchData['role'] = get_role_id();
return $this->respond(['status' => true,'code' => 200,'data' => $branchData], 200);
}else{
return $this->respond(['status' => false,'code' => 404, 'message' => 'no data found'], 200);
@ -588,22 +619,13 @@ class ClientController extends AdminController
$policy_type_id = $this->request->getPost('policy_type_id');
$client_branch_id = $this->request->getPost('client_branch_id');
$policyCount = $this->clientPolicyModel
->where('policy_type_id', $policy_type_id)
->where('client_branch_id', $client_branch_id)
->countAllResults();
if($policyCount > 0 ){
$clientPoliceData = $this->clientPolicyModel->getClientPolicyByClientId($this->request->getPost('client_id'));
return $this->respond(['status' => 'policy_exist','code' => 200,'data' => $clientPoliceData, 'method' => 'CERATE'], 200);
}
$insurerValue = (string) $this->request->getPost('insurer');
list($insurerBranchId, $insurerId) = explode('-', $insurerValue);
$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;
@ -638,7 +660,9 @@ class ClientController extends AdminController
$data['base_policy'] = $this->request->getPost('base_policy');
$data['policy_status'] = 1;
$data['inception_type'] = $this->request->getPost('inception_type') ? 2 : 1;
$data['client_branch_id'] = $this->request->getPost('client_branch_id');
$data['client_branch_id'] = $this->request->getPost('client_branch_id');
$data['cd_ac_no'] = $this->request->getPost('cd_ac_no');
$data['gst'] = $this->request->getPost('gst');
@ -733,10 +757,11 @@ class ClientController extends AdminController
$data['base_policy'] = $this->request->getPost('base_policy');
$data['policy_status'] = 1;
$data['inception_type'] = $this->request->getPost('inception_type') ? 2 : 1;
$data['client_branch_id'] = $this->request->getPost('client_branch_id');
$data['client_branch_id'] = $this->request->getPost('client_branch_id');
$data['cd_ac_no'] = $this->request->getPost('cd_ac_no');
$data['gst'] = $this->request->getPost('gst');
$policy_terms = $this->clientPolicyModel->where('id', $this->request->getPost('base_policy'))->first();
if ( $this->request->getPost('is_addon') == 2 || $this->request->getPost('is_addon') == 3) {
@ -884,6 +909,24 @@ class ClientController extends AdminController
$policyPremium = $this->policyPremium1Model->insert($data);
}
}else if ($si_or_bp == '2') {
$premium = str_replace(',', '', $this->request->getPost('gpa_basic_premium[]'));
$sum_insure = str_replace(',', '', $this->request->getPost('gpa_basic_si[]'));
$basic_pay = str_replace(',', '', $this->request->getPost('basic_pay[]'));
for ($i = 0; $i < count($premium); $i++) {
$data['si_or_bp'] = $this->request->getPost('si_or_bp');
$data['basic_multiplier'] = str_replace(',', '', $this->request->getPost('basic_multiplier'));
$data['multiplier'] = $this->request->getPost('premium_multiplier');
$data['basic_pay'] = $basic_pay[$i];
$data['si'] = $sum_insure[$i];
$data['premium'] = $premium[$i];
$policyPremium = $this->policyPremium1Model->insert($data);
}
}else {
$data['premium'] = str_replace(',', '', $this->request->getPost('gpa_basic_premium'));
@ -1140,9 +1183,10 @@ class ClientController extends AdminController
$client_id = $client_policy_data['client_id'];
$polices = $this->policesModel->where(['insurer_id' => $insurer_id, 'is_active' => 1])->findAll();
$client_policy_list = $this->clientPolicyModel->getpolicyWithPattern( $client_id );
$cd_data = $this->CDMasterModel->where('client_id', $client_id)->where('insurer_id', $insurer_id)->findAll();
return $this->respond(['status' => true,'code' => 200, 'client_policy_list' => $client_policy_list, 'data' => $client_policy_data, "insurer_id" => $client_policy_data['insurer_id'], 'policy' => $polices], 200);
return $this->respond(['status' => true,'code' => 200, 'client_policy_list' => $client_policy_list, 'data' => $client_policy_data, 'cd_data' => $cd_data, "insurer_id" => $client_policy_data['insurer_id'], 'policy' => $polices], 200);
}else{
return $this->respond(['status' => false,'code' => 404, 'message' => 'no data found'], 200);
}
@ -1177,19 +1221,11 @@ class ClientController extends AdminController
$emp_count = $this->employeePolicyModel
->join('client_policy cp', "cp.id = employee_polices.client_policy_id")
->where("employee_polices.client_policy_id", $client_policy_id)
->where("employee_polices.status", 'active')
->where("employee_polices.is_active", 1)
->countAllResults();
// $emp_count = count($data);
// if($emp_count == 0){
// $emp_count = true;
// }else{
// $emp_count = false;
// }
->join('client_policy cp', "cp.id = employee_polices.client_policy_id")
->where("employee_polices.client_policy_id", $client_policy_id)
->where("employee_polices.status", 'active')
->where("employee_polices.is_active", 1)
->countAllResults();
$data = $this->policesModel->getPolicyPremium($record['policy_id']);
@ -1197,9 +1233,11 @@ class ClientController extends AdminController
$gmc_pattern = '/gmc/i';
$gpa_pattern = '/gpa/i';
$subject = $data[0]->policy_type;
$policy_type_id = $data[0]->id;
if (preg_match($gmc_pattern, $subject)) {
$search_term = 'GMC';
} else if (preg_match($gpa_pattern, $subject)) {
} else if (preg_match($gpa_pattern, $subject) || $policy_type_id == 6 || $policy_type_id == 7) {
$search_term = 'GPA';
} else {
$search_term = "";
@ -1207,7 +1245,7 @@ class ClientController extends AdminController
$results = $this->policyGridModel->like('policy_type', $search_term)->findAll();
if ($search_term === 'GPA') {
if ($search_term === 'GPA' || $policy_type_id == 6 || $policy_type_id == 7) {
$premiumData = $this->policyPremium1Model->where(['client_id' => $record['client_id'], 'client_policy_id' => $client_policy_id, 'is_active' => 1])->findAll();
} else if ($search_term === 'GMC') {
@ -1218,9 +1256,6 @@ class ClientController extends AdminController
$premiumData = "";
}
// echo '<pre>';
// print_r($premiumData); die;
@ -1294,7 +1329,7 @@ class ClientController extends AdminController
return $this->respond(['status' => true, 'code' => 200, 'data' => $resultss, 'premiumData' => json_encode($premiumDataa), 'count' => $emp_count, 'policy_name' => $policy_name, 'family_floater' => $family_floater, 'self' => $self, 'client_policy_id' => $client_policy_id], 200);
} else if ($search_term === 'GPA') {
} else if ($search_term === 'GPA' || $policy_type_id == 6 || $policy_type_id == 7) {
return $this->respond(['status' => true, 'code' => 200, 'data' => $results, 'premiumData' => json_encode($premiumData), 'count' => $emp_count, 'policy_name' => $policy_name, 'family_floater' => $family_floater, 'self' => $self, 'client_policy_id' => $client_policy_id], 200);
} else {
@ -1315,7 +1350,7 @@ class ClientController extends AdminController
$data['sum_insured'] =str_replace(',', '',$this->request->getPost("sum_insured"));
$data['family_floater'] =$this->request->getPost("family_floater") ? $this->request->getPost("family_floater") : 0;
$data['corporatebuffer'] = $this->request->getPost("corporatebuffer") ? $this->request->getPost("corporatebuffer") : 0;
// $data['corporatebuffer'] = $this->request->getPost("corporatebuffer") ? $this->request->getPost("corporatebuffer") : 0;
$data['family_floaters'] = $this->request->getPost("family_floaters") ?? [];
$data['age_ratio']['self']['min'] = $this->request->getPost("self_min_age") ? $this->request->getPost("self_min_age") :0;
@ -1399,7 +1434,7 @@ class ClientController extends AdminController
}
}
$data['family_floaters']['elders_count'] =$this->request->getPost("member_count") ? $this->request->getPost("member_count") : 0;
$data['family_floaters']['elders_count'] =$this->request->getPost("elder_member_count") ? $this->request->getPost("elder_member_count") : 0;
// print_r($data);die;
@ -1427,7 +1462,7 @@ class ClientController extends AdminController
$data['bioabsorbablestenttoriclensmultifocallens'] =$this->request->getPost("bioabsorbablestenttoriclensmultifocallens");
$data['roomrentlimit'] =str_replace(',', '',$this->request->getPost("roomrentlimit"));
$data['proportionatedeductionclause'] =str_replace(',', '',$this->request->getPost("proportionatedeductionclause"));
$data['nursingallowance'] =str_replace(',', '',$this->request->getPost("nursingallowance"));
// $data['nursingallowance'] =str_replace(',', '',$this->request->getPost("nursingallowance"));
$data['ailmentcapping'] =str_replace(',', '',$this->request->getPost("ailmentcapping"));
$data['ambulancecharges'] =str_replace(',', '',$this->request->getPost("ambulancecharges"));
$data['airambulance'] =str_replace(',', '',$this->request->getPost("airambulance"));
@ -1435,6 +1470,12 @@ class ClientController extends AdminController
$data['reasonableandcustomarycharges'] =str_replace(',', '',$this->request->getPost("reasonableandcustomarycharges"));
$data['ayudhtreatmentcover'] =str_replace(',', '',$this->request->getPost("ayudhtreatmentcover"));
$data['congenitaldiseasesexternal'] =str_replace(',', '',$this->request->getPost("congenitaldiseasesexternal"));
$data['optionalparentalcopay'] =str_replace(',', '',$this->request->getPost("optionalparentalcopay"));
$data['posthospitalizationcover'] =str_replace(',', '',$this->request->getPost("posthospitalizationcover"));
$data['corporatebuffer'] =str_replace(',', '',$this->request->getPost("corporatebuffer"));
$data['sublimitofcorporatebuffer'] =str_replace(',', '',$this->request->getPost("sublimitofcorporatebuffer"));
if ($data['ayudhtreatmentcover'] == 1) {
$data['ayushTreatmentCoverData'] = str_replace(',', '',$this->request->getPost("ayushTreatmentCoverData"));
}else{
@ -1455,6 +1496,7 @@ class ClientController extends AdminController
$data['days_from_dod'] =str_replace(',', '',$this->request->getPost("days_from_dod"));
$data['special_condition_label'] = str_replace(',', '',$this->request->getPost("special_condition_label")) ?? [];
$data['special_condition_input'] = str_replace(',', '',$this->request->getPost("special_condition_input")) ?? [];
$data['multiple_sum_insured'] = str_replace(',', '',$this->request->getPost("multiple_sum_insured")) ?? [];
$data['cataract'] =str_replace(',', '',$this->request->getPost("cataract"));
@ -1509,16 +1551,22 @@ class ClientController extends AdminController
// ->where("employees.emp_status",'active')
// ->countAllResults();
$emp_count_by_policy = $this->employeePolicyModel->where('client_policy_id',$client_policy_id)->where('is_active',1)->countAllResults();
$emp_count_by_policy = $this->employeePolicyModel
->where('client_policy_id',$client_policy_id)
->where("status", 'active')
->where('is_active',1)
->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'], 'policy_name' => $policy_name,'policy_addon' => $record['is_addon'], 'emp_count_by_policy'=>$emp_count_by_policy], 200);
return $this->respond([
'Status' => true,
'code' => 200,
'data' => $record['policy_terms'],
'policy_name' => $policy_name,
'policy_addon' => $record['is_addon'],
'emp_count_by_policy'=>$emp_count_by_policy],
200);
} else {
return $this->respond(['Status' => false,'code' => 200,'message' => 'Record not found.', 'policy_name' => $policy_name], 200);
}
@ -1584,6 +1632,8 @@ class ClientController extends AdminController
$data['worldwideCover'] = $this->request->getPost("worldwideCover");
$data['gpa_special_condition_label'] = str_replace(',', '',$this->request->getPost("gpa_special_condition_label")) ?? [];
$data['gpa_special_condition_input'] = str_replace(',', '',$this->request->getPost("gpa_special_condition_input")) ?? [];
$data['multiple_sum_insured'] = str_replace(',', '',$this->request->getPost("multiple_sum_insured")) ?? [];
$jsonData = json_encode($data);
@ -1859,7 +1909,7 @@ class ClientController extends AdminController
"sum_insured" => "Sum Insured",
"family_floater" => "Family Floater",
"family_floaters" => "Family Floaters",
"member_count" => "Elders Count:",
"elders_count" => "Elders Count:",
"other_member_min_age" => "Min Age:",
"other_member_max_age" => "Min Age:",
"waiverofpreexistingdiseases" => "Waiver of Pre-existing Diseases",
@ -1924,8 +1974,6 @@ class ClientController extends AdminController
];
foreach ($client_policy as $key => $value) {
$policy_terms = json_decode($value['policy_terms'], true);
@ -1942,10 +1990,6 @@ class ClientController extends AdminController
$data['client_policy'] = $client_policy;
$data['client_branch'] = $this->clientModel
->select('
@ -2025,19 +2069,27 @@ class ClientController extends AdminController
} else if (array_key_exists($key, $mapping)) {
$transformedData[$mapping[$key]] = $value;
} else if ($key == 'special_condition_label') {
foreach ($value as $key => $value) {
$transformedData[$value] = $data['special_condition_input'][$key];
if (is_array($value)) {
foreach ($value as $key => $value) {
$transformedData[$value] = $data['special_condition_input'][$key];
}
}
} else if ($key == 'gpa_special_condition_label') {
foreach ($value as $key => $value) {
$transformedData[$value] = $data['gpa_special_condition_input'][$key];
} else if ($key == 'gpa_special_condition_label') {
if (is_array($value)) {
foreach ($value as $key => $value) {
$transformedData[$value] = $data['gpa_special_condition_input'][$key];
}
}
} else if ($key == 'other_special_condition_label') {
if (is_array($value)) {
foreach ($value as $key => $value) {
$transformedData[$value] = $data['other_special_condition_label'][$key];
}
}
} else if ($key == 'age_ratio') {
if (isset($data['sumInsured2'])) {
$transformedData['Self'] = "(Min: " . $data['age_ratio']['self']['min'] . ", Max: " . $data['age_ratio']['self']['max'] . ")";
}
} else {
@ -2120,5 +2172,137 @@ class ClientController extends AdminController
public function get_cd_ac($client_id, $insurer_id){
$cd_data = $this->CDMasterModel->where('client_id', $client_id)->where('insurer_id', $insurer_id)->findAll();
if($cd_data){
return $this->respond(['status' => true, 'code' => 200, 'data' => $cd_data], 200);
}else{
return $this->respond(['status' => false, 'code' => 404, 'insurer_id' => $insurer_id, 'client_id' => $client_id], 200);
}
}
public function otherPolicyTermsFormSubmit()
{
$client_policy_id = $this->request->getPost("client_policy_id");
$policy_terms = $this->request->getPost("policy_terms");
$record = $this->clientPolicyModel->where('id', $client_policy_id)->first();
if ($record) {
$update = $this->clientPolicyModel->where('id', $client_policy_id)->set('policy_terms', $policy_terms)->update();
if ($update) {
return $this->respond(['status' => true, 'code' => 200, 'message' => 'Data updated successfully', 'client_policy_id' => $client_policy_id], 200);
} else {
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to update data', 'formdata' => $this->request->getPost()], 200);
}
} else {
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to store data. The client policy does not exist', 'formdata' => $this->request->getPost()], 200);
}
}
public function checkPolicyType($policy_type_id, $client_branch_id, $client_id){
$policyCount = $this->clientPolicyModel
->where('policy_type_id', $policy_type_id)
->where('client_branch_id', $client_branch_id)
->where('client_id', $client_id)
->countAllResults();
if($policyCount > 0 ){
$clientPoliceData = $this->clientPolicyModel->getClientPolicyByClientId($client_id);
return $this->respond(['status' => true,'code' => 200, 'count' => $policyCount, 'data' => $clientPoliceData, 'method' => 'CERATE' ,'client_id' => $client_id, 'client_branch_id' => $client_branch_id, 'policy_type_id' => $policy_type_id], 200);
}else{
return $this->respond(['status' => false,'code' => 200,'client_id' => $client_id, 'client_branch_id' => $client_branch_id, 'policy_type_id' => $policy_type_id], 200);
}
}
public function getPolicyTerms($client_policy_id)
{
$policy_terms = $this->clientPolicyModel->where('id', $client_policy_id)->first();
if (!$policy_terms) {
return $this->respond(['status' => false, 'error' => 'Policy not found'], 404);
}
if (is_array($policy_terms)) {
if (!isset($policy_terms['policy_terms'])) {
return $this->respond(['status' => false, 'error' => 'Policy terms not found in array'], 500);
}
$JSON = json_decode($policy_terms['policy_terms']);
} elseif (is_object($policy_terms)) {
if (!isset($policy_terms->policy_terms)) {
return $this->respond(['status' => false, 'error' => 'Policy terms not found in object'], 500);
}
$JSON = json_decode($policy_terms->policy_terms);
} else {
return $this->respond(['status' => false, 'error' => 'Unexpected data type for policy terms'], 500);
}
if (!$JSON) {
return $this->respond(['status' => false, 'error' => 'Invalid JSON format in policy terms'], 500);
}
$multi_si = [];
if (isset($JSON->sum_insured) && !empty($JSON->sum_insured)) {
$multi_si[] = $JSON->sum_insured;
} elseif (isset($JSON->sumInsured2) && !empty($JSON->sumInsured2)) {
$multi_si[] = $JSON->sumInsured2;
}
if (isset($JSON->multiple_sum_insured) && is_array($JSON->multiple_sum_insured)) {
foreach ($JSON->multiple_sum_insured as $msi) {
if (!empty($msi)) {
$multi_si[] = $msi;
}
}
}
return $this->respond(['status' => true, 'data' => $multi_si], 200);
}
public function getPolicyTermsFormJson($policy_type_id){
$JSON = $this->policyTypeModel->where('id', $policy_type_id)->first();
return $this->respond(['status' => true, 'data' => $JSON], 200);
}
public function createPolicyTermsHtmlAsJSON(){
}
public function checkHRNumber($mobileNumber)
{
try {
$mobileNumberCount = $this->levelContactModel
->join('client_branch', 'client_branch.id = level_contacts.ref_id')
->join('clients', 'clients.id = client_branch.client_id')
->where('clients.is_active', 1)
->where('client_branch.is_active', 1)
->where('level_contacts.is_active', 1)
->where('level_contacts.contact_type', 'client')
->where('level_contacts.mobile', $mobileNumber)
->countAllResults();
return $this->respond(['status' => true, 'data' => $mobileNumberCount, 'message' => "try"], 200);
} catch (\Exception $e) {
log_message('error', 'Error checking mobile number: ' . $e->getMessage());
return $this->respond(['status' => false, 'data' => 0, 'message' => 'An error occurred while checking the mobile number. Please try again later.'], 500);
}
}
}

View File

@ -24,6 +24,7 @@ use App\Models\ClientDepositModel;
use App\Models\NotificationModel;
use App\Models\MessageModel;
use App\Models\UserMessageModel;
use App\Models\CDMasterModel;
use App\Controllers\Jobs;
use App\Controllers\JobWorker;
@ -52,6 +53,8 @@ class EmpDataServiceController extends BaseController
protected $notificationModel;
protected $messageModel;
protected $userMessageModel;
protected $CDMasterModel;
public function __construct()
{
@ -70,6 +73,8 @@ class EmpDataServiceController extends BaseController
$this->notificationModel = new NotificationModel();
$this->messageModel = new MessageModel();
$this->userMessageModel = new UserMessageModel();
$this->CDMasterModel = new CDMasterModel();
}
@ -135,9 +140,30 @@ class EmpDataServiceController extends BaseController
// Fetch employee data for export from the database
$objects = $this->employeePolicyModel->getInceptionEmployeeDataForExportExcel($export_data);
$insurer_id = $this->clientPolicyModel->where('id', $export_data['client_policy_id'])->first();
$cash_balance = $this->clientDepositModel->where('client_id', $export_data['client_id'])->where('insurer_id', $insurer_id['insurer_id'])->orderBy('id', 'DESC')->first();
$policy_details = $this->clientPolicyModel->where('id', $export_data['client_policy_id'])->first();
// dd($export_data, $policy_details['cd_ac_no']);
if ($policy_details['cd_ac_no'] == null) {
// dd("The policy does not have a CD account number");
$this->myLogger->logme('error', 'The policy does not have a CD account number.');
return 5;
}
$cash_balance = $this->clientDepositModel->where('cd_ac_no', $policy_details['cd_ac_no'])->orderBy('id', 'DESC')->first();
if ($cash_balance == null) {
$balance = $this->CDMasterModel
->where('client_id', $export_data['client_id'])
->where('insurer_id', $policy_details['insurer_id'])
->where('cd_ac_no', $policy_details['cd_ac_no'])
->first();
$cash_balance['balance'] = $balance['opening_bal'];
}
// dd($cash_balance);
// Calculate the total amount from the objects
$totals = array_reduce($objects, function ($carry, $item) {
@ -147,9 +173,8 @@ class EmpDataServiceController extends BaseController
$totals = round($totals, 2);
if (!empty($cash_balance)) {
if ((int) $cash_balance['balance'] < (int) $totals) {
$this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount.');
$this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount. CASH BALANCE : {balance} and TOTAL AMOUNT : {total}', ['balance' => $cash_balance['balance'], 'total' => $totals]);
return 0;
@ -188,7 +213,7 @@ class EmpDataServiceController extends BaseController
'NAME OF EMP/DEP',
'EMP ID',
'EMP/DEP TYPE',
'RELATION',
'RELATIONSHIP CODE',
'DOB',
'GENDER',
'PRE EXISTING AILMENTS',
@ -352,6 +377,26 @@ class EmpDataServiceController extends BaseController
$ids = [];
$objects = $this->employeePolicyModel->getSIEnhancementEmployeesDataForExportExcel($export_data);
$policy_details = $this->clientPolicyModel->where('id', $export_data['client_policy_id'])->first();
if ($policy_details['cd_ac_no'] == null) {
$this->myLogger->logme('error', 'The policy does not have a CD account number.');
return 1;
}
$cash_balance = $this->clientDepositModel->where('cd_ac_no', $policy_details['cd_ac_no'])->orderBy('id', 'DESC')->first();
if ($cash_balance == null) {
$balance = $this->CDMasterModel
->where('client_id', $export_data['client_id'])
->where('insurer_id', $policy_details['insurer_id'])
->where('cd_ac_no', $policy_details['cd_ac_no'])
->first();
$cash_balance['balance'] = $balance['opening_bal'];
}
$totals = 0;
foreach ($objects as $obj) {
@ -363,6 +408,14 @@ class EmpDataServiceController extends BaseController
// echo '<pre>';
// print_r($ids); die;
if (!empty($cash_balance)) {
if ((int) $cash_balance['balance'] < (int) $rounded_totals) {
$this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount.');
$this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount. CASH BALANCE : {balance} and TOTAL AMOUNT : {total}', ['balance' => $cash_balance['balance'], 'total' => $totals]);
return 0;
}
}
$count = count($objects);
$export_data['count'] = $count;
$export_data['amount'] = $rounded_totals;
@ -534,7 +587,7 @@ class EmpDataServiceController extends BaseController
}
//not in use
public function generateExcelForAdditionAndDependentAddition($export_data)
{
$ids = [];
@ -617,7 +670,7 @@ class EmpDataServiceController extends BaseController
}
}
}
//end not in use
/**
* The below functions are Imports data from an Excel file for :
@ -673,7 +726,7 @@ class EmpDataServiceController extends BaseController
unset($excel_data[0]);
array_pop($excel_data);
$inceptionHeader = ['S.No', 'NAME OF EMP/DEP','EMP ID','EMP/DEP TYPE','RELATION','DOB','GENDER','PRE EXISTING AILMENTS','BASIC COVER SI','DATE OF COVERAGE','AGE','RELATIONSHIP','REMARKS','POLICY END DATE','NO OF DAYS','TPA ID','UHID','PREMIUM','PR0 RATA PREMIUM','GST','TOTAL'];
$inceptionHeader = ['S.No', 'NAME OF EMP/DEP','EMP ID','EMP/DEP TYPE','RELATIONSHIP CODE','DOB','GENDER','PRE EXISTING AILMENTS','BASIC COVER SI','DATE OF COVERAGE','AGE','RELATIONSHIP','REMARKS','POLICY END DATE','NO OF DAYS','TPA ID','UHID','PREMIUM','PR0 RATA PREMIUM','GST','TOTAL'];
foreach ($inceptionHeader as $key => $value) {
if($excel_header[$key] != $value){
@ -1083,6 +1136,13 @@ class EmpDataServiceController extends BaseController
$batch_code = $file['batch_code'];
$user_id = $file['created_by'];
$insurer_id = $this->clientPolicyModel->where('id', $client_policy_id)->first();
$CD_Account_Number = $this->CDMasterModel
->where('client_id', $client_id)
->where('insurer_id', $insurer_id['insurer_id'])
->first();
$get_policy_type = $this->clientPolicyModel
->select('policy_type.policy_type, policies.policy_type_id as policy_type_id')
@ -1192,6 +1252,8 @@ class EmpDataServiceController extends BaseController
'employeeIds' => $emp_policy_ids,
'client_id' => $client_id,
'client_policy_id' => $client_policy_id,
'cd_ac_no' => $CD_Account_Number['cd_ac_no'] ?? null,
'endorsement_no' => null,
'client_branch_id' => $client_branch_id,
'count' => $emp_count,
'event' => $file['event_type'],
@ -2095,6 +2157,13 @@ class EmpDataServiceController extends BaseController
$batch_code = $file['batch_code'];
$user_id = $file['created_by'];
$insurer_id = $this->clientPolicyModel->where('id', $client_policy_id)->first();
$CD_Account_Number = $this->CDMasterModel
->where('client_id', $client_id)
->where('insurer_id', $insurer_id['insurer_id'])
->first();
$status_val = 'success';
if ($status == 'in-progress-partially') {
@ -2113,7 +2182,7 @@ class EmpDataServiceController extends BaseController
$emp_policy_ids = [];
$employeeIds = [];
$emp_details = [];
$endorsement_id = [];
$endorsement_id = '';
$endorsement_details = [];
$totals = 0;
@ -2121,7 +2190,7 @@ class EmpDataServiceController extends BaseController
$emp_name = $value[1];
$emp_code = $value[2];
$endorsement_id[] = $value[19];
$endorsement_id = $value[19];
$totals += $value[18];
@ -2229,6 +2298,8 @@ class EmpDataServiceController extends BaseController
'client_id' => $client_id,
'client_policy_id' => $client_policy_id,
'client_branch_id' => $client_branch_id,
'cd_ac_no' => $CD_Account_Number['cd_ac_no'] ?? null,
'endorsement_no' => $endorsement_id ?? null,
'count' => $emp_count,
'event' => $file['event_type'],
'policy_name' => $policy_name['policy_name'],
@ -2633,6 +2704,13 @@ class EmpDataServiceController extends BaseController
$batch_code = $file['batch_code'];
$user_id = $file['created_by'];
$insurer_id = $this->clientPolicyModel->where('id', $client_policy_id)->first();
$CD_Account_Number = $this->CDMasterModel
->where('client_id', $client_id)
->where('insurer_id', $insurer_id['insurer_id'])
->first();
$status_val = 'success';
if ($status == 'in-progress-partially') {
@ -2653,6 +2731,7 @@ class EmpDataServiceController extends BaseController
$emp_endorsement_table_data = [];
$employee_policy_table_data = [];
$employee_policy_table_primaryKey = [];
$endorsement_id = '';
$totals = 0;
@ -2662,6 +2741,7 @@ class EmpDataServiceController extends BaseController
$emp_name = $value[2]; //employee name
$emp_code = $value[1]; //employee code
$totals = $totals + $value[13];
$endorsement_id = $value[15];
$fetch_data = [
@ -2733,6 +2813,8 @@ class EmpDataServiceController extends BaseController
'client_id' => $client_id,
'client_policy_id' => $client_policy_id,
'client_branch_id' => $client_branch_id,
'cd_ac_no' => $CD_Account_Number['cd_ac_no'] ?? null,
'endorsement_no' => $endorsement_id ?? null,
'count' => $emp_count,
'event' => $file['event_type'],
'policy_name' => $policy_name['policy_name'],
@ -2748,7 +2830,7 @@ class EmpDataServiceController extends BaseController
//Endorsement Addition and Dependent Addition
//not in use
public function AdditionAndDependentAddition($params)
{
@ -3139,6 +3221,7 @@ class EmpDataServiceController extends BaseController
}
//end not in use
/**
* The below functions are Calculates and records cash deposits for employee policies at inception.
@ -3176,6 +3259,9 @@ class EmpDataServiceController extends BaseController
'amount' => $amount->total_sum ?? 0,
'sub_type_id' => 4,
'client_id' => $arrayData['client_id'],
'client_policy_id' => $arrayData['client_policy_id'],
'endorsement_no' => $arrayData['endorsement_no'] ?? null,
'cd_ac_no' => $arrayData['cd_ac_no'] ?? null,
'insurer_id' => $insurer_id['insurer_id'],
'description' => $description,
'transaction_type' => 'Debit',
@ -3214,6 +3300,9 @@ class EmpDataServiceController extends BaseController
'amount' => $amount->total_sum,
'sub_type_id' => 4,
'client_id' => $arrayData['client_id'],
'client_policy_id' => $arrayData['client_policy_id'],
'endorsement_no' => $arrayData['endorsement_no'] ?? null,
'cd_ac_no' => $arrayData['cd_ac_no'] ?? null,
'insurer_id' => $insurer_id['insurer_id'],
'description' => $description,
'transaction_type' => 'Debit',
@ -3254,6 +3343,9 @@ class EmpDataServiceController extends BaseController
'amount' => $amount->total_sum,
'sub_type_id' => 3,
'client_id' => $arrayData['client_id'],
'client_policy_id' => $arrayData['client_policy_id'],
'endorsement_no' => $arrayData['endorsement_no'] ?? null,
'cd_ac_no' => $arrayData['cd_ac_no'] ?? null,
'insurer_id' => $insurer_id['insurer_id'],
'description' => $description,
'transaction_type' => 'Credit',

View File

@ -79,13 +79,16 @@ class EmployeeController extends AdminController
$data['employees'] = $this->employeePolicyModel->getEmployeePolicy(
client_id: $filterData['client_id'],
policy_id: $filterData['policy_id'],
status: $filterData['status'],
branch_id: $filterData['branch_id']
branch_id: $filterData['branch_id'],
emp_code : $filterData['emp_code'],
emp_name : $filterData['emp_name'],
status : $filterData['status'],
);
$data['getData'] = $filterData;
}
// dd($this->request->getGet());
$this->myLogger->logme('error', 'list called');
$this->loadLayout('employee_list', $data);
}
@ -265,22 +268,33 @@ class EmployeeController extends AdminController
'(SELECT SUM(ep.rata_premimum) + SUM(ep.gst)
FROM employees e
JOIN employee_polices ep ON e.id = ep.employee_id
WHERE e.file_id = files.id AND ep.client_policy_id = files.policy_id) as total'
WHERE e.file_id = files.id AND ep.client_policy_id = files.policy_id) as total',
'policy_type.policy_type' ,
'cp.policy_no' ,
])
->join('user_profiles up', 'files.created_by = up.id')
->join('client_policy cp', 'files.policy_id = cp.id', 'left')
->join('client_branch cb', 'files.client_branch_id = cb.id', 'left')
->join('policies pm', 'cp.policy_id = pm.id', 'left')
->join('policy_type', 'policy_type.id = pm.policy_type_id')
->join('clients c', 'files.client_id = c.id and files.client_id = cp.client_id', 'left')
->where('files.created_by', get_session_userid())
->orderBy('files.created_at', 'desc')
->findAll();
// dd($data['fileList']);
$data['batch_list'] = $this->batchFileModel->select('batch_files.*, policies.name as policy_name, clients.short_name as client_short_name, client_branch.branch_name')
$data['batch_list'] = $this->batchFileModel->select(
'batch_files.*,
policies.name as policy_name,
clients.short_name as client_short_name,
client_branch.branch_name,
client_policy.policy_no,
policy_type.policy_type
')
->join('client_policy', 'client_policy.id = batch_files.client_policy_id')
->join('client_branch', 'client_branch.id = batch_files.client_branch_id')
->join('policies', 'policies.id = client_policy.policy_id')
->join('policy_type', 'policy_type.id = policies.policy_type_id')
->join('clients', 'clients.id = client_policy.client_id')
->orderBy('batch_files.id', 'desc')
->findAll();
@ -408,10 +422,15 @@ class EmployeeController extends AdminController
$return = $empDataServiceController->generateExcelForAdditionandInception($batch_data);
if ($return == 0) {
if ($return === 0) {
session()->setFlashdata('error', "Insufficient deposit amount.");
return redirect()->to(base_url('employee/upload'));
}else if($return === 5){
session()->setFlashdata('error', "The policy does not have a CD account number.");
return redirect()->to(base_url('employee/upload'));
}
if (!$return) {
@ -439,10 +458,14 @@ class EmployeeController extends AdminController
$return = $empDataServiceController->generateExcelForSIEnhancement($batch_data);
if ($return == 0) {
if ($return === 0) {
session()->setFlashdata('error', "Insufficient deposit amount.");
return redirect()->to(base_url('employee/upload'));
}else if($return === 5){
session()->setFlashdata('error', "The policy does not have a CD account number.");
return redirect()->to(base_url('employee/upload'));
}
if (!$return) {
@ -772,13 +795,9 @@ class EmployeeController extends AdminController
->findAll();
$emp_count = count($data);
if ($data) {
return $this->respond(['dataStatus' => true, 'code' => 200, 'emp_count' => $emp_count], 200);
} else {
return $this->respond(['dataStatus' => false, 'code' => 404], 404);
}
$events = ['inception' => 'Inception (Employee + Dependents)', 'addition' => 'Addition (Employee + Dependents)', 'dependent_addition' => 'Dependent Addition (Only Dependents)', 'deletion' => 'Deletion', 'correction' => 'Correction', 'si_enhancement' => 'SI Enhancement'];
return $this->respond(['dataStatus' => true, 'code' => 200, 'emp_count' => $emp_count, 'events' => $events, 'client_policy_id' => $id], 200);
}
@ -1060,33 +1079,34 @@ class EmployeeController extends AdminController
public function viewECard()
{
$this->loadLayout('ecard_template/default_ecard');
// $this->loadLayout('ecard_template/default_ecard');
// Load the session library if it's not autoloaded
// $session = \Config\Services::session();
// Access session data
$sessionData = session()->get();
// Check if session data exists and if expiration time is set
if (!empty($sessionData) && isset($sessionData['isLoggedIn']) && isset($sessionData['session_expiration'])) {
// Get the session expiration timestamp
$expirationTimestamp = $sessionData['session_expiration'];
// Get the current timestamp
$currentTimestamp = time();
// Check if the current time is greater than the expiration time
if ($currentTimestamp > $expirationTimestamp) {
// Session has expired
echo "Session has expired";
} else {
// Session is active
echo "Session is active";
}
} else {
// Session data is not set or session is not started
echo "Session is not started or data is not set";
$empDataServiceController = new EmpDataServiceController();
$file_name = generate_filename("TCS", 'inception', 'export', 'insurer', 'policy', 'branch');
$batch_data = [
'client_id' => 12,
'client_policy_id' => 12,
'client_branch_id' => 1,
'insurer_or_tpa' => 'insurer',
'event_type' => 'inception',
'actions' => 'export',
'file_name' => $file_name,
];
$return = $empDataServiceController->generateExcelForAdditionandInception($batch_data);
if ($return == 0) {
dd('error', "Insufficient deposit amount.");
}else if($return == 1){
dd('error', "The policy does not have a CD account number.");
}
if (!$return) {
dd('error', "No data was found");
}
}

View File

@ -27,6 +27,7 @@ use App\Models\NotificationModel;
use App\Models\UserModel;
use App\Models\FEContentModel;
use App\Models\AddImgModel;
use App\Models\FileModel;
use App\Controllers\Jobs ;
@ -40,6 +41,8 @@ use PhpOffice\PhpSpreadsheet\IOFactory;
use CodeIgniter\API\ResponseTrait;
use Illuminate\Http\Request;
use App\Controllers\EmployeeServiceController;
class EmployeeRestController extends AdminController
{
@ -83,6 +86,7 @@ class EmployeeRestController extends AdminController
$this->userModel = new UserModel();
$this->feContentModel = new FEContentModel();
$this->addImgModel = new AddImgModel();
}
@ -487,7 +491,7 @@ class EmployeeRestController extends AdminController
{
try {
$empData = $this->employeePolicyModel->getEmployeePolicy( client_id:$this->request->getGet('client_id'),policy_id: $this->request->getGet('client_policy_id'),status:0,branch_id:$this->request->getGet('client_branch_id'));
if ($empData) {
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $empData], 200);
} else {
@ -648,9 +652,24 @@ class EmployeeRestController extends AdminController
$sum_insured_amount_for_check_employee_1 = isset($policy_permium_1['si']) ? $policy_permium_1['si'] : null;
$sum_insured_amount_for_check_employee_2 = isset($policy_permium_2['si']) ? $policy_permium_2['si'] : null;
$is_moved = $file->move(WRITEPATH . 'uploads/import_excel');
$is_moved = $file->move(WRITEPATH . 'uploads/excel');
$filename = $file->getName();
$file_name_with_path = WRITEPATH."/uploads/import_excel/".$filename;
$file_name_with_path = WRITEPATH."/uploads/excel/".$filename;
//make an entry in DB
$file_id = $this->fileModel->insert(['file_name' => $filename, 'client_id' => $client_id, 'policy_id' => $policy_id, 'created_by' => $loggedInUserID, 'status' => $status, 'action' => 'enrollment', 'client_branch_id' => $client_branch_id]); //here field policy_id have client_policy_id and not policy id from policy master
$this->myLogger->logme("error", '{file_id} - client uploaded success', ['file_id' => $file_id]);
$empServiceController = new EmployeeServiceController();
$result = $empServiceController->excelFileFormatValidation(['file_id' => $file_id]);
// dd($result);
if(isset($result['error_summary']) && count($result['error_summary']))
{
$result = $empServiceController->getExcelErrorData($file_id);
return $this->respond(['status' => 'failed', 'code' => 404, 'message' => "file upload failed with errors",'data' => $result], 200);
}
//check the file exist or not
if(!file_exists($file_name_with_path))

View File

@ -35,14 +35,576 @@ class EmployeeServiceController extends AdminController
protected $policiesModel;
protected $empEndorsementModel;
protected $messageModel;
protected $general_relationships = ['self' => ['name' => 'Self', 'gender' => 'M','age_min' => 18,'age_max' => null], 'spouse' => ['name' => 'Spouse', 'gender' => 'F','age_min' => 18,'age_max' => null], 'son' => ['name' => 'Son', 'gender' => 'M','age_min' => null,'age_max' => 25], 'daughter' => ['name' => 'Daughter', 'gender' => 'F','age_min' => null,'age_max' => 25], 'father' => ['name' => 'Father', 'gender' => 'M','age_min' => 18,'age_max' => null], 'mother' => ['name' => 'Mother', 'gender' => 'F','age_min' => 18,'age_max' => null], 'father-in-law' => ['name' => 'Father in Law', 'gender' => 'M','age_min' => 18,'age_max' => null], 'mother-in-law' => ['name' => 'Mother in Law', 'gender' => 'F','age_min' => 18,'age_max' => null]];
protected $inception_excel_columns = ['sno'=>['col_idx'=>0,'col_cell_name'=>'A','col_name'=>'S.No','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'emp_id'=>['col_idx'=>1,'col_cell_name'=>'B','col_name'=>'EMP ID','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'name_of_emp_dep'=>['col_idx'=>2,'col_cell_name'=>'C','col_name'=>'NAME OF EMP/DEP','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'dob'=>['col_idx'=>3,'col_cell_name'=>'D','col_name'=>'DOB','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null,'custom'=>'check_dob_diff','params'=>['row','relationship','default_age_ratio']],'gender'=>['col_idx'=>4,'col_cell_name'=>'E','col_name'=>'Gender','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>null,'allowed_values'=>['M','F']],'relationship'=>['col_idx'=>5,'col_cell_name'=>'F','col_name'=>'RELATIONSHIP','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom'=>'check_relationship','params'=>['row','relationship','policy_terms']],'basic_cover_si'=>['col_idx'=>6,'col_cell_name'=>'G','col_name'=>'BASIC COVER SI','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom' => 'check_si','params' => ['row','policy_terms','slab_details']],'doc'=>['col_idx'=>7,'col_cell_name'=>'H','col_name'=>'Date of Coverage','is_mandatory'=>['A','DA'],'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null,'params'=>['row']],'doj'=>['col_idx'=>8,'col_cell_name'=>'I','col_name'=>'DOJ','is_mandatory'=>false,'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null,'custom'=>'check_doj','params'=>['row']],'basic_pay'=>['col_idx'=>9,'col_cell_name'=>'J','col_name'=>'Basic Pay','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom'=>'check_basic_pay','params'=>['row','policy_terms','slab_details']],'band_grade'=>['col_idx'=>10,'col_cell_name'=>'K','col_name'=>'Band/Grade','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom'=>'check_employee_band','params'=>['row','policy_terms','slab_details']],'designation'=>['col_idx'=>11,'col_cell_name'=>'L','col_name'=>'Designation','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null],'phone'=>['col_idx'=>12,'col_cell_name'=>'M','col_name'=>'Phone','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom' => 'check_dup_mobileno','params' => ['row','existing_mobilenos']],'email'=>['col_idx'=>13,'col_cell_name'=>'N','col_name'=>'Email','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null],'pre_existing_ailments'=>['col_idx'=>14,'col_cell_name'=>'O','col_name'=>'PRE EXISTING AILMENTS','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>null,'allowed_values'=>['0','1']],'change_event'=>['col_idx'=>15,'col_cell_name'=>'P','col_name'=>'Change event','is_mandatory'=>['A','DA','D'],'data_type'=>'str','format'=>null,'allowed_values'=>null],'date_of_exit'=>['col_idx'=>16,'col_cell_name'=>'Q','col_name'=>'Date of exit','is_mandatory'=>['D'],'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null],'reason_for_exit'=>['col_idx'=>17,'col_cell_name'=>'R','col_name'=>'Reason for exit','is_mandatory'=>['D'],'data_type'=>'str','format'=>null,'allowed_values'=>null]];
protected $general_relationships = [
'self' => [
'name' => 'Self',
'gender' => 'M',
'age_min' => 18,
'age_max' => null
],
'spouse' => [
'name' => 'Spouse',
'gender' => 'F',
'age_min' => 18,
'age_max' => null
],
'son' => [
'name' => 'Son',
'gender' => 'M',
'age_min' => null,
'age_max' => 25
],
'daughter' => [
'name' => 'Daughter',
'gender' => 'F',
'age_min' => null,
'age_max' => 25
],
'father' => [
'name' => 'Father',
'gender' => 'M',
'age_min' => 18,
'age_max' => null
],
'mother' => [
'name' => 'Mother',
'gender' => 'F',
'age_min' => 18,
'age_max' => null
],
'father-in-law' => [
'name' => 'Father in Law',
'gender' => 'M',
'age_min' => 18,
'age_max' => null
],
'mother-in-law' => [
'name' => 'Mother in Law',
'gender' => 'F',
'age_min' => 18,
'age_max' => null
]
];
protected $inception_excel_columns = [
'sno' => [
'col_idx' => 0,
'col_cell_name' => 'A',
'col_name' => 'S.No',
'is_mandatory' => true,
'data_type' => 'str',
'format' => null,
'allowed_values' => null
],
'emp_id' => [
'col_idx' => 1,
'col_cell_name' => 'B',
'col_name' => 'EMP ID',
'is_mandatory' => true,
'data_type' => 'str',
'format' => null,
'allowed_values' => null
],
'name_of_emp_dep' => [
'col_idx' => 2,
'col_cell_name' => 'C',
'col_name' => 'NAME OF EMP/DEP',
'is_mandatory' => true,
'data_type' => 'str',
'format' => null,
'allowed_values' => null
],
'dob' => [
'col_idx' => 3,
'col_cell_name' => 'D',
'col_name' => 'DOB',
'is_mandatory' => ['I', 'A', 'DA'],
'data_type' => 'str',
'format' => 'd-M-Y',
'allowed_values' => null,
'custom' => 'check_dob_diff',
'params' => ['row', 'relationship', 'default_age_ratio']
],
'gender' => [
'col_idx' => 4,
'col_cell_name' => 'E',
'col_name' => 'Gender',
'is_mandatory' => ['I', 'A', 'DA'],
'data_type' => 'str',
'format' => null,
'allowed_values' => ['M', 'F']
],
'relationship' => [
'col_idx' => 5,
'col_cell_name' => 'F',
'col_name' => 'RELATIONSHIP',
'is_mandatory' => ['I', 'A', 'DA'],
'data_type' => 'str',
'format' => null,
'allowed_values' => null,
'custom' => 'check_relationship',
'params' => ['row', 'relationship', 'policy_terms']
],
'basic_cover_si' => [
'col_idx' => 6,
'col_cell_name' => 'G',
'col_name' => 'BASIC COVER SI',
'is_mandatory' => null,
'data_type' => 'str',
'format' => null,
'allowed_values' => null,
'custom' => 'check_si',
'params' => ['row', 'policy_terms', 'slab_details']
],
'doc' => [
'col_idx' => 7,
'col_cell_name' => 'H',
'col_name' => 'Date of Coverage',
'is_mandatory' => ['A', 'DA'],
'data_type' => 'str',
'format' => 'd-M-Y',
'allowed_values' => null,
'custom' => 'check_doc',
'params' => ['row', 'policy_details']
],
'doj' => [
'col_idx' => 8,
'col_cell_name' => 'I',
'col_name' => 'DOJ',
'is_mandatory' => false,
'data_type' => 'str',
'format' => 'd-M-Y',
'allowed_values' => null,
'custom' => 'check_doj',
'params' => ['row']
],
'basic_pay' => [
'col_idx' => 9,
'col_cell_name' => 'J',
'col_name' => 'Basic Pay',
'is_mandatory' => false,
'data_type' => 'str',
'format' => null,
'allowed_values' => null,
'custom' => 'check_basic_pay',
'params' => ['row', 'policy_terms', 'slab_details']
],
'band_grade' => [
'col_idx' => 10,
'col_cell_name' => 'K',
'col_name' => 'Band/Grade',
'is_mandatory' => false,
'data_type' => 'str',
'format' => null,
'allowed_values' => null,
'custom' => 'check_employee_band',
'params' => ['row', 'policy_terms', 'slab_details']
],
'designation' => [
'col_idx' => 11,
'col_cell_name' => 'L',
'col_name' => 'Designation',
'is_mandatory' => false,
'data_type' => 'str',
'format' => null,
'allowed_values' => null
],
'phone' => [
'col_idx' => 12,
'col_cell_name' => 'M',
'col_name' => 'Phone',
'is_mandatory' => false,
'data_type' => 'str',
'format' => null,
'allowed_values' => null,
'custom' => 'check_dup_mobileno',
'params' => ['row', 'existing_mobilenos']
],
'email' => [
'col_idx' => 13,
'col_cell_name' => 'N',
'col_name' => 'Email',
'is_mandatory' => false,
'data_type' => 'str',
'format' => null,
'allowed_values' => null
],
'pre_existing_ailments' => [
'col_idx' => 14,
'col_cell_name' => 'O',
'col_name' => 'PRE EXISTING AILMENTS',
'is_mandatory' => ['I', 'A', 'DA'],
'data_type' => 'str',
'format' => null,
'allowed_values' => ['0', '1']
],
'change_event' => [
'col_idx' => 15,
'col_cell_name' => 'P',
'col_name' => 'Change event',
'is_mandatory' => ['A', 'DA', 'D'],
'data_type' => 'str',
'format' => null,
'allowed_values' => null
],
'date_of_exit' => [
'col_idx' => 16,
'col_cell_name' => 'Q',
'col_name' => 'Date of exit',
'is_mandatory' => ['D'],
'data_type' => 'str',
'format' => 'd-M-Y',
'allowed_values' => null
],
'reason_for_exit' => [
'col_idx' => 17,
'col_cell_name' => 'R',
'col_name' => 'Reason for exit',
'is_mandatory' => ['D'],
'data_type' => 'str',
'format' => null,
'allowed_values' => null
]
];
protected $deletion_excel_columns = ['sno'=>['col_idx'=>0,'col_cell_name'=>'A','col_name'=>'S.No','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'emp_id'=>['col_idx'=>1,'col_cell_name'=>'B','col_name'=>'EMP ID','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'name_of_emp_dep'=>['col_idx'=>2,'col_cell_name'=>'C','col_name'=>'NAME OF EMP/DEP','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'change_event'=>['col_idx'=>3,'col_cell_name'=>'D','col_name'=>'Change event','is_mandatory'=>['D'],'data_type'=>'str','format'=>null,'allowed_values'=>null],'date_of_exit'=>['col_idx'=>4,'col_cell_name'=>'E','col_name'=>'Date of exit','is_mandatory'=>['D'],'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null],'reason_for_exit'=>['col_idx'=>5,'col_cell_name'=>'F','col_name'=>'Reason for exit','is_mandatory'=>['D'],'data_type'=>'str','format'=>null,'allowed_values'=>null]];
protected $deletion_excel_columns = [
'sno' => [
'col_idx' => 0,
'col_cell_name' => 'A',
'col_name' => 'S.No',
'is_mandatory' => true,
'data_type' => 'str',
'format' => null,
'allowed_values' => null
],
'emp_id' => [
'col_idx' => 1,
'col_cell_name' => 'B',
'col_name' => 'EMP ID',
'is_mandatory' => true,
'data_type' => 'str',
'format' => null,
'allowed_values' => null
],
'name_of_emp_dep' => [
'col_idx' => 2,
'col_cell_name' => 'C',
'col_name' => 'NAME OF EMP/DEP',
'is_mandatory' => true,
'data_type' => 'str',
'format' => null,
'allowed_values' => null
],
'change_event' => [
'col_idx' => 3,
'col_cell_name' => 'D',
'col_name' => 'Change event',
'is_mandatory' => ['D'],
'data_type' => 'str',
'format' => null,
'allowed_values' => null
],
'date_of_exit' => [
'col_idx' => 4,
'col_cell_name' => 'E',
'col_name' => 'Date of exit',
'is_mandatory' => ['D'],
'data_type' => 'str',
'format' => 'd-M-Y',
'allowed_values' => null
],
'reason_for_exit' => [
'col_idx' => 5,
'col_cell_name' => 'F',
'col_name' => 'Reason for exit',
'is_mandatory' => ['D'],
'data_type' => 'str',
'format' => null,
'allowed_values' => null
]
];
protected $correction_excel_columns = ['sno'=>['col_idx'=>0,'col_cell_name'=>'A','col_name'=>'S.No','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'emp_id'=>['col_idx'=>1,'col_cell_name'=>'B','col_name'=>'EMP ID','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'name_of_emp_dep'=>['col_idx'=>2,'col_cell_name'=>'C','col_name'=>'NAME OF EMP/DEP','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'field'=>['col_idx'=>3,'col_cell_name'=>'D','col_name'=>'Field','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>['name','dob','relationship']],'value'=>['col_idx'=>4,'col_cell_name'=>'E','col_name'=>'Value','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'date_of_correction'=>['col_idx'=>5,'col_cell_name'=>'F','col_name'=>'Date of Correction','is_mandatory'=>true,'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null],'change_event'=>['col_idx'=>6,'col_cell_name'=>'G','col_name'=>'Change event','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'remarks'=>['col_idx'=>7,'col_cell_name'=>'H','col_name'=>'Remarks','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null]];
protected $correction_excel_columns = [
'sno' => [
'col_idx' => 0,
'col_cell_name' => 'A',
'col_name' => 'S.No',
'is_mandatory' => true,
'data_type' => 'str',
'format' => null,
'allowed_values' => null
],
'emp_id' => [
'col_idx' => 1,
'col_cell_name' => 'B',
'col_name' => 'EMP ID',
'is_mandatory' => true,
'data_type' => 'str',
'format' => null,
'allowed_values' => null
],
'name_of_emp_dep' => [
'col_idx' => 2,
'col_cell_name' => 'C',
'col_name' => 'NAME OF EMP/DEP',
'is_mandatory' => true,
'data_type' => 'str',
'format' => null,
'allowed_values' => null
],
'field' => [
'col_idx' => 3,
'col_cell_name' => 'D',
'col_name' => 'Field',
'is_mandatory' => true,
'data_type' => 'str',
'format' => null,
'allowed_values' => ['name', 'dob', 'relationship']
],
'value' => [
'col_idx' => 4,
'col_cell_name' => 'E',
'col_name' => 'Value',
'is_mandatory' => true,
'data_type' => 'str',
'format' => null,
'allowed_values' => null
],
'date_of_correction' => [
'col_idx' => 5,
'col_cell_name' => 'F',
'col_name' => 'Date of Correction',
'is_mandatory' => true,
'data_type' => 'str',
'format' => 'd-M-Y',
'allowed_values' => null
],
'change_event' => [
'col_idx' => 6,
'col_cell_name' => 'G',
'col_name' => 'Change event',
'is_mandatory' => true,
'data_type' => 'str',
'format' => null,
'allowed_values' => null
],
'remarks' => [
'col_idx' => 7,
'col_cell_name' => 'H',
'col_name' => 'Remarks',
'is_mandatory' => false,
'data_type' => 'str',
'format' => null,
'allowed_values' => null
]
];
protected $si_enhance_excel_columns = ['sno'=>['col_idx'=>0,'col_cell_name'=>'A','col_name'=>'S.No','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'emp_id'=>['col_idx'=>1,'col_cell_name'=>'B','col_name'=>'EMP ID','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'name_of_emp_dep'=>['col_idx'=>2,'col_cell_name'=>'C','col_name'=>'NAME OF EMP/DEP','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'augmented_si'=>['col_idx'=>3,'col_cell_name'=>'D','col_name'=>'Augmented SI','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom' => 'check_si','params' => ['row','policy_terms','slab_details']],'date_of_enhancement'=>['col_idx'=>4,'col_cell_name'=>'E','col_name'=>'Date of SI Enhancement','is_mandatory'=>true,'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null]];
protected $si_enhance_excel_columns = [
'sno' => [
'col_idx' => 0,
'col_cell_name' => 'A',
'col_name' => 'S.No',
'is_mandatory' => true,
'data_type' => 'str',
'format' => null,
'allowed_values' => null
],
'emp_id' => [
'col_idx' => 1,
'col_cell_name' => 'B',
'col_name' => 'EMP ID',
'is_mandatory' => true,
'data_type' => 'str',
'format' => null,
'allowed_values' => null
],
'name_of_emp_dep' => [
'col_idx' => 2,
'col_cell_name' => 'C',
'col_name' => 'NAME OF EMP/DEP',
'is_mandatory' => true,
'data_type' => 'str',
'format' => null,
'allowed_values' => null
],
'augmented_si' => [
'col_idx' => 3,
'col_cell_name' => 'D',
'col_name' => 'Augmented SI',
'is_mandatory' => true,
'data_type' => 'str',
'format' => null,
'allowed_values' => null,
'custom' => 'check_si',
'params' => ['row', 'policy_terms', 'slab_details']
],
'date_of_enhancement' => [
'col_idx' => 4,
'col_cell_name' => 'E',
'col_name' => 'Date of SI Enhancement',
'is_mandatory' => true,
'data_type' => 'str',
'format' => 'd-M-Y',
'allowed_values' => null
]
];
protected $enrollment_excel_columns = [
'sno' => [
'col_idx' => 0,
'col_cell_name' => 'A',
'col_name' => 'Sno',
'is_mandatory' => true,
'data_type' => 'str',
'format' => null,
'allowed_values' => null
],
'emp_id' => [
'col_idx' => 1,
'col_cell_name' => 'B',
'col_name' => 'Emp code',
'is_mandatory' => true,
'data_type' => 'str',
'format' => null,
'allowed_values' => null
],
'name_of_emp_dep' => [
'col_idx' => 2,
'col_cell_name' => 'C',
'col_name' => 'Name',
'is_mandatory' => true,
'data_type' => 'str',
'format' => null,
'allowed_values' => null
],
'doj' => [
'col_idx' => 3,
'col_cell_name' => 'D',
'col_name' => 'DOJ',
'is_mandatory' => true,
'data_type' => 'str',
'format' => 'd-M-Y',
'allowed_values' => null,
'custom' => null
],
'gender' => [
'col_idx' => 4,
'col_cell_name' => 'E',
'col_name' => 'Gender',
'is_mandatory' => ['I', 'A', 'DA','E'],
'data_type' => 'str',
'format' => null,
'allowed_values' => ['M', 'F']
],
'relationship' => [
'col_idx' => 5,
'col_cell_name' => 'F',
'col_name' => 'Relation',
'is_mandatory' => ['I', 'A', 'DA','E'],
'data_type' => 'str',
'format' => null,
'allowed_values' => null,
'custom' => null
],
'dob' => [
'col_idx' => 6,
'col_cell_name' => 'G',
'col_name' => 'DOB',
'is_mandatory' => ['I', 'A', 'DA'],
'data_type' => 'str',
'format' => 'd-M-Y',
'allowed_values' => null,
'custom' => null,
],
'email' => [
'col_idx' => 7,
'col_cell_name' => 'H',
'col_name' => 'Mail',
'is_mandatory' => false,
'data_type' => 'str',
'format' => null,
'allowed_values' => null
],
'phone' => [
'col_idx' => 8,
'col_cell_name' => 'I',
'col_name' => 'Mobile',
'is_mandatory' => false,
'data_type' => 'str',
'format' => null,
'allowed_values' => null,
'custom' => null
],
'basic_cover_si' => [
'col_idx' => 9,
'col_cell_name' => 'J',
'col_name' => 'SI',
'is_mandatory' => null,
'data_type' => 'str',
'format' => null,
'allowed_values' => null,
'custom' => null
],
'band_grade' => [
'col_idx' => 10,
'col_cell_name' => 'K',
'col_name' => 'Grade',
'is_mandatory' => false,
'data_type' => 'str',
'format' => null,
'allowed_values' => null,
'custom' => null
],
'basic_pay' => [
'col_idx' => 11,
'col_cell_name' => 'L',
'col_name' => 'Basic Pay',
'is_mandatory' => false,
'data_type' => 'str',
'format' => null,
'allowed_values' => null,
'custom' => null
]
];
protected $incetion_to_enrollment_mapping = [
0 => 0, // inception: sno (S.No) -> enrollment: sno (Sno)
1 => 1, // inception: emp_id (EMP ID) -> enrollment: emp_code (Emp_Code)
2 => 2, // inception: name_of_emp_dep (NAME OF EMP/DEP) -> enrollment: name (NAME OF EMP/DEP)
3 => 6, // inception: dob (DOB) -> enrollment: dob (DOB)
4 => 4, // inception: gender (Gender) -> enrollment: gender (Gender)
5 => 5, // inception: relationship (RELATIONSHIP) -> enrollment: relationship (Relation)
6 => 9, // inception: basic_cover_si (BASIC COVER SI) -> enrollment: basic_cover_si (SI)
7 => null, // inception: doc (Date of Coverage) -> No match in enrollment
8 => 3, // inception: doj (DOJ) -> enrollment: doj (DOJ)
9 => 11, // inception: basic_pay (Basic Pay) -> enrollment: basic_pay (Basic Pay)
10 => 10, // inception: band_grade (Band/Grade) -> enrollment: band_grade (Grade)
11 => null, // inception: designation (Designation) -> No match in enrollment
12 => 8, // inception: phone (Phone) -> enrollment: phone (Mobile)
13 => 7, // inception: email (Email) -> enrollment: email (Email)
14 => null, // inception: pre_existing_ailments (PRE EXISTING AILMENTS) -> No match in enrollment
15 => null, // inception: change_event (Change event) -> No match in enrollment
16 => null, // inception: date_of_exit (Date of exit) -> No match in enrollment
17 => null // inception: reason_for_exit (Reason for exit) -> No match in enrollment
];
protected $enrollment_to_inception_mapping = [
0 => 0, // enrollment: sno (Sno) -> inception: sno (S.No)
1 => 1, // enrollment: emp_code (Emp_Code) -> inception: emp_id (EMP ID)
2 => 2, // enrollment: name (NAME OF EMP/DEP) -> inception: name_of_emp_dep (NAME OF EMP/DEP)
3 => 8, // enrollment: doj (DOJ) -> inception: doj (DOJ)
4 => 4, // enrollment: gender (Gender) -> inception: gender (Gender)
5 => 5, // enrollment: relationship (Relation) -> inception: relationship (RELATIONSHIP)
6 => 3, // enrollment: dob (DOB) -> inception: dob (DOB)
7 => 13, // enrollment: email (Email) -> inception: email (Email)
8 => 12, // enrollment: phone (Mobile) -> inception: phone (Phone)
9 => 6, // enrollment: basic_cover_si (SI) -> inception: basic_cover_si (BASIC COVER SI)
10 => 10, // enrollment: band_grade (Grade) -> inception: band_grade (Band/Grade)
11 => 9 // enrollment: basic_pay (Basic Pay) -> inception: basic_pay (Basic Pay)
];
public function __construct()
{
@ -100,6 +662,7 @@ class EmployeeServiceController extends AdminController
if($file['action'] == 'deletion'){ $columns_to_check = $this->deletion_excel_columns; }
if($file['action'] == 'correction'){ $columns_to_check = $this->correction_excel_columns; }
if($file['action'] == 'si_enhancement'){ $columns_to_check = $this->si_enhance_excel_columns; }
if($file['action'] == 'enrollment'){ $columns_to_check = $this->enrollment_excel_columns; }
$result = ['error_type' => 1,'error_summary' => [], 'error_data' => [] ];
@ -162,7 +725,6 @@ class EmployeeServiceController extends AdminController
// dd($existing_mobilenos);
foreach ($excel_data as $row_key => $row)
{
//define row wise action/event in temporary variable
$current_column_action = null;
if($file['action'] == 'inception'){ $current_column_action = 'I'; }
@ -171,25 +733,44 @@ class EmployeeServiceController extends AdminController
else if($file['action'] == 'deletion'){ $current_column_action = 'D'; }
else if($file['action'] == 'correction'){ $current_column_action = 'C'; }
else if($file['action'] == 'si_enhancement'){ $current_column_action = 'SI'; }
else if($file['action'] == 'enrollment'){ $current_column_action = 'I'; }
//1. avoid empty rows
if(check_row_is_empty_or_null($row))
{
break;
}
// Kint::dump($keys);
if ($file['action'] == 'enrollment')
{
$row = transform_enrollment_row_to_inception_row($row);
$columns_to_check = $this->inception_excel_columns;
$keys = array_keys($columns_to_check);
$enrollment_columns_to_check = $this->enrollment_excel_columns;
$enrollment_keys = array_keys($enrollment_columns_to_check);
}
//iterate each row for columns validations
foreach ($row as $col_key => $col)
{
$is_mandatory = $columns_to_check[$keys[$col_key]]['is_mandatory'];
$format = $columns_to_check[$keys[$col_key]]['format'];
$allowed_values = $columns_to_check[$keys[$col_key]]['allowed_values'];
$custom_function = isset($columns_to_check[$keys[$col_key]]['custom']) ? $columns_to_check[$keys[$col_key]]['custom'] : null;
$binding_params = isset($columns_to_check[$keys[$col_key]]['params']) ? $columns_to_check[$keys[$col_key]]['params'] : null;
$column_dispaly_name = $columns_to_check[$keys[$col_key]]['col_name'];
$column_index = $columns_to_check[$keys[$col_key]]['col_idx'];
$column_cell = $columns_to_check[$keys[$col_key]]['col_cell_name'];
if($file['action'] == 'enrollment')
{
if(isset($enrollment_keys[$this->incetion_to_enrollment_mapping[$col_key]]) && $enrollment_keys[$this->incetion_to_enrollment_mapping[$col_key]] != null && $enrollment_keys[$this->incetion_to_enrollment_mapping[$col_key]] != "")
{
$column_dispaly_name = $enrollment_columns_to_check[$enrollment_keys[$this->incetion_to_enrollment_mapping[$col_key]]]['col_name'];
$column_index = $enrollment_columns_to_check[$enrollment_keys[$this->incetion_to_enrollment_mapping[$col_key]]]['col_idx'];
$column_cell = $enrollment_columns_to_check[$enrollment_keys[$this->incetion_to_enrollment_mapping[$col_key]]]['col_cell_name'];
}
}
$row['current_action'] = $current_column_action;
//mandatory check
@ -278,20 +859,27 @@ class EmployeeServiceController extends AdminController
//set failure msg to pull notifications
$this->setPullNotification($this->getFileMetaDataByFileId($file_id,'failure'));
}
else //trigger next data validation via job queue server
{
//proceed next data level validation in JOB queue
if($file['action'] == 'enrollment') // if current action is enrollment call next validation and return result
{
$res = $this->excelFileDataValidation(['file_id' => $file['id']]);
return $res;
}
//proceed next data level validation in JOB queue
$job_details = new Jobs();
$r = Jobs::addJob(['job_name' => 'excelFileDataValidation','payload' => ['file_id' => $file_id]]);
// $jobWorker = new JobWorker();
// JobWorker::processJob($r);
// JobWorker::processJob($r);s
}
return $result;
}
public function excelFileDataValidation($params)
{
helper('excel_util_helper');
@ -325,6 +913,7 @@ class EmployeeServiceController extends AdminController
if($file['action'] == 'deletion'){ $columns_to_check = $this->deletion_excel_columns; }
if($file['action'] == 'correction'){ $columns_to_check = $this->correction_excel_columns; }
if($file['action'] == 'si_enhancement'){ $columns_to_check = $this->si_enhance_excel_columns; }
if($file['action'] == 'enrollment'){ $columns_to_check = $this->enrollment_excel_columns; }
// get policy and rack details
$policy_terms = $this->clientPolicyModel->getPolicyDetails($file['client_id'],$file['policy_id']);
@ -347,19 +936,23 @@ class EmployeeServiceController extends AdminController
//remove header
unset($excel_data[0]);
// dd($columns_to_check);
$relationship = $this->general_relationships;
if(in_array($file['action'],['inception','addition','dependent_addition']))// the below funcitons are only for I,DA,A
if(in_array($file['action'],['inception','addition','dependent_addition','deletion','correction','si_enhancement','enrollment']))// the below funcitons are only for I,DA,A
{
$employee_data_group_by_family = data_group_by_family($excel_data);
$employee_data_group_by_family = data_group_by_family($excel_data,'excel','enrollment');
// dd($employee_data_group_by_family);
$is_self_available_in_policy_terms = false;
if($policy_details['policy_type_id'] == 3) // GMC parents
{
$temp = $policy_terms['family_floaters'];
$temp = is_array($temp) ? $temp : (is_object($temp) ? (array)$temp : []);
$is_self_available_in_policy_terms = isset($temp['self']) ? true : false;
$is_self_available_in_policy_terms = isset($temp['self']) && $temp['self'] == 1 ? true : false;
// Kint::dump($temp['self']);
// dd($is_self_available_in_policy_terms);
}
// dd($employee_data_group_by_family);
foreach ($employee_data_group_by_family as $emp_id => $family)
@ -378,9 +971,9 @@ class EmployeeServiceController extends AdminController
$family = data_group_by_family($family)[ $emp_id ];// reason to call this again is bring self to first index of the array
}
// kint::dump($family);//die();
//check name dup within a family
if($file['action'] == 'inception' || $file['action'] == 'addition' || $file['action'] == 'dependent_addition')
if($file['action'] == 'inception' || $file['action'] == 'addition' || $file['action'] == 'dependent_addition' || $file['action'] == 'enrollment')
{
$res = name_dup_check_within_family($family,$file['action']);//in both file data & DB data
// dd($res);
@ -395,11 +988,9 @@ class EmployeeServiceController extends AdminController
}
//check self availbale in uploaded file
if(($file['action'] == 'inception' || $file['action'] == 'addition') && ($policy_details['policy_type_id'] == 3 && $is_self_available_in_policy_terms)) // 3 is GMC parents dep addon)
if(($file['action'] == 'inception' || $file['action'] == 'addition' || $file['action'] == 'enrollment') || ($policy_details['policy_type_id'] == 3 && $is_self_available_in_policy_terms)) // 3 is GMC parents dep addon)
{
// dd('file check');
$res = check_self_available_in_family($family,$file['action']);
// dd($res);
if(!$res['is_self_found'])
{
array_push($result['error_summary'],14); // Self not found
@ -415,12 +1006,12 @@ class EmployeeServiceController extends AdminController
if(!count($self_details))
{
array_push($result['error_summary'],14); // Self not found
$result['error_data'][ $family[0][0] ]['sno']['error'][] = "Self not found in System";
$result['error_data'][ $family[0][0] ]['sno']['error'][] = "Self not found in Database";
}
}
if($file['action'] == 'dependent_addition' || $file['action'] == 'addition' || $file['action'] == 'inception')
if($file['action'] == 'dependent_addition' || $file['action'] == 'addition' || $file['action'] == 'inception' || $file['action'] == 'enrollment')
{
$res = check_dependent_conflict($family,$policy_terms,$file['action']);
// dd($res);
@ -491,7 +1082,7 @@ class EmployeeServiceController extends AdminController
$r = Jobs::addJob(['job_name' => 'employeesCorrectionProcess','payload' => ['file_id' => $file_id]]);
}
else //inception OR addition OR dependent addition
else if ($file['action'] == 'inception' || $file['action'] == 'addition' || $file['action'] == 'dependent_addition')//inception OR addition OR dependent addition
{
//proceed next data level validation in JOB queue
$job_details = new Jobs();
@ -499,6 +1090,8 @@ class EmployeeServiceController extends AdminController
// $jobWorker = new JobWorker();
// JobWorker::processJob($r);
}
return $result;
}

View File

@ -25,6 +25,7 @@ use App\Models\TPABranchModel;
use App\Models\TPAModel;
use App\Models\StateModel;
use App\Models\PolicyTypeModel;
use App\Models\CDMasterModel;
class MasterController extends AdminController
{
@ -45,6 +46,9 @@ class MasterController extends AdminController
protected $tpaModel;
protected $stateModel;
protected $policyTypeModel;
protected $CDMasterModel;
protected $clientModel;
public function __construct()
@ -68,6 +72,9 @@ class MasterController extends AdminController
$this->tpaModel = new TPAModel();
$this->stateModel = new StateModel();
$this->policyTypeModel = new PolicyTypeModel();
$this->CDMasterModel = new CDMasterModel();
$this->clientModel = new ClientModel();
}
public function insurerList()
@ -1111,4 +1118,111 @@ class MasterController extends AdminController
}
}
public function CDMasterList()
{
$data['CD_Master_Data'] = $this->CDMasterModel->getCDMasterList();
$data['insurers'] = $this->insurerModel->findAll();
$data['clients'] = $this->clientModel->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));
if ($data) {
$insert = $this->CDMasterModel->insert($data);
if ($insert) {
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();
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)->first();
$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)->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;
$update = $this->CDMasterModel->where('id', $id)->set($data)->update();
if($update){
return $this->respond(['status' => true,'code' => 200], 200);
}else{
return $this->respond(['status' => false,'code' => 404], 200);
}
}
}

View File

@ -4,6 +4,7 @@
namespace App\Helpers;
use App\Models\ClientDepositModel;
use App\Models\CDMasterModel;
class DepositHelper
{
@ -32,7 +33,7 @@ class DepositHelper
public static function saveDeposit(array $data, int $loggedInUserID): array
{
// Retrieve the last known balance
$lastBalance = self::calculateLastBalance($data['client_id'], $data['insurer_id']);
$lastBalance = self::calculateLastBalance($data['client_id'], $data['insurer_id'], $data['cd_ac_no']);
// Calculate the new balance based on the transaction type
$newBalance = self::calculateBalance(
@ -49,6 +50,9 @@ class DepositHelper
'amount' => $data['amount'],
'sub_type' => $data['sub_type_id'],
'client_id' => $data['client_id'],
'client_policy_id' => $data['client_policy_id'],
'cd_ac_no' => $data['cd_ac_no'],
'endorsement_no' => $data['endorsement_no'],
'insurer_id' => $data['insurer_id'],
'description' => $data['description'],
'transaction_type' => $data['transaction_type'],
@ -83,14 +87,27 @@ class DepositHelper
*
* @return float The last known balance.
*/
public static function calculateLastBalance(int $clientId, int $insurerId): float
public static function calculateLastBalance(int $clientId, int $insurerId, $cd_ac_no): float
{
$model = new ClientDepositModel();
$getLastBalanceQuery = "SELECT balance FROM cash_deposit WHERE client_id = ? AND insurer_id = ? ORDER BY created_at DESC LIMIT 1";
$getLastBalanceParams = [$clientId, $insurerId];
// $getLastBalanceQuery = "SELECT balance FROM cash_deposit WHERE client_id = ? AND insurer_id = ? ORDER BY created_at DESC LIMIT 1";
// $getLastBalanceParams = [$clientId, $insurerId];
$lastBalance = $model->query($getLastBalanceQuery, $getLastBalanceParams)->getRow()->balance ?? 0;
$getLastBalanceQuery = "SELECT balance FROM cash_deposit WHERE cd_ac_no = ? ORDER BY created_at DESC LIMIT 1";
$getLastBalanceParams = [$cd_ac_no];
$lastBalance = $model->query($getLastBalanceQuery, $getLastBalanceParams)->getRow()->balance ?? null;
if(empty($lastBalance) && $lastBalance == null){
$cd_model = new ClientDepositModel();
$getLastBalanceQuery = "SELECT opening_bal FROM cd_master WHERE client_id = ? AND insurer_id = ? AND cd_ac_no = ? ORDER BY created_at DESC LIMIT 1";
$getLastBalanceParams = [$clientId, $insurerId, $cd_ac_no];
$lastBalance = $cd_model->query($getLastBalanceQuery, $getLastBalanceParams)->getRow()->opening_bal ?? 0;
}
return $lastBalance;
}

View File

@ -65,10 +65,19 @@ if (!function_exists('check_excel_date_format')) {
if($dateString == ""){ return array('status' => true); }
$date = DateTime::createFromFormat('d-M-Y', $dateString);
if ($date !== false && !is_array($date::getLastErrors())) {
if ($date && $date->format('d-M-Y') == $dateString) {
return array('status' => true);
} else {
return array('status' => false,'error' => "wrong date format: Expected 'd-M-Y' and received $dateString");
$res = convert_string_to_date($dateString);
if(!$res)
{
return array('status' => false,'error' => "wrong date format: Expected 'd-M-Y' and received $dateString");
}
else
{
return array('status' => true);
}
}
}
}
@ -143,6 +152,36 @@ if(!function_exists('check_doj'))
}
}
if(!function_exists('check_doc'))
{
function check_doc($row,$policy_details)
{
if($row['current_action'] != null && $row[7] != null && $row[7] != '' && in_array(strtoupper($row['current_action']), ['A','DA']))// check rule only of action column data available
{
// dd($policy_details);
$dateString = convert_string_to_date($row[7]);
if($dateString)
{
$date = new DateTime($dateString);
$startDate = new DateTime($policy_details[0]->policy_start_date);
$endDate = new DateTime($policy_details[0]->policy_end_date);
if ($date >= $startDate && $date <= $endDate) {
return array('status' => true);
} else {
return array('status' => false,'error' => 'the given date of coverage is not between policy start/end date');
}
}
else
{
return array('status' => false,'error' => 'date format error');
}
}
else { return array('status' => true); } // in else condition no need to check rule, just return true
}
}
if(!function_exists('check_employee_band'))
{
@ -151,6 +190,7 @@ if(!function_exists('check_employee_band'))
if($row['current_action'] != null && in_array(strtoupper($row['current_action']), ['I','A','DA']))// check rule only of action column data available
{
$is_emp_band_needed = $slab_details['grid_master']['emp_band'];
// $is_emp_band_needed = true;
if($slab_details['grid_master']['ui_type'] == 1) //gpa rack rate 1
{
if($slab_details['slab_rates'][0]['si_or_bp'] == 3)
@ -206,36 +246,40 @@ if(!function_exists('check_si'))
}
// check age slab
if(in_array(strtoupper($row['current_action']), ['I','A','DA']))
if(in_array(strtoupper($row['current_action']), ['I','A','DA']) && strtolower($row['5']) == 'self')
{
if($row[3] != null && DateTime::createFromFormat('d-M-Y', $row[3]) !== false)// dob
if($row[3] != '' && $row[3] != null)// dob
{
$dob = change_date_format($row[3],'d-M-Y','Y-m-d');
// echo $row[3].' - '.$dob;echo '<br>';
$currentDateTime = new DateTime();//die();
$passedDateTime = new DateTime($dob);
$interval = $currentDateTime->diff($passedDateTime);
if(!$is_age_slab_found)
{
if(isset($slab_value['age_from']) && isset($slab_value['age_to']))
$dob = convert_string_to_date($row[3]);
if($dob !== false)
{
if($slab_value['age_from'] !== null && $slab_value['age_to'] !== null && $slab_value['age_from'] <= $interval->y && $slab_value['age_to'] >= $interval->y && $slab_value['si'] == $received_si)
// echo $row[3].' - '.$dob;echo '<br>';
$currentDateTime = new DateTime();//die();
$passedDateTime = new DateTime($dob);
$interval = $currentDateTime->diff($passedDateTime);
if(!$is_age_slab_found)
{
$is_age_slab_found = true;// send true if age slab found
if(isset($slab_value['age_from']) && isset($slab_value['age_to']))
{
if($slab_value['age_from'] !== null && $slab_value['age_to'] !== null && $slab_value['age_from'] <= $interval->y && $slab_value['age_to'] >= $interval->y && $slab_value['si'] == $received_si)
{
$is_age_slab_found = true;// send true if age slab found
}
}
else
{
$is_age_slab_found = true;// send true if age conditin is not applicable
}
}
}
else
{
$is_age_slab_found = true;// send true if age conditin is not applicable
}
}
}
}
else
{
$is_age_slab_found = true;// send true if age conditin is not applicable
$is_si_found = true;
}//end of check age slab
}// end of for loop
@ -252,6 +296,12 @@ if(!function_exists('check_si'))
$return_array['error'] = !empty($return_array['error']) ? ($return_array['error'].', '.'Sum insured not configured for this age slab') : 'Sum insured not configured for this age slab';
}
if(empty($received_si))
{
$return_array['status'] = false;
$return_array['error'] = "Sum insured value mandantory";
}
return $return_array;
}
}
@ -263,6 +313,7 @@ if(!function_exists('check_basic_pay'))
if($row['current_action'] != null && in_array(strtoupper($row['current_action']), ['I','A','DA']))// check rule only of action column data available
{
$is_basic_pay_needed = $slab_details['grid_master']['basicpay'];
// $is_basic_pay_needed = true;
$slug = \Config\Services::slug();
$relationship = $slug->slugify($row[5]);
// echo $relationship;echo $row[7];
@ -281,12 +332,13 @@ if (!function_exists('check_dob_diff'))
{
if($row[3] != null && $row[5] != null)
{
if (DateTime::createFromFormat('d-M-Y', $row[3]) === false)
$dateString = convert_string_to_date($row[3]);
if ($dateString === false)
{
return array('status' => false,'error' => 'Not a valid Date');
}
// return array('status' => true);
$dob = change_date_format($row[3],'d-M-Y','Y-m-d');
$dob = $dateString;
// echo $row[3].' - '.$dob;echo '<br>';
$currentDateTime = new DateTime();//die();
// print_r($currentDateTime);
@ -325,7 +377,7 @@ if (!function_exists('check_dob_diff'))
if (!function_exists('data_group_by_family'))
{
function data_group_by_family($emp_data,$data_source = 'excel')
function data_group_by_family($emp_data,$data_source = 'excel',$action = '')
{
$result = [];
// Kint::dump($emp_data);
@ -335,6 +387,11 @@ if (!function_exists('data_group_by_family'))
{
if(!check_row_is_empty_or_null($row))
{
if($action == 'enrollment') //if action is enrollment transform current row into inception row, becoz we treat enrollment as inception
{
$row = transform_enrollment_row_to_inception_row($row);
}
if(strtolower($row[5]) == 'self' && isset($result[$row[1]]))
{
array_unshift($result[$row[1]],$row);
@ -417,6 +474,7 @@ if (!function_exists('name_and_empid_check_in_db'))
$result = ['del' => [],'i' => []];
$client_id = $actionArr['client_id'];
$policy_id = $actionArr['policy_id'];
$client_branch_id = $actionArr['client_branch_id'];
$current_action = $actionArr['action'];
foreach ($family_data as $rkey => $row)
@ -428,6 +486,7 @@ if (!function_exists('name_and_empid_check_in_db'))
->join('employee_polices ep',"cp.id = ep.client_policy_id AND employees.id = ep.employee_id")
->where("cp.id",$policy_id)
->where("employees.client_id",$client_id)
->where("employees.client_branch_id",$client_branch_id)
->where("employees.is_active",1)
->where("employees.emp_status",'active')
->where("ep.is_active",1)
@ -443,7 +502,7 @@ if (!function_exists('name_and_empid_check_in_db'))
{
array_push($result['del'],$row[0]);
}
if(($current_action == 'inception' || $current_action == 'dependent_addition' || $current_action == 'addition') && count($res))
if(($current_action == 'inception' || $current_action == 'dependent_addition' || $current_action == 'addition' || $current_action == 'enrollment') && count($res))
{
array_push($result['i'],$row[0]);
}
@ -572,10 +631,8 @@ if (!function_exists('check_dependent_conflict'))
$result['error_data'][] = ['code' => 12,'col_name' => 'sno','msg' => 'Rule conflict: As per policy, count of dependents has exceeded configured count','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $family_data[0][0])];//dependent count mismatch
}
}
// var_dump($allowed_adults == 0);
// dd($allowed_adults == 0 && (($allowed_parents_count < $received_parents_count) || ($allowed_parent_in_laws_count < $received_parent_in_laws_count)));
if($allowed_adults == 0 && (($allowed_parents_count < $received_parents_count) || ($allowed_parent_in_laws_count < $received_parent_in_laws_count) ))
//check for any cross parents but not more than two
if($allowed_adults == 0 && $allowed_parents_count == 1 && $allowed_parent_in_laws_count == 1 && (2 < ($received_parents_count + $received_parent_in_laws_count)))
{
// dd($allowed_adults);
$result['status'] = false;
@ -813,7 +870,7 @@ if (!function_exists('transform_excel_data_to_db'))
// $policy['date_of_exit'] = isset($memArr[16]) ? change_date_format($memArr[16],'d-M-Y','Y-m-d') : NULL;
// $policy['reason_for_exit'] = $memArr[17];
$policy['client_policy_id'] = $actionArr['policy_id'];
$policy['date_coverage'] = isset($memArr[7]) ? change_date_format($memArr[7],'d-M-Y','Y-m-d') : NULL;;
$policy['date_coverage'] = isset($memArr[7]) ? convert_string_to_date($memArr[7],'Y-m-d') : NULL;
$policy['policy_end_date'] = null;
$policy['days'] = null;
$policy['premium'] = null;
@ -823,11 +880,11 @@ if (!function_exists('transform_excel_data_to_db'))
$result['emp_code'] = $memArr[1];
$result['name'] = $memArr[2];
$result['dob'] = isset($memArr[3]) ? change_date_format($memArr[3],'d-M-Y','Y-m-d') : NULL;
$result['dob'] = isset($memArr[3]) ? convert_string_to_date($memArr[3],'Y-m-d') : NULL;
$result['gender'] = $memArr[4];
$result['relationship'] = $memArr[5];
$result['relationship_code'] = $memArr[5];
$result['doj'] = isset($memArr[8]) ? change_date_format($memArr[8],'d-M-Y','Y-m-d') : NULL;
$result['doj'] = isset($memArr[8]) ? convert_string_to_date($memArr[8],'Y-m-d') : NULL;
$result['basic_pay'] = $memArr[9];
$result['band'] = $memArr[10];
$result['designation'] = $memArr[11];
@ -897,7 +954,7 @@ if (!function_exists('premium_calculation_manager'))
$slug = \Config\Services::slug();
$grid_type = $emp_data['temp']['grid_id'];
$temp_slab_rates = $emp_data['temp']['grid_type'] == 'primary' ? $slab_details['slab_rates'] : $slab_details['additional_slab_info']['slab_rates'];
//if curent action is dependent addition OR addition then pull insurer master to set whether add one day from employee date of coverage
if($emp_data['temp']['action'] == 'DA' || $emp_data['temp']['action'] == 'A')
{
@ -956,7 +1013,7 @@ if (!function_exists('premium_calculation_manager'))
$employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si;
foreach ($temp_slab_rates as $skey => $slab_value)
{
if($slab_value['si'] == $employee_received_si)
if($slab_value['si'] == $employee_received_si && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['additional_rack_rate_acting_self']) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) ))
{
$emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
$emp_data['policy_details']['date_coverage'] = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
@ -979,7 +1036,7 @@ if (!function_exists('premium_calculation_manager'))
foreach ($temp_slab_rates as $skey => $slab_value)
{
$age = calculate_days_bw_dates(from_date: $emp_data['dob'])->y;
if($slab_value['si'] == $employee_received_si && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age))
if($slab_value['si'] == $employee_received_si && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['additional_rack_rate_acting_self']) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) ))
{
// dd($slab_value);
$emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
@ -1000,7 +1057,7 @@ if (!function_exists('premium_calculation_manager'))
foreach ($temp_slab_rates as $skey => $slab_value)
{
$age = calculate_days_bw_dates(from_date: $emp_data['dob'])->y;
if($slab_value['si'] == $employee_received_si && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age))
if($slab_value['si'] == $employee_received_si && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['additional_rack_rate_acting_self']) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) ))
{
$emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
$emp_data['policy_details']['date_coverage'] = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
@ -1505,4 +1562,57 @@ if(!function_exists('generate_family_relationship_array'))
return $family_relationships;
}
}
if(!function_exists('convert_string_to_date'))
{
function convert_string_to_date($dateString,$defaultFormat = 'd-M-Y')
{
$formats = [
'd-M-Y', // 03-APr-2024
'd M Y', // 03 Apr 2024
'd/M/Y', // 03/Apr/2024
'j M Y', // 3 Apr 2024
'j/M/Y', // 3/Apr/2024
'j-M-Y', // 3-Apr-2024
'Y-m-d' // 2024-04-04
];
foreach ($formats as $format) {
$date = DateTime::createFromFormat($format, $dateString);
if ($date && $date->format($format) == $dateString) {
return $date->format($defaultFormat);
}
}
return false;
}
}
if(!function_exists('transform_enrollment_row_to_inception_row'))
{
function transform_enrollment_row_to_inception_row($row)
{
$res = [];
$res[0] = $row[0]; // inception: sno (S.No) -> enrollment: sno (Sno)
$res[1] = $row[1]; // inception: emp_id (EMP ID) -> enrollment: emp_code (Emp_Code)
$res[2] = $row[2]; // inception: name_of_emp_dep (NAME OF EMP/DEP) -> enrollment: name (NAME OF EMP/DEP)
$res[3] = $row[6]; // inception: dob (DOB) -> enrollment: dob (DOB)
$res[4] = $row[4]; // inception: gender (Gender) -> enrollment: gender (Gender)
$res[5] = $row[5]; // inception: relationship (RELATIONSHIP) -> enrollment: relationship (Relation)
$res[6] = $row[9]; // inception: basic_cover_si (BASIC COVER SI) -> enrollment: basic_cover_si (SI)
$res[7] = null; // inception: doc (Date of Coverage) -> No match in enrollment
$res[8] = $row[3]; // inception: doj (DOJ) -> enrollment: doj (DOJ)
$res[9] = $row[11]; // inception: basic_pay (Basic Pay) -> enrollment: basic_pay (Basic Pay)
$res[10] = $row[10]; // inception: band_grade (Band/Grade) -> enrollment: band_grade (Grade)
$res[11] = null; // inception: designation (Designation) -> No match in enrollment
$res[12] = $row[8]; // inception: phone (Phone) -> enrollment: phone (Mobile)
$res[13] = $row[7]; // inception: email (Email) -> enrollment: email (Email)
$res[14] = 1; // inception: pre_existing_ailments (PRE EXISTING AILMENTS) -> No match in enrollment
$res[15] = null; // inception: change_event (Change event) -> No match in enrollment
$res[16] = null; // inception: date_of_exit (Date of exit) -> No match in enrollment
$res[17] = null; // inception: reason_for_exit (Reason for exit) -> No match in enrollment
return $res;
}
}

View File

@ -239,3 +239,12 @@ if (!function_exists('get_username')) {
}
if (!function_exists('get_role_id')) {
function get_role_id() {
$role_id = get_session_userdata()->role;
return $role_id;
}
}

View File

@ -0,0 +1,86 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class CDMasterModel extends Model
{
protected $table = 'cd_master';
protected $primaryKey = 'id';
protected $useAutoIncrement = true;
protected $returnType = 'array';
protected $useSoftDeletes = false;
protected $protectFields = true;
protected $allowedFields = [
'id',
'client_id',
'insurer_id',
'cd_ac_no',
'opening_bal',
'opening_date',
'created_at',
'updated_at',
'created_by',
'updated_by',
'is_active',
];
// Callbacks
protected $allowCallbacks = true;
protected $beforeInsert = ["checkAndADDCreatedByValue"];
protected $afterInsert = [];
protected $beforeUpdate = ["checkAndUpdateUpdatedByValue"];
protected $afterUpdate = [];
protected $beforeFind = [];
protected $afterFind = [];
protected $beforeDelete = [];
protected $afterDelete = [];
protected function checkAndADDCreatedByValue(array $data)
{
// Check if 'updated_by' value is null or empty
if (empty($data['data']['created_by'])) {
// Set 'updated_by' value to the current session user ID
$data['data']['created_by'] = get_session_userid();
}
return $data;
}
protected function checkAndUpdateUpdatedByValue(array $data)
{
// Check if 'updated_by' value is null or empty
if (empty($data['data']['updated_by'])) {
// Set 'updated_by' value to the current session user ID
$data['data']['updated_by'] = get_session_userid();
}
return $data;
}
public function getCDMasterList(){
$query = $this->db->table('cd_master')
->select('cd_master.*, clients.client_name, clients.short_name, insurers.name AS insurer_name, user_profiles.first_name AS user_name, IFNULL(cd_ac_counts.cd_ac_no_count, 0) AS cd_ac_no_count')
->join('clients', 'clients.id = cd_master.client_id')
->join('insurers', 'insurers.id = cd_master.insurer_id')
->join('user_profiles', 'user_profiles.id = cd_master.created_by')
->join(
'(SELECT cd_master.cd_ac_no, COUNT(client_policy.cd_ac_no) AS cd_ac_no_count
FROM cd_master
JOIN client_policy ON client_policy.cd_ac_no = cd_master.cd_ac_no
GROUP BY cd_master.cd_ac_no) AS cd_ac_counts',
'cd_ac_counts.cd_ac_no = cd_master.cd_ac_no',
'left'
)
->where('cd_master.is_active', 1)
->get();
$result = $query->getResultArray();
return $result;
}
}

View File

@ -0,0 +1,22 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class ChatBotModel extends Model
{
protected $table = 'chat_bot';
protected $primaryKey = 'id';
protected $allowedFields = [
"id",
"request",
"options",
"created_by",
"updated_by",
"is_active",
];
}
?>

View File

@ -22,6 +22,9 @@ class ClientDepositModel extends Model
"updated_at",
"description",
"balance",
"client_policy_id",
"cd_ac_no",
"endorsement_no",
];

View File

@ -36,9 +36,25 @@ class ClientModel extends Model
//get client and its associated policies in same array
public function clientsWithPolicies()
{
$role_id = get_role_id();
$user_id = get_session_userid();
$columns = ['clients.id ', 'client_name','short_name'];
$clients = $this->select($columns)
->where('is_active',1)
->findAll();
// if($role_id == 2 || $role_id == 3){
// $clients = $this->select($columns)
// ->join('client_rm', 'client_rm.client_id = clients.id')
// ->where('client_rm.user_id', $user_id)
// ->where('clients.is_active',1)
// ->findAll();
// }
$columns = ['id', 'client_name','short_name'];
$clients = $this->select($columns)->where('is_active',1)->findAll();
foreach ($clients as &$client) {
$clientPolicyModel = new ClientPolicyModel();
@ -51,6 +67,7 @@ class ClientModel extends Model
'client_branch.client_id',
'client_policy.id as client_policy_id',
'client_policy.policy_terms',
'client_policy.policy_no',
'p.name',
'pt.policy_type',
])

View File

@ -42,7 +42,9 @@ class ClientPolicyModel extends Model
"date_of_exit",
"reason_for_exit",
"policy_no",
"client_branch_id"
"client_branch_id",
"cd_ac_no",
"gst",
];
public function getClientPolicyById($id){
@ -76,12 +78,14 @@ class ClientPolicyModel extends Model
->select('insurer_branch.branch_name as insurer_branch_name, insurer_branch.branch_code as insurer_branch_code')
->select('tpa_branch.branch_name as tpa_branch_name, tpa_branch.branch_code as tpa_branch_code')
->select('policy_type.policy_type as policy_type_name')
->select('client_branch.branch_name as branch_name')
->join('insurers', 'insurers.id = client_policy.insurer_id')
->join('insurer_branch', 'client_policy.insurer_branch_id = insurer_branch.id')
->join('tpa', 'tpa.id = client_policy.tpa_id', 'left')
->join('tpa_branch', 'client_policy.tpa_branch_id = tpa_branch.id', 'left')
->join('policies', 'policies.id = client_policy.policy_id')
->join('policy_type', 'policy_type.id = policies.policy_type_id')
->join('client_branch', 'client_branch.id = client_policy.client_branch_id')
->where('client_policy.client_id', $client_id)
->where('client_policy.policy_status', 1)
->where('client_policy.is_active', 1)
@ -182,18 +186,21 @@ class ClientPolicyModel extends Model
->select('cash_deposit.*')
->select('insurers.name as insurer_name, insurers.short_name as insurer_short')
->select('clients.client_name as clientname, clients.short_name as clientshort')
->select('policies.name as policy_name')
->select('user_profiles.first_name as username')
->join('user_profiles','user_profiles.id=cash_deposit.created_by')
->join('insurers', 'insurers.id = cash_deposit.insurer_id')
->join('clients', 'clients.id = cash_deposit.client_id')
->join('user_profiles', 'user_profiles.id = cash_deposit.created_by', 'left')
->join('insurers', 'insurers.id = cash_deposit.insurer_id', 'left')
->join('clients', 'clients.id = cash_deposit.client_id', 'left')
->join('client_policy', 'client_policy.id = cash_deposit.client_policy_id', 'left')
->join('policies', 'policies.id = client_policy.policy_id', 'left')
->where('cash_deposit.client_id', $clientId)
->where('cash_deposit.insurer_id', $insurerId) // Add this line to filter by insurer_id
->where('cash_deposit.insurer_id', $insurerId)
->orderBy('cash_deposit.id', 'DESC')
->get()
->getResult();
}
public function getDepositSummary($clientId, $insurerId)
{
// Fetch the sum of credit and debit transactions and calculate the balance

View File

@ -76,31 +76,71 @@ class EmployeePolicyModel extends Model
}
// -----------------------------------------------------------------------------------------------------
public function getEmployeePolicy($client_id,$policy_id,$status, $branch_id)
public function getEmployeePolicy($client_id = 0, $policy_id=0, $status=0, $branch_id=0, $emp_code="", $emp_name="")
{
$result = $this->select(['employee_polices.*','pm.name as policy_name','im.short_name as insurer_short_name','ib.branch_name as insurer_branch_name','ib.branch_code as insurer_branch_code','tpam.name as tpa_name','tpam.short_name as tpa_short_name','tpab.branch_code as tpa_branch_code','cm.client_name','cm.short_name as client_short_name','emp.relationship','emp.relationship_code','emp.change_event','emp.emp_code','emp.name','emp.email_corporate','emp.dob','emp.gender','emp.emp_status','emp.is_active as emp_is_active','emp.mobile as mobile'])
->join('employees emp', 'employee_polices.employee_id = emp.id')
->join('client_policy cp', 'employee_polices.client_policy_id = cp.id') //cp - client policy
->join('policies pm', 'cp.policy_id = pm.id') //pm - policy master
->join('insurers im', 'cp.insurer_id = im.id') //im - insurar master
->join('insurer_branch ib', 'cp.insurer_branch_id = ib.id') //ib - insurar branch
->join('tpa tpam', 'cp.tpa_id = tpam.id') //tpam - tpa master
->join('tpa_branch tpab', 'cp.tpa_branch_id = tpab.id') //tpab - tpa brach
->join('clients cm', 'cp.client_id = cm.id') //cm - client master
->where('emp.client_id',$client_id)
->where('emp.client_branch_id',$branch_id)
->where('employee_polices.is_active',1)
->where('emp.is_active',1)
->where('employee_polices.client_policy_id',$policy_id)
->orderBy('emp.emp_code','ASC')->orderBy('employee_polices.employee_id','ASC');
if($status != 0 && !empty($status)){
$result = $this->select([
'employee_polices.*',
'pm.name as policy_name',
'im.short_name as insurer_short_name',
'ib.branch_name as insurer_branch_name',
'ib.branch_code as insurer_branch_code',
'tpam.name as tpa_name',
'tpam.short_name as tpa_short_name',
'tpab.branch_code as tpa_branch_code',
'cm.client_name',
'cm.short_name as client_short_name',
'emp.relationship',
'emp.relationship_code',
'emp.change_event',
'emp.emp_code',
'emp.name',
'emp.email_corporate',
'emp.dob',
'emp.gender',
'emp.emp_status',
'emp.is_active as emp_is_active',
'emp.mobile as mobile',
'policy_type.policy_type',
'cp.policy_no',
])
->join('employees emp', 'employee_polices.employee_id = emp.id')
->join('client_policy cp', 'employee_polices.client_policy_id = cp.id') //cp - client policy
->join('policies pm', 'cp.policy_id = pm.id') //pm - policy master
->join('policy_type', 'policy_type.id = pm.policy_type_id')
->join('insurers im', 'cp.insurer_id = im.id') //im - insurer master
->join('insurer_branch ib', 'cp.insurer_branch_id = ib.id') //ib - insurer branch
->join('tpa tpam', 'cp.tpa_id = tpam.id', 'left') //tpam - tpa master
->join('tpa_branch tpab', 'cp.tpa_branch_id = tpab.id', 'left') //tpab - tpa branch
->join('clients cm', 'cp.client_id = cm.id') //cm - client master
->orderBy('emp.emp_code', 'ASC')
->orderBy('employee_polices.employee_id', 'ASC');
// Conditionally add where clauses
if ($client_id !=0 && !empty($client_id)) {
$result->where('emp.client_id', $client_id);
}
if ($branch_id !=0 && !empty($branch_id)) {
$result->where('emp.client_branch_id', $branch_id);
}
if ($policy_id !=0 && !empty($policy_id)) {
$result->where('employee_polices.client_policy_id', $policy_id);
}
if ($status !=0 && !empty($status)) {
$result->where('employee_polices.status', $status);
}
if (!empty($emp_code)) {
$result->where('emp.emp_code', $emp_code);
}
if (!empty($emp_name)) {
$result->like('emp.name', $emp_name);
}
$result = $result->findAll();
return ($result);
// Always check these conditions
$result->where('employee_polices.is_active', 1)
->where('emp.is_active', 1);
return $result->findAll();
}
@ -665,7 +705,9 @@ class EmployeePolicyModel extends Model
e.endorsement_id,
ep.client_policy_id,
policies.name as policy_name,
insurers.short_name as insurer_short_name
insurers.short_name as insurer_short_name,
client_policy.policy_no,
policy_type.policy_type
');
$query1->distinct();
$query1->join('employee_polices ep', 'ep.id = e.pk');
@ -673,6 +715,7 @@ class EmployeePolicyModel extends Model
$query1->join('client_policy', 'client_policy.id = ep.client_policy_id');
$query1->join('client_branch', 'client_branch.id = employees.client_branch_id');
$query1->join('policies', 'policies.id = client_policy.policy_id');
$query1->join('policy_type', 'policy_type.id = policies.policy_type_id');
$query1->join('insurers', 'insurers.id = policies.insurer_id');
$query1->whereIn('e.actions', ['c']);
$query1->where('ep.client_policy_id', $policy_id);
@ -699,18 +742,21 @@ class EmployeePolicyModel extends Model
e.remarks,
ep.client_policy_id,
policies.name as policy_name,
insurers.short_name as insurer_short_name
insurers.short_name as insurer_short_name,
client_policy.policy_no,
policy_type.policy_type
');
$query2->join('employee_polices ep', 'ep.id = e.pk');
$query2->join('employees', 'employees.id = ep.employee_id');
$query2->join('client_policy', 'client_policy.id = ep.client_policy_id');
$query2->join('client_branch', 'client_branch.id = employees.client_branch_id');
$query2->join('policies', 'policies.id = client_policy.policy_id');
$query2->join('policy_type', 'policy_type.id = policies.policy_type_id');
$query2->join('insurers', 'insurers.id = policies.insurer_id');
$query2->whereIn('e.actions', ['si', 'd']);
$query2->where('ep.client_policy_id', $policy_id);
$query2->where('employees.client_id', $client_id);
$query1->where('employees.client_branch_id', $branch_id);
$query2->where('employees.client_branch_id', $branch_id);
if($status != 0 && !empty($status)){
$query2->where('e.status', $status);

View File

@ -269,20 +269,19 @@ $(document).ready(function () {
$('body').on('click', '.btnDelete', function () {
Swal.fire({
title: "Are you sure?",
text: "You won't be able to revert this!",
icon: "warning",
showCancelButton: true,
confirmButtonColor: "#3085d6",
cancelButtonColor: "#d33",
confirmButtonText: "Yes, delete it!"
title: "Are you sure?",
text: "You need to remove this user",
icon: "info",
showCancelButton: true,
confirmButtonColor: "#3085d6",
confirmButtonText: "Yes",
}).then((result) => {
if (result.isConfirmed) {
var student_id = $(this).attr('data-id');
$.get('<?php echo base_url('user/deactive/');?>'+student_id, function (data) {
console.log(data);
// $('#tickets-table tbody #'+ student_id).remove();
toastr.success('User removed successfully', 'success');
window.location.reload()
})
}

View File

@ -6,6 +6,13 @@
.reload:hover {
cursor: pointer;
}
.truncate {
max-width: 80px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
</style>
<div class="col-12" id="second_page">
@ -22,13 +29,13 @@
<thead class="bg-light">
<tr>
<th class="font-weight-medium">SNO</th>
<th class="font-weight-medium">Batch <br> Code</th>
<th class="font-weight-medium">Batch Code</th>
<th class="font-weight-medium">File Name</th>
<th class="font-weight-medium">Client</th>
<th class="font-weight-medium">Client <br> Branch</th>
<th class="font-weight-medium">Client Branch</th>
<th class="font-weight-medium">Client Policy</th>
<th class="font-weight-medium">Event <br> Type</th>
<th class="font-weight-medium">Insurer/ <br> TPA</th>
<th class="font-weight-medium">Event Type</th>
<th class="font-weight-medium">Insurer/ TPA</th>
<th class="font-weight-medium">Action</th>
<th class="font-weight-medium">Count</th>
<th class="font-weight-medium">()Amount</th>
@ -46,13 +53,12 @@
<tr>
<td><b><?php echo ($key + 1) ?></b></td>
<td><?php echo $file['batch_code'] ?></td>
<td class="reload" data-toggle="tooltip" data-placement="top"
title="<?php echo $file['file_name'] ?>">
<?php echo $file['file_name'] ?>
<td style="overflow: hidden;" class="reload truncate" data-toggle="tooltip" data-placement="top" title="<?php echo $file['file_name'] ?>">
<?php echo $file['file_name']?>
</td>
<td><?php echo $file['client_short_name'] ?></td>
<td><?php echo $file['branch_name'] ?></td>
<td><?php echo $file['policy_name'] ?></td>
<td><?php echo isset($file['policy_name']) ? $file['policy_name'] : '' ?> - <?php echo isset($file['policy_no']) ? $file['policy_no'] : '' ?> - <?php echo isset($file['policy_type']) ? $file['policy_type'] : '' ?></td>
<td><?php echo $file['event_type'] ?></td>
<td><?php echo $file['insurer_or_tpa'] ?></td>
<td><?php echo $file['actions'] ?></td>

View File

@ -0,0 +1,339 @@
<style>
.table th,
.table td {
padding: 8px;
}
table.dataTable tbody td {
padding: 4px 4px !important;
}
table.dataTable thead th {
padding: 4px 4px !important;
}
.col-12 {
max-width: 98% !important;
}
</style>
<div class="row" id="client_list">
<div class="col-12">
<div class="card">
<div class="card-body">
<div class="row" style="margin-bottom:1rem;">
<div class="col-6" style="align-self: center;">
<h4 style="position: relative;">CD Master List</h4>
</div>
<div class="col-6" style="text-align: right; position: relative;top: 56px;">
<button type="button" id="btnAdd" class="btn btn-primary waves-effect waves-light"
data-toggle="modal" data-target="#con-close-modal" data-placement="top" title="Add"
data-trigger="hover">ADD</button>
</div>
</div>
<table class="table table-sm table-hover m-0 table-centered dt-responsive w-100" cellspacing="0"
id="tickets-table">
<thead class="bg-light">
<tr>
<th class="font-weight-medium">Client Name</th>
<th class="font-weight-medium">Insurer Name</th>
<th class="font-weight-medium">Opening Date</th>
<th class="font-weight-medium">CD Account No</th>
<th class="font-weight-medium">Deposite Amount</th>
<th class="font-weight-medium">Date/User</th>
<th class="font-weight-medium">Action</th>
</tr>
</thead>
<tbody>
<?php foreach($CD_Master_Data as $row){ ?>
<tr>
<td><?php echo $row['client_name']; ?>( <?= $row['short_name'] ?> )</td>
<td><?php echo $row['insurer_name']; ?></td>
<td><?php echo date('d-m-Y', strtotime($row['opening_date'])); ?></td>
<td><?php echo $row['cd_ac_no']; ?></td>
<td><?php echo $row['opening_bal']; ?></td>
<td><?php echo date('d-M-Y h:i A', strtotime($row['created_at'])) ?> by
<?php echo $row['user_name']; ?></td>
<td>
<div class="btn-group dropdown">
<a href="javascript: void(0);"class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item btnEdit" data-id="<?= $row['id'];?>" data-toggle="modal" data-target="#con-close-modal"> <i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
<?php if($row['cd_ac_no_count'] == 0) { ?>
<a class="dropdown-item" data-id="<?= $row['id'];?>" onclick="removeCDMaster(this)"><i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete</a>
<?php } ?>
</div>
</div>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div><!-- end col -->
</div>
<!-- end row -->
<!-- modal content -->
<div id="con-close-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
aria-hidden="true" data-backdrop="static" style="display: none;">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="title">Add Cash Deposite</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body p-4">
<div class="">
<form role="form" class="parsley-examples" method="post" id="CDMasterForm" action=""
enctype="multipart/form-data">
<input type="hidden" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
<input type="hidden" name="PrimaryKey" id="CD_Master_ID" />
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-12">
<label for="emp_code">Client<span class="text-danger">*</span></label>
<select class="form-control" id="client_id" name="client_id" required>
<option value="">Select Client</option>
<?php foreach($clients as $value) { ?>
<option value="<?= $value['id'] ?>"><?= $value['client_name'] ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<label for="profile">Insurer<span class="text-danger">*</span></label>
<select class="form-control" id="insurer_id" name="insurer_id" required>
<option value="">Select Insurer</option>
<?php foreach($insurers as $value) { ?>
<option value="<?= $value['id'] ?>"><?= $value['name'] ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<label for="email">Opening Date<span class="text-danger">*</span></label>
<input type="text" class="form-control" name="opening_date" id="opening_date" required>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<label for="mobile">CD Account Number<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="cd_ac_no" name="cd_ac_no" required>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<label for="mobile">Deposite Amount<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="opening_bal" name="opening_bal" required>
</div>
</div>
</div>
<div class="form-group text-right m-b-0">
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
id="btnSubmit">Submit</button>
<!-- <button type="button" class="btn btn-secondry waves-effect waves-light mr-1" data-dismiss="modal" aria-hidden="true">Close</button> -->
</div>
</form>
</div>
</div>
</div>
</div>
</div><!-- /.modal -->
<script>
$(document).ready(function() {
$('#tickets-table').DataTable({
dom: "<'row'<'col-sm-0'f><'col-sm-9 text-right'B>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
buttons: [{
extend: 'csv',
text: 'CSV',
title: 'CD-Master-List',
className: 'my_class',
exportOptions: {
columns: ':not(:last-child)'
},
}],
language: {
search: "_INPUT_",
searchPlaceholder: "Search..."
},
paging: true,
});
})
$(document).ready(function(){
<?php if (session()->has('error')) : ?>
toastr.error('<?= session()->getFlashdata('error') ?>', 'Failed');
<?php endif; ?>
<?php if (session()->has('success')) : ?>
toastr.success('<?= session()->getFlashdata('success') ?>', 'success');
<?php endif; ?>
var endDatePicker = flatpickr("#opening_date", {
dateFormat: "d-m-Y",
// defaultDate: endDate,
allowInput: false
});
$('#client_id').select2();
$('#insurer_id').select2();
})
$('#btnAdd').click(function(){
$('#client_id').val('');
$('#insurer_id').val('');
$('#opening_date').val('');
$('#cd_ac_no').val('');
$('#opening_bal').val('');
$('#CDMasterForm').attr('action', '<?php echo base_url('master/cash_deposite/create');?>');
$('#title').html('Add Cash Deposite');
$('#btnSubmit').html('Submit');
})
$('.close').click(function(){
$('#CD_Master_ID').val('');
$('#client_id').val('').change();
$('#insurer_id').val('').change();
$('#opening_date').val('');
$('#cd_ac_no').val('');
$('#opening_bal').val('');
$('#CDMasterForm')[0].reset();
$('#CDMasterForm').parsley().reset();
})
$('body').on('click', '.btnEdit', function () {
var cd_id = $(this).attr('data-id');
$('#title').html('Update Cash Deposite');
$.ajax({
url: '<?php echo base_url('master/cash_deposite/list/');?>'+cd_id,
type: "GET",
dataType: 'json',
success: function (res) {
console.log(res)
$('#updateModal').modal('show');
$('#CDMasterForm').attr('action', '<?php echo base_url('master/cash_deposite/edit');?>');
$('#CD_Master_ID').val(res.data.id);
$('#client_id').val(res.data.client_id).change();
$('#insurer_id').val(res.data.insurer_id).change();
$('#opening_date').val(res.data.opening_date);
$('#cd_ac_no').val(res.data.cd_ac_no);
$('#opening_bal').val(res.data.opening_bal);
$('#btnSubmit').html('Update');
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
}
});
});
$('#cd_ac_no').change(function(){
var cd_ac_no = $(this).val();
$.ajax({
url: '<?php echo base_url('util/check_cd_ac_no/');?>'+cd_ac_no,
type: "GET",
dataType: 'json',
success: function (res) {
console.log(res)
if(res.status == true){
toastr.warning(res.message, 'warning');
$('#cd_ac_no').val('');
}
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
}
});
})
function removeCDMaster(element) {
Swal.fire({
title: "Are you sure?",
text: "You need to remove this CD.",
icon: "info",
showCancelButton: true,
confirmButtonColor: "#3085d6",
confirmButtonText: "Yes",
}).then((result) => {
if (result.isConfirmed) {
var id = element.getAttribute('data-id');
var form_action = '<?= base_url("master/cash_deposite/remove/") ?>' + id;
$.ajax({
url: form_action,
type: "GET",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
// console.log(res.status == true);
if(res){
if (res.status == true) {
toastr.success('CD removed successfully.', 'success');
location.reload();
} else {
toastr.warning('Failed to remove CD.', 'warning');
}
}
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.log('Something Wrong!', 'warning');
}
});
}
});
}
</script>

View File

@ -1,11 +1,12 @@
<div class="tab-pane fade" id="branch-tab">
<input type="hidden" id="client_id_for_client_branch" value="<?= isset($client['id']) ? $client['id'] : '' ?>"/>
<input type="hidden" id="client_id_for_client_branch" value="<?= isset($client['id']) ? $client['id'] : '' ?>" />
<div class="row float-right" style="padding-bottom: 10px;position: relative;right: 13px;">
<button type="button" id="btnBranchAdd" class="btn btn-primary waves-effect waves-light btn-sm"><span class="fa fa-plus-square" aria-hidden="true" style="padding: 5px 10px;"></span>Add Branch</button>
<button type="button" id="btnBranchAdd" class="btn btn-primary waves-effect waves-light btn-sm"><span
class="fa fa-plus-square" aria-hidden="true" style="padding: 5px 10px;"></span>Add Branch</button>
</div>
<div class="table-responsive" id="branch_table" >
<div class="table-responsive" id="branch_table">
<table class="table table-borderless table-nowrap mb-0">
<thead class="thead-light">
<tr>
@ -23,52 +24,51 @@
<div class="col-12">
<div class="card-body">
<div class="row float-right" style="position: relative; bottom: 20px; right: 13px;">
<button type="button" id="btnBranchBack" class="btn btn-primary waves-effect waves-light btn-sm btnBack"><span class="fa fa-list" aria-hidden="true" style="padding: 5px 10px;"></span>Back To List</button>
<button type="button" id="btnBranchBack"
class="btn btn-primary waves-effect waves-light btn-sm btnBack"><span class="fa fa-list"
aria-hidden="true" style="padding: 5px 10px;"></span>Back To List</button>
</div>
<hr>
<form role="form" class="parsley-examples" method="post" id="branch_form"
enctype="multipart/form-data">
<input type="hidden" class="form-control" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
<input type="hidden" name="client_id" id="client_id_branch" value="<?= isset($client['id']) ? $client['id'] : '' ?>"/>
<input type="hidden" name="branch_id_primarykey" id="branch_id_primarykey"/>
<form role="form" class="parsley-examples" method="post" id="branch_form" enctype="multipart/form-data">
<input type="hidden" class="form-control" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
<input type="hidden" name="client_id" id="client_id_branch"
value="<?= isset($client['id']) ? $client['id'] : '' ?>" />
<input type="hidden" name="branch_id_primarykey" id="branch_id_primarykey" />
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-6">
<label for="branch_name">Branch Name<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="branch_name" placeholder="Enter Branch Name" name="branch_name" required>
<input type="text" class="form-control" id="branch_name" placeholder="Enter Branch Name"
name="branch_name" required>
</div>
<div class="form-group col-md-6">
<label for="branch_code">Branch Code<span
class="text-danger">*</span></label>
<input type="text" class="form-control" id="branch_code"
placeholder="Enter Branch Code" name="branch_code" required>
<label for="branch_code">Branch Code<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="branch_code" placeholder="Enter Branch Code"
name="branch_code" required>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-4">
<label for="state">State<span
class="text-danger">*</span></label>
<label for="state">State<span class="text-danger">*</span></label>
<select class="form-control" id="state" name="state" required>
<option value="">Select State</option>
<?php foreach($state as $value) { ?>
<option value="<?= $value['id'] ?>"><?= $value['state'] ?></option>
<?php } ?>
<option value="<?= $value['id'] ?>"><?= $value['state'] ?></option>
<?php } ?>
</select>
</div>
<div class="form-group col-md-4">
<label for="district">District<span
class="text-danger">*</span></label>
<input type="text" class="form-control" id="district"
placeholder="Enter District" name="district" required>
<label for="district">District<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="district" placeholder="Enter District"
name="district" required>
</div>
<div class="form-group col-md-4">
<label for="city">City<span
class="text-danger">*</span></label>
<input type="text" class="form-control" id="branch_city"
placeholder="Enter City" name="city" required>
<label for="city">City<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="branch_city" placeholder="Enter City"
name="city" required>
</div>
</div>
@ -79,26 +79,37 @@
<div class="form-row">
<div class="form-group col-md-6">
<label for="first_name">Name<span class="text-danger">*</span></label>
<input value="" type="text" class="form-control" placeholder="Enter Contact Name" name="name[]" id="name" required>
<input value="" type="text" class="form-control" placeholder="Enter Contact Name"
name="name[]" id="name" required>
</div>
<div class="form-group col-md-6">
<label for="last_name">Email<span class="text-danger">*</span></label>
<input value="" type="text" class="form-control" placeholder="Enter Contact Email" name="email[]" id="email" data-parsley-trigger="change" data-parsley-type="email" required>
<input value="" type="text" class="form-control" placeholder="Enter Contact Email"
name="email[]" id="email" data-parsley-trigger="change" data-parsley-type="email"
required>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="mobile">Mobile<span class="text-danger">*</span></label>
<input value="" type="text" class="form-control" placeholder="Enter Contact Mobile" name="mobile[]" id="mobile" onkeypress = "return onlyNumbers(event)" maxlength="10" minlength="10" data-parsley-type-message="Please enter a valid 10-digit mobile number." data-parsley-required-message="Please enter a valid 10-digit mobile number." required>
<input value="" type="text" class="form-control" placeholder="Enter Contact Mobile"
name="mobile[]" id="mobile" onchange="checkMobileNumber(this)"
onkeypress="return onlyNumbers(event)" maxlength="10" minlength="10"
data-parsley-type-message="Please enter a valid 10-digit mobile number."
data-parsley-required-message="Please enter a valid 10-digit mobile number."
required>
</div>
<div class="form-group col-md-6">
<label for="designation">Designation<span class="text-danger">*</span></label>
<input value="" type="text" class="form-control" placeholder="Enter Designation Name" name="designation[]" id="designation" required>
<input value="" type="text" class="form-control" placeholder="Enter Designation Name"
name="designation[]" id="designation" required>
</div>
</div>
<div class="form-group" style="display: flex;">
<button style="margin-right: 10px;" type="button" class="btn btn-primary btn-sm ac" onclick="appendContactHtml()" id="add">Add Contact</button>
<button type="button" class="btn btn-danger btn-sm" onclick="removeContact(this)" id="remove_btn">Remove</button>
<button style="margin-right: 10px;" type="button" class="btn btn-primary btn-sm ac"
onclick="appendContactHtml()" id="add">Add Contact</button>
<button type="button" class="btn btn-danger btn-sm" onclick="removeContact(this)"
id="remove_btn">Remove</button>
</div>
<div id="container"></div>
@ -119,168 +130,196 @@
<script>
var branch_form_action = '';
var contactCount = 1;
var branch_PrimaryKey = $('#client_id_for_client_branch').val();
var branch_PrimaryKey = $('#client_id_for_client_branch').val();
$(document).ready(function () {
$(document).ready(function() {
branch_PrimaryKey = $('#client_id_branch').val();
branch_PrimaryKey = $('#client_id_branch').val();
$('#add_branch').hide();
$('.btnBack').hide();
if(branch_PrimaryKey !== ''){
if (branch_PrimaryKey !== '') {
var branchTable = '';
var data = <?= isset($client_branch) ? json_encode($client_branch) : '[]' ?>;
var data = <?= isset($client_branch) ? json_encode($client_branch) : '[]' ?>;
var role = data.role
delete data.role;
console.log(role)
$.each(data, function(index, item) {
branchTable += `
<tr>
<td>${item.branch_name}</td>
<td>${item.branch_code}</td>
<td>
<a class="mdi mdi-lead-pencil btnBranchEdit" href="#" data-id="${item.id}" style="font-size:18px;"></a>
<a style="color:#02a8b5" data-id="${item.id}" onclick="removeClientBranch(this)"><i data-id="${item.id}" class="mdi mdi-delete" style="font-size:18px;"></i></a>
</td>
</tr>
`;
if(role != 3 && role != 4){
branchTable += `
<tr>
<td>${item.branch_name}</td>
<td>${item.branch_code}</td>
<td>
<a class="mdi mdi-lead-pencil btnBranchEdit" href="#" data-id="${item.id}" style="font-size:18px;"></a>
<a style="color:#02a8b5" data-id="${item.id}" onclick="removeClientBranch(this)"><i data-id="${item.id}" class="mdi mdi-delete" style="font-size:18px;"></i></a>
</td>
</tr>
`;
}else{
branchTable += `
<tr>
<td>${item.branch_name}</td>
<td>${item.branch_code}</td>
<td>
<a class="mdi mdi-lead-pencil btnBranchEdit" href="#" data-id="${item.id}" style="font-size:18px;"></a>
</td>
</tr>
`;
}
});
$('#branch_list').append(branchTable);
$('#branch_list').append(branchTable);
}
});
});
$('#btnBranchAdd').click(function(){
$('#btnBranchAdd').click(function() {
branch_form_action = '<?= base_url("client/branch/create"); ?>';
branch_form_action = '<?= base_url("client/branch/create"); ?>';
$('#add_branch').show();
$('#branch_table').hide();
$('.btnBack').show();
$('#btnBranchAdd').hide();
$('#add_branch').show();
$('#branch_table').hide();
$('.btnBack').show();
$('#btnBranchAdd').hide();
$('#branch_name').val('');
$('#branch_code').val('');
$('#state').val('');
$('#district').val('');
$('#branch_city').val('');
$('#branch_form')[0].reset();
$('.ac').css('display', 'block');
contactCount = 1
$('#branch_name').val('');
$('#branch_code').val('');
$('#state').val('');
$('#district').val('');
$('#branch_city').val('');
$('#branch_form')[0].reset();
$('.ac').css('display', 'block');
contactCount = 1
var addButton = document.getElementById('add');
if (addButton.style.display === 'none') {
addButton.style.display = 'block';
}
var addButton = document.getElementById('add');
if (addButton.style.display === 'none') {
addButton.style.display = 'block';
}
var buttonIds = JSON.parse(localStorage.getItem('buttonIds')) || [];
for (var i = 0; i < buttonIds.length; i++) {
var firstElement = buttonIds[i].split('_')[0];
console.log(firstElement);
var buttonIds = JSON.parse(localStorage.getItem('buttonIds')) || [];
for (var i = 0; i < buttonIds.length; i++) {
var firstElement = buttonIds[i].split('_')[0];
console.log(firstElement);
// Find the element by its ID
var elementToRemove = document.getElementById(firstElement);
// Find the element by its ID
var elementToRemove = document.getElementById(firstElement);
console.log(elementToRemove);
if (elementToRemove) {
console.log(elementToRemove);
if (elementToRemove) {
console.log(elementToRemove);
elementToRemove.parentNode.removeChild(elementToRemove);
}
localStorage.removeItem('buttonIds')
elementToRemove.parentNode.removeChild(elementToRemove);
}
localStorage.removeItem('buttonIds')
}
})
})
$('.btnBack').click(function(){
$('.btnBack').click(function() {
$('#add_branch').hide();
$('#branch_table').show();
$('.btnBack').hide();
$('#btnBranchAdd').show();
$('#add_branch').hide();
$('#branch_table').show();
$('.btnBack').hide();
$('#btnBranchAdd').show();
$('#branch_name').val('');
$('#branch_code').val('');
$('#state').val('');
$('#district').val('');
$('#branch_city').val('');
$('#branch_form')[0].reset();
$('.ac').css('display', 'block');
$('.parsley-errors-list').remove();
$('#branch_form').parsley().reset();
contactCount = 1
$('#branch_name').val('');
$('#branch_code').val('');
$('#state').val('');
$('#district').val('');
$('#branch_city').val('');
$('#branch_form')[0].reset();
$('.ac').css('display', 'block');
$('.parsley-errors-list').remove();
$('#branch_form').parsley().reset();
contactCount = 1
var buttonIds = JSON.parse(localStorage.getItem('buttonIds')) || [];
for (var i = 0; i < buttonIds.length; i++) {
var firstElement = buttonIds[i].split('_')[0];
console.log(firstElement);
var buttonIds = JSON.parse(localStorage.getItem('buttonIds')) || [];
for (var i = 0; i < buttonIds.length; i++) {
var firstElement = buttonIds[i].split('_')[0];
console.log(firstElement);
// Find the element by its ID
var elementToRemove = document.getElementById(firstElement);
// Find the element by its ID
var elementToRemove = document.getElementById(firstElement);
console.log(elementToRemove);
if (elementToRemove) {
console.log(elementToRemove);
if (elementToRemove) {
console.log(elementToRemove);
elementToRemove.parentNode.removeChild(elementToRemove);
}
elementToRemove.parentNode.removeChild(elementToRemove);
}
}
})
})
$("#branch_form").submit(function(event) {
$("#branch_form").submit(function(event) {
event.preventDefault();
branch_PrimaryKey = $('#client_id_branch').val();
event.preventDefault();
branch_PrimaryKey = $('#client_id_branch').val();
console.log('branch_PrimaryKey', branch_PrimaryKey)
if (branch_PrimaryKey === '') {
toastr.error('Client is required', 'Error');
$('#insurer').val('');
$('#tpa').val('');
$('#policy').html('<option value="" selected>Select Policy</option>');
return;
}
console.log('branch_PrimaryKey', branch_PrimaryKey)
var isValid = $('#branch_form').parsley().validate();
if (branch_PrimaryKey === '') {
toastr.error('Client is required', 'Error');
$('#insurer').val('');
$('#tpa').val('');
$('#policy').html('<option value="" selected>Select Policy</option>');
return;
}
if (isValid) {
var isValid = $('#branch_form').parsley().validate();
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
if (isValid) {
var formData = new FormData($('#branch_form')[0]);
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
$.ajax({
data: formData,
url: branch_form_action,
type: "POST",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
var formData = new FormData($('#branch_form')[0]);
if(res){
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
$('#add_branch').hide();
$('#branch_table').show();
$('.btnBack').hide();
$('#btnBranchAdd').show();
var message = (branch_PrimaryKey === '') ? 'Client Branch Created successfully' : 'Client Branch Updated successfully';
toastr.success(message, 'Success');
}, 1000);
}
$.ajax({
data: formData,
url: branch_form_action,
type: "POST",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
if (res) {
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
$('#add_branch').hide();
$('#branch_table').show();
$('.btnBack').hide();
$('#btnBranchAdd').show();
var message = (branch_PrimaryKey === '') ?
'Client Branch Created successfully' :
'Client Branch Updated successfully';
toastr.success(message, 'Success');
}, 1000);
}
$('#branch_list tr').remove();
var branchTableInsert = ''
var role = res.data.role
delete res.data.role;
console.log(role)
$.each(res.data, function(index, item) {
console.log('client_branch_data', item)
if(role != 3 && role != 4){
$('#branch_list tr').remove();
var branchTableInsert = ''
$.each(res.data, function(index, item) {
branchTableInsert += `
<tr>
<td>${item.branch_name}</td>
@ -290,92 +329,26 @@ $(document).ready(function () {
<a style="color:#02a8b5" data-id="${item.id}" onclick="removeClientBranch(this)"><i data-id="${item.id}" class="mdi mdi-delete" style="font-size:18px;"></i></a>
</td>
</tr>
`;
});
$('#branch_list').append(branchTableInsert);
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.warning('Something Wrong!', 'warning');
}, 1000);
}
});
}
contactCount = 1
});
`;
}else{
$('body').on('click', '.btnBranchEdit', function () {
branchTableInsert += `
<tr>
<td>${item.branch_name}</td>
<td>${item.branch_code}</td>
<td>
<a class="mdi mdi-lead-pencil btnBranchEdit" href="#" data-id="${item.id}" style="font-size:18px;"></a>
</td>
</tr>
`;
var buttonIds = JSON.parse(localStorage.getItem('buttonIds')) || [];
for (var i = 0; i < buttonIds.length; i++) {
var firstElement = buttonIds[i].split('_')[0];
console.log(firstElement);
// Find the element by its ID
var elementToRemove = document.getElementById(firstElement);
console.log(elementToRemove);
if (elementToRemove) {
console.log(elementToRemove);
elementToRemove.parentNode.removeChild(elementToRemove);
}
localStorage.removeItem('buttonIds')
}
contactCount = 1
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
var branch_id = $(this).attr('data-id');
$('#branch_id_primarykey').val(branch_id);
branch_form_action = '<?= base_url("client/branch/edit"); ?>';
$.ajax({
url: '<?php echo base_url('client/branch/list/');?>'+branch_id,
type: "GET",
dataType: 'json',
success: function (res) {
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, 500);
// console.log('branch contact : ',res.contact)
$('#add_branch').show();
$('#branch_table').hide();
$('.btnBack').show();
$('#btnBranchAdd').hide();
$('#branch_name').val(res.data.branch_name);
$('#branch_code').val(res.data.branch_code);
$('#state option[value="' + res.data.state + '"]').prop('selected', true);
$('#district').val(res.data.district);
$('#branch_city').val(res.data.city);
$('#branch_PrimaryKey').val(res.data.id);
$('#name').val(res.contact[0].name);
$('#email').val(res.contact[0].email);
$('#mobile').val(res.contact[0].mobile);
$('#designation').val(res.contact[0].designation);
res.contact.shift();
// console.log(res.contact.length)
for (let index = 0; index < res.contact.length; index++) {
const contact = res.contact[index];
if (contact !== undefined) {
appendContactHtml(contact);
}
}
});
$('#branch_list').append(branchTableInsert);
},
error: function (xhr, status, error) {
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
setTimeout(function() {
@ -383,29 +356,110 @@ $(document).ready(function () {
$('.loader-mask').delay(350).fadeOut('slow');
toastr.warning('Something Wrong!', 'warning');
}, 1000);
}
}
});
console.log(branch_form_action);
}
contactCount = 1
});
$('body').on('click', '.btnBranchEdit', function() {
var buttonIds = JSON.parse(localStorage.getItem('buttonIds')) || [];
for (var i = 0; i < buttonIds.length; i++) {
var firstElement = buttonIds[i].split('_')[0];
console.log(firstElement);
// Find the element by its ID
var elementToRemove = document.getElementById(firstElement);
console.log(elementToRemove);
if (elementToRemove) {
console.log(elementToRemove);
elementToRemove.parentNode.removeChild(elementToRemove);
}
localStorage.removeItem('buttonIds')
}
contactCount = 1
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
var branch_id = $(this).attr('data-id');
$('#branch_id_primarykey').val(branch_id);
branch_form_action = '<?= base_url("client/branch/edit"); ?>';
$.ajax({
url: '<?php echo base_url('client/branch/list/');?>' + branch_id,
type: "GET",
dataType: 'json',
success: function(res) {
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, 500);
// console.log('branch contact : ',res.contact)
$('#add_branch').show();
$('#branch_table').hide();
$('.btnBack').show();
$('#btnBranchAdd').hide();
$('#branch_name').val(res.data.branch_name);
$('#branch_code').val(res.data.branch_code);
$('#state option[value="' + res.data.state + '"]').prop('selected', true);
$('#district').val(res.data.district);
$('#branch_city').val(res.data.city);
$('#branch_PrimaryKey').val(res.data.id);
$('#name').val(res.contact[0].name);
$('#email').val(res.contact[0].email);
$('#mobile').val(res.contact[0].mobile);
$('#designation').val(res.contact[0].designation);
res.contact.shift();
// console.log(res.contact.length)
for (let index = 0; index < res.contact.length; index++) {
const contact = res.contact[index];
if (contact !== undefined) {
appendContactHtml(contact);
}
}
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.warning('Something Wrong!', 'warning');
}, 1000);
}
});
console.log(branch_form_action);
});
$("#remove_btn").click(function(){
$("#name").val('');
$("#email").val('');
$("#mobile").val('');
$("#designation").val('');
})
$("#remove_btn").click(function() {
$("#name").val('');
$("#email").val('');
$("#mobile").val('');
$("#designation").val('');
})
// Initialize the contact count
function appendContactHtml(contact = false, reset = false) {
// Initialize the contact count
function appendContactHtml(contact = false, reset = false) {
console.log('appendContactHtml function called ')
contactCount++;
console.log('appendContactHtml function called ')
contactCount++;
var container = document.getElementById('container');
var uniqueId = Date.now().toString();
var container = document.getElementById('container');
var uniqueId = Date.now().toString();
var html = `
var html = `
<div id="${uniqueId}">
<hr>
<h6 class="header-title">Contact ${contactCount}</h6>
@ -423,7 +477,7 @@ $(document).ready(function () {
<div class="form-row">
<div class="form-group col-md-6">
<label for="${uniqueId}_mobile">Mobile<span class="text-danger">*</span></label>
<input value="${contact !== undefined && contact !== false ? contact.mobile : ''}" type="text" class="form-control" placeholder="Enter Contact Mobile" name="mobile[]" id="${uniqueId}_mobile" onkeypress = "return onlyNumbers(event)" maxlength="10" min="10" data-parsley-type-message="Please enter a valid 10-digit mobile number." data-parsley-required-message="Please enter a valid 10-digit mobile number." required>
<input value="${contact !== undefined && contact !== false ? contact.mobile : ''}" type="text" class="form-control" placeholder="Enter Contact Mobile" name="mobile[]" id="${uniqueId}_mobile" onchange="checkMobileNumber(this)" onkeypress = "return onlyNumbers(event)" maxlength="10" min="10" data-parsley-type-message="Please enter a valid 10-digit mobile number." data-parsley-required-message="Please enter a valid 10-digit mobile number." required>
</div>
<div class="form-group col-md-6">
<label for="${uniqueId}_designation">Designation<span class="text-danger">*</span></label>
@ -437,132 +491,169 @@ $(document).ready(function () {
</div>
`;
if(reset == false){
console.log(reset)
container.insertAdjacentHTML('beforeend', html);
storeButtonId(uniqueId + '_add');
if (reset == false) {
console.log(reset)
container.insertAdjacentHTML('beforeend', html);
storeButtonId(uniqueId + '_add');
if (contactCount >= 3) {
hideStoredAddButtons();
}
}
}
function removeContact(button) {
var uniqueId = button.id.split("_")[0];
var contactSection = document.getElementById(uniqueId);
if (contactSection) {
contactSection.parentNode.removeChild(contactSection);
contactCount --;
if (contactCount < 3) {
var addButton = document.querySelector('.ac');
if (addButton) {
addButton.style.display = 'block';
}
}
if (contactCount >= 3) {
hideStoredAddButtons();
}
}
function storeButtonId(id) {
}
var buttonIds = JSON.parse(localStorage.getItem('buttonIds')) || [];
buttonIds.push(id);
localStorage.setItem('buttonIds', JSON.stringify(buttonIds));
}
function removeContact(button) {
var uniqueId = button.id.split("_")[0];
var contactSection = document.getElementById(uniqueId);
if (contactSection) {
contactSection.parentNode.removeChild(contactSection);
contactCount--;
function hideStoredAddButtons() {
var storedIds = JSON.parse(localStorage.getItem('buttonIds')) || [];
storedIds.forEach(function(id) {
var addButton = document.getElementById(id);
var first_addButton = document.querySelector('.ac')
if (contactCount < 3) {
var addButton = document.querySelector('.ac');
if (addButton) {
addButton.style.display = 'none';
first_addButton.style.display = 'none';
addButton.style.display = 'block';
}
});
}
}
}
function showNextAddButton() {
var storedIds = JSON.parse(localStorage.getItem('buttonIds')) || [];
var addButtonShown = false;
function storeButtonId(id) {
// Iterate through the stored IDs to find the next "Add" button to show
storedIds.forEach(function(id) {
if (!addButtonShown) {
var addButton = document.getElementById(id);
if (addButton && addButton.style.display === 'none') {
addButton.style.display = 'block';
addButtonShown = true; // Set to true once an "Add" button is shown
}
var buttonIds = JSON.parse(localStorage.getItem('buttonIds')) || [];
buttonIds.push(id);
localStorage.setItem('buttonIds', JSON.stringify(buttonIds));
}
function hideStoredAddButtons() {
var storedIds = JSON.parse(localStorage.getItem('buttonIds')) || [];
storedIds.forEach(function(id) {
var addButton = document.getElementById(id);
var first_addButton = document.querySelector('.ac')
if (addButton) {
addButton.style.display = 'none';
first_addButton.style.display = 'none';
}
});
}
function showNextAddButton() {
var storedIds = JSON.parse(localStorage.getItem('buttonIds')) || [];
var addButtonShown = false;
// Iterate through the stored IDs to find the next "Add" button to show
storedIds.forEach(function(id) {
if (!addButtonShown) {
var addButton = document.getElementById(id);
if (addButton && addButton.style.display === 'none') {
addButton.style.display = 'block';
addButtonShown = true; // Set to true once an "Add" button is shown
}
});
}
}
});
}
function validateForm() {
var isValid = true;
$('#branch_form input, #branch_form select').each(function() {
function validateForm() {
var isValid = true;
if ($(this).is('input[type="text"]') || $(this).is('select')) {
if ($.trim($(this).val()) == '') {
isValid = false;
return false;
}
$('#branch_form input, #branch_form select').each(function() {
if ($(this).is('input[type="text"]') || $(this).is('select')) {
if ($.trim($(this).val()) == '') {
isValid = false;
return false;
}
}
});
});
return isValid;
}
return isValid;
}
function onlyNumbers(event){
function onlyNumbers(event) {
var charcode;
charcode = event.which || event.keyCode;
if(charcode>= 48 && charcode <= 57)return true;
return false;
}
var charcode;
charcode = event.which || event.keyCode;
if (charcode >= 48 && charcode <= 57) return true;
return false;
}
function removeClientBranch(element) {
var id = element.getAttribute('data-id');
var form_action = '<?= base_url("client/branch/remove/") ?>' + id;
$.ajax({
url: form_action,
type: "GET",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
// console.log(res.status == true);
if(res){
if (res.status == true) {
toastr.success('Remove Done!', 'success');
function removeClientBranch(element) {
location.reload();
Swal.fire({
title: "Are you sure?",
text: "You need to remove this client branch.",
icon: "info",
showCancelButton: true,
confirmButtonColor: "#3085d6",
confirmButtonText: "Yes",
}).then((result) => {
} else {
toastr.warning('Remove Not Done!', 'warning');
if (result.isConfirmed) {
var id = element.getAttribute('data-id');
var form_action = '<?= base_url("client/branch/remove/") ?>' + id;
$.ajax({
url: form_action,
type: "GET",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
// console.log(res.status == true);
if (res) {
if (res.status == true) {
toastr.success('Client branch removed successfully', 'success');
location.reload();
} else {
toastr.warning('Failed to remove client branch', 'warning');
}
}
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.log('Something Wrong!', 'warning');
}, 1000);
}
}
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.warning('Something Wrong!', 'warning');
}, 1000);
}
});
}
});
}
});
}
function checkMobileNumber(input) {
console.log('function called')
console.log(input);
console.log('Input Value', input.value);
var mobileNumber = input.value;
var url = '<?php echo base_url('util/checkHRNumber/') ?>' + mobileNumber;
$.get(url, function(response) {
console.log(response)
console.log(response.data)
if (response.data > 0) {
toastr.warning('The Mobile Number Already Exist.', 'Warning');
input.value = "";
return;
}
}).fail(function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
});
}
</script>

View File

@ -16,7 +16,8 @@
<div class="row">
<div class="col-6" style="position: relative;left: 455px;">
<button id="close_btn" class="btn btn-primary waves-effect waves-light client_info_close">Close</button>
<button id="close_btn"
class="btn btn-primary waves-effect waves-light client_info_close">Close</button>
</div>
<div class="col-1 float-right" style="position: relative;left: 255px;">
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse"
@ -33,7 +34,7 @@
<div class="card-body" style="position: relative;bottom: 25px;">
<div class="row" >
<div class="row">
<div class="col-6">
@ -204,7 +205,7 @@
</div>
</div>
<div id="collapseThree" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
<div class="card-body" style="position: relative;bottom: 25px;">
<div class="card-body" style="position: relative;bottom: 25px;">
<div class="row">
<table id="tb1" class="table table-hover m-0 table-centered dt-responsive nowrap w-100"
cellspacing="0">
@ -253,7 +254,7 @@
</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body" id="modal_body" >
<div class="modal-body" id="modal_body">
</div>
</div><!-- /.modal-content -->
@ -270,50 +271,71 @@ $(document).ready(function() {
$(document).on('click', '.policy_terms', function() {
var terms = $(this).data('id');
console.log(terms);
console.log(terms.length);
console.log(JSON.stringify(terms));
// terms = JSON.parse(terms);
$('#modal_body').empty();
function createListItems(obj) {
if (obj.length == 0) {
const message = document.createElement('div');
message.textContent = 'Policy Terms Not Available';
message.style.display = 'flex';
message.style.justifyContent = 'center';
message.style.alignItems = 'center';
message.style.height = '100%'; // Adjust as necessary to fit the context
message.style.textAlign = 'center';
return message;
}
const fragment = document.createDocumentFragment();
for (const key in obj) {
if (obj.hasOwnProperty(key) && obj[key] !== null && obj[key] !== '' && key !=
'family_floater' && key != 'gpa_special_condition_input' && key !=
'gpa_special_condition_label' && key != 'special_condition_label' && key !=
'special_condition_input' && key != 'age_ratio') {
if (
obj.hasOwnProperty(key) &&
obj[key] !== null &&
obj[key] !== '' &&
key !== 'family_floater' &&
key !== 'gpa_special_condition_input' &&
key !== 'gpa_special_condition_label' &&
key !== 'special_condition_label' &&
key !== 'special_condition_input' &&
key !== 'age_ratio' &&
key !== 'multiple_sum_insured' &&
key !== 'other_special_condition_label' &&
key !== 'other_special_condition_input'
) {
const listItem = document.createElement('li');
let formattedKey = key.replace(/_/g, ' ');
var formattedKey = '';
formattedKey = key.replace(/_/g, ' ');
obj[key] = obj[key].replace(/<\/?[^>]+>/gi, '');
console.log('type', typeof obj[key])
// Strip HTML tags from values
if (typeof obj[key] === 'string') {
console.log('before', obj[key])
obj[key] = obj[key].replace(/<\/?[^>]+>/gi, '');
console.log('after', obj[key])
}
// Convert 0 and 1 to 'No' and 'Yes'
if (obj[key] == 0) {
obj[key] = 'No';
}
if (obj[key] == 1) {
obj[key] = 'Yes';
}
console.log(formattedKey)
if (key == 'burnExpenses' && obj[key] == 'Yes') {
listItem.innerHTML =
`<strong>${formattedKey.charAt(0).toUpperCase() + formattedKey.slice(1)}:</strong> ${obj['burnExpensesData']}`;
} else if (typeof obj[key] === 'object' && !Array.isArray(obj[key])) {
// Handle nested objects
if (typeof obj[key] === 'object' && !Array.isArray(obj[key])) {
listItem.innerHTML =
`<strong>${formattedKey.charAt(0).toUpperCase() + formattedKey.slice(1)}:</strong>`;
const nestedList = document.createElement('ul');
nestedList.appendChild(createListItems(obj[key]));
listItem.appendChild(nestedList);
} else {
listItem.innerHTML =
`<strong>${formattedKey.charAt(0).toUpperCase() + formattedKey.slice(1)}:</strong> ${Array.isArray(obj[key]) ? JSON.stringify(obj[key]) : obj[key]}`;
@ -325,7 +347,8 @@ $(document).on('click', '.policy_terms', function() {
return fragment;
}
$('#modal_body').append(createListItems(terms));
});
$('#modal_body').append(createListItems(terms));
});
</script>

View File

@ -59,7 +59,9 @@ table.dataTable thead th {
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" href="<?= base_url("client/list/"); ?><?= $row->id;?>"><i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
<a class="dropdown-item" href="<?= base_url("client/deposit/{$row->id}"); ?>"><i class="mdi mdi-cash mr-2 text-muted font-18 vertical-middle"></i>Deposit</a>
<a class="dropdown-item" data-id="<?= $row->id;?>" onclick="removeClient(this)"><i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete</a>
<?php if(get_role_id() != 3 && get_role_id() != 4) { ?>
<a class="dropdown-item" data-id="<?= $row->id;?>" onclick="removeClient(this)"><i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete</a>
<?php } ?>
</div>
</div>
</td>
@ -111,38 +113,47 @@ table.dataTable thead th {
function removeClient(element) {
var id = element.getAttribute('data-id');
var form_action = '<?= base_url("client/remove/") ?>' + id;
$.ajax({
url: form_action,
type: "GET",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
// console.log(res.status == true);
if(res){
if (res.status == true) {
toastr.success('Remove Done!', 'success');
location.reload();
Swal.fire({
title: "Are you sure?",
text: "You need to remove this client.",
icon: "info",
showCancelButton: true,
confirmButtonColor: "#3085d6",
confirmButtonText: "Yes",
}).then((result) => {
} else {
toastr.warning('Remove Not Done!', 'warning');
}
if (result.isConfirmed) {
var id = element.getAttribute('data-id');
var form_action = '<?= base_url("client/remove/") ?>' + id;
$.ajax({
url: form_action,
type: "GET",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
// console.log(res.status == true);
if(res){
if (res.status == true) {
toastr.success('Client removed successfully.', 'success');
location.reload();
} else {
toastr.warning('Failed to remove client.', 'warning');
}
}
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.log('Something Wrong!', 'warning');
}
});
}
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.warning('Something Wrong!', 'warning');
}, 1000);
}
});
});
}

View File

@ -7,14 +7,15 @@
<div class="table-responsive" id="table_list">
<table class="table table-borderless table-nowrap mb-0" id="table-client-policy">
<thead class="thead-light">
<table class="table table-borderless table mb-0" id="table-client-policy">
<thead class="thead-light">
<tr>
<th>Insurer</th>
<th>Policy</th>
<th>Client Branch</th>
<th>TPA</th>
<th>Date</th>
<th>Enrollment <br> Status</th>
<th>Enrollment Status</th>
<th>Status</th>
<th>Action</th>
</tr>
@ -39,6 +40,7 @@
<input type="hidden" name="PrimaryKey" id="policy_PrimaryKey" />
<input type="hidden" id="policy_form_action" />
<input type="hidden" name="policy_type_id" id="policy_type_id" />
<input type="hidden" id="insurer_policy_id" />
<input type="hidden" name="client_id" id="client_id_policy" value="<?= isset($client['id']) ? $client['id'] : '' ?>" />
<div class="form-group">
@ -121,13 +123,28 @@
<div class="form-row" id="third" style="display: none; position: relative;top: 22px;">
<label class="switch">
<input id="inception_type" type="checkbox" name="inception_type">
<span class="slider round" style="height: 27px;"></span>
</label>
<div class="form-group col-md-4">
<label for="mobile">CD Account Number<span id="tpa_danger" class="text-danger">*</span></label>
<select class="form-control" id="cd_ac_no" name="cd_ac_no" required>
<option value="">Select CD Account Number</option>
</select>
</div>
<label for="inception_type" style="position: relative;bottom: 5px;left: 10px;">Enable
Employee Enrolment Process</label>
<div class="form-group col-md-4">
<label for="mobile">GST ( % )<span id="tpa_danger" class="text-danger">*</span></label>
<input type="text" class="form-control" placeholder="GST (%)" id="gst_no" name="gst" required>
</div>
<div class="form-group col-md-4">
<label class="switch" style="position: relative;top: 43px;left: 20px;">
<input id="inception_type" type="checkbox" name="inception_type">
<span class="slider round" style="height: 27px;"></span>
</label>
<label for="inception_type" style="position: relative;bottom: 5px;left: 85px;">Enable
Employee Enrolment Process</label>
</div>
</div>
<div id="policy_fields"></div>
@ -148,6 +165,7 @@
<?php include('policy_grid.php'); ?>
<?php include('policy_gmc_terms.php'); ?>
<?php include('policy_gpa_terms.php'); ?>
<?php include('other_policy_terms.php'); ?>
<script>
var policy_PrimaryKey = $('#client_id_policy').val();
@ -201,13 +219,15 @@
if (policy_PrimaryKey !== '') {
var policyTable = '';
var data = <?= isset($client_policy) ? json_encode($client_policy) : '[]' ?>;
// console.log('client_policy_data',data)
// //console.log('client_policy_data',data)
data.forEach(function(item) {
// console.log(item.open_for_enrollment);
// //console.log(item.open_for_enrollment);
var patternGMC = /gmc/i; // Case insensitive pattern for 'gmc'
var patternGPA = /gpa/i; // Case insensitive pattern for 'gpa'
var subject = item.policy_type_name;
//console.log('search terms subject', subject);
if (patternGMC.test(subject)) {
search_term = 'GMC';
} else if (patternGPA.test(subject)) {
@ -215,7 +235,7 @@
} else {
search_term = subject; // Set default value if neither 'GMC' nor 'GPA' exists
}
// console.log('search_term :', search_term)
//console.log('search_term :', search_term)
var enrollmentStatus = '';
if (item.inception_type == 1) {
@ -246,13 +266,15 @@
tpaValue = item.tpa_short + '-' + item.tpa_branch_code;
}
var policy_name_data = `${item.policy_name ?? ''}` + ' - ' + `${item.policy_no ?? ''}` + ' - ' + `${item.policy_type_name ?? ''}`;
policyTable += `
<tr>
<td>${item.insurer_short} - ${item.insurer_branch_name}</td>
<td>${item.policy_name} (${item.policy_type_name})</td>
<td>${policy_name_data}</td>
<td>${item.branch_name ? item.branch_name : ' - '}</td>
<td>${tpaValue}</td>
<td>${(item.policy_start_date)} / <br> ${(item.policy_end_date)}</td>
<td>${(item.policy_start_date)} / ${(item.policy_end_date)}</td>
<td style="text-align: center;">${(enrollmentStatus)}</td>
<td>${checkDateStatus(item.policy_end_date, 1)}</td>
<td>
@ -260,8 +282,8 @@
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a href="#" data-id="${item.id}" id="${item.policy_id}" class="dropdown-item btnPolicyEdit"><i class="mdi mdi-lead-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
<a href="#" data-id="${item.id}" id="${search_term}" class="dropdown-item btnPolicyMaster" data-toggle="modal"><i class="mdi mdi-wrench mr-2 text-muted font-18 vertical-middle"></i>Terms</a>
<a href="#" data-id="${item.id}" id="${search_term}"class="dropdown-item btnPolicyModel" data-toggle="modal" data-target="#bs-example-modal-lg"><i class="mdi mdi-book-open mr-2 text-muted font-18 vertical-middle"></i>Rack Rate</a>
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item btnPolicyMaster" data-toggle="modal"><i class="mdi mdi-wrench mr-2 text-muted font-18 vertical-middle"></i>Terms</a>
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item btnPolicyModel" data-toggle="modal" data-target="#bs-example-modal-lg"><i class="mdi mdi-book-open mr-2 text-muted font-18 vertical-middle"></i>Rack Rate</a>
</div>
</div>
</td>
@ -270,12 +292,14 @@
});
$('#policy_table').append(policyTable);
// console.log(policyTable);
}
$('#table-client-policy').DataTable({
paging: true,
searching: false
searching: false,
// ordering: false
});
});
@ -300,6 +324,9 @@
$('#policy_form_action').val('<?= base_url("client/policy/create"); ?>');
$('#policy_status_field').hide()
$('#base_policy_id').hide();
$('#policy_PrimaryKey').val("");
$('#insurer_policy_id').val("");
$('#gst_no').val(18);
$('#first').hide();
@ -330,7 +357,6 @@
})
/******** for form submit using AJAX *******/
$("#policy_form").submit(function(event) {
@ -342,8 +368,8 @@
var policyDataId = $('#policy').children('option:selected').attr('data-id');
var basePolicyDataId = $('#base_policy').children('option:selected').attr('data-id');
// console.log('policyDataId', policyDataId);
// console.log('basePolicyDataId', basePolicyDataId);
// //console.log('policyDataId', policyDataId);
// //console.log('basePolicyDataId', basePolicyDataId);
if (policy_PrimaryKey === '' && policy_client === '') {
toastr.error('Client is required', 'Error');
@ -371,7 +397,7 @@
var isValid = $('#policy_form').parsley().validate();
if (!isValid) {
console.log('Form is Empty', 'Warning');
//console.log('Form is Empty', 'Warning');
return;
}
@ -390,18 +416,13 @@
contentType: false,
success: function(res) {
console.log(res);
//console.log(res);
$('#policy_form')[0].reset();
if (res.status === false) {
toastr.error('Policy Dose Not Create', 'Error');
return;
}
if (res.staus === 'policy_exist') {
toastr.error('Policy already exist in the branch', 'Error');
}
if (res) {
setTimeout(function() {
@ -435,7 +456,7 @@
subject; // Set default value if neither 'GMC' nor 'GPA' exists
}
// console.log('search_term :', search_term)
// //console.log('search_term :', search_term)
var enrollmentStatus = '';
if (item.inception_type == 1) {
@ -473,8 +494,9 @@
<tr>
<td>${item.insurer_short} - ${item.insurer_branch_name}</td>
<td>${item.policy_name} (${item.policy_type_name})</td>
<td>${item.branch_name}</td>
<td>${tpaValue}</td>
<td>${rearrangeDateFormat(item.policy_start_date)} / <br> ${rearrangeDateFormat(item.policy_end_date)}</td>
<td>${rearrangeDateFormat(item.policy_start_date)} / ${rearrangeDateFormat(item.policy_end_date)}</td>
<td style="text-align: center;">${(enrollmentStatus)}</td>
<td>${checkDateStatus(item.policy_end_date, 1)}</td>
<td>
@ -482,8 +504,8 @@
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a href="#" data-id="${item.id}" id="${item.policy_id}" class="dropdown-item btnPolicyEdit"><i class="mdi mdi-lead-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
<a href="#" data-id="${item.id}" id="${search_term}" class="dropdown-item btnPolicyMaster" data-toggle="modal"><i class="mdi mdi-wrench mr-2 text-muted font-18 vertical-middle"></i>Terms</a>
<a href="#" data-id="${item.id}" id="${search_term}"class="dropdown-item btnPolicyModel" data-toggle="modal" data-target="#bs-example-modal-lg"><i class="mdi mdi-book-open mr-2 text-muted font-18 vertical-middle"></i>Rack Rate</a>
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item btnPolicyMaster" data-toggle="modal"><i class="mdi mdi-wrench mr-2 text-muted font-18 vertical-middle"></i>Terms</a>
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}"class="dropdown-item btnPolicyModel" data-toggle="modal" data-target="#bs-example-modal-lg"><i class="mdi mdi-book-open mr-2 text-muted font-18 vertical-middle"></i>Rack Rate</a>
</div>
</div>
</td>
@ -491,6 +513,8 @@
`;
});
$('#policy_table').append(policyTable);
console.log(policyTable);
$('#insurer').val('');
$('#tpa').val('');
@ -506,11 +530,11 @@
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
if (xhr.status === 404) {
console.log('Resource not found', 'Warning');
//console.log('Resource not found', 'Warning');
} else if (xhr.status === 500) {
console.log('Internal server error', 'Warning');
//console.log('Internal server error', 'Warning');
} else {
console.log('Unknown error occurred', 'Warning');
//console.log('Unknown error occurred', 'Warning');
}
}, 1000);
}
@ -521,19 +545,22 @@
$(document).ready(function() {
/********* To get the POLICY base on Insurer *******/
$('#insurer').change(function() {
var id = $(this).val();
var client_id = $('#client_id_policy').val()
var parts = id.split('-');
var secondPart = parts[1];
var url = "<?= base_url("util/police-by-insurer/") ?>" + secondPart;
var url_for_cd = "<?= base_url("util/get_cd_ac/") ?>" + client_id + '/' + secondPart;
var selectedOption = $('#base_policy').find(':selected');
var base_policy_data_id = selectedOption.data('id');
console.log('base_policy_data_id', base_policy_data_id);
// //console.log('base_policy_data_id', base_policy_data_id);
$.get(url, function(res) {
// res = JSON.parse(res)//
// console.log(res)
//console.log('polices', res)
var OptionsHTML = '';
OptionsHTML += '<option value="" selected>Select Policy</option>';
$policy_type_value = $('#policy_type').val();
@ -575,13 +602,14 @@
}
} else if ($policy_type_value == 1) {
if (item.policy_type_id == 1 || item.policy_type_id == 2 || item
.policy_type_id == 3) {
// const policyTypeId = Number(item.policy_type_id);
OptionsHTML += '<option data-id="' + item.policy_type_id +
'" value="' +
item.id +
'">' + item.name + '( ' + item.policy_type + ' )</option>';
// if ([1, 2, 3, 6, 7,].includes(policyTypeId))
if (item.policy_type_id == 1 || item.policy_type_id == 2 || item
.policy_type_id == 3 || item.policy_type_id == 7 || item.policy_type_id == 6){
//console.log(item.policy_type_id)
OptionsHTML += '<option data-id="' + item.policy_type_id + '" value="' + item.id + '">' + item.name + '( ' + item.policy_type + ' )</option>';
}
} else {
@ -597,7 +625,28 @@
console.error(xhr.responseText);
console.error(status, error);
});
$.get(url_for_cd, function(response){
//console.log(response)
//console.log(response.data)
if(response.status == false && response.insurer_id != 'undefined'){
toastr.warning('The CD Account Number not found.', 'Warning');
return;
}
appendCDACNO(response.data)
}).fail(function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
});
});
});
$(document).ready(function() {
@ -606,9 +655,44 @@
var id = $(this).val();
var dataId = $(this).children('option:selected').attr('data-id');
// console.log('id', id)
var branch_id = $('#client_branch').val();
var client_id = $('#client_id_policy').val();
console.log('client_id', client_id)
console.log('branch_id', branch_id)
console.log('policy_type_id', dataId)
console.log('client_policy_id', $('#policy_PrimaryKey').val())
$('#policy_type_id').val(dataId);
var url = '<?php echo base_url('util/check_policy_type/') ?>' + dataId + '/' + branch_id + '/' + client_id;
// if (dataId && branch_id && client_id) {
// // Check if all parameters exist
// if ($('#policy_PrimaryKey').val() == "" || id != $('#insurer_policy_id').val()) {
// $.get(url, function(response) {
// console.log(response);
// console.log(response.count);
// if (response.count > 0) {
// console.log('Policy already exist in the branch');
// toastr.error('Policy already exist in the branch', 'Error');
// $('#policy').val('').change();
// }
// console.log('outer');
// }).fail(function(xhr, status, error) {
// console.error(xhr.responseText);
// console.error(status, error);
// });
// }
// } else {
// console.log('Missing parameter(s): dataId, branch_id, or client_id');
// }
if (dataId == 1) {
$('#tpa').prop('required', false);
$('#tpa_danger').hide()
@ -617,28 +701,15 @@
$('#tpa_danger').show()
}
var base_policy_dataId = $('#base_policy').children('option:selected').attr('data-id');
if ($('#policy_type').val() == 1) {
// $('#base_policy option').each(function() {
// var val = $(this).val();
// if (val == id) {
// $(this)
// .hide(); // Hide the option if its value matches the selected value of #policy
// } else {
// $(this).show(); // Show all other options
// }
// });
if ($('#policy_type').val() == 1) {
// console.log('step 1')
// //console.log('step 1')
if (dataId == 3) {
// console.log('step 2')
// //console.log('step 2')
var displayStatus = $('#base_policy_id').css('display');
$('#base_policy_id').show();
@ -646,7 +717,7 @@
// $('#base_policy').prop('required', true);
if (displayStatus === 'none') {
// console.log('step 2.1')
// //console.log('step 2.1')
$('#base_policy').val('').change();
}
@ -655,7 +726,7 @@
} else {
// console.log('step 3')
// //console.log('step 3')
var displayStatus = $('#base_policy_id').css('display');
$('#base_policy_id').hide();
@ -663,7 +734,7 @@
// $('#base_policy').prop('required', false);
if (displayStatus === 'none') {
// console.log('step 3.1')
// //console.log('step 3.1')
$('#base_policy').val('').change();
}
@ -691,6 +762,10 @@
success: function(res) {
console.log('client_policy_res', res)
console.log('gst', res.data.gst);
var gst = (res.data.gst == 0.00) ? 18 : res.data.gst;
console.log(gst);
setTimeout(function() {
$('.loader').fadeOut();
@ -720,16 +795,18 @@
// $('#policy').val(res.data.policy_id).change();
$('#policy_type').val(res.data.is_addon).change();
$('#base_policy').val(res.data.base_policy);
$('#client_branch').val(res.data.client_branch_id).change();
$('#policy_type_id').val(res.data.policy_type_id);
$('#policy_PrimaryKey').val(res.data.id);
$('#insurer_policy_id').val(res.data.policy_id);
$('#policy_no').val(res.data.policy_no);
$('#start_date').val(rearrangeDateFormat(res.data.policy_start_date));
$('#end_date').val(rearrangeDateFormat(res.data.policy_end_date));
$('#policy_status').val(checkDateStatus(res.data.policy_end_date));
$('#gst_no').val(gst);
$('#policy_status_field').show();
if (res.data.inception_type == 2) {
$('#inception_type').prop('checked', true);
} else {
@ -841,6 +918,12 @@
}, 3000);
setTimeout(function(){
appendCDACNO(res.cd_data, res.data.cd_ac_no)
}, 3000)
$('#client_branch').val(res.data.client_branch_id).change();
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
@ -848,12 +931,13 @@
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.log('Something Wrong!', 'warning');
//console.log('Something Wrong!', 'warning');
}, 1000);
}
});
});
$('body').on('click', '.btnOpenEnroll', function() {
Swal.fire({
@ -938,11 +1022,11 @@
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
if (xhr.status === 404) {
console.log('Resource not found', 'Warning');
//console.log('Resource not found', 'Warning');
} else if (xhr.status === 500) {
console.log('Internal server error', 'Warning');
//console.log('Internal server error', 'Warning');
} else {
console.log('Unknown error occurred', 'Warning');
//console.log('Unknown error occurred', 'Warning');
}
}, 1000);
}
@ -1086,8 +1170,8 @@
const integerWord = convertNumberToWords(parseInt(integerPart, 10));
let result = `${integerWord}`;
console.log('decimalPart',decimalPart)
console.log('decimalPart',typeof decimalPart)
////console.log('decimalPart',decimalPart)
//console.log('decimalPart',typeof decimalPart)
if (decimalPart != '00' && decimalPart != undefined) {
result += ` and `;
@ -1110,17 +1194,17 @@
function formatNumber(input, maxLength) {
console.log("input", input);
console.log("input value", input.value);
//console.log("input", input);
//console.log("input value", input.value);
maxLength = 16;
let value = input.value.replace(/[^\d.]/g, ''); // Remove non-numeric characters
console.log('Remove non-numeric characters', value)
//console.log('Remove non-numeric characters', value)
// Limit the number of digits
value = value.slice(0, maxLength);
console.log('Limited value', value);
//console.log('Limited value', value);
// Format the number with commas using Indian numbering system
@ -1128,7 +1212,7 @@
maximumFractionDigits: 2
});
console.log('formetted value', value);
//console.log('formetted value', value);
input.value = (value);
@ -1195,7 +1279,7 @@
function removeClientPolicy(element) {
// console.log(element);
// //console.log(element);
}
@ -1247,8 +1331,6 @@
});
}
if ($(this).val() == 3) {
toastr.warning('Please Change the Policy Terms after Submit the Policy!', 'INFO');
}
@ -1286,7 +1368,7 @@
var client_id = $('#client_id_policy').val()
var client_branch_id = $('#client_branch').val()
// console.log('client_branch_id', client_branch_id)
// //console.log('client_branch_id', client_branch_id)
$.ajax({
url: '<?= base_url("util/featch-client-policy-list/") ?>' + client_id,
@ -1294,7 +1376,7 @@
dataType: 'json',
success: function(res) {
console.log('one', res)
//console.log('one', res)
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
@ -1308,7 +1390,7 @@
OptionsHTML += '<option value="" selected>Select Base Policy</option>';
$.each(res.data, function(index, item) {
// console.log('item.client_branch_id', item.client_branch_id)
// //console.log('item.client_branch_id', item.client_branch_id)
if (item.client_branch_id == client_branch_id) {
@ -1316,7 +1398,7 @@
if ($('#policy_type').val() == 1) {
if (item.policy_type_id == 1 || item.policy_type_id == 2) {
// console.log('if 2')
// //console.log('if 2')
OptionsHTML += '<option data-id="' + item.policy_type_id + '" value="' +
item.id +
'">' + item.name + '( ' + item.policy_type + ' )</option>';
@ -1338,7 +1420,7 @@
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.log('Something Wrong!', 'warning');
//console.log('Something Wrong!', 'warning');
}, 1000);
}
});
@ -1350,15 +1432,15 @@
$('#base_policy').change(function() {
var client_policy_id = $(this).val()
var client_policy_id = $(this).val() ? $(this).val() : 0;
var policy_type = $('#policy_type').val()
// console.log(client_policy_id);
// //console.log(client_policy_id);
dataId = $('#policy').children('option:selected').attr('data-id');
// console.log('dataId', dataId)
// //console.log('dataId', dataId)
base_policy_data_id = $(this).children('option:selected').attr('data-id');
// console.log('base_policy_data_id', base_policy_data_id);
// //console.log('base_policy_data_id', base_policy_data_id);
var queryParams = {
client_policy_id: client_policy_id,
@ -1368,8 +1450,8 @@
const queryString = objectToQueryString(queryParams);
// var uri = '<?= base_url('util/fetch-policy-for-policy-type') ?>?' + queryString
var uri = '<?= base_url('client/policy/list/') ?>' + client_policy_id
// console.log('uri', uri)
// console.log('queryString', queryString)
// //console.log('uri', uri)
// //console.log('queryString', queryString)
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
@ -1388,48 +1470,52 @@
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, 500);
if(res.status == true){
$('#insurer').val(res.data.insurer_branch_id + '-' + res.data.insurer_id)
.change();
$('#tpa').val(res.data.tpa_branch_id + '-' + res.data.tpa_id).change();
$('#policy_no').val(res.data.policy_no).change();
$('#start_date').val(rearrangeDateFormat(res.data.policy_start_date))
.change();
$('#end_date').val(rearrangeDateFormat(res.data.policy_end_date)).change();
$('#insurer').val(res.data.insurer_branch_id + '-' + res.data.insurer_id)
.change();
$('#tpa').val(res.data.tpa_branch_id + '-' + res.data.tpa_id).change();
$('#policy_no').val(res.data.policy_no).change();
$('#start_date').val(rearrangeDateFormat(res.data.policy_start_date))
.change();
$('#end_date').val(rearrangeDateFormat(res.data.policy_end_date)).change();
var policeOptionHTML = '';
$policy_type_value = $('#policy_type').val();
$.each(res.policy, function(index, item) {
var policeOptionHTML = '';
$policy_type_value = $('#policy_type').val();
$.each(res.policy, function(index, item) {
// console.log(item);
// //console.log(item);
policeOptionHTML += '<option data-id="' + item.policy_type_id +
'" value="' + item.id + '" ' + (res.data.policy_id === item
.id ?
'selected="selected"' : '') + '>' + item.name +
'</option>';
policeOptionHTML += '<option data-id="' + item.policy_type_id +
'" value="' + item.id + '" ' + (res.data.policy_id === item
.id ?
'selected="selected"' : '') + '>' + item.name +
'</option>';
});
});
$('#policy').html(policeOptionHTML);
$('#policy').html(policeOptionHTML);
if (dataId == 3 || policy_type == 1) {
if (dataId == 3 || policy_type == 1) {
// console.log('step 1')
// //console.log('step 1')
setTimeout(function() {
// //console.log('step 2')
var $option = $('#policy').find('option[data-id="3"]');
if ($option.length > 0) {
// //console.log('step 3')
$option.prop('selected', true).change();
} else {
// //console.log('step 4');
toastr.warning(
'The insurer does not have a GMC-Parents policy.',
'Warning');
}
}, 1500);
}
setTimeout(function() {
// console.log('step 2')
var $option = $('#policy').find('option[data-id="3"]');
if ($option.length > 0) {
// console.log('step 3')
$option.prop('selected', true).change();
} else {
// console.log('step 4');
toastr.warning(
'The insurer does not have a GMC-Parents policy.',
'Warning');
}
}, 1500);
}
},
@ -1439,7 +1525,7 @@
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.log('Something Wrong!', 'warning');
//console.log('Something Wrong!', 'warning');
}, 500);
}
});
@ -1454,7 +1540,7 @@
function fetchClientBranch() {
console.log('function called');
//console.log('function called');
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
@ -1478,8 +1564,8 @@
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.log(res);
// console.log(res.data.length);
//console.log(res);
// //console.log(res.data.length);
if (res.data.length == 0) {
toastr.warning('The client does not have any branches.', 'warning');
@ -1523,9 +1609,37 @@
$(document).ready(function() {
$("#client_branch").on('change', function() {
// console.log('fetchClientPolicyList change')
// //console.log('fetchClientPolicyList change')
fetchClientPolicyList();
});
})
function appendCDACNO(data, select = null) {
//console.log('appendCDACNO', data);
//console.log('appendCDACNO', select);
$('#cd_ac_no').empty();
$('#cd_ac_no').append($('<option>', {
value: '',
text: 'Select CD Account Number'
}));
$.each(data, function(index, item) {
const option = $('<option>', {
value: item.cd_ac_no,
text: item.cd_ac_no
});
if (select === item.cd_ac_no) {
//console.log('selected');
option.attr('selected', true);
}
$('#cd_ac_no').append(option);
});
}
</script>

View File

@ -16,7 +16,7 @@
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-4">
<label for="emp_code">Account Manager</label>
<label for="emp_code">Account Manager ( L2 )</label>
<select class="form-control" id="account_manager" name="account_manager[]" multiple>
<?php foreach($RM as $value) { ?>
<?php if($value['role'] === '3') { ?>
@ -26,7 +26,7 @@
</select>
</div>
<div class="form-group col-md-4">
<label for="profile">Manager</label>
<label for="profile">Manager ( L1 )</label>
<select class="form-control" id="manager" name="manager">user_id
<option value="">Select Manager</option>
<?php foreach($RM as $value) { ?>

View File

@ -76,7 +76,7 @@
<tr>
<td><b><?php echo ($key + 1)?></b></td>
<td><?php echo $employee['name']?>( <?php echo $employee['emp_code']?> - <?php echo $employee['relationship']?> )</td>
<td><?php echo $employee['policy_name']?></td>
<td><?php echo isset($employee['policy_name']) ? $employee['policy_name'] : '' ?> - <?php echo isset($employee['policy_no']) ? $employee['policy_no'] : '' ?> - <?php echo isset($employee['policy_type']) ? $employee['policy_type'] : '' ?></td>
<td><?php echo $employee['insurer_short_name']?></td>
<td><?php echo $employee['tpa_id']?></td>
<td><?php echo $employee['uhid']?></td>

View File

@ -59,6 +59,16 @@ table.dataTable tbody td {
</select>
</div>
<div class="form-group col-md-4">
<label>Employee Code</label> <br />
<input type="text" class="form-control" id="emp_code" name="emp_code" value="<?= isset($getData['emp_code']) && !empty($getData['emp_code']) ? $getData['emp_code'] : '' ?>">
</div>
<div class="form-group col-md-4">
<label>Employee Name</label> <br />
<input type="text" class="form-control" id="emp_name" name="emp_name" value="<?= isset($getData['emp_name']) && !empty($getData['emp_name']) ? $getData['emp_name'] : '' ?>">
</div>
</div>
<div class="row">
<div class="col-12" style="text-align: right;">
@ -243,7 +253,7 @@ function appendPolicies(data) {
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.client_policy_id,
text: item.name + ' - ' + item.policy_type
text: `${item.name ?? ''} - ${item.policy_no ?? ''} - ${item.policy_type ?? ''}`
});
if (PolicyID == item.client_policy_id) {
option.attr('selected', true);
@ -318,18 +328,22 @@ function fetchEmpolyeeList(event) {
var policy_id = $('#policies').val();
var status = $('#status2').val();
var branch_id = $('#branch_id').val();
var emp_code = $('#emp_code').val();
var emp_name = $('#emp_name').val();
// console.log(client_id + '-' + policy_id);
if (client_id == '0' || policy_id == '0') {
alert('Please select values in both dropdowns.');
return;
}
// if (client_id == '0' || policy_id == '0') {
// alert('Please select values in both dropdowns.');
// return;
// }
var queryParams = {
client_id: client_id,
policy_id: policy_id,
branch_id: branch_id,
emp_code : emp_code,
emp_name : emp_name,
status : status,
};

View File

@ -443,6 +443,7 @@ function fetchClientPolicies() {
},
error: function(xhr, status, error) {
console.error('Error fetching data from API:', error);
console.error(xhr.responseText);
}
});
@ -644,7 +645,7 @@ function appendPolicies(data) {
var option = $('<option>', {
value: item.client_policy_id,
text: item.name + ' - ' + item.policy_type
text:`${item.name ?? ''} - ${item.policy_no ?? ''} - ${item.policy_type ?? ''}`
});
if (client_policy_param == item.client_policy_id) {
option.attr('selected', true);
@ -869,7 +870,7 @@ $(document).ready(function() {
$('#policy_id').change(function(){
var selectedpolicy = $(this).val();
// console.log('selectedpolicy',selectedpolicy)
console.log('selectedpolicy',selectedpolicy)
$('#upload-action-type').val('').change();
$('#file_upload').hide();
$('#excel_download').removeAttr('href');
@ -885,27 +886,31 @@ $(document).ready(function() {
},
success: function(response) {
// console.log('responce data emp_count', response);
console.log('responce data emp_count', response);
if (response.code === 200 && response.dataStatus === true && response.data !== "") {
try {
// console.log(response.emp_count.length)
console.log(response.emp_count.length)
if(response.emp_count > 0){
var select = document.getElementById("upload-action-type");
for (var i = 0; i < select.options.length; i++) {
select.options[i].disabled = false;
if (select.options[i].value === "inception") {
select.options[i].disabled = true;
break;
// break;
}
}
}else{
}else {
var select = document.getElementById("upload-action-type");
for (var i = 0; i < select.options.length; i++) {
select.options[i].disabled = true;
if (select.options[i].value === "inception") {
select.options[i].disabled = false;
break;
}
if (select.options[i].value === "") {
select.options[i].disabled = false;
}
}
}
@ -933,6 +938,16 @@ $(document).ready(function() {
}
});
if($('#policy_id').val() == 0){
var select = document.getElementById("upload-action-type");
console.log('select', select)
for (var i = 0; i < select.options.length; i++) {
select.options[i].disabled = false;
console.log(select.options[i])
}
}
})
})

View File

@ -87,7 +87,7 @@
</div>
</div>
<table class="table table-hover m-0 table-centered dt-responsive nowrap w-100" cellspacing="0" id="tickets-table">
<table class="table table-hover m-0 table-centered dt-responsive w-100" cellspacing="0" id="tickets-table">
<thead class="bg-light">
<tr>
<th class="font-weight-medium">SNO</th>
@ -110,7 +110,7 @@
<tr>
<td><b><?php echo ($key + 1) ?></b></td>
<td><?php echo $employee['name'] ?>( <?php echo $employee['emp_code'] ?> )</td>
<td><?php echo isset($employee['policy_name']) ? $employee['policy_name'] : '' ?></td>
<td><?php echo isset($employee['policy_name']) ? $employee['policy_name'] : '' ?> - <?php echo isset($employee['policy_no']) ? $employee['policy_no'] : '' ?> - <?php echo isset($employee['policy_type']) ? $employee['policy_type'] : '' ?></td>
<td><?php echo $employee['endorsement_id'] ?></td>
<td><?php echo isset($employee['insurer_short_name']) ? $employee['insurer_short_name'] : '' ?>
</td>
@ -326,7 +326,7 @@
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.client_policy_id,
text: item.name
text: `${item.name ?? ''} - ${item.policy_no ?? ''} - ${item.policy_type ?? ''}`
});
if (PolicyID == item.client_policy_id) {
option.attr('selected', true);
@ -587,16 +587,25 @@
dom: "<'row'<'col-sm-0'f><'col-sm-9 text-right'B>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
"buttons": [{
"extend": 'csv',
"text": 'CSV',
"title": 'Endorsement-List',
"className": 'my_class',
"exportOptions": {
"columns": ':not(:last-child)'
},
buttons: [{
extend: 'csv',
text: 'CSV',
title: 'Endorsement-List',
className: 'my_class',
exportOptions: {
columns: ':not(:last-child)',
format: {
body: function (data, row, column, node) {
// Convert data to string to avoid scientific notation in CSV
if (!isNaN(data) && parseFloat(data) > 1e20) {
return `'${data}`;
}
return data.toString();// Ensures all data is treated as strings
}
}
}
}],
"initComplete": function(settings, json) {
initComplete: function(settings, json) {
$('.my_class').css({
"position": "relative",
"left": "79px"
@ -608,7 +617,12 @@
},
paging: true,
// pagingType: 'full_numbers'
columnDefs: [
{ type: 'scientific', targets: 0 } // Apply custom sorting type to the first column
],
});
});
</script>

View File

@ -45,10 +45,12 @@
<tr>
<td><b><?php echo ($key + 1) ?></b></td>
<td><?php echo $file['file_name'] ?></td>
<td style="overflow: hidden;" class="reload truncate" data-toggle="tooltip" data-placement="top" title="<?php echo $file['file_name'] ?>">
<?php echo $file['file_name']?>
</td>
<td><?php echo $file['short_name'] ?></td>
<td><?php echo $file['branch_name'] ?></td>
<td><?php echo $file['policy_name'] ?></td>
<td><?php echo isset($file['policy_name']) ? $file['policy_name'] : '' ?> - <?php echo isset($file['policy_no']) ? $file['policy_no'] : '' ?> - <?php echo isset($file['policy_type']) ? $file['policy_type'] : '' ?></td>
<td><?php echo $file['action'] ?></td>
<td><?php echo fancy_date_time_format($file['created_at']) . ' by <strong>' . $file['first_name'] . '</strong>' ?>
</td>

View File

@ -473,38 +473,48 @@
function removeInsurerBranch(element) {
var id = element.getAttribute('data-id');
var form_action = '<?= base_url("master/insurer/branch/remove/") ?>' + id;
$.ajax({
url: form_action,
type: "GET",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
// console.log(res.status == true);
if(res){
if (res.status == true) {
toastr.success('Remove Done!', 'success');
location.reload();
Swal.fire({
title: "Are you sure?",
text: "You need to remove this insurer branch.",
icon: "info",
showCancelButton: true,
confirmButtonColor: "#3085d6",
confirmButtonText: "Yes",
}).then((result) => {
if (result.isConfirmed) {
var id = element.getAttribute('data-id');
var form_action = '<?= base_url("master/insurer/branch/remove/") ?>' + id;
$.ajax({
url: form_action,
type: "GET",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
// console.log(res.status == true);
if(res){
if (res.status == true) {
toastr.success('Insurer branch removed successfully', 'success');
location.reload();
} else {
toastr.warning('Failed to remove insurer branch', 'warning');
}
}
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.warning('Failed to remove insurer branch', 'warning');
}
});
} else {
toastr.warning('Remove Not Done!', 'warning');
}
}
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.warning('Something Wrong!', 'warning');
}, 1000);
}
});
}
});
}
</script>

View File

@ -134,38 +134,47 @@ class csvExport {
function removeInsurer(element) {
var id = element.getAttribute('data-id');
var form_action = '<?= base_url("master/insurer/remove/") ?>' + id;
$.ajax({
url: form_action,
type: "GET",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
// console.log(res.status == true);
if(res){
if (res.status == true) {
toastr.success('Remove Done!', 'success');
location.reload();
Swal.fire({
title: "Are you sure?",
text: "You need to remove this insurer.",
icon: "info",
showCancelButton: true,
confirmButtonColor: "#3085d6",
confirmButtonText: "Yes",
}).then((result) => {
} else {
toastr.warning('Remove Not Done!', 'warning');
}
if (result.isConfirmed) {
var id = element.getAttribute('data-id');
var form_action = '<?= base_url("master/insurer/remove/") ?>' + id;
$.ajax({
url: form_action,
type: "GET",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
// console.log(res.status == true);
if(res){
if (res.status == true) {
toastr.success('Insurer removed successfully', 'success');
location.reload();
} else {
toastr.warning('Failed to remove insurer', 'warning');
}
}
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.warning('Failed to remove insurer', 'warning');
}
});
}
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.warning('Something Wrong!', 'warning');
}, 1000);
}
});
}

View File

@ -415,7 +415,7 @@
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.client_policy_id,
text: item.name + ' - ' + item.policy_type
text: `${item.name ?? ''} - ${item.policy_no ?? ''} - ${item.policy_type ?? ''}`
});
if (client_policy_param2 == item.client_policy_id) {
option.attr('selected', true);

View File

@ -323,38 +323,49 @@ $(document).ready(function () {
function removeKYCDocs(element) {
var kyc_docs_id_for_reload = $('#kyc_type_id').val();
var id = element.getAttribute('data-id');
var form_action = '<?= base_url("master/kyc/kycdocs/remove/") ?>' + id;
$.ajax({
url: form_action,
type: "GET",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
// console.log(res.status == true);
if(res){
if (res.status == true) {
toastr.success('Remove Done!', 'success');
// location.reload();
window.location.href = '<?= base_url("master/kyc/list/") ?>' + kyc_docs_id_for_reload;
Swal.fire({
title: "Are you sure?",
text: "You need to remove this!.",
icon: "info",
showCancelButton: true,
confirmButtonColor: "#3085d6",
confirmButtonText: "Yes",
}).then((result) => {
} else {
toastr.warning('Remove Not Done!', 'warning');
}
}
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.warning('Something Wrong!', 'warning');
}, 1000);
if (result.isConfirmed) {
var kyc_docs_id_for_reload = $('#kyc_type_id').val();
var id = element.getAttribute('data-id');
var form_action = '<?= base_url("master/kyc/kycdocs/remove/") ?>' + id;
$.ajax({
url: form_action,
type: "GET",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
// console.log(res.status == true);
if(res){
if (res.status == true) {
toastr.success('KYC docs removed successfully');
// location.reload();
window.location.href = '<?= base_url("master/kyc/list/") ?>' + kyc_docs_id_for_reload;
} else {
toastr.warning('Failed to remove KYC docs', 'warning');
}
}
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.warning('Failed to remove KYC docs', 'warning');
}
});
}
});
}

View File

@ -133,39 +133,49 @@ class csvExport {
function removeKYC(element) {
var id = element.getAttribute('data-id');
var form_action = '<?= base_url("master/kyc/remove/") ?>' + id;
$.ajax({
url: form_action,
type: "GET",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
// console.log(res.status == true);
if(res){
if (res.status == true) {
toastr.success('Remove Done!', 'success');
location.reload();
Swal.fire({
title: "Are you sure?",
text: "You need to remove this!",
icon: "info",
showCancelButton: true,
confirmButtonColor: "#3085d6",
confirmButtonText: "Yes",
}).then((result) => {
if (result.isConfirmed) {
var id = element.getAttribute('data-id');
var form_action = '<?= base_url("master/kyc/remove/") ?>' + id;
$.ajax({
url: form_action,
type: "GET",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
// console.log(res.status == true);
if(res){
if (res.status == true) {
toastr.success('KYC entity removed successfully', 'success');
} else {
toastr.warning('Remove Not Done!', 'warning');
location.reload();
} else {
toastr.warning('Failed to remove KYC entity', 'warning');
}
}
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.warning('Something Wrong!', 'warning');
}, 1000);
}
}
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.warning('Something Wrong!', 'warning');
}, 1000);
}
});
}
});
}

View File

@ -136,6 +136,7 @@
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
<script src="https://cdn.datatables.net/plug-ins/2.0.8/sorting/scientific.js"></script>
<script>
toastr.options = {
@ -159,7 +160,7 @@
method: 'GET',
success: function(response) {
console.log('responce', response)
// console.log('responce', response)
if(response.status == false){
$('#notification_count').html('0')

View File

@ -550,16 +550,17 @@
<a href="#sidebarDashboards" data-toggle="collapse" class="waves-effect">
<i class="fas fa-user-tie"></i>
<span class="badge badge-success badge-pill float-right">2</span>
<span> Employees </span>
<span> Members </span>
</a>
<div class="collapse" id="sidebarDashboards">
<ul class="nav-second-level">
<li>
<a href="<?= base_url('/employee/list') ?>">List</a>
</li>
<li>
<a href="<?= base_url('/employee/upload') ?>">Upload</a>
</li>
<li>
<a href="<?= base_url('/employee/list') ?>">List</a>
</li>
<li>
<a href="<?= base_url('/employee/endorsement-list') ?>">Endorsement List</a>
</li>
@ -587,6 +588,9 @@
<li>
<a href="<?= base_url('/master/policy/list') ?>">Policy</a>
</li>
<li>
<a href="<?= base_url('/master/cash_deposite/list') ?>">CD Master</a>
</li>
</ul>
</div>
</li>

View File

@ -0,0 +1,702 @@
<style>
.button-like {
display: inline-block;
padding: 8px 15px;
background-color: #02a8b5;
color: white;
text-decoration: none;
border-radius: 2px;
cursor: pointer;
margin-right: -85px;
}
.radiobuttondiv {
margin-left: 32px;
}
.form-control-client-policy-master {
width: 62% !important;
margin-left: 30px;
margin-top: 3px
}
/* .form-group.col-md-6 */
.form-group-client-policy-master {
display: -webkit-box;
max-width: 100% !important;
/* border:1px solid; */
/* background-color: #0001; */
}
.form-group-client-policy-masters {
display: -webkit-box;
max-width: 100% !important;
}
.flex-container {
display: block;
/* flex-wrap: wrap; */
/* align-items: center; Align items vertically center */
}
.flex-container>div {
flex: 1;
/* Each div takes equal space */
}
label {
padding-top: 7px;
width: 400px;
/* background-color: #0001; */
height: 36px;
/* text-align: center; */
}
.jodit-status-bar {
display: none;
}
.input-group {
width: 64.5% !important;
}
.input-group-append-client-policy-master {
margin-top: 3px;
}
.jodit-wysiwyg {
margin-bottom: 162px;
}
.form-control-client-policy-masters {
margin-left: 30px;
width: 689px;
}
</style>
<div id="OtherPolicyTermsForm" style="display:none">
<span id="otherPolicyTermsClose"
style="float: right;font-size: 26px;color: red;margin-top: -42px;margin-left: 3px;margin-right: 7px;">x</span>
<h5><label for="gpaTerms" style="margin-bottom: 20px;">Policy Terms <span
id="nameOfThePolicyOnOther"></span></label>
</h5>
<form role="form" class="parsley-examples" method="post" id="otherPolicyTerms" enctype="multipart/form-data">
<input type="hidden" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
<input type="hidden" name="client_id" id="Client_id" value="<?= isset($client['id']) ? $client['id'] : '' ?>" />
<input type="hidden" name="client_policy_id" id="other_client_policy_id" />
<input type="hidden" name="policy_id" id="gpa_policy_id" />
<input type="hidden" id="emp_count" />
<div id="append_html_for_other_policy_terms"></div>
<hr>
<div class="other_special_condition">
</div>
<br>
<div class="form-group text-right m-b-0" style="margin-top: -49px;">
<a href="#" class="button-like" id="otherButtonSpecialCondition" title="Special Condition">Special
Condition</a>
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1" id="btnOtherTermsSubmit"
style="margin-top: 100px;">Submit</button>
</div>
</div>
</form>
</div>
<script>
$("#otherPolicyTerms").submit(function(event) {
event.preventDefault();
var isValid = $('#otherPolicyTerms').parsley().validate();
console.log('isvalid', isValid);
if ($('#emp_count').val() == true) {
toastr.warning('Client has active employees', 'Warning');
return;
}
if (!isValid) {
console.log('Form is Empty', 'Warning');
return;
}
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
var formData = new FormData($('#otherPolicyTerms')[0]);
var policy_form_action = '<?= base_url("client/terms/other_terms") ?>';
// Convert the FormData object to a JSON object
const formObject = {};
formData.forEach((value, key) => {
if (key != 'csrf_test_name' && key != 'client_policy_id' && key != 'policy_id' && key !=
'client_id') {
if (key.endsWith('[]')) {
const baseKey = key.slice(0, -2);
if (!formObject[baseKey]) {
formObject[baseKey] = [];
}
formObject[baseKey].push(value.replace(/,/g, ''));
} else if(key == 'sum_insureds'){
formObject['sum_insured'] = value.replace(/,/g, '');
}
else {
formObject[key] = value;
}
}
});
console.log(formObject);
const jsonString = JSON.stringify(formObject);
console.log(jsonString);
// return;
// Append the JSON string to the FormData object
formData.append('policy_terms', jsonString);
$.ajax({
data: formData,
url: policy_form_action,
type: "POST",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
$('#otherPolicyTerms')[0].reset();
$('.text-danger-2').html('');
console.log(res);
if (res.status === false) {
toastr.error(res.message, 'Error');
return;
}
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, 1000);
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
}
});
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
$('#OtherPolicyTermsForm').css('display', 'none');
$('#police-tab').css('display', '');
$('.nav.nav-pills.navtab-bg').css('display', '');
$('.nav.nav-pills.navtab-bg').prev().css('display', '');
var message = 'Policy Terms Updated successfully';
toastr.success(message, 'Success');
}, 1000);
});
$('body').on('click', '.btnPolicyMaster', function() {
var client_policy_id = $(this).data('id');
var policy_type_id = $(this).data('typeid');
console.log('policy_type_id', policy_type_id);
console.log('client_policy_id :', client_policy_id);
$('#other_client_policy_id').val(client_policy_id);
appendPolicyTermsHTML(policy_type_id);
var gpa_policy_type_id = $(this).attr('id');
// console.log('gpa_policy_type_id', gpa_policy_type_id)
if (policy_type_id > 5) {
$('#OtherPolicyTermsForm').css('display', '');
$('#police-tab').css('display', 'none');
$('.nav.nav-pills.navtab-bg').css('display', 'none');
$('.nav.nav-pills.navtab-bg').prev().css('display', 'none');
$('.removeDom').remove()
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
$.ajax({
url: '<?= base_url("client/policy/getterms") ?>',
method: 'GET',
data: {
client_policy_id: client_policy_id
},
success: function(res) {
console.log('response of the other policy terms', res);
console.log('employee count', res.emp_count_by_policy);
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, 500);
$('#nameOfThePolicyOnOther').html(' - ' + res.policy_name.name);
$('#emp_count').val(res.count)
if (res.emp_count_by_policy != 0) {
$("#btnOtherTermsSubmit").hide();
$("#otherButtonSpecialCondition").hide();
} else {
$("#btnOtherTermsSubmit").show();
$("#otherButtonSpecialCondition").show();
}
if (res) {
//special conditions fields
let gpaJsonObjectForSpecialCondition = JSON.parse(res.data);
Object.keys(gpaJsonObjectForSpecialCondition).forEach(function(key) {
if (key.includes("other_special_condition_label") || key.includes(
"other_special_condition_input")) {
if (key.includes("other_special_condition_label")) {
for (let index = 0; index <
gpaJsonObjectForSpecialCondition[key].length; index++) {
specialConditionForOthers();
}
}
let elements = document.getElementsByName(`${key}[]`);
if (elements) {
elements.forEach((element, index) => {
if (gpaJsonObjectForSpecialCondition[key][
index
] == undefined) {
element.value = " ";
} else {
element.value =
gpaJsonObjectForSpecialCondition[key][
index
];
}
});
}
}
if (key.includes("multiple_sum_insured")) {
gpaJsonObjectForSpecialCondition[key].forEach((value, index) => {
appendOtherSIAddMore(value);
});
}
});
//normal terms fields
let jsonObject = JSON.parse(res.data);
Object.keys(jsonObject).forEach(function(key) {
console.log(key)
let elements = document.getElementsByName(key);
if(key == 'sum_insured'){
elements = document.getElementsByName('sum_insureds')
}
console.log(elements)
if (elements && elements.length > 0) {
let element = elements[0];
if (element.tagName === 'INPUT' && (element.type ===
'checkbox' || element.type === 'radio')) {
if (element.type === 'checkbox') {
element.checked = jsonObject[key] === '1';
} else if (element.type === 'radio') {
element.checked = element.value === jsonObject[key];
}
} else {
if (jsonObject[key] == undefined) {
element.value = " ";
} else {
element.value = jsonObject[key];
console.log(element);
console.log(jsonObject[key]);
console.log(element.value);
}
}
}
});
}
$('#sum_insured_others').trigger('keyup');
$(".multiple_sum_insured").trigger("keyup");
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.log('Something Wrong!', 'warning');
}
});
}
});
</script>
<script>
document.getElementById('otherButtonSpecialCondition').addEventListener('click', function(event) {
console.log('specialConditionForOthers callback clicked')
event.preventDefault();
specialConditionForOthers();
});
function specialConditionForOthers(count = 0) {
console.log('specialConditionForOthers function called')
console.log('before if count', count)
if (count === 0) {
console.log('after if count', count)
var index = $('.modifyclassinput').length;
var appendElement = `<div class="form-group col-md-6 form-group-client-policy-masters removeDom">
<label for="specialconditionlabel" class="special_condition_label[]" style="width: 450px;position: relative;bottom: 6px;">
<input class="form-control" name="other_special_condition_label[]" id="other_special_condition_label[]" style="position: relative;right: 15px;">
<span class="specialConditionClose" style="color: red; float: right;position: relative;bottom: 28px;left: 15px;">X</span>
</label>
<input type="text" name="other_special_condition_input[]" id="other_special_condition_input[]" class="form-control s special_condition_input[]">
</div>`;
console.log($(this));
$('.other_special_condition').each(function() {
$(this).append(appendElement);
});
} else {
console.log('else')
}
}
$(document).on('click', '#otherPolicyTermsClose', function() {
$('#OtherPolicyTermsForm').css('display', 'none');
$('#police-tab').css('display', '');
$('.nav.nav-pills.navtab-bg').css('display', '');
$('.nav.nav-pills.navtab-bg').prev().css('display', '');
$('#otherPolicyTerms')[0].reset();
$('.text-danger-2').html('');
});
$("#sum_insured_others").on("keyup", function() {
var inputNumber = $(this).val();
console.log('sum_insured_others keyup', inputNumber)
if (inputNumber) {
var result = convertCommaNumberToWords(inputNumber);
$("#numberToWordOthers").text(result);
} else {
$("#numberToWordOthers").text("");
}
});
$("#totalSumInsured").on("keyup", function() {
var inputNumber = $(this).val();
if (inputNumber) {
var result = convertCommaNumberToWords(inputNumber);
$("#numberToWordTotalSumInsured").text(result);
} else {
$("#numberToWordTotalSumInsured").text("");
}
});
function si_keup_num_to_word2(input) {
console.log('keyup sum insured');
var inputNumber = $(input).val();
console.log(inputNumber)
if (inputNumber) {
var result = convertCommaNumberToWords(inputNumber);
$("#numberToWordOthers").text(result);
} else {
$("#numberToWordOthers").text("");
}
};
function appendPolicyTermsHTML(policy_type) {
var termsHTML = ""
$('#append_html_for_other_policy_terms').empty();
if (policy_type == 7) {
termsHTML = `
<div class="form-group">
<div class="row" style="margin-bottom: 10px;">
<div class="col-md-6">
<label for="sumInsured">Sum Insured</label>
</div>
<div class="col-md-4">
<input style="width: 128%;" type="text" name="sum_insureds" id="sum_insured_others" class="form-control" onkeypress = "return onlyNumbers(event)" onkeyup=" formatNumber(this); si_keup_num_to_word2(this)">
</div>
<div class="col-md-2" style="position: relative;left: 88px;">
<button type="button" class="btn btn-primary si-add-more" onclick="appendOtherSIAddMore()">+</button>
</div>
<div class="col-md-6">
</div>
<div class="col-md-6">
<div id='numberToWordOthers' class="text-danger-2" ></div>
</div>
</div>
<div id="sum_insured_add_more" ></div>
<div class="row" style="margin-bottom: 10px;">
<div class="col-md-6">
<label for="totalSumInsured">Policy Type</label>
</div>
<div class="col-md-6">
<input type="text" name="policy_type" id="policy_type" class="form-control">
</div>
</div>
<div class="row" style="margin-bottom: 10px;">
<div class="col-md-6">
<label for="totalSumInsured">Existing Insurer</label>
</div>
<div class="col-md-6">
<input type="text" name="existing_insurer" id="existing_insurer" class="form-control">
</div>
</div>
<div class="row" style="margin-bottom: 10px;">
<div class="col-md-6">
<label for="renewal_lives">Renewal Lives</label>
</div>
<div class="col-md-6">
<input type="text" name="renewal_lives" id="renewal_lives" class="form-control">
</div>
</div>
<div class="row" style="margin-bottom: 10px;">
<div class="col-md-6">
<label for="totalSumInsured">Total Sum Assured</label>
</div>
<div class="col-md-6">
<input type="text" style="width: 100% !important;" class="form-control" name="total_sum_insured"
id="total_sum_insured" onkeypress="return onlyNumbers(event)" onkeyup="formatNumber(this)">
</div>
<div class="col-md-6">
</div>
<div class="col-md-6">
<div id='numberToWordTotalSumInsured' class="text-danger-2"></div>
</div>
</div>
<div class="row" style="margin-bottom: 10px;display:true;">
<div class="col-md-6">
<label for="lives_at_inception">Lives at Inception</label>
</div>
<div class="col-md-6">
<input type="text" name="lives_at_inception" id="lives_at_inception" class="form-control">
</div>
</div>
<div class="row" style="margin-bottom: 10px;display:true;">
<div class="col-md-6">
<label for="totalSumInsured">Total Sum Insured at Inception</label>
</div>
<div class="col-md-6">
<input type="text" name="total_sum_insured_at_inception" id="total_sum_insured_at_inception"
class="form-control" onkeypress="return onlyNumbers(event)" onkeyup="formatNumber(this)">
</div>
</div>
<div class="row" style="margin-bottom: 10px;display:true;">
<div class="col-md-6">
<label for="totalSumInsured">Premium at Inception (Excl GST)</label>
</div>
<div class="col-md-6">
<input type="text" name="premium_at_inception" id="premium_at_inception" class="form-control">
</div>
</div>
<div class="row" style="margin-bottom: 10px;display:true;">
<div class="col-md-6">
<label for="coverage">Coverage</label>
</div>
<div class="col-md-6">
<input type="text" name="coverage " id="coverage" class="form-control">
</div>
</div>
<div class="row" style="margin-bottom: 10px;display:true;">
<div class="col-md-6">
<label for="free_cover_limit">Free Cover Limit</label>
</div>
<div class="col-md-6">
<input type="text" name="free_cover_limit" id="free_cover_limit" class="form-control">
</div>
</div>
</div>
`
} else if (policy_type == 6) {
termsHTML = `
<div class="form-group EDLI">
<div class="row" style="margin-bottom: 10px;">
<div class="col-md-6">
<label for="sumInsured">Sum Insured</label>
</div>
<div class="col-md-4" >
<input style="width: 128%;" type="text" name="sum_insureds" id="sum_insured_others" class="form-control" onkeypress = "return onlyNumbers(event)" onkeyup=" formatNumber(this); si_keup_num_to_word2(this)">
</div>
<div class="col-md-2" style="position: relative;left: 88px;">
<button type="button" class="btn btn-primary si-add-more" onclick="appendOtherSIAddMore()">+</button>
</div>
<div class="col-md-6">
</div>
<div class="col-md-6">
<div id='numberToWordOthers' class="text-danger-2" ></div>
</div>
</div>
<div id="sum_insured_add_more" ></div>
<div class="row" style="margin-bottom: 10px;">
<div class="col-md-6">
<label for="totalSumInsured">Existing Insurer</label>
</div>
<div class="col-md-6">
<input type="text" name="existing_insurer" id="existing_insurer" class="form-control">
</div>
</div>
<div class="row" style="margin-bottom: 10px;">
<div class="col-md-6">
<label for="renewal_lives">Renewal Lives</label>
</div>
<div class="col-md-6">
<input type="text" name="renewal_lives" id="renewal_lives" class="form-control">
</div>
</div>
<div class="row" style="margin-bottom: 10px;display:true;">
<div class="col-md-6">
<label for="lives_at_inception">Lives at Inception</label>
</div>
<div class="col-md-6">
<input type="text" name="lives_at_inception" id="lives_at_inception" class="form-control">
</div>
</div>
<div class="row" style="margin-bottom: 10px;display:true;">
<div class="col-md-6">
<label for="totalSumInsured">Total Sum Insured at Inception</label>
</div>
<div class="col-md-6">
<input type="text" name="total_sum_insured_at_inception" id="total_sum_insured_at_inception"
class="form-control" onkeypress="return onlyNumbers(event)" onkeyup="formatNumber(this)">
</div>
</div>
<div class="row" style="margin-bottom: 10px;display:true;">
<div class="col-md-6">
<label for="coverage">Coverage</label>
</div>
<div class="col-md-6">
<input type="text" name="coverage " id="coverage" class="form-control">
</div>
</div>
<div class="row" style="margin-bottom: 10px;display:true;">
<div class="col-md-6">
<label for="free_cover_limit">Free Cover Limit for Base Cover</label>
</div>
<div class="col-md-6">
<input type="text" name="free_cover_limit_for_base_cover" id="free_cover_limit_for_base_cover" class="form-control">
</div>
</div>
</div>
`
}
$('#append_html_for_other_policy_terms').append(termsHTML);
}
function appendOtherSIAddMore(data = null) {
const addMoreContainer = document.getElementById('sum_insured_add_more');
console.log(addMoreContainer)
const html = `
<div class="row" style="margin-bottom: 10px;">
<div class="col-md-6">
<label for="sumInsured">Additional Sum Insured</label>
</div>
<div class="col-md-4">
<input style="width: 128%;" value="${data ? data : ''}" type="text" name="multiple_sum_insured[]" class="form-control multiple_sum_insured" onkeypress="return onlyNumbers(event)" onkeyup="formatNumber(this); numtowordinkeyup(this)">
</div>
<div class="col-md-2" style="position: relative;left: 88px;">
<button type="button" class="btn btn-danger si-remove-multi" onclick="removeGMCAdditionalSI(this)">x</button>
<button type="button" class="btn btn-primary si-add-more" onclick="appendOtherSIAddMore()">+</button>
</div>
<div class="col-md-6">
</div>
<div class="col-md-6">
<div class="text-danger-2 numberToWordSumInsured"></div>
</div>
</div>`;
addMoreContainer.insertAdjacentHTML('beforeend', html);
}
</script>

View File

@ -396,42 +396,52 @@ $(document).ready(function () {
function removePolicies(element) {
var policy_id_for_reload = $('#policy_type_id').val()
var id = element.getAttribute('data-id');
var form_action = '<?= base_url("master/policy/policies/remove/") ?>' + id;
$.ajax({
url: form_action,
type: "GET",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
// console.log(res.status == true);
if(res){
if (res.status == true) {
toastr.success('Remove Done!', 'success');
// $('#branch_table').empty();
Swal.fire({
title: "Are you sure?",
text: "You need to remove this Policy.",
icon: "info",
showCancelButton: true,
confirmButtonColor: "#3085d6",
confirmButtonText: "Yes",
}).then((result) => {
// location.reload();
window.location.href = '<?= base_url("master/policy/list/") ?>' + policy_id_for_reload;
if (result.isConfirmed) {
var policy_id_for_reload = $('#policy_type_id').val()
var id = element.getAttribute('data-id');
var form_action = '<?= base_url("master/policy/policies/remove/") ?>' + id;
$.ajax({
url: form_action,
type: "GET",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
// console.log(res.status == true);
if(res){
if (res.status == true) {
toastr.success('Policy removed successfully', 'success');
// $('#branch_table').empty();
// location.reload();
window.location.href = '<?= base_url("master/policy/list/") ?>' + policy_id_for_reload;
} else {
toastr.warning('Remove Not Done!', 'warning');
}
}
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.warning('Something Wrong!', 'warning');
}, 1000);
} else {
toastr.warning('Failed to remove policy', 'warning');
}
}
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.warning('Failed to remove policy', 'warning');
}
});
}
});
}
}
</script>

View File

@ -110,9 +110,12 @@
<div class="col-md-6">
<label for="sumInsured">Sum Insured</label>
</div>
<div class="col-md-6">
<input type="text" name="sum_insured" id="sum_insured" class="form-control" onkeypress = "return onlyNumbers(event)" onkeyup=" formatNumber(this)">
<div class="col-md-4">
<input style="width: 128%;" type="text" name="sum_insured" id="sum_insured" class="form-control" onkeypress = "return onlyNumbers(event)" onkeyup=" formatNumber(this); si_keup_num_to_word(this)">
</div>
<div class="col-md-2" style="position: relative;left: 88px;">
<button type="button" class="btn btn-primary si-add-more" onclick="appendGMCSIAddMore()">+</button>
</div>
<div class="col-md-6">
</div>
<div class="col-md-6">
@ -120,6 +123,8 @@
</div>
</div>
<div id="gmc_si_add_more"></div>
<div class="row" style="margin-bottom: 10px;">
<div class="col-md-6">
<label for="totalSumInsured">Family Floater</label>
@ -136,14 +141,14 @@
<tr>
<td style="width: 11%;"><span style="margin-right: 20px;">Self:</span></td>
<td style="width: 11%;"><input type="checkbox" style="margin-right: 70px;" name="family_floaters[]" value="self" id="self" checked> </td>
<td style="width: 28%;" ><div class="self-age"><span style="margin-right: 20px;">Min Age:</span><input class="underline-input min_age" value="<?php echo (isset($self_min_age) && $self_min_age > 0) ? $self_min_age : '18'; ?>" style="width: 25%;;" type="number" name="self_min_age" id="self_min_age" oninput="lowerIsEighteen(this)"></div></td>
<td style="width: 28%;" ><div class="self-age"><span style="margin-right: 20px;">Max Age:</span><input class="underline-input max_age" value="<?php echo isset($self_max_age) ? $self_max_age : '60'; ?>" style="width: 25%;;" type="number" name="self_max_age" id="self_max_age" oninput="this.value = this.value.replace(/\D/g, '').substring(0, 2)"></div></td>
<td style="width: 28%;" ><div class="self-age"><span style="margin-right: 20px;">Min Age:</span><input class="underline-input min_age" value="<?php echo (isset($self_min_age) && $self_min_age > 0) ? $self_min_age : '18'; ?>" style="width: 35%;;" type="number" name="self_min_age" id="self_min_age" onchange="lowerIsEighteen(this)"></div></td>
<td style="width: 28%;" ><div class="self-age"><span style="margin-right: 20px;">Max Age:</span><input class="underline-input max_age" value="<?php echo isset($self_max_age) ? $self_max_age : '60'; ?>" style="width: 35%;;" type="number" name="self_max_age" id="self_max_age" onchange="lowerIsEighteen(this)"></div></td>
</tr><tr><td></td></tr><tr><td></td></tr><tr><td></td></tr>
<tr>
<td style="width: 11%;"><span style="margin-right: 20px;">Spouse:</span></td>
<td style="width: 11%;"><input type="checkbox" style="margin-right: 70px;"name="family_floaters[]" value="spouse" id="spouse"></td>
<td style="width: 28%;" ><div class="spouse-age"><span style="margin-right: 20px;">Min Age:</span><input class="underline-input min_age" value="<?php echo isset($spouse_min_age) ? $spouse_min_age : '18'; ?>" style="width: 25%;;" type="number" name="spouse_min_age" id="spouse_min_age" oninput="lowerIsEighteen(this)"></div></td>
<td style="width: 28%;" ><div class="spouse-age"><span style="margin-right: 20px;">Max Age:</span><input class="underline-input max_age" value="<?php echo isset($spouse_max_age) ? $spouse_max_age : '60'; ?>" style="width: 25%;;" type="number" name="spouse_max_age" id="spouse_max_age" ></div></td>
<td style="width: 28%;" ><div class="spouse-age"><span style="margin-right: 20px;">Min Age:</span><input class="underline-input min_age" value="<?php echo isset($spouse_min_age) ? $spouse_min_age : '18'; ?>" style="width: 35%;;" type="number" name="spouse_min_age" id="spouse_min_age" onchange="lowerIsEighteen(this)"></div></td>
<td style="width: 28%;" ><div class="spouse-age"><span style="margin-right: 20px;">Max Age:</span><input class="underline-input max_age" value="<?php echo isset($spouse_max_age) ? $spouse_max_age : '60'; ?>" style="width: 35%;;" type="number" name="spouse_max_age" id="spouse_max_age" onchange="lowerIsEighteen(this)"></div></td>
</tr><tr><td></td></tr><tr><td></td></tr><tr><td></td></tr>
<tr>
<td style="width: 11%;"><span for="children">Children:</span></td>
@ -155,8 +160,8 @@
<option value="4">4</option>
</select>
</td>
<td style="width: 28%;" ><div class="child-age"><span style="margin-right: 20px;">Min Age:</span><input class="underline-input min_age" value="<?php echo isset($child_min_age) ? $child_min_age : '0'; ?>" style="width: 25%;;" type="number" name="child_min_age" id="child_min_age" oninput="this.value = this.value.replace(/\D/g, '').substring(0, 2)"></div></td>
<td style="width: 28%;" ><div class="child-age"><span style="margin-right: 20px;">Max Age:</span><input class="underline-input max_age" value="<?php echo isset($child_max_age) ? $child_max_age : '25'; ?>" style="width: 25%;;" type="number" name="child_max_age" id="child_max_age" oninput="this.value = this.value.replace(/\D/g, '').substring(0, 2)"></div></td>
<td style="width: 28%;" ><div class="child-age"><span style="margin-right: 20px;">Min Age:</span><input class="underline-input min_age" value="<?php echo isset($child_min_age) ? $child_min_age : '0'; ?>" style="width: 35%;;" type="number" name="child_min_age" id="child_min_age" oninput="this.value = this.value.replace(/\D/g, '').substring(0, 2)"></div></td>
<td style="width: 28%;" ><div class="child-age"><span style="margin-right: 20px;">Max Age:</span><input class="underline-input max_age" value="<?php echo isset($child_max_age) ? $child_max_age : '25'; ?>" style="width: 35%;;" type="number" name="child_max_age" id="child_max_age" oninput="this.value = this.value.replace(/\D/g, '').substring(0, 2)"></div></td>
</tr><tr><td></td></tr><tr><td></td></tr><tr><td></td></tr>
</tbody>
</table>
@ -184,21 +189,19 @@
<table>
<tbody>
<tr>
<td style="width: 22%;" ><div class="other-member-age"><span style="margin-right: 20px;">Elders Count:</span><input class="underline-input" id="member_count" style="width: 25%;;" type="number" name="member_count" disabled id="member_count"></div></td>
<td style="width: 28%;" ><div class="other-member-age"><span style="margin-right: 20px;">Min Age:</span><input class="underline-input min_age" value="<?php echo isset($other_member_min_age) ? $other_member_min_age : '18'; ?>" style="width: 25%;;" type="number" class="underline-input min_age" name="other_member_min_age" id="other_member_min_age" oninput="lowerIsEighteen(this)"></div></td>
<td style="width: 28%;" ><div class="other-member-age"><span style="margin-right: 20px;">Max Age:</span><input class="underline-input max_age" value="<?php echo isset($other_member_max_age) ? $other_member_max_age : '60'; ?>" style="width: 25%;;" type="number" class="underline-input max_age" name="other_member_max_age" id="other_member_max_age" ></div></td>
<td style="width: 22%;" ><div class="other-member-age"><span style="margin-right: 20px;">Elders Count:</span><input class="underline-input" id="member_count" style="width: 30%; width: 30%;background: lightgray;" type="number" name="elder_member_count" id="member_count" readonly></div></td>
<td style="width: 28%;" ><div class="other-member-age" style="margin-left: 32px;"><span style="margin-right: 20px;">Min Age:</span><input class="underline-input min_age" value="<?php echo isset($other_member_min_age) ? $other_member_min_age : '18'; ?>" style="width: 35%;;" type="number" class="underline-input min_age" name="other_member_min_age" id="other_member_min_age" onchange="lowerIsEighteen(this)"></div></td>
<td style="width: 28%;" ><div class="other-member-age" style="margin-left: 17px;"><span style="margin-right: 20px;">Max Age:</span><input class="underline-input max_age" value="<?php echo isset($other_member_max_age) ? $other_member_max_age : '60'; ?>" style="width: 35%;;" type="number" class="underline-input max_age" name="other_member_max_age" id="other_member_max_age" onchange="lowerIsEighteen(this)"></div></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<hr>
<div class="row" style="margin-bottom: 10px;display:none;">
<!-- <div class="row" style="margin-bottom: 10px;display:none;">
<div class="col-md-6">
<label for="totalSumInsured">Corporate Buffer</label>
</div>
@ -206,7 +209,7 @@
<input type="radio" name="corporatebuffer" value="1"> Yes
<input type="radio" name="corporatebuffer" value="0" style="margin-left:10px"> No
</div>
</div>
</div> -->
<div class="row" style="margin-bottom: 10px;">
@ -305,6 +308,15 @@
</div>
</div>
<div class="row" style="margin-bottom: 10px;">
<div class="col-md-6">
<label for="totalSumInsured">Post Hospitalization Cover</label>
</div>
<div class="col-md-6">
<input type="text" name="posthospitalizationcover" id="posthospitalizationcover" class="form-control ">
</div>
</div>
<div class="row" style="margin-bottom: 10px;">
<div class="col-md-6">
<label for="totalSumInsured">Congenital Diseases - Internal</label>
@ -315,6 +327,15 @@
</div>
</div>
<div class="row" style="margin-bottom: 10px;">
<div class="col-md-6">
<label for="totalSumInsured">Congenital Diseases - External</label>
</div>
<div class="col-md-6">
<input type="text" name="congenitaldiseasesexternal" id="congenitaldiseasesexternal" class="form-control ">
</div>
</div>
<div class="row" style="margin-bottom: 10px;">
<div class="col-md-6">
<label for="totalSumInsured">Co-Pay/Zone wise Co Pay</label>
@ -323,6 +344,29 @@
<select name="copayzonewisecopay" id="copayzonewisecopay" class="form-control ">
<option value="">Select an option</option>
<option value="Nil">Nil</option>
<option value="5%">5%</option>
<option value="10%">10%</option>
<option value="15%">15%</option>
<option value="20%">20%</option>
<option value="25%">25%</option>
<option value="30%">30%</option>
<option value="35%">35%</option>
<option value="40%">40%</option>
<option value="45%">45%</option>
<option value="50%">50%</option>
</select>
</div>
</div>
<div class="row" style="margin-bottom: 10px;">
<div class="col-md-6">
<label for="totalSumInsured">Optional Parental Co-Pay</label>
</div>
<div class="col-md-6">
<select name="optionalparentalcopay" id="optionalparentalcopay" class="form-control ">
<option value="">Select an option</option>
<option value="Nil">Nil</option>
<option value="5%">5%</option>
<option value="10%">10%</option>
<option value="15%">15%</option>
<option value="20%">20%</option>
@ -367,14 +411,14 @@
</div>
</div>
<div class="row" style="margin-bottom: 10px;">
<!-- <div class="row" style="margin-bottom: 10px;">
<div class="col-md-6">
<label for="totalSumInsured">Nursing Allowance</label>
</div>
<div class="col-md-6">
<input type="text" name="nursingallowance" id="nursingallowance" class="form-control ">
</div>
</div>
</div> -->
<div class="row" style="margin-bottom: 10px;">
<div class="col-md-6">
@ -386,6 +430,24 @@
</div>
</div>
<div class="row" style="margin-bottom: 10px;">
<div class="col-md-6">
<label for="totalSumInsured">Corporate Buffer</label>
</div>
<div class="col-md-6">
<input type="text" name="corporatebuffer" id="corporatebuffer" class="form-control ">
</div>
</div>
<div class="row" style="margin-bottom: 10px;">
<div class="col-md-6">
<label for="totalSumInsured">Sublimit of Corporate Buffer</label>
</div>
<div class="col-md-6">
<input type="text" name="sublimitofcorporatebuffer" id="sublimitofcorporatebuffer" class="form-control ">
</div>
</div>
<div class="row" style="margin-bottom: 10px;">
<div class="col-md-6">
<label for="totalSumInsured">Ambulance Charges</label>
@ -445,7 +507,7 @@
<div class="row" style="margin-bottom: 10px;display:none;">
<div class="col-md-6">
<label for="totalSumInsured">AYUSH treatment cover Data</label>
<label for="totalSumInsured">AYUSH treatment cover Limit</label>
</div>
<div class="col-md-6">
<input type="text" name="ayushTreatmentCoverData" id="ayushTreatmentCoverData" class="form-control">
@ -575,7 +637,7 @@
<div class="row" style="margin-bottom: 10px;display:none;">
<div class="col-md-6">
<label for="totalSumInsured">Cataract Data</label>
<label for="totalSumInsured">Cataract Limit</label>
</div>
<div class="col-md-6">
<input type="text" name="cataractData" id="cataractData" class="form-control">
@ -615,7 +677,7 @@
// $('input[name="family_floater"]').change(function() {
// console.log($(this).val());
// //console.log($(this).val());
// if ($(this).val() == '1') {
// var element = $(this).parent().next()[0];
// $(element).css("display", "block");
@ -631,7 +693,7 @@
$('input[name="ayudhtreatmentcover"]').change(function() {
console.log($(this).val());
////console.log($(this).val());
if ($(this).val() == '1') {
var element = $(this).parent().parent().next()[0];
@ -645,7 +707,7 @@
$('input[name="cataract"]').change(function() {
console.log($(this).val());
//console.log($(this).val());
if ($(this).val() == '1') {
var element = $(this).parent().parent().next()[0];
@ -715,7 +777,7 @@
}
if (!isValid) {
console.log('Form is Empty', 'Warning');
//console.log('Form is Empty', 'Warning');
return;
}
@ -751,7 +813,7 @@
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.log('Something Wrong!', 'warning');
//console.log('Something Wrong!', 'warning');
}, 1000);
}
});
@ -773,14 +835,15 @@
$('body').on('click', '.btnPolicyMaster', function() {
var client_policy_id = $(this).data('id');
console.log('gmc_client_policy_id :', client_policy_id);
//console.log('gmc_client_policy_id :', client_policy_id);
$('#gmc_client_policy_id').val(client_policy_id)
$('.removeDom').remove();
$('#gmc_si_add_more').empty();
var gmc_policy_type_id = $(this).attr('id');
// console.log(gmc_policy_type_id)
// //console.log(gmc_policy_type_id)
if (gmc_policy_type_id == 'GMC') {
@ -798,10 +861,10 @@
client_policy_id: client_policy_id
},
success: function(response) {
console.log('response', response);
//console.log('response', response);
// console.log('count', response.count);
// //console.log('count', response.count);
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
@ -809,18 +872,18 @@
$('#nameOfThePolicyInGMC').html(' - ' + response.policy_name.name);
$('gmc_emp_count').val(response.count);
// console.log('count--1', response.count);
// //console.log('count--1', response.count);
// $('emp_count').val(response.count)
// if (response && response.hasOwnProperty('count')) {
// if (response.count === false) {
// console.log('count -- 2', response.count);
// console.log(document.getElementById('btnGridSubmit1'))
// //console.log('count -- 2', response.count);
// //console.log(document.getElementById('btnGridSubmit1'))
// $("#btnGridSubmit1").hide();
// $("#myButtonSpecialCondition").hide();
// } else {
// $("#btnGridSubmit1").show();
// $("#myButtonSpecialCondition").show();
// console.log('count -- ', response.count);
// //console.log('count -- ', response.count);
// }
// } else {
// console.error('Response object does not have a "count" property or is invalid.');
@ -849,13 +912,13 @@
}
}
console.log('key', key)
//console.log('key', key)
let elements = document.getElementsByName(`${key}[]`);
console.log(elements)
//console.log(elements)
if (elements) {
elements.forEach((element, index) => {
console.log()
//console.log()
if(jsonObject[key][index] == undefined){
element.value = " ";
}else{
@ -865,12 +928,30 @@
}
}
// if (key.includes("multiple_sum_insured")) {
// jsonObject[key].forEach((value, index) => {
// appendGMCSIAddMore(value);
// });
// }
if (key.includes("multiple_sum_insured") && key != "") {
if (Array.isArray(jsonObject[key])) {
jsonObject[key].forEach((value, index) => {
appendGMCSIAddMore(value);
});
} else {
console.error(`${key} is not an array.`);
}
}
if (key.includes("family_floaters")) {
let checkboxes = document.querySelectorAll(`input[name="${key}[]"]`);
if (jsonObject[key]) {
console.log(jsonObject[key]);
// console.log(jsonObject[key]);
//console.log(jsonObject[key]);
// //console.log(jsonObject[key]);
if (jsonObject[key].childrens) {
$('#children').val(jsonObject[key].childrens);
}
@ -916,8 +997,11 @@
$('.waiverof1234thyearexclusions').prop('disabled', true);
$('.waiverof30dayswaitingperiod').prop('disabled', true);
$('#prehospitalizationcover').prop('disabled', true);
$('#posthospitalizationcover').prop('disabled', true);
$('.congenitaldiseasesinternal').prop('disabled', true);
$('#congenitaldiseasesexternal').prop('disabled', true);
$('#copayzonewisecopay').prop('disabled', true);
$('#optionalparentalcopay').prop('disabled', true);
$('#bioabsorbablestenttoriclensmultifocallens').prop('disabled', true);
$('#roomrentlimit').prop('disabled', true);
$('#proportionatedeductionclause').prop('disabled', true);
@ -939,6 +1023,8 @@
$('#moderntreatmentsasperirdai').prop('disabled', true);
$('#days_of_discharge').prop('disabled', true);
$('#days_from_dod').prop('disabled', true);
$('#corporatebuffer').prop('disabled', true);
$('#sublimitofcorporatebuffer').prop('disabled', true);
setTimeout(function() {
var editor1 = new Jodit('#additionalsicknessbenefit');
@ -998,7 +1084,7 @@
pTag.innerHTML = jsonObject[key]; // Add your new content inside the <p> tag
}
}
// console.log(jsonObject[key]);
// //console.log(jsonObject[key]);
} else {
if(jsonObject[key] == undefined){
@ -1027,7 +1113,8 @@
});
}
$("#sum_insured").trigger("keyup");
$(".multiple_sum_insured").trigger("keyup");
$('.jodit-wysiwyg').each(function() {
$(this).click();
});
@ -1047,8 +1134,8 @@
$('.spouse-age').css('display','none');
}
console.log("child ");
console.log($('#children').val());
//console.log("child ");
//console.log($('#children').val());
if($('#children').val() != 0){
$('.child-age').css('display','');
@ -1087,7 +1174,7 @@
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.log('Something Wrong!', 'warning');
//console.log('Something Wrong!', 'warning');
}, 1000);
}
});
@ -1109,8 +1196,8 @@
$('.spouse-age').css('display','none');
}
console.log("child ");
console.log($('#children').val());
//console.log("child ");
//console.log($('#children').val());
if($('#children').val() != 0){
$('.child-age').css('display','');
@ -1145,8 +1232,11 @@
});
$("#sum_insured").on("keyup", function() {
var inputNumber = $(this).val();
function si_keup_num_to_word(input) {
console.log('keyup sum insured');
var inputNumber = $(input).val();
console.log(inputNumber)
if (inputNumber) {
var result = convertCommaNumberToWords(inputNumber);
@ -1154,7 +1244,7 @@
} else {
$("#numberToWordGMC").text("");
}
});
};
</script>
@ -1179,7 +1269,7 @@
<script>
document.getElementById('myButtonSpecialCondition').addEventListener('click', function(event) {
console.log('specialCondition callback clicked')
//console.log('specialCondition callback clicked')
event.preventDefault();
specialCondition();
@ -1188,13 +1278,13 @@
function specialCondition(count = 0) {
console.log('specialCondition function called')
//console.log('specialCondition function called')
console.log('before if count', count)
//console.log('before if count', count)
if (count === 0) {
console.log('after if count', count)
//console.log('after if count', count)
var index = $('.modifyclassinput').length;
var appendElement = `<div class="form-group col-md-6 form-group-client-policy-masters removeDom">
@ -1204,13 +1294,13 @@
</label>
<input type="text" name="special_condition_input[]" id="special_condition_input[]" class="form-control s special_condition_input[]">
</div>`;
console.log($(this));
//console.log($(this));
$('.form-column').each(function() {
$(this).append(appendElement);
});
} else {
console.log('else')
//console.log('else')
}
}
@ -1319,12 +1409,45 @@
function lowerIsEighteen(params) {
var value = $(params).val();
if($(params).val() < 18){
if (value < 18) {
$(params).val(18);
} else if (value > 99) {
$(params).val(99);
}
}
function appendGMCSIAddMore(data = null){
console.log('function called')
var html = `
<div class="row" style="margin-bottom: 10px;">
<div class="col-md-6">
<label for="sumInsured">Additional Sum Insured</label>
</div>
<div class="col-md-4">
<input style="width: 128%;" value="${data == null || data == undefined || data == "" ? '' : data}" type="text" name="multiple_sum_insured[]" class="form-control multiple_sum_insured" onkeypress="return onlyNumbers(event)" onkeyup="formatNumber(this); numtowordinkeyup(this)">
</div>
<div class="col-md-2" style="position: relative;left: 88px;">
<button type="button" class="btn btn-danger si-remove-multi" onclick="removeGMCAdditionalSI(this)">x</button>
<button type="button" class="btn btn-primary si-add-more" onclick="appendGMCSIAddMore()">+</button>
</div>
<div class="col-md-6">
</div>
<div class="col-md-6">
<div class="text-danger-2 numberToWordSumInsured"></div>
</div>
</div>`;
$('#gmc_si_add_more').append(html);
}
function removeGMCAdditionalSI(button) {
console.log('remove clicked');
$(button).closest('.row').remove();
}
</script>

View File

@ -90,16 +90,21 @@
<div class="col-md-6">
<label for="sumInsured">Sum Insured</label>
</div>
<div class="col-md-6">
<input class="form-control" type="text" name="sumInsured2" id="sumInsured2" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" style="width: 100% !important;">
<div class="col-md-4">
<input style="width: 128%;" class="form-control" type="text" name="sumInsured2" id="sumInsured2" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" style="width: 100% !important;">
</div>
<div class="col-md-6">
<div class="col-md-2" style="position: relative;left: 88px;">
<button type="button" class="btn btn-primary si-add-more" onclick="appendGPASIAddMore()">+</button>
</div>
<div class="col-md-6">
</div>
<div class="col-md-6">
<div id='numberToWordSumInsured' class="text-danger-2" ></div>
</div>
</div>
<div id="gpa_si_add_more"></div>
<div class="row" style="margin-bottom: 10px;">
<div class="col-md-6">
<label for="totalSumInsured">Total Sum Assured</label>
@ -132,13 +137,13 @@
<td style="width: 20%;">
<div class="self-age">
<span style="margin-right: 20px;">Min Age:</span>
<input class="underline-input min_age" value="<?php echo isset($self_min_age) ? $self_min_age : '18'; ?>" style="width: 44%;" type="number" name="self_min_age" id="self_min_age_gpa" oninput="this.value = this.value.replace(/\D/g, '').substring(0, 2)">
<input class="underline-input min_age" value="<?php echo isset($self_min_age) ? $self_min_age : '18'; ?>" style="width: 65%;" type="number" name="self_min_age" id="self_min_age_gpa" onchange="lowerIsEighteen(this)">
</div>
</td>
<td style="width: 20%;">
<div class="self-age">
<span style="margin-right: 20px;">Max Age:</span>
<input class="underline-input max_age" value="<?php echo isset($self_max_age) ? $self_max_age : '60'; ?>" style="width: 44%;" type="number" name="self_max_age" id="self_max_age_gpa" oninput="this.value = this.value.replace(/\D/g, '').substring(0, 2)">
<input class="underline-input max_age" value="<?php echo isset($self_max_age) ? $self_max_age : '60'; ?>" style="width: 65%;" type="number" name="self_max_age" id="self_max_age_gpa" onchange="lowerIsEighteen(this)">
</div>
</td>
<td ></td>
@ -569,6 +574,18 @@
});
}
}
if (key.includes("multiple_sum_insured") && key != "") {
if (Array.isArray(gpaJsonObjectForSpecialCondition[key])) {
gpaJsonObjectForSpecialCondition[key].forEach((value, index) => {
appendGPASIAddMore(value);
});
} else {
console.error(`${key} is not an array.`);
}
}
});
let jsonObject = JSON.parse(res.data);
@ -634,6 +651,7 @@
}
$("#sumInsured2").trigger("keyup");
$('.multiple_sum_insured').trigger("keyup");
$("#totalSumInsured").trigger("keyup");
@ -651,7 +669,7 @@
});
} else if (gpa_policy_type_id != 'GPA' && gpa_policy_type_id != 'GMC') {
toastr.warning("This policy has no policy terms.", 'warning');
// toastr.warning("This policy has no policy terms.", 'warning');
}
});
@ -723,6 +741,41 @@
}
});
$(".multiple_sum_insured").on("keyup", function() {
console.log('multiple_sum_insured key up')
var inputNumber = $(this).val();
console.log('inputNumber', inputNumber);
if (inputNumber) {
var result = convertCommaNumberToWords(inputNumber);
console.log(result);
$(".numberToWordSumInsured").text(result);
} else {
$(".numberToWordSumInsured").text("");
}
});
function numtowordinkeyup(input){
console.log('testing......')
console.log(input);
var inputNumber = $(input).val();
console.log('inputNumber', inputNumber);
if (inputNumber) {
var result = convertCommaNumberToWords(inputNumber);
console.log(result);
var $parentRow = $(input).closest('.row');
console.log('$parentRow', $parentRow)
var $targetDiv = $parentRow.find('.numberToWordSumInsured');
$targetDiv.text(result)
console.log('$targetDiv', $targetDiv)
}
}
$("#totalSumInsured").on("keyup", function() {
var inputNumber = $(this).val();
@ -735,16 +788,29 @@
});
function appendGPASIAddMore(data = null){
console.log('function called')
// function formatNumber(input) {
// Remove non-numeric characters
// let value = input.value.replace(/\D/g, '');
var html = `
<div class="row" style="margin-bottom: 10px;">
<div class="col-md-6">
<label for="sumInsured">Additional Sum Insured</label>
</div>
<div class="col-md-4">
<input style="width: 128%;" value="${data == null || data == undefined || data == "" ? '' : data}" type="text" name="multiple_sum_insured[]" class="form-control multiple_sum_insured" onkeypress="return onlyNumbers(event)" onkeyup="formatNumber(this); numtowordinkeyup(this)">
</div>
<div class="col-md-2" style="position: relative;left: 88px;">
<button type="button" class="btn btn-danger si-remove-multi" onclick="removeGMCAdditionalSI(this)">x</button>
<button type="button" class="btn btn-primary si-add-more" onclick="appendGPASIAddMore()">+</button>
</div>
<div class="col-md-6">
</div>
<div class="col-md-6">
<div class="text-danger-2 numberToWordSumInsured"></div>
</div>
</div>`;
// Add commas
// value = Number(value).toLocaleString('en-IN');
// Update the input value
// input.value = value;
// }
$('#gpa_si_add_more').append(html);
}
</script>

File diff suppressed because it is too large Load Diff

View File

@ -30,383 +30,542 @@ th {
<script>
const formatType = 0; // Specify the format type here
const excel_headers = {
const formatType = 0; // Specify the format type here
const excel_headers = {
1: {
1: {
"sum_insured": "Sum Insured",
},
2: {
"basic_pay": "Basic Pay",
},
3: {
"band_or_grade": "Band or Grade",
"sum_insured": "Sum Insured",
"premium": "Premium"
},
4: {
"sum_insured": "Sum Insured",
"from_age": "From Age",
"to_age": "To Age",
"premium": "Premium"
},
5: {
"sum_insured": "Sum Insured",
"from_age": "From Age",
"to_age": "To Age",
"premium": "Premium"
},
6: {
"sum_insured": "Sum Insured",
"from_age": "From Age",
"to_age": "To Age",
"premium": "Premium"
},
7: {
"sum_insured": "Sum Insured",
"from_age": "From Age",
"to_age": "To Age",
"premium": "Premium"
},
8: {
"sum_insured": "Sum Insured",
"grade": "Grade",
"premium": "Premium"
},
9: {
"sum_insured": "Sum Insured",
"premium": "Premium"
},
10: {
"sum_insured": "Sum Insured",
"from_age": "From Age",
"to_age": "To Age",
"premium": "Premium"
},
11: {
"sum_insured": "Sum Insured",
"grade": "Grade",
"premium": "Premium",
"max_si": "Max Si"
},
12: {
"sum_insured": "Sum Insured",
"relationship": "Relationship",
"premium": "Premium"
},
13: {
"sum_insured": "Sum Insured",
"relationship": "Relationship",
"from_age": "From Age",
"to_age": "To Age",
"premium": "Premium"
}
};
function slugify(text) {
return text.toString().toLowerCase().replace(/\s+/g, '_').replace(/[^\w\-]+/g, '').replace(/\-\-+/g, '_')
.replace(/^-+/, '').replace(/-+$/, '');
},
2: {
"sum_insured": "Sum Insured",
"premium": "Premium"
},
3: {
"sum_insured": "Sum Insured",
"premium": "Premium"
},
4: {
"sum_insured": "Sum Insured",
"from_age": "From Age",
"to_age": "To Age",
"premium": "Premium"
},
5: {
"sum_insured": "Sum Insured",
"from_age": "From Age",
"to_age": "To Age",
"premium": "Premium"
},
6: {
"sum_insured": "Sum Insured",
"from_age": "From Age",
"to_age": "To Age",
"premium": "Premium"
},
7: {
"sum_insured": "Sum Insured",
"from_age": "From Age",
"to_age": "To Age",
"premium": "Premium"
},
8: {
"sum_insured": "Sum Insured",
"grade": "Grade",
"premium": "Premium"
},
9: {
"sum_insured": "Sum Insured",
"premium": "Premium"
},
10: {
"sum_insured": "Sum Insured",
"from_age": "From Age",
"to_age": "To Age",
"premium": "Premium"
},
11: {
"sum_insured": "Sum Insured",
"grade": "Grade",
"premium": "Premium",
"max_si": "Max Si"
},
12: {
"sum_insured": "Sum Insured",
"relationship": "Relationship",
"premium": "Premium"
},
13: {
"sum_insured": "Sum Insured",
"relationship": "Relationship",
"from_age": "From Age",
"to_age": "To Age",
"premium": "Premium"
}
function copyHeaders(rack_rate_type) {
};
let formatType = $('#grid').val();
var obj = $('#grid');
if(rack_rate_type == 1){
formatType = $('#additional_grid').val();
obj = $('#additional_grid');
}
function slugify(text) {
return text.toString().toLowerCase().replace(/\s+/g, '_').replace(/[^\w\-]+/g, '').replace(/\-\-+/g, '_')
.replace(/^-+/, '').replace(/-+$/, '');
}
console.log(obj)
console.log(formatType)
function copyHeaders(rack_rate_type) {
if(!formatType && formatType == ""){
toastr.warning('Please select the Policy Premium Type', 'Warning');
return;
}
const headerString = Object.values(excel_headers[formatType]).join("\t"); // Using specified format type for copying headers
navigator.clipboard.writeText(headerString).then(function() {
toastr.success('Headers copied to clipboard', 'success');
}, function(err) {
toastr.error(err, 'Could not copy headers:');
});
let formatType = $('#grid').val();
var secondKey = $('#si_or_bp').val();
var obj = $('#grid');
if (rack_rate_type == 1) {
formatType = $('#additional_grid').val();
obj = $('#additional_grid');
}
function generateTable(rack_rate_type) {
var data = $('#copied_excel_data').val();
let formatType = $('#grid').val();
var obj = $('#grid');
if (rack_rate_type == 1) {
data = $('#additional_copied_excel_data').val();
formatType = $('#additional_grid').val();
obj = $('#additional_grid');
}
console.log(obj);
console.log(formatType);
console.log(data);
if (!formatType || formatType == "") {
$('.excel_table_class').empty();
$('.excel_textarea').val('');
toastr.warning('Please select the Policy Premium Type', 'Warning');
if (formatType == 1) {
if (secondKey == "") {
toastr.warning('Please select the Basic Pay, Sum Insured or Band/Grade', 'Warning');
return;
}
}
// Check if Excel data is empty
if (!data.trim()) {
toastr.warning('Excel data is empty.', 'Warning');
return;
// //console.log(obj)
// //console.log(formatType)
// //console.log(rack_rate_type)
if (!formatType && formatType == "") {
toastr.warning('Please select the Policy Premium Type', 'Warning');
return;
}
// //console.log('after toastr')
// //console.log('excel_headers[formatType]', excel_headers[formatType])
// //console.log('excel_headers[formatType]', typeof excel_headers[formatType])
if (excel_headers[formatType] == undefined) {
toastr.error('Headers not found', 'Warning');
return;
}
var headerString = Object.values(excel_headers[formatType]).join(
"\t"); // Using specified format type for copying headers
if (formatType == 1) {
var headerString = Object.values(excel_headers[formatType][secondKey]).join(
"\t"); // Using specified format type for copying headers
}
//console.log('headerString', headerString);
navigator.clipboard.writeText(headerString).then(function() {
toastr.success('Headers copied to clipboard', 'success');
}, function(err) {
toastr.error(err, 'Could not copy headers:');
});
}
function generateTable(rack_rate_type) {
var data = $('#copied_excel_data').val();
let formatType = $('#grid').val();
var obj = $('#grid');
var secondKey = $('#si_or_bp').val();
if (rack_rate_type == 1) {
data = $('#additional_copied_excel_data').val();
formatType = $('#additional_grid').val();
obj = $('#additional_grid');
}
//console.log(obj);
//console.log(formatType);
//console.log(data);
console.log(secondKey);
if (!formatType || formatType == "") {
$('.excel_table_class').empty();
$('.excel_textarea').val('');
toastr.warning('Please select the Policy Premium Type', 'Warning');
return;
}
// Check if Excel data is empty
if (!data.trim()) {
toastr.warning('Excel data is empty.', 'Warning');
return;
}
var rows = data.split("\n");
//console.log('rows', rows)
// Filter out empty rows
rows = rows.filter(rowText => rowText.split("\t").some(cell => cell.trim()));
//console.log('rows', rows)
if (rows.length === 0) {
toastr.warning('All rows are empty after filtering.', 'Warning');
return;
}
var header = rows[0].split("\t");
console
// Determine the columns to keep (non-empty columns)
var columnsToKeep = [];
for (let i = 0; i < header.length; i++) {
if (rows.some(rowText => rowText.split("\t")[i].trim())) {
columnsToKeep.push(i);
}
}
var rows = data.split("\n");
// Filter header based on columns to keep
header = columnsToKeep.map(i => slugify(header[i]));
// Filter out empty rows
rows = rows.filter(rowText => rowText.split("\t").some(cell => cell.trim()));
if (!excel_headers[formatType]) {
toastr.warning("Unknown format type. Please check the header columns.", 'Warning');
$('.excel_table_class').empty();
$('.excel_textarea').val('');
return;
}
if (rows.length === 0) {
toastr.warning('All rows are empty after filtering.', 'Warning');
return;
}
var expectedHeader = Object.keys(excel_headers[formatType]);
//console.log('expectedHeader 1st', expectedHeader);
var header = rows[0].split("\t");
// Determine the columns to keep (non-empty columns)
var columnsToKeep = [];
for (let i = 0; i < header.length; i++) {
if (rows.some(rowText => rowText.split("\t")[i].trim())) {
columnsToKeep.push(i);
}
}
if (formatType == 1) {
// Filter header based on columns to keep
header = columnsToKeep.map(i => slugify(header[i]));
//console.log('si_or_bp secondKey', secondKey)
expectedHeader = Object.keys(excel_headers[formatType][secondKey]);
}
if (!excel_headers[formatType]) {
toastr.warning("Unknown format type. Please check the header columns.", 'Warning');
$('.excel_table_class').empty();
$('.excel_textarea').val('');
return;
}
//console.log('expectedHeader', expectedHeader);
//console.log('HEADERS' , JSON.stringify(header))
//console.log('Excepted HEADERS' , JSON.stringify(expectedHeader))
var expectedHeader = Object.keys(excel_headers[formatType]);
if (JSON.stringify(header) !== JSON.stringify(expectedHeader)) {
const expectedHeaders = JSON.stringify(Object.values(excel_headers[formatType]));
const receivedHeaders = JSON.stringify(columnsToKeep.map(i => rows[0].split("\t")[i]));
if (secondKey != 2) {
Swal.fire({
title: "Header Mismatch",
html: `
if (JSON.stringify(header) !== JSON.stringify(expectedHeader)) {
const expectedHeaders = JSON.stringify(Object.values(excel_headers[formatType][secondKey]));
const receivedHeaders = JSON.stringify(columnsToKeep.map(i => rows[0].split("\t")[i]));
Swal.fire({
title: "Header Mismatch",
html: `
<p>Header columns do not match expected format:</p>
<p><strong>Expected:</strong> ${expectedHeaders}</p>
<p><strong>Received:</strong> ${receivedHeaders}</p>
`,
icon: "error"
});
$('.excel_table_class').empty();
$('.excel_textarea').val('');
icon: "error"
});
$('.excel_table_class').empty();
$('.excel_textarea').val('');
return;
}
}
var table = $('<table class="table table-striped compact-table" />');
var uniqueRows = new Set();
var emptyCellCount = 0;
rows.forEach((rowText, y) => {
var cells = rowText.split("\t").filter((_, i) => columnsToKeep.includes(i));
var row = $('<tr />');
// Skip empty rows after filtering columns
if (cells.every(cell => !cell.trim())) {
return;
}
var table = $('<table class="table table-striped compact-table" />');
var uniqueRows = new Set();
var emptyCellCount = 0;
rows.forEach((rowText, y) => {
var cells = rowText.split("\t").filter((_, i) => columnsToKeep.includes(i));
var row = $('<tr />');
// Skip empty rows after filtering columns
if (cells.every(cell => !cell.trim())) {
return;
cells.forEach(cellText => {
row.append('<td>' + cellText + '</td>');
if (!cellText.trim()) {
emptyCellCount++;
}
cells.forEach(cellText => {
row.append('<td>' + cellText + '</td>');
if (!cellText.trim()) {
emptyCellCount++;
}
});
var key;
switch (formatType) {
case 3:
key = cells[0] + "|" + cells[1] // Sum Insured, Premium
break;
case 4:
key = cells[0] + "|" + cells[1] + "|" + cells[2] + "|" + cells[3]; // Sum Insured, From Age, To Age, Premium
break;
case 5:
key = cells[0] + "|" + cells[1] + "|" + cells[2] + "|" + cells[3]; // Sum Insured, From Age, To Age, Premium
break;
case 6:
key = cells[0] + "|" + cells[1] + "|" + cells[2] + "|" + cells[3]; // Sum Insured, From Age, To Age, Premium
break;
case 7:
key = cells[0] + "|" + cells[1] + "|" + cells[2] + "|" + cells[3]; // Sum Insured, From Age, To Age, Premium
break;
case 8:
key = cells[0] + "|" + cells[1] + "|" + cells[2]; // Sum Insured, Grade, Premium
break;
case 9:
key = cells[0] + "|" + cells[1]; // Sum Insured, Premium
break;
case 10:
key = cells[0] + "|" + cells[1] + "|" + cells[2] + "|" + cells[3]; // Sum Insured, From Age, To Age, Premium
break;
case 11:
key = cells[0] + "|" + cells[1] + "|" + cells[2] + "|" + cells[3]; // Sum Insured, Grade, Premium, Max SI
break;
case 12:
key = cells[0] + "|" + cells[1] + "|" + cells[2]; // Sum Insured, Relationship, Premium
break;
case 13:
key = cells[0] + "|" + cells[1] + "|" + cells[2] + "|" + cells[3] + "|" + cells[4]; // Sum Insured, Relationship, From Age, To Age, Premium
break;
default:
key = cells.join("|");
}
if (y > 0 && uniqueRows.has(key)) {
row.addClass('duplicate');
} else {
uniqueRows.add(key);
}
table.append(row);
});
if (rack_rate_type == 1) {
$('#additional_excel_table').empty();
$('#additional_excel_table').html(table);
} else if (rack_rate_type == 0) {
$('#excel_table').empty();
$('#excel_table').html(table);
var si_or_bp = $('#si_or_bp').val();
var key;
switch (formatType) {
case 1:
if (si_or_bp == 1) {
key = cells[0] // Sum Insured,
} else if (si_or_bp == 2) {
key = cells[0] //Basic Pay
} else if (si_or_bp == 3) {
key = cells[0] + "|" + cells[1] //Band or Grade, Sum Insured
}
break;
case 2:
key = cells[0] + "|" + cells[1] // Sum Insured, Premium
break;
case 3:
key = cells[0] + "|" + cells[1] // Sum Insured, Premium
break;
case 4:
key = cells[0] + "|" + cells[1] + "|" + cells[2] + "|" + cells[
3]; // Sum Insured, From Age, To Age, Premium
break;
case 5:
key = cells[0] + "|" + cells[1] + "|" + cells[2] + "|" + cells[
3]; // Sum Insured, From Age, To Age, Premium
break;
case 6:
key = cells[0] + "|" + cells[1] + "|" + cells[2] + "|" + cells[
3]; // Sum Insured, From Age, To Age, Premium
break;
case 7:
key = cells[0] + "|" + cells[1] + "|" + cells[2] + "|" + cells[
3]; // Sum Insured, From Age, To Age, Premium
break;
case 8:
key = cells[0] + "|" + cells[1] + "|" + cells[2]; // Sum Insured, Grade, Premium
break;
case 9:
key = cells[0] + "|" + cells[1]; // Sum Insured, Premium
break;
case 10:
key = cells[0] + "|" + cells[1] + "|" + cells[2] + "|" + cells[
3]; // Sum Insured, From Age, To Age, Premium
break;
case 11:
key = cells[0] + "|" + cells[1] + "|" + cells[2] + "|" + cells[
3]; // Sum Insured, Grade, Premium, Max SI
break;
case 12:
key = cells[0] + "|" + cells[1] + "|" + cells[2]; // Sum Insured, Relationship, Premium
break;
case 13:
key = cells[0] + "|" + cells[1] + "|" + cells[2] + "|" + cells[3] + "|" + cells[
4]; // Sum Insured, Relationship, From Age, To Age, Premium
break;
default:
key = cells.join("|");
}
if (y > 0 && uniqueRows.has(key)) {
row.addClass('duplicate');
} else {
uniqueRows.add(key);
}
table.append(row);
});
if (rack_rate_type == 1) {
$('#additional_excel_table').empty();
$('#additional_excel_table').html(table);
} else if (rack_rate_type == 0) {
$('#excel_table').empty();
$('#excel_table').html(table);
}
if(secondKey != 2){
console.log(secondKey)
if ($('.duplicate').length > 0) {
console.log('test');
//console.log('test');
toastr.warning("Duplicates found!", "warning");
$('.excel_table_class').empty();
$('.excel_textarea').val('');
}
if (emptyCellCount > 0) {
toastr.warning('Number of empty cells: ' + emptyCellCount);
$('.excel_table_class').empty();
$('.excel_textarea').val('');
}
submitData(rack_rate_type);
}
function submitData(rack_rate_type) {
if (emptyCellCount > 0) {
toastr.warning('Number of empty cells: ' + emptyCellCount);
$('.excel_table_class').empty();
$('.excel_textarea').val('');
}
submitData(rack_rate_type);
}
let formatType = $('#grid').val();
var table = $('#excel_table table');
var obj = $('#grid');
function submitData(rack_rate_type) {
if(rack_rate_type == 1){
let formatType = $('#grid').val();
var table = $('#excel_table table');
var obj = $('#grid');
formatType = $('#additional_grid').val();
table = $('#additional_excel_table table');
obj = $('#additional_grid');
var si_or_bp = $('#si_or_bp').val();
var basic_multiplier = $('#basic_multiplier').val();
var premium_multiplier = $('#premium_multiplier').val();
var gpa_sum_multiplier2 = $('#gpa_sum_multiplier2').val();
var gpa_sum_multiplier = $('#gpa_sum_multiplier').val();
if (rack_rate_type == 1) {
formatType = $('#additional_grid').val();
table = $('#additional_excel_table table');
obj = $('#additional_grid');
}
var headers = $(table).find('tr').first().find('td').map(function() {
return slugify($(this).text());
}).get();
var rows = $(table).find('tr:gt(0)').map(function() {
return $(this).find('td').map(function() {
return $(this).text();
}).get();
}).get();
var jsonData = [];
$(table).find('tr:gt(0)').each(function(idx) {
var row = $(this).find('td').map(function() {
return $(this).text();
}).get();
var rowData = {};
row.forEach((cell, colIdx) => {
rowData[headers[colIdx]] = cell;
});
jsonData.push(rowData);
});
//console.log(jsonData);
jsonData.forEach(obj => {
// console.log('obj', obj)
// console.log('length of the obj', obj.length)
if ('sum_insured' in obj) {
obj.si = obj.sum_insured;
delete obj.sum_insured;
}
var headers = $(table).find('tr').first().find('td').map(function() {
return slugify($(this).text());
}).get();
var rows = $(table).find('tr:gt(0)').map(function() {
return $(this).find('td').map(function() {
return $(this).text();
}).get();
}).get();
var jsonData = [];
$(table).find('tr:gt(0)').each(function(idx) {
var row = $(this).find('td').map(function() {
return $(this).text();
}).get();
var rowData = {};
row.forEach((cell, colIdx) => {
rowData[headers[colIdx]] = cell;
});
jsonData.push(rowData);
});
console.log(jsonData);
jsonData.forEach(obj => {
if ('sum_insured' in obj) {
obj.si = obj.sum_insured;
delete obj.sum_insured;
}
if ('from_age' in obj) {
obj.age_from = obj.from_age;
delete obj.from_age;
}
if ('to_age' in obj) {
obj.age_to = obj.to_age;
delete obj.to_age;
}
});
console.log(jsonData);
if(rack_rate_type == 1){
$('#additional_grid_content_input').empty()
if ($('#copyfromexcelforadditional').text() == "Manual entry") {
$('#copyfromexcelforadditional').text("Copy from excel")
} else {
$('#copyfromexcelforadditional').text("Copy from excel");
}
$('#additional_grid_content_input').toggle();
$('#additional_grid_content_from_excel').toggle();
}else{
$('#grid_content_input').empty()
if ($('#copyfromexcel').text() == "Manual entry") {
$('#copyfromexcel').text("Copy from excel")
} else {
$('#copyfromexcel').text("Copy from excel");
}
$('#grid_content_input').toggle();
$('#grid_content_from_excel').toggle();
if ('from_age' in obj) {
obj.age_from = obj.from_age;
delete obj.from_age;
}
$.each(jsonData, function(index, item) {
appendGridtHtml(formatType, rack_rate_type, item)
});
if ('to_age' in obj) {
obj.age_to = obj.to_age;
delete obj.to_age;
}
if ('band_or_grade' in obj) {
obj.grade = obj.band_or_grade;
delete obj.band_or_grade;
}
$('input[name="11_max_si[]"]').each(function() {
$(this).trigger('keyup');
});
if (formatType == 1) {
if (si_or_bp == 1) {
$(`input[name="${formatType}_si[]"]`).each(function() {
// console.log($(this));
$(this).trigger('keyup');
});
obj.si_or_bp = si_or_bp;
obj.multiplier = gpa_sum_multiplier ? gpa_sum_multiplier : 0;
$(`input[name="${formatType}_premium[]"]`).each(function() {
// console.log($(this));
$(this).trigger('keyup');
});
} else if (si_or_bp == 2) {
obj.si_or_bp = si_or_bp;
obj.basic_multiplier = basic_multiplier ? basic_multiplier : 0;
obj.multiplier = premium_multiplier ? premium_multiplier : 0;
obj.si = obj.basic_pay * obj.basic_multiplier
obj.premium = obj.si * obj.multiplier / 1000
} else if (si_or_bp == 3) {
obj.si_or_bp = si_or_bp;
obj.multiplier = gpa_sum_multiplier2 ? gpa_sum_multiplier2 : 0;
}
}
});
console.log(jsonData);
if (rack_rate_type == 1) {
$('#additional_grid_content_input').empty()
if ($('#copyfromexcelforadditional').text() == "Manual entry") {
$('#copyfromexcelforadditional').text("Copy from excel")
} else {
$('#copyfromexcelforadditional').text("Copy from excel");
}
$('#additional_grid_content_input').toggle();
$('#additional_grid_content_from_excel').toggle();
} else {
$('#grid_content_input').empty()
if ($('#copyfromexcel').text() == "Manual entry") {
$('#copyfromexcel').text("Copy from excel")
} else {
$('#copyfromexcel').text("Copy from excel");
}
$('#grid_content_input').toggle();
$('#grid_content_from_excel').toggle();
}
if (formatType == 1 || formatType == 2) {
var FirstIndex = jsonData[0]
addGridHTML(false, FirstIndex, formatType, si_or_bp, 0)
jsonData.shift();
}
$.each(jsonData, function(index, item) {
appendGridtHtml(formatType, rack_rate_type, item)
});
$('input[name="11_max_si[]"]').each(function() {
$(this).trigger('keyup');
});
$(`input[name="${formatType}_si[]"]`).each(function() {
// //console.log($(this));
$(this).trigger('keyup');
$(this).trigger('change').keyup();
});
$(`input[name="${formatType}_premium[]"]`).each(function() {
// //console.log($(this));
$(this).trigger('keyup');
$(this).trigger('change').keyup();
});
$(`input[name="basic_pay[]"]`).each(function() {
// //console.log($(this));
$(this).trigger('keyup');
$(this).trigger('change').keyup();
});
$(`input[name="gpa_basic_si[]"]`).each(function() {
// //console.log($(this));
$(this).trigger('keyup');
$(this).trigger('change').keyup();
});
$(`input[name="gpa_basic_premium[]"]`).each(function() {
// //console.log($(this));
$(this).trigger('keyup');
$(this).trigger('change').keyup();
});
}
</script>

View File

@ -138,38 +138,47 @@ class csvExport {
function removePolciyType(element) {
var id = element.getAttribute('data-id');
var form_action = '<?= base_url("master/policy/remove/") ?>' + id;
$.ajax({
url: form_action,
type: "GET",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
// console.log(res.status == true);
if(res){
if (res.status == true) {
toastr.success('Remove Done!', 'success');
location.reload();
Swal.fire({
title: "Are you sure?",
text: "You need to remove this!",
icon: "info",
showCancelButton: true,
confirmButtonColor: "#3085d6",
confirmButtonText: "Yes",
}).then((result) => {
} else {
toastr.warning('Remove Not Done!', 'warning');
}
}
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.warning('Something Wrong!', 'warning');
}, 1000);
if (result.isConfirmed) {
var id = element.getAttribute('data-id');
var form_action = '<?= base_url("master/policy/remove/") ?>' + id;
$.ajax({
url: form_action,
type: "GET",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
// console.log(res.status == true);
if(res){
if (res.status == true) {
toastr.success('Policy type removed successfully', 'success');
location.reload();
} else {
toastr.warning('Failed to remove policy type', 'warning');
}
}
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.warning('Failed to remove policy type', 'warning');
}
});
}
});
}

View File

@ -507,36 +507,46 @@ function validateForm() {
function removeTPABranch(element) {
var id = element.getAttribute('data-id');
var form_action = '<?= base_url("master/tpa/branch/remove/") ?>' + id;
$.ajax({
url: form_action,
type: "GET",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
// console.log(res.status == true);
if(res){
if (res.status == true) {
toastr.success('Remove Done!', 'success');
Swal.fire({
title: "Are you sure?",
text: "You need to remove this TPA branch.",
icon: "info",
showCancelButton: true,
confirmButtonColor: "#3085d6",
confirmButtonText: "Yes",
}).then((result) => {
location.reload();
} else {
toastr.warning('Remove Not Done!', 'warning');
}
}
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.warning('Something Wrong!', 'warning');
}, 1000);
if (result.isConfirmed) {
var id = element.getAttribute('data-id');
var form_action = '<?= base_url("master/tpa/branch/remove/") ?>' + id;
$.ajax({
url: form_action,
type: "GET",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
// console.log(res.status == true);
if(res){
if (res.status == true) {
toastr.success('TPA branch removed successfully', 'success');
location.reload();
} else {
toastr.warning('Failed to remove TPA branch', 'warning');
}
}
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.warning('Failed to remove TPA branch', 'warning');
}
});
}
});
}
</script>

View File

@ -132,39 +132,47 @@ class csvExport {
function removeTPA(element) {
var id = element.getAttribute('data-id');
var form_action = '<?= base_url("master/tpa/remove/") ?>' + id;
$.ajax({
url: form_action,
type: "GET",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
// console.log(res.status == true);
if(res){
if (res.status == true) {
toastr.success('Remove Done!', 'success');
location.reload();
Swal.fire({
title: "Are you sure?",
text: "You need to remove this TPA",
icon: "info",
showCancelButton: true,
confirmButtonColor: "#3085d6",
confirmButtonText: "Yes",
}).then((result) => {
} else {
toastr.warning('Remove Not Done!', 'warning');
}
if (result.isConfirmed) {
var id = element.getAttribute('data-id');
var form_action = '<?= base_url("master/tpa/remove/") ?>' + id;
$.ajax({
url: form_action,
type: "GET",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
// console.log(res.status == true);
if(res){
if (res.status == true) {
toastr.success('TPA removed successfully', 'success');
location.reload();
} else {
toastr.warning('Failed to remove TPA', 'warning');
}
}
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.warning('Failed to remove TPA', 'warning');
}
});
}
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.warning('Something Wrong!', 'warning');
}, 1000);
}
});
});
}

View File

@ -76,11 +76,12 @@
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-12" style="text-align: right;">
<a href="<?= base_url("client/deposit/$clientData->id"); ?>"><i class="fas fa-arrow-left" style="font-size: 17px;"></i></a>
<div class="row">
<div class="col-12" style="text-align: right;">
<a href="<?= base_url("client/deposit/$clientData->id"); ?>"><i class="fas fa-arrow-left"
style="font-size: 17px;"></i></a>
</div>
</div>
</div>
<div class="row" style="margin-bottom:1rem;">
<div class="col-6" style="align-self: center;">
@ -97,27 +98,31 @@
id="tickets-table">
<thead class="bg-light">
<tr>
<th class="font-weight-medium">Date</th>
<th class="font-weight-medium">User</th>
<th class="font-weight-medium">Description</th>
<th class="font-weight-medium">CD Account No</th>
<th class="font-weight-medium">Policy Name</th>
<th class="font-weight-medium">Endorsement No</th>
<th class="font-weight-medium">Sub Type</th>
<th class="font-weight-medium">Credit</th>
<th class="font-weight-medium">Debit</th>
<th class="font-weight-medium">Balance</th>
<th class="font-weight-medium">Description</th>
<th class="font-weight-medium">Date/User</th>
</tr>
</thead>
<tbody>
<?php foreach($depositdata as $row) { ?>
<tr id="<?php echo $row->id;?>">
<td><?php echo date('d-M-Y h:i A', strtotime($row->created_at)); ?></td>
<td><?php echo $row->username; ?></td>
<td><?php echo $row->description; ?></td>
<td><?php echo isset($subTypeOptions[$row->sub_type]) ? $subTypeOptions[$row->sub_type] : ''; ?></td>
<td><?php echo $row->cd_ac_no; ?></td>
<td><?php echo $row->policy_name; ?></td>
<td><?php echo $row->endorsement_no; ?></td>
<td><?php echo isset($subTypeOptions[$row->sub_type]) ? $subTypeOptions[$row->sub_type] : ''; ?>
</td>
<td><?php echo ($row->transaction_type == 'Credit') ? $row->amount : ''; ?></td>
<td><?php echo ($row->transaction_type == 'Debit') ? $row->amount : ''; ?></td>
<td><?php echo $row->balance; ?></td>
<td><?php echo $row->description; ?></td>
<td><?php echo date('d-M-Y h:i A', strtotime($row->created_at)); ?> by
<?php echo $row->username; ?> </td>
</tr>
<?php } ?>
</tbody>
@ -144,31 +149,43 @@
</button>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="transactionMode" class="control-label">Transaction Mode</label>
<div class="form-check">
<input class="form-check-input" type="radio" name="transactionMode" id="addMode"
value="add" checked>
<label class="form-check-label" for="addMode">Deposit</label>
<input class="form-check-input" type="radio" name="transactionMode" id="addMode"value="1" checked>
<label class="form-check-label" for="addMode">Replenishment</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="transactionMode" id="adjustmentMode"
value="adjustment">
<label class="form-check-label" for="adjustmentMode">Adjustment</label>
<input class="form-check-input" type="radio" name="transactionMode" id="adjustmentModeadd"value="2">
<label class="form-check-label" for="adjustmentMode">Adjustment Add</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="transactionMode" id="adjustmentModereduce"value="3">
<label class="form-check-label" for="adjustmentMode">Adjustment Reduce</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="transactionMode" id="assetpolicyadd"value="4">
<label class="form-check-label" for="adjustmentMode">Asset policy Add</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="transactionMode" id="assetpolicyreduce"value="5">
<label class="form-check-label" for="adjustmentMode">Asset policy Reduce</label>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="field-1" class="control-label">Amount</label>
<input type="number" class="form-control" id="amount" placeholder="Amount">
<label for="field-1" class="control-label">Amount<span class="text-danger">*</span></label>
<input type="number" class="form-control" id="amount" placeholder="Amount" required>
</div>
</div>
</div>
<div class="row" id="transactionTypeRow" style="display:none;">
<!-- <div class="row" id="transactionTypeRow" style="display:none;">
<div class="col-md-6">
<div class="form-group">
<label for="transactionType" class="control-label">Transaction Type</label>
@ -178,29 +195,32 @@
</select>
</div>
</div>
</div>
</div> -->
<div class="row">
<div class="col-md-12">
<div class="form-group no-margin">
<label for="description" class="control-label">Description</label>
<label for="description" class="control-label">Description<span class="text-danger">*</span></label>
<textarea class="form-control" id="description"
placeholder="Write something about the transaction"></textarea>
placeholder="Write something about the transaction" required></textarea>
</div>
</div>
</div>
<div class="form-group">
<!-- <div class="form-group">
<label for="subType" class="control-label" style="display: none;">Transaction Sub Type</label>
<select class="form-control" id="subType" name="sub_type" style="display: none;">
<option value="Deposit" hidden>Deposit</option>
<option value="Deposit" hidden>Replenishment</option>
<option value="Adjustment" hidden>Adjustment</option>
<!-- Add more options as needed -->
</select>
</div>
</div> -->
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" id="saveTransactionBtn">Save Transaction</button>
</div>
</div>
</div>
</div>
@ -222,22 +242,22 @@ $(document).ready(function() {
$('#tickets-table').DataTable({
dom: "<'row'<'col-sm-0'f><'col-sm-9 text-right'B>>",
buttons: [{
extend: 'csv',
text: 'CSV',
title: 'TransactionDetails',
exportOptions: {
columns: ''
extend: 'csv',
text: 'CSV',
title: 'TransactionDetails',
exportOptions: {
columns: ''
}
},
{
extend: 'pdf',
text: 'PDF',
title: 'TransactionDetails',
exportOptions: {
columns: ''
}
}
},
{
extend: 'pdf',
text: 'PDF',
title: 'TransactionDetails',
exportOptions: {
columns: ''
}
}
],
],
language: {
@ -252,51 +272,68 @@ $(document).ready(function() {
<script>
$(document).ready(function() {
// Event listener for radio buttons
$('input[name="transactionMode"]').change(function() {
if ($(this).val() === 'add') {
// Set the hidden input value to 'Deposit' when 'Deposit' radio button is selected
$('#subType').val('Deposit');
} else if ($(this).val() === 'adjustment') {
// Set the hidden input value to 'Adjustment' when 'Adjustment' radio button is selected
$('#subType').val('Adjustment');
}
});
// // Event listener for radio buttons
// $('input[name="transactionMode"]').change(function() {
// if ($(this).val() === 'add') {
// // Set the hidden input value to 'Deposit' when 'Deposit' radio button is selected
// $('#subType').val('Deposit');
// } else if ($(this).val() === 'adjustment') {
// // Set the hidden input value to 'Adjustment' when 'Adjustment' radio button is selected
// $('#subType').val('Adjustment');
// }
// });
$('#saveTransactionBtn').on('click', function() {
// Collect data from modal fields
var amount = $('#amount').val();
var description = $('#description').val();
var clientId = '<?php echo $clientData->id; ?>';
var insurerId = '<?php echo $insurerName->id; ?>';
var transactionType;
if ($('#addMode').is(':checked')) {
transactionType =
'Credit'; // Assuming 'Credit' is the default when the 'Deposit' radio button is selected
} else if ($('#adjustmentMode').is(':checked') && $('#transactionTypeRow').is(':visible')) {
transactionType = $('#transactionType').val();
} else {
transactionType = ''; // You might want to handle this case based on your requirements
}
var transactionTypeValue = $('input[name="transactionMode"]:checked').val();
var subType = "";
// Fetch sub_type_id based on the selected sub_type
var subTypeOptions = {
'Deposit': 1,
'Adjustment': 2,
'Deletion': 3,
// Add more options as needed
};
var subType = $('#subType').val();
var subTypeId = subTypeOptions[subType] || null;
if (subTypeId === null) {
// Handle the case where sub_type is not found in the options
alert('Invalid sub_type selected.');
if(amount == ""){
toastr.warning('Amount field is required')
return;
}
if(description == ""){
toastr.warning('Description field is required')
return;
}
//tranction type
if(transactionTypeValue == 1){
transactionType = 'Credit';
subType = '1'; // Replenishment or Deposite
}else if(transactionTypeValue == 2){
transactionType = 'Credit'
subType = '2'; // Adjustment add
}else if(transactionTypeValue == 3){
transactionType = 'Debit'
subType = '2'; // Adjustment reduce
}else if(transactionTypeValue == 4){
transactionType = 'Credit'
subType = '5'; // Asset Policy add
}else if(transactionTypeValue == 5){
transactionType = 'Debit'
subType = '5'; // Asset Policy reduce
}
console.log('transactionTypeValue', transactionTypeValue)
console.log('transactionType', transactionType)
console.log('description ', description)
console.log('amount ', amount)
console.log('clientId ', clientId)
console.log('insurerId ', insurerId)
console.log('subType ', subType)
// Send data to the server using Ajax
$.ajax({
type: 'POST',
@ -305,22 +342,24 @@ $(document).ready(function() {
amount: amount,
description: description,
transaction_type: transactionType,
sub_type: subType,
sub_type_id: subTypeId, // Include sub_type_id
sub_type_id: subType, // Include sub_type_id
client_id: clientId,
insurer_id: insurerId
},
success: function(response) {
// Handle success response
console.log("Transaction saved successfully");
toastr.success("Transaction saved successfully", "Success");
// Reload the page or perform other actions as needed
location.reload();
},
error: function(error) {
// Handle error response
console.error(error);
error: function(xhr, status, error) {
toastr.error("Transaction save failed", "Error");
console.error(xhr.responseText);
console.error(status, error);
location.reload(); // Uncomment if you need to reload the page on error
}
});
});
});
</script>

View File

@ -20,7 +20,7 @@
"laminas/laminas-escaper": "^2.9",
"php-amqplib/php-amqplib": "^2.8",
"phpmailer/phpmailer": "^6.9",
"phpoffice/phpspreadsheet": "^2.0",
"phpoffice/phpspreadsheet": "^2.1",
"psr/log": "^1.1",
"slim/slim": "^4.13",
"zircote/swagger-php": "^4.8"

View File

@ -38,6 +38,22 @@ Options -Indexes
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/js "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/javascript "access 1 month"
ExpiresByType application/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.