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

This commit is contained in:
Gowtham M 2025-12-11 16:33:47 +05:30
commit 053341b4a0
21 changed files with 5041 additions and 424 deletions

View File

@ -124,7 +124,7 @@ class Database extends Config
$this->defaultGroup = 'tests';
}
$this->enableSSL = env('DB_SSL_ENABLE');
$this->enableSSL = env('DB_SSL_ENABLE') ?? false;
if ($this->enableSSL === true || $this->enableSSL === 'true' || $this->enableSSL === 1 || $this->enableSSL === '1') {

View File

@ -52,10 +52,11 @@ $routes->get("importRules", "RuleImportController::upload");
// $routes->post("employeeUpload", "EmployeeRestController::employeeUpload");
$routes->post("add_advertise_image", "AppContentManagementController::add_advertise_image");
$routes->post('remove_advertise_image', 'AppContentManagementController::remove_advertise_image');
$routes->get("add_image_index", "AppContentManagementController::add_image_index");
$routes->get("getAdvertiseImage/(:any)", "AppContentManagementController::getAdvertiseImage/$1");
$routes->get("frontend_content", "AppContentManagementController::frontend_content");
$routes->get('showAdvertiseImage/(:any)', 'AdvertiseController::showAdvertiseImage/$1');
$routes->get('showAdvertiseImage/(:any)', 'AppContentManagementController::showAdvertiseImage/$1');
// $routes->get('/', 'LoginController::index');
@ -448,6 +449,8 @@ $routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) {
$routes->post("create", "PolicyTransactionController::createEndorsementPolicy");
$routes->get("list/(:any)", "PolicyTransactionController::getEndorsementDataForEdit/$1");
$routes->get("remove/(:any)", "PolicyTransactionController::removeCDMaster/$1");
$routes->get("list2", "PolicyTransactionController::viewEndorsement2");
$routes->get("list2/(:any)", "PolicyTransactionController::getEndorsementDataForEdit2/$1");
});
$routes->group("report", ["filter" => "authMVC"], function ($routes) {

View File

@ -255,7 +255,7 @@ class ApiServiceController extends BaseController
public function pushClaimFiles($claimId)
{
$claimId = $this->request->getGet('claim_id');
// $claimId = $this->request->getGet('claim_id');
$data = $this->db->table('ticket_master tm')
->select('tm.id,tm.tpa_id ')->where('tm.id', $claimId)->get()->getRowArray(); // single record

View File

@ -10,6 +10,7 @@ use CodeIgniter\API\ResponseTrait;
use App\Models\AddImgModel;
use App\Models\FEContentModel;
use App\Models\ClientModel;
class AppContentManagementController extends AdminController
{
@ -17,19 +18,31 @@ class AppContentManagementController extends AdminController
protected $myLogger;
protected $addImgModel;
protected $feContentModel;
protected $clientModel;
public function __construct()
{
$this->myLogger = \Config\Services::mylogger();
$this->addImgModel = new AddImgModel();
$this->addImgModel = new AddImgModel();
$this->feContentModel = new FEContentModel();
$this->clientModel = new ClientModel();
}
public function add_image_index()
{
$this->myLogger->logme('error','Addvertisement Image list function called');
$headerData['tab_name'] = 'Addvertisement Images';
$headerData['page_name'] = 'Addvertisement Images';
$data['addImageList'] = $this->addImgModel->findAll();
// $data['addImageList'] = $this->addImgModel->findAll();
$data['addImageList'] = $this->addImgModel->select('advertisement_images.*,
clients.client_name,
clients.short_name,
CASE WHEN advertisement_images.is_active = 1 THEN "Active" ELSE "Inactive" END AS status', false)
->join('clients', 'advertisement_images.client_id = clients.id', 'left')
->where('advertisement_images.is_active', 1)
->findAll();
$data['client'] = $this->clientModel->where('is_active', 1)->where('client_type', 1)->findAll();
// dd($data);
@ -40,12 +53,14 @@ class AppContentManagementController extends AdminController
// $this->loadLayout('client_onboarding', $data);
}
// using add and edit
public function add_advertise_image() {
try {
$file = $this->request->getFile('advertise_image');
$client_id = $this->request->getPost('client_id');
//1) original file name for vaildations
$fileName = $file->getClientName(); //original file name for vaildations
$existing = $this->addImgModel->where('name', $fileName)->where('is_active', 1)->first();
$existing = $this->addImgModel->where('name', $fileName)->where('client_id', $fileName)->where('is_active', 1)->first();
if($existing){ return $this->respond(['status' => false, 'message' => 'This file has already been uploaded in active state.'], 400); }
//skip 1) and use this
@ -62,7 +77,7 @@ class AppContentManagementController extends AdminController
$file->move($uploadPath, $fileName);
$id = $this->request->getPost('add_image_id');
$data = ['name' => $fileName];
$data = ['name' => $fileName,'client_id'=>$client_id];
if ($id == 0) {
$this->addImgModel->insert($data);
@ -76,22 +91,57 @@ class AppContentManagementController extends AdminController
}
}
public function showAdvertiseImage($fileName)
public function remove_advertise_image()
{
try {
$id = $this->request->getPost('add_image_id');
$filePath = WRITEPATH . 'uploads/advertiseImage/' . $fileName;
if (!$id) {
return $this->respond(['status' => false, 'message' => 'ID missing'], 400);
}
if (!file_exists($filePath)) {
return $this->response->setStatusCode(404, 'File not found');
$data = ['is_active' => 0];
$this->addImgModel->update($id, $data);
return $this->respond(['status' => true, 'message' => 'Deleted successfully']);
} catch (\Exception $e) {
return $this->respond(['status' => false, 'message' => $e->getMessage()], 500);
}
}
// public function showAdvertiseImage($fileName)
// {
// $filePath = WRITEPATH . 'uploads/advertiseImage/' . $fileName;
// if (!file_exists($filePath)) {
// return $this->response->setStatusCode(404, 'File not found');
// }
// $mimeType = mime_content_type($filePath);
// header('Content-Type: ' . $mimeType);
// readfile($filePath);
// exit;
// }
// In AppContentManagementController.php (This is what needs to be fixed if the direct path fails)
public function showAdvertiseImage($filename)
{
$path = WRITEPATH . 'uploads/advertiseImage/' . $filename;
if (!file_exists($path)) {
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
}
$mimeType = mime_content_type($filePath);
header('Content-Type: ' . $mimeType);
readfile($filePath);
exit;
$mime = mime_content_type($path);
return $this->response->setHeader('Content-Type', $mime)->setBody(file_get_contents($path));
}
public function getAdvertiseImage($image_id){
$image_data = $this->addImgModel->select('name')->where(['id' => $image_id])->first();

View File

@ -928,7 +928,8 @@ class BDSReportController extends AdminController
$default_start = new \DateTime();
$data['default_end'] = $default_start->format('d-m-Y');
$data['default_start'] = $default_start->modify('-60 days')->format('d-m-Y');
$data['issuer_branch'] = $this->nhanceBranchModel->where('is_active', 1)->findAll();;
$data['issuer_branch'] = $this->nhanceBranchModel->where('is_active', 1)->findAll();
$data['client_list'] = $this->clientModel->where('is_active', 1)->findAll();
$data['tab_name'] = "Renewal Reports";
$data['page_name'] = "Renewal Report";
return $this->loadLayout('renewal_search', $data);

View File

@ -4832,8 +4832,9 @@ class ClientController extends AdminController
$client_data = [
'client_type' => $postData['client_type'],
'client_name' => $postData['client_name'],
'email' => $postData['short_name'] ?? $postData['client_name'],
'phone' => $postData['mobile'],
'short_name' => $postData['short_name'] ?? $postData['client_name'],
'email' => $postData['email'] ?? null,
'phone' => $postData['mobile'] ?? null,
'client_code' => generate_client_code()
];
@ -4844,6 +4845,8 @@ class ClientController extends AdminController
'client_type' => $postData['client_type'],
'client_name' => $postData['client_name'],
'short_name' => $postData['short_name'] ?? $postData['client_name'],
'email' => $postData['email'] ?? null,
'phone' => $postData['mobile'] ?? null,
'client_code' => generate_client_code(),
'entity_type_id' => 2
];
@ -4958,8 +4961,9 @@ class ClientController extends AdminController
$client_data = [
'client_type' => $data['client_type'],
'client_name' => $data['client_name'],
'email' => $data['short_name'] ?? $data['client_name'],
'phone' => $data['mobile'],
'short_name' => $postData['short_name'] ?? $data['client_name'],
'email' => $data['email'] ?? null,
'phone' => $data['mobile'] ?? null,
'client_code' => generate_client_code()
];
@ -4970,6 +4974,8 @@ class ClientController extends AdminController
'client_type' => $data['client_type'],
'client_name' => $data['client_name'],
'short_name' => $data['short_name'] ?? $data['client_name'],
'email' => $data['email'] ?? null,
'phone' => $data['mobile'] ?? null,
'client_code' => generate_client_code(),
'entity_type_id' => 2
];
@ -5890,10 +5896,11 @@ class ClientController extends AdminController
// $response = $ticketServiceController->extractExcelData("claims_dump_form_client.xlsx");
// dd($response);
// ---------- TICKET SERVICE CONTROLLER --------------------------------------------------------------------------------
// ---------- TICKET CONTROLLER --------------------------------------------------------------------------------
$TicketController = new TicketController();
// $response = $TicketController->getMoreInfo($requestFrom = 'rest', $ticket_id = 70);
// $response = $TicketController->sendAutoMailTrigger($ticket_id = 602);
// dd($response);
// ---------- EMP SERVICE CONTROLLER --------------------------------------------------------------------------------

View File

@ -176,7 +176,7 @@ class DeployController extends AdminController
public function fedeploy()
{
$request = $this->request;
echo 'HI';die();
// Single zip file: <input type="file" name="zip_file">
$file = $request->getFile('zip_file');
@ -186,7 +186,7 @@ class DeployController extends AdminController
'message' => 'No valid zip file uploaded',
]);
}
echo 'cool';die();
// Read scalar form values
$zipFolder = (string) $request->getPost('zip_folder') ?: 'web/';
$s3Bucket = (string) $request->getPost('s3_bucket') ?: '';
@ -283,4 +283,10 @@ class DeployController extends AdminController
$this->loadLayout('fedeploy');
}
public function fetest()
{
echo 'Hello from DeployController fetest!';
}
}

View File

@ -2308,6 +2308,10 @@ class EmployeeController extends AdminController
}
$message = isset($message) ? ($message . ' not defined for choosed policy') : null;
if ($policy_details['cd_ac_pk'] == null) {
$message = isset($message) ? ($message . ' The policy does not have a CD account number.') : null;
}
return $this->respond(['dataStatus' => true, 'code' => 200, 'message' => $message, 'si_enhancement' => $si_enhancement_true_or_false, 'insurer_multi_event' => $insurer_details['is_multi_event'], 'tpa_api_service_status' => $tpa_api_service_status], 200);
}

View File

@ -2592,7 +2592,7 @@ class EmployeeRestController extends AdminController
// print_r($ticketHistory); die;
$currentClaimStatus = $this->claimStatusModel->select("claim_status")->where('id', $data['claims_data']['claim_status_id'])->where('is_active', 1)->first();
$ticketClaimStatus = $this->claimStatusModel->select('claim_status, display_name')->where('display_name is not null')->where('is_active', 1)->findAll();
$ticketClaimStatus = $this->claimStatusModel->select('claim_status, display_name')->where('display_name is not null')->where('ticket_type', $data['claims_data']['ticket_type_id'])->where('is_active', 1)->findAll();
$status_list = array_column($ticketClaimStatus, 'display_name', 'claim_status');
// print_r($currentClaimStatus); die;
@ -2888,9 +2888,13 @@ class EmployeeRestController extends AdminController
$clientId = $this->request->getGet('client_id');
if (!empty($employeeSelfData) && isset($employeeSelfData->email_corporate)) {
$prePolicyCount = $this->getPreEmployeePolicyCount($empMobileNo, $clientId, $employeeSelfData->email_corporate);
$prePolicyCountData = $this->getPreEmployeePolicyCount($empMobileNo, $clientId, $employeeSelfData->email_corporate);
$prePolicyCount = $prePolicyCountData['pre_policy_count'] ?? 0;
$empNotEnrolledCount = $prePolicyCountData['emp_not_enrolled_count'] ?? 0;
} else {
$prePolicyCount = $this->getPreEmployeePolicyCount($empMobileNo, $clientId);
$prePolicyCountData = $this->getPreEmployeePolicyCount($empMobileNo, $clientId);
$prePolicyCount = $prePolicyCountData['emp_not_enrolled_count'] ?? 0;
$empNotEnrolledCount = $prePolicyCountData['emp_not_enrolled_count'] ?? 0;
}
$whereArrayForId = [];
@ -2950,6 +2954,7 @@ class EmployeeRestController extends AdminController
$data['claims_grace_date'] = $this->convertDateFormatDisplay($ClientPolicyValue['claims_grace_date']);
$data['policy_status'] = $policy_status_key;
$data['pre_policy_count'] = $prePolicyCount;
$data['emp_not_enrolled_count'] = $empNotEnrolledCount;
// $data['policy_terms'] = $terms;
// if($ClientPolicyValue['policy_type_id'] == 1){ $data['heading'] = 'Group Personal Accident Coverage'; }else
@ -3020,13 +3025,12 @@ class EmployeeRestController extends AdminController
array_push($result, $data);
}
}
$emp_reatail_policy_data = $this->getEmpRetailPolicy($employeeSelfData);
$emp_wellness_data = $this->getWellnessUrl($employeeSelfData->id ?? null);
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $result, 'emp_name' => $employeeName, 'pre_policy_count' => $prePolicyCount, 'retail_policy_data' => $emp_reatail_policy_data, 'wellness_data' => $emp_wellness_data], 200);
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $result, 'emp_name' => $employeeName, 'pre_policy_count' => $prePolicyCount, 'emp_not_enrolled_count' => $empNotEnrolledCount, 'retail_policy_data' => $emp_reatail_policy_data, 'wellness_data' => $emp_wellness_data], 200);
} else {
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => []], 200);
}
@ -3711,6 +3715,7 @@ class EmployeeRestController extends AdminController
$claimData = [
'ticket_type_id' => $data['policy_type_id'],
'policy_transaction_id' => $data['policy_transaction_id'],
'claim_status_id' => 62,
'policy_no' => $policy['policy_no'],
'client_policy_id' => $policy['client_policy_id'],
@ -3731,7 +3736,26 @@ class EmployeeRestController extends AdminController
$ticket_id = $this->ticketMaster->insert($claimData);
if($ticket_id){
if ($ticket_id) {
$mail_sent_status = ($this->ticketController->sendAutoMailTrigger($ticket_id));
if (gettype($mail_sent_status) == 'array') {
$message = 'Claim Iniated Successfully';
return ['status' => true, 'code' => 200, 'message' => $message];
} else {
$mail_sent_status_object = json_decode($mail_sent_status);
}
if ($mail_sent_status_object->status == 'success') {
$message = 'Claim Initiated Successfully';
return ['status' => true, 'code' => 200, 'data' => $ticket_id, 'message' => $message];
} else {
$message = 'Claim Initiated, Failed to send Mail ';
$this->myLogger->logme('error', "Claim initiated, Failed to send Mail :$ticket_id ");
return ['status' => false, 'code' => 400, 'message' => $message];
}
$message = 'Claim Initiated Successfully';
return ['status' => true, 'code' => 200, 'data' => $ticket_id, 'message' => $message];
}else{
@ -3745,7 +3769,6 @@ class EmployeeRestController extends AdminController
}else{
$message = 'Claim Initiation failed';
return ['status' => false, 'code' => 404, 'message' => $message];
}
}
@ -3910,6 +3933,8 @@ class EmployeeRestController extends AdminController
$emp_id = $this->request->getGet('emp_id');
$ticket_type = $this->request->getGet('ticket_type') ?? null;
$ticket_id = $this->request->getGet('ticket_id') ?? null;
$mobile_number = $this->request->getGet('mobile_number') ?? null;
$email_id = $this->request->getGet('email_id') ?? null;
$request = \Config\Services::request();
$uri = $request->uri->getPath();
$returnType = "";
@ -3920,6 +3945,11 @@ class EmployeeRestController extends AdminController
return $this->response->setJSON(['status' => false, 'code' => 200, 'message' => 'emp_id is required.'])->setStatusCode(404);
}
$retail_ticket_data = [];
if(!empty($mobile_number) || !empty($email_id)){
$retail_ticket_data = $this->getRetailPolicyClaimData($this->request->getGet());
}
$TicketMasterModel = new TicketMasterModel();
$ticket_data = $TicketMasterModel->get_ticket_data($emp_id, $returnType, $ticket_type, $ticket_id);
@ -3994,9 +4024,113 @@ class EmployeeRestController extends AdminController
}
}
$ticket_data = array_merge($ticket_data, $retail_ticket_data);
return $this->response->setJSON(['ticket_data' => $ticket_data])->setStatusCode(200);
}
public function getRetailPolicyClaimData($receviedPayload)
{
try {
// Create minimal retail user object
$retailUserData = (object) [
'id' => null,
'mobile' => $receviedPayload['mobile_number'] ?? null,
'email_id' => $receviedPayload['email_id'] ?? null
];
// Get retail policies of user
$empRetailPolicyData = $this->getEmpRetailPolicy($retailUserData);
if (empty($empRetailPolicyData)) {
return [];
}
// Fetch ticket data for each policy
$retail_ticket_data = [];
foreach ($empRetailPolicyData as $policy) {
$tickets = $this->ticketMaster
->select("
ticket_master.*,
vehicle.vehicle_no,
(
SELECT th1.old_value
FROM ticket_history th1
JOIN ticket_claim_status tcs ON th1.old_value = tcs.id
WHERE th1.field_name = 'claim_status_id'
AND th1.ticket_id = ticket_master.id
AND th1.id = (
SELECT MAX(th2.id)
FROM ticket_history th2
WHERE th2.ticket_id = th1.ticket_id
AND th2.field_name = 'claim_status_id'
)
) AS old_status_id
")
->join("vehicle", "ticket_master.vehicle_id = vehicle.id", "left")
->where('ticket_master.is_active', 1)
->where('ticket_master.client_id', $policy['client_id'])
->where('ticket_master.policy_transaction_id', $policy['policy_transaction_id'])
->findAll();
if (!empty($tickets)) {
$retail_ticket_data = array_merge($retail_ticket_data, $tickets);
}
}
if (empty($retail_ticket_data)) {
return [];
}
// Fetch grouped claim statuses
$client_claim_status = $this->getClaimStatusGrouped(); // Format expected: [status => [ids]]
$claim_type = $this->getClaimTypeMaster('internal');
// Convert claim type for quick access
$typeMap = array_column($claim_type, 'claim_type', 'id');
// Map status name to each ticket
foreach ($retail_ticket_data as &$ticket) {
$ticket['claim_status'] = null; // Default
$ticket['claim_type_name'] = $typeMap[$ticket['claim_type']] ?? null;
if($ticket['ticket_type_id'] == 8){
$ticket['ticket_policy_type'] = 'Motor';
}
foreach ($client_claim_status as $status_name => $status_list) {
if (in_array($ticket['claim_status_id'], $status_list)) {
$ticket['claim_status'] = $status_name;
break;
}
if (in_array($ticket['old_status_id'], $status_list)) {
$ticket['claim_status'] = $status_name;
break;
}
}
}
return $retail_ticket_data;
}catch (\Throwable $th) {
$errorData = [
'message' => $th->getMessage(),
'file' => $th->getFile(),
'line' => $th->getLine(),
'code' => $th->getCode(),
'trace' => $th->getTraceAsString(),
'trace_array' => $th->getTrace(), // full array version (optional)
'function' => $th->getTrace()[0]['function'] ?? null,
'class' => $th->getTrace()[0]['class'] ?? null,
];
$this->myLogger->logme("error", "EMPLOYEE-REST-CONTROLLER - getRetailPolicyClaimData: Exception: " . json_encode($errorData ?? []));
return [];
}
}
public function getClaimStatusGrouped()
{
// Fetch active claim statuses
@ -4022,7 +4156,6 @@ class EmployeeRestController extends AdminController
return $result;
}
// not in use did for testing
function encrypt_for_sso(): string
{
@ -4230,17 +4363,12 @@ class EmployeeRestController extends AdminController
try {
$response = $this->callThirdPartyAPI($post_data, 'getPreEmployeePolicyCount');
log_message('error', 'STEP 6: API raw response: ' . $response);
log_message('error', 'STEP 6: API raw response: ' . json_encode($response ?? []));
$response = json_decode($response, true);
$response = json_decode($response ?? '{}', true);
if (json_last_error() !== JSON_ERROR_NONE) {
log_message('error', 'STEP 7: JSON decoding failed: ' . json_last_error_msg());
return 0;
}
$count = $response['data'] ?? 0;
log_message('error', 'STEP 8: Final count extracted: ' . $count);
$count = $response ?? [];
log_message('error', 'STEP 8: Final count extracted: ' . json_encode($count ?? []));
return $count;
} catch (\Throwable $e) {
@ -4706,6 +4834,18 @@ class EmployeeRestController extends AdminController
return $this->respond(['status' => 'failed','code' => 400,'message' => 'emp_id is required' ], 200);
}
if(isset($payload['policy_end_date']) && !empty($payload['policy_end_date'])){
$payload['policy_end_date'] = change_date_format($payload['policy_end_date'], 'd M Y', 'Y-m-d');
}else{
$payload['policy_end_date'] = null;
}
if(isset($payload['policy_start_date']) && !empty($payload['policy_start_date'])){
$payload['policy_start_date'] = change_date_format($payload['policy_start_date'], 'd M Y', 'Y-m-d');
}else{
$payload['policy_start_date'] = null;
}
if(empty($pk)){
$payload['created_by'] = $emp_id;
$emp_retail_policy_id = $this->employeeRetailPolicy->insert($payload);
@ -4778,6 +4918,7 @@ class EmployeeRestController extends AdminController
$emp_retail_client_data = $this->clientModel
->select("
'{$emp_id}' AS emp_id,
clients.id as client_id,
clients.client_name as insurerd_name,
clients.email as insurerd_mail,
clients.phone as insurerd_mobile,
@ -4810,6 +4951,7 @@ class EmployeeRestController extends AdminController
$emp_retail_client_data = $this->clientModel
->select("
'{$emp_id}' AS emp_id,
clients.id as client_id,
clients.client_name as insurerd_name,
clients.email as insurerd_mail,
clients.phone as insurerd_mobile,
@ -4972,7 +5114,7 @@ class EmployeeRestController extends AdminController
], 200);
}
public function getClaimTypeMaster()
public function getClaimTypeMaster($return_type = 'api')
{
$data = db_connect()->table('partner_claim_type_master')->select('id,claim_type')->where('is_active',1)->get()->getResultArray();
@ -4980,7 +5122,11 @@ class EmployeeRestController extends AdminController
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => []], 200);
}
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $data]);
if($return_type == 'api'){
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $data]);
}else{
return $data;
}
}
public function uploadIRDocs()
@ -5011,7 +5157,9 @@ class EmployeeRestController extends AdminController
"UPDATE ticket_master SET required_docs = ? WHERE id = ?",
[$required_docs, $ticket_id]
);
return $this->respond(['status' => true, 'code' => 200, 'message' => 'Files uploaded successfully'], 200);
$apiServiceController = new ApiServiceController();
$tpaIrFilePushResponce = $apiServiceController->pushClaimFiles($ticket_id);
return $this->respond(['status' => true, 'code' => 200, 'message' => 'Files uploaded successfully', 'tpaIrFilePushResponce' => $tpaIrFilePushResponce], 200);
}else{
return $this->respond(['status' => false, 'code' => 400, 'message' => 'Failed to upload the file'], 200);
}

View File

@ -10,6 +10,7 @@ class InsuranceCommissionController extends AdminController
use ResponseTrait;
private $rules = [];
private $myLogger;
public function __construct()
{
@ -66,7 +67,7 @@ class InsuranceCommissionController extends AdminController
$folderName = $month . $year; // SEP2025
$insurerId = $input['insurer_id']; // 5
$department = ucfirst(strtolower($input['department'])); // Motor, Health, Fire
$department = (strtolower($input['department'])); // Motor, Health, Fire
// Final Path: WRITEPATH/rules/SEP2025/5_Motor.json
$rulesPath = WRITEPATH . "uploads/commission/rules/{$folderName}/{$insurerId}_{$department}.json";
@ -183,6 +184,8 @@ class InsuranceCommissionController extends AdminController
private function compareValues($actual, string $operator, $expected): bool
{
$actual = strtolower($actual);
$expected = strtolower($expected);
switch ($operator) {
case '==':
return $actual == $expected;

View File

@ -837,6 +837,7 @@
->where('user_teams.team_id', 5)
->where('user_teams.is_active', 1)
->where('user_profiles.is_active', 1)
->groupBy('user_profiles.id', 'asc')
->findAll();
// Fetch Partner Agent
@ -858,6 +859,7 @@
->join('user_profiles AS rm', 'user_profiles.rm_id = rm.id', 'left')
->where('user_profiles.role', 3)
->where('user_profiles.is_active', 1)
->groupBy('user_profiles.id', 'asc')
->findAll();
// echo '<pre>';
@ -2078,6 +2080,100 @@
$this->loadLayout('policy_transaction_endorsement_list', $data);
}
public function viewEndorsement2()
{
// echo '<pre>';
// !dd($this->getEndorsementDataForEdit(17));
$bds_edit_pt_id = $this->request->getGet('pt_id') ?? null;
$data['tab_name'] = 'Endorsements';
$data['page_name'] = 'Endorsements';
$data['issuer'] = [1 => 'JIBS', 2 => 'Nhance'];
$data['issuer_branch'] = $this->nhanceBranchModel->where('is_active', 1)->findAll();
$data['client_type'] = [1 => 'Group', 2 => 'Individual'];
$data['policy_status'] = [
'under_process' => 'Under Process',
'client_pending' => 'Client Pending',
'insurer_pending' => 'Insurer Pending',
'co_insurer_pending' => 'Co-Insurer Pending',
'tpa_pending' => 'TPA Pending',
'validated' => 'Validated',
'cancelled' => 'Cancelled',
'instalment_pending' => 'Instalment Pending',
'completed' => 'Completed',
];
$data['invoice_status'] = [
'yet_to_generate' => 'Pending',
'generated' => 'Generated',
'send' => 'Sent',
'recived' => 'Payment Received',
];
$data['action_type'] = [
'addition' => 'Addition',
'deletion' => 'Deletion',
'addition_deletion' => 'Addition & Deletion',
'si_enhancement' => 'SI Enhancement',
'combo_a_d_si' => 'Combo A, D & SI',
'correction' => 'Correction',
'baby_addition' => 'Baby Addition',
'policy_instalment' => 'Policy Instalment',
'addition_inception' => 'Addition-Inception',
'bds_correction' => 'BDS Correction',
'policy_correction' => 'Policy Correction',
'policy_cancellation' => 'Policy Cancellation',
];
$data['date_type'] = [
'policy_issue_date' => 'Policy Issue Date',
'policy_start_date' => 'Policy Start Date',
'policy_end_date' => 'Policy End Date',
];
//filter datas
$start_date = $this->request->getGet('start_date');
$end_date = $this->request->getGet('end_date');
$client_id = $this->request->getGet('client_id');
$insurer_id = $this->request->getGet('insurer_id');
$policy_type_id = $this->request->getGet('policy_type_id');
$date_type = $this->request->getGet('date_type');
$issuer = $this->request->getGet('issuer');
$status = $this->request->getGet('status');
$start_date = (!isset($start_date) || $start_date === '' || $start_date === null) ? 0 : $start_date;
$end_date = (!isset($end_date) || $end_date === '' || $end_date === null) ? 0 : $end_date;
$client_id = (!isset($client_id) || $client_id === '' || $client_id === null) ? 0 : $client_id;
$insurer_id = (!isset($insurer_id) || $insurer_id === '' || $insurer_id === null) ? 0 : $insurer_id;
$policy_type_id = (!isset($policy_type_id) || $policy_type_id === '' || $policy_type_id === null) ? 0 : $policy_type_id;
$date_type = (!isset($date_type) || $date_type === '' || $date_type === null) ? 0 : $date_type;
$issuer = (!isset($issuer) || $issuer === '' || $issuer === null) ? 0 : $issuer;
$status = (!isset($issuer) || $status === '' || $status === null) ? 0 : $status;
if($bds_edit_pt_id == null){
$data['endorsement_data_list'] = $this->policyTransactionModel->getEndorsementTranctionListData($start_date, $end_date, $client_id, $insurer_id, $policy_type_id, $date_type, $issuer, $status);
}else{
$data['endorsement_data_list'] = [];
}
$data['client'] = $this->clientModel->where('is_active', 1)->findAll();
$data['policy_types'] = $this->policyTypeModel->where('is_active', 1)->findAll();
$data['insurer'] = $this->insurerModel->where('is_active', 1)->findAll();
// $data['tpa'] = $this->tpaModel->where('is_active', 1)->findAll();
$data['insurer_branch'] = $this->insurerBranchModel->getInsurerBranchesWithInsurerNames();
$data['tpa'] = $this->tpaBranchModel->getTpaBranchesWithTpaNames();
list($policyList, $policyListByClient) = $this->getPolicyForEndorsment();
$data['endorsementPolicies'] = $policyList;
$data['endorsementPolicyListByClient'] = $policyListByClient;
// dd($data);
// print_r($data['endorsementPolicies']);die();
$this->loadLayout('policy_transaction_endorsement_list_2', $data);
}
public function createEndorsementPolicy()
{
$id = $this->request->getPost('id');
@ -2214,7 +2310,12 @@
'listed_insurers' => $issue_type['listed_insurers'] ?? null,
'ppteam' => $issue_type['ppteam'] ?? null,
'sales_generated_by' => $issue_type['sales_generated_by'] ?? null,
'serviced_by' => $issue_type['serviced_by'] ?? null
'serviced_by' => $issue_type['serviced_by'] ?? null,
'salse_person_manager_id' => $issue_type['salse_person_manager_id'] ?? null,
'service_person_manager_id' => $issue_type['service_person_manager_id'] ?? null,
'service_person_branch_id' => $issue_type['service_person_branch_id'] ?? null,
'agent_id' => $issue_type['agent_id'] ?? null,
'agent_code' => $issue_type['agent_code'] ?? null,
];
$data['client_branch_id'] = $client_branch_id;
@ -2515,6 +2616,220 @@
}
}
public function getEndorsementDataForEdit2($id)
{
$data = $this->policyTransactionModel
->select('
policy_transaction.*,
clients.short_name as client_short_name,
clients.client_type,
(
select last_action_date
from policy_transaction_status
where policy_tran_id = policy_transaction.id
and status = policy_transaction.status
order by id desc
limit 1
) as last_action_date
')
->join('clients', 'clients.id = policy_transaction.client_id')
->join('client_policy', 'policy_transaction.client_policy_id = client_policy.id', 'left')
->where('policy_transaction.id', $id)
->where('policy_transaction.is_active', 1)
->orderBy('id', 'asc')
->first();
$pt_id = null;
if(!empty($data)){
$inception_data = $this->policyTransactionModel
->where('policy_no', $data['policy_no'])
->where('client_id', $data['client_id'])
->where('action_type', 'inception')
->first();
$pt_id = $inception_data['id'];
}
if (!empty($data['policy_start_date'])) {
$data['policy_start_date'] = change_date_format($data['policy_start_date'], 'Y-m-d', 'd/m/Y');
}
if (!empty($data['policy_end_date'])) {
$data['policy_end_date'] = change_date_format($data['policy_end_date'], 'Y-m-d', 'd/m/Y');
}
if (!empty($data['data_received_date'])) {
$data['data_received_date'] = change_date_format($data['data_received_date'], 'Y-m-d', 'd/m/Y');
}
if (!empty($data['policy_issue_date'])) {
$data['policy_issue_date'] = change_date_format($data['policy_issue_date'], 'Y-m-d', 'd/m/Y');
}
if (!empty($data['endorse_eff_date'])) {
$data['endorse_eff_date'] = change_date_format($data['endorse_eff_date'], 'Y-m-d', 'd/m/Y');
}
if (!empty($data['install_due_date'])) {
$data['install_due_date'] = change_date_format($data['install_due_date'], 'Y-m-d', 'd/m/Y');
}
if (!empty($data['last_action_date'])) {
$data['last_action_date'] = change_date_format($data['last_action_date'], 'Y-m-d', 'd/m/Y');
}
if (!empty($data['month'])) {
$data['month'] = change_date_format($data['month'], 'Y-m-d', 'M/Y');
}
// print_r($data); die;
//get PT Co-Share Details
$data['pt_co_share_details'] = $this->PTCOShareDetailsModel
->select("
pt_co_share_details.*,
(
SELECT
COUNT(*)
FROM
co_share_stmt_details
WHERE
co_share_stmt_details.co_share_id = pt_co_share_details.id
AND co_share_stmt_details.is_active = 1
) AS record_count,
(
SELECT
SUM(actual_bp_amt)
FROM
co_share_stmt_details
WHERE
co_share_id = pt_co_share_details.id
AND is_active = 1
) AS actual_bp_amount,
(
SELECT
SUM(actual_tp_amt)
FROM
co_share_stmt_details
WHERE
co_share_id = pt_co_share_details.id
AND is_active = 1
) AS actual_tp_amount,
(
SELECT
SUM(actual_tep_amt)
FROM
co_share_stmt_details
WHERE
co_share_id = pt_co_share_details.id
AND is_active = 1
) AS actual_tep_amount,
(
SELECT
SUM(actual_bp_per)
FROM
co_share_stmt_details
WHERE
co_share_id = pt_co_share_details.id
AND is_active = 1
) AS actual_bp_percentage,
(
SELECT
SUM(actual_tp_per)
FROM
co_share_stmt_details
WHERE
co_share_id = pt_co_share_details.id
AND is_active = 1
) AS actual_tp_percentage,
(
SELECT
SUM(actual_tep_per)
FROM
co_share_stmt_details
WHERE
co_share_id = pt_co_share_details.id
AND is_active = 1
) AS actual_tep_percentage,
(
SELECT
SUM(actual_bp_brokerage_amt)
FROM
co_share_stmt_details
WHERE
co_share_id = pt_co_share_details.id
AND is_active = 1
) AS actual_bp_brokerage_amount,
(
SELECT
SUM(actual_tp_brokerage_amt)
FROM
co_share_stmt_details
WHERE
co_share_id = pt_co_share_details.id
AND is_active = 1
) AS actual_tp_brokerage_amount,
(
SELECT
SUM(actual_tep_brokerage_amt)
FROM
co_share_stmt_details
WHERE
co_share_id = pt_co_share_details.id
AND is_active = 1
) AS actual_tep_brokerage_amount,
DATE_FORMAT(pt_policy_issue_date, '%d/%m/%Y') AS pt_policy_issue_date
")
->where('pt_id', $id)
->where('is_active', 1)
->orderBy('id', 'asc')
->findAll();
// print_r($data['endorse_eff_date']); die;
$pt_bp_amt = $this->PTCOShareDetailsModel
->select('bp_amt, amount')
->where('pt_id', $id)
->where('co_share_type', 1)
->where('is_active', 1)
->first();
// dd(db_connect()->getLastQuery() ,$pt_bp_amt);
$data['base_cd_amount'] = $pt_bp_amt['amount'] ?? null;
if ($data) {
return $this->respond(['status' => true, 'data' => $data, 'pt_id' => $pt_id], 200);
} else {
return $this->respond(['status' => false], 200);
}
}
//------------------------------------------------------------------------------------------------
//file upload function

View File

@ -910,7 +910,7 @@ class TicketController extends BaseController
$data['ticket_history'] = $this->ticketHistory($ticket_id);
$data['ticket_check_list'] = db_connect()->table('ticket_check_list')->where('is_active', 1)->where('ticket_type_id', $ticket_data['ticket_type_id'])->get()->getResultArray();
if (!empty($ticket_data['client_policy_id'])){
$ticket_data['client_policy_id_text'] = $this->clientPolicyModel->select('concat(policy_type.policy_type,"-",client_policy.policy_no) as client_policy_name')->join('policy_type','policy_type.id = client_policy.policy_type_id and policy_type.is_active = 1')->where('client_policy.id',$ticket_data['client_policy_id'])->first()['client_policy_name'];
$ticket_data['client_policy_id_text'] = $this->clientPolicyModel->select('concat(policy_type.policy_type,"-",client_policy.policy_no) as client_policy_name')->join('policy_type','policy_type.id = client_policy.policy_type_id and policy_type.is_active = 1')->where('client_policy.id',$ticket_data['client_policy_id'])->first()['client_policy_name'] ?? "N/A";
}
// dd($data);
$data['ticket_data'] = $ticket_data;

View File

@ -10,7 +10,7 @@ class CommissionApiFilter implements FilterInterface
{
public function before(RequestInterface $request, $arguments = null)
{
return null;
// Read API key from header
// $authHeader = $request->getHeaderLine('X');
$authHeader = $_SERVER['REDIRECT_HTTP_AUTHORIZATION'];

View File

@ -91,6 +91,7 @@ class TicketMasterModel extends Model
'hospital_phone_no',
'claim_description',
'required_docs',
'policy_transaction_id',
];

View File

@ -40,6 +40,8 @@ table.dataTable thead th {
<thead class="bg-light">
<tr>
<th class="font-weight-medium"><div class="column-header">Advertisement Image Name</div></th>
<th class="font-weight-medium"><div class="column-header">Client Name</div></th>
<th class="font-weight-medium"><div class="column-header">Client Short Name</div></th>
<th class="font-weight-medium"><div class="column-header">Status</div></th>
<th class="font-weight-medium"><div class="column-header">Action</div></th>
</tr>
@ -49,19 +51,18 @@ table.dataTable thead th {
<?php foreach($addImageList as $row){ ?>
<tr >
<td class="client_info" data-id="<?php echo $row['id']; ?>"><?php echo $row['name']; ?></td>
<td class="client_info" ><?php echo $row['client_name']; ?></td>
<td class="client_info" ><?php echo $row['short_name']; ?></td>
<td class="client_info" ><?php echo $row['status']; ?></td>
<td>
<?php echo $row['is_active']; ?>
</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 advertise_image_edit" href="#" data-toggle="modal" data-id="<?php echo $row['id']; ?>" data-name="<?php echo $row['name']; ?>" data-target="#bike_make_login-modal"><i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</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>
<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 advertise_image_edit" href="#" data-toggle="modal" data-wholearray='<?php echo json_encode($row, JSON_HEX_APOS); ?>' data-target="#bike_make_login-modal"><i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
<a class="dropdown-item" onclick="remove_advertise_image('<?= $row['id'];?>')"><i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete</a>
</div>
</div>
</div>
</td>
</tr>
<?php } ?>
@ -88,6 +89,7 @@ table.dataTable thead th {
<form id="model_form_data" class="px-4" enctype="multipart/form-data">
<input type="hidden" name="add_image_id" id="add_image_id" value="0">
<!-- old
<div class="row">
<div class="col-md-12">
<div class="form-group">
@ -100,8 +102,63 @@ table.dataTable thead th {
<div class="form-group col-md-6 float-left" style="position: relative;top: 0px;">
<img src=" " width="100" height="100" id="uploadPreview" class="avatar img-circle img-thumbnail" alt="avatar"/>
</div>
<div class="form-group col-md-3">
<label for="client_branch">Client<span class="text-danger">*</span></label>
<select class="form-control" id="client_id" name="client_id" required>
<option value="">Select Client</option>
<?php
if (isset($client) && count($client)) {
foreach ($client as $key => $value) {
echo "<option value='" . $value['id'] . "'>" . $value['client_name'] . "</option>";
}
}
?>
</select>
</div>
</div>
</div>
-->
<div class="row mb-2 align-items-stretch">
<!-- Left column: col-8 -->
<div class="col-md-8 d-flex flex-column justify-content-between">
<!-- Top section -->
<div class="form-group">
<label for="branchname">Upload Image</label>
<div class="input-icon">
<input type="file" class="form-control" name="advertise_image" id="advertise_image" accept="image/*" onchange="PreviewImage();" required>
<i class="mdi mdi-upload additional-icon"></i>
</div>
</div>
<!-- Bottom section -->
<div class="form-group">
<label for="client_branch">Client <span class="text-danger">*</span></label>
<select class="form-control" id="client_id" name="client_id" required>
<option value="">Select Client</option>
<?php
if (isset($client) && count($client)) {
foreach ($client as $value) {
echo "<option value='" . $value['id'] . "'>" . $value['client_name'] . "</option>";
}
}
?>
</select>
</div>
</div>
<!-- Right column: col-4, preview image -->
<div class="col-md-4 d-flex flex-column align-items-center justify-content-center">
<img src="" class="avatar img-circle img-thumbnail" id="uploadPreview" alt="Preview" style="max-width: 100%; height: auto;">
<small style="font-size: x-small; margin-top: 5px; text-align: center;">
dimensions - 1640x664 pixels <br> size - 200kb
</small>
</div>
</div>
<div class="form-group text-center">
<button type="button" class="btn btn-primary" onclick="submitBranch()">Submit</button>
@ -116,158 +173,192 @@ table.dataTable thead th {
<script>
function submitBranch() {
const fileInput = $('#advertise_image')[0].files[0]; // get actual file object
const imageId = $('#add_image_id').val();
function submitBranch() {
const fileInput = $('#advertise_image')[0].files[0]; // get actual file object
const imageId = $('#add_image_id').val();
const clientId = $('#client_id').val();
if (!fileInput) {
toastr.warning('Please upload an image before submitting', 'Warning');
$('#advertise_image').focus();
return;
if (!fileInput) {
toastr.warning('Please upload an image before submitting', 'Warning');
$('#advertise_image').focus();
return;
}
if(!clientId){
toastr.warning('Please Select Client.', 'Warning');
$('#client_id').focus();
return;
}
var url = '<?= base_url("add_advertise_image") ?>';
var formData = new FormData();
formData.append('advertise_image', fileInput);
formData.append('add_image_id', imageId);
formData.append('client_id', clientId);
$.ajax({
type: 'POST',
url: url,
data: formData,
processData: false,
contentType: false,
dataType: 'json',
success: function(response) {
console.log(response);
if (response.status) {
$('#bike_make_login-modal').modal('hide');
$('#advertise_image').val('');
$('#client_id').val('');
$('#uploadPreview').attr('src', '<?= base_url('public/assets/images/avatar_2x.png') ?>');
toastr.success('Image uploaded successfully!');
window.location.reload();
} else {
toastr.error(response.message || 'Something went wrong.');
}
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error('Status:', status);
console.error('Error:', error);
let msg = 'Something went wrong. Please try again later.';
switch (xhr.status) {
case 400:
msg = xhr.responseJSON?.message || 'Bad Request — Invalid input.';
break;
case 401:
msg = 'Unauthorized — Please log in again.';
break;
case 403:
msg = 'Forbidden — You do not have permission.';
break;
case 404:
msg = 'Not Found — Requested URL or resource not found.';
break;
case 500:
console.log('Internal Server Error — Please contact support.');
msg = xhr.responseJSON?.message || xhr.responseText || msg;
break;
default:
msg = xhr.responseJSON?.message || xhr.responseText || msg;
}
}
});
}
var url = '<?= base_url("add_advertise_image") ?>';
var formData = new FormData();
formData.append('advertise_image', fileInput);
formData.append('add_image_id', imageId);
function PreviewImage() {
console.log('function called');
var fileInput = document.getElementById("advertise_image");
var file = fileInput.files[0];
if (file) {
var allowedExtensions = ["jpg", "jpeg", "png"];
var fileExtension = file.name.split('.').pop().toLowerCase();
if (!allowedExtensions.includes(fileExtension) || file.size > 200 * 1024) {
toastr.warning('Maximum file size allowed is 200KB.', 'File size exceeds limit.');
fileInput.value = ""; // Clear the file input
document.getElementById("uploadPreview").src = "<?= base_url()."public/assets/images/avatar_2x.png" ?>"; // Remove the preview image
return;
}
var reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = function (event) {
var img = new Image();
img.src = event.target.result;
img.onload = function () {
if (img.width !== 1640 || img.height !== 664) {
toastr.warning('Image dimensions must be 1640x664 pixels.', 'Invalid image dimensions.');
fileInput.value = ""; // Clear the file input
document.getElementById("uploadPreview").src = "<?= base_url()."public/assets/images/avatar_2x.png" ?>"; // Remove the preview image
} else {
document.getElementById("uploadPreview").src = img.src;
}
};
};
}
}
var table;
$(document).ready(function() {
$('#add_image_id').val('');
$('#client_id').val('');
$('#client_id').select2();
$('#advertise_image').val('');
table = $('#tickets-table').DataTable({
// dom: "<'row'<'col-sm-1'f><'col-sm-11 text-right'B>>" + // Filter left, button right
// "<'row'<'col-sm-12'tr>>" +
// "<'row'<'col-sm-5'i><'col-sm-7'p>>",
dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
text: '<i class="mdi mdi-plus"></i> <span class="btn-custom">Add</span>',
className: 'btn app-btn-primary',
action: function (e, dt, node, config) {
// ✅ Call your modal logic
callmodal();
}
}
],
language: {
search: `
<div class="datatable-search-wrapper" style="position:relative; display:inline-block;">
_INPUT_
<i class="mdi mdi-magnify datatable-search-icon"
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666;"></i>
<i class="mdi mdi-close-circle datatable-clear-icon"
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666; display:none;"></i>
</div>`,
searchPlaceholder: "Search",
emptyTable: '<div class="text-center text-muted">No Data found</div>'
},
paging: true
});
});
// ✅ Define your modal function separately
function callmodal() {
$('#add_image_id').val(0);
$('#advertise_add_edit').html('Add Advertise Image');
$('#uploadPreview').attr('src', '<?= base_url()."public/assets/images/avatar_2x.png" ?>');
$('#bike_model_login-modal').modal('show'); // ✅ this shows the modal
var myModal = new bootstrap.Modal(document.getElementById('bike_make_login-modal'));
myModal.show();
}
function remove_advertise_image(id) {
if (!confirm("Are you sure you want to delete this image?")) return;
$.ajax({
type: 'POST',
url: url,
data: formData,
processData: false,
contentType: false,
dataType: 'json',
success: function(response) {
console.log(response);
if (response.status) {
$('#bike_make_login-modal').modal('hide');
$('#advertise_image').val('');
$('#uploadPreview').attr('src', '<?= base_url('public/assets/images/avatar_2x.png') ?>');
toastr.success('Image uploaded successfully!');
window.location.reload();
} else {
toastr.error(response.message || 'Something went wrong.');
}
url: '<?= base_url("remove_advertise_image"); ?>',
data: { add_image_id: id },
success: function (response) {
toastr.success('Deleted successfully');
location.reload(); // refresh page
},
error: function(xhr, status, error) {
error: function (xhr) {
console.error(xhr.responseText);
console.error('Status:', status);
console.error('Error:', error);
let msg = 'Something went wrong. Please try again later.';
switch (xhr.status) {
case 400:
msg = xhr.responseJSON?.message || 'Bad Request — Invalid input.';
break;
case 401:
msg = 'Unauthorized — Please log in again.';
break;
case 403:
msg = 'Forbidden — You do not have permission.';
break;
case 404:
msg = 'Not Found — Requested URL or resource not found.';
break;
case 500:
console.log('Internal Server Error — Please contact support.');
msg = xhr.responseJSON?.message || xhr.responseText || msg;
break;
default:
msg = xhr.responseJSON?.message || xhr.responseText || msg;
}
}
});
}
function PreviewImage() {
console.log('function called');
var fileInput = document.getElementById("advertise_image");
var file = fileInput.files[0];
if (file) {
var allowedExtensions = ["jpg", "jpeg", "png"];
var fileExtension = file.name.split('.').pop().toLowerCase();
if (!allowedExtensions.includes(fileExtension) || file.size > 200 * 1024) {
toastr.warning('Maximum file size allowed is 200KB.', 'File size exceeds limit.');
fileInput.value = ""; // Clear the file input
document.getElementById("uploadPreview").src = "<?= base_url()."public/assets/images/avatar_2x.png" ?>"; // Remove the preview image
return;
}
var reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = function (event) {
var img = new Image();
img.src = event.target.result;
img.onload = function () {
if (img.width !== 1640 || img.height !== 664) {
toastr.warning('Image dimensions must be 1640x664 pixels.', 'Invalid image dimensions.');
fileInput.value = ""; // Clear the file input
document.getElementById("uploadPreview").src = "<?= base_url()."public/assets/images/avatar_2x.png" ?>"; // Remove the preview image
} else {
document.getElementById("uploadPreview").src = img.src;
}
};
};
}
}
var table;
$(document).ready(function() {
table = $('#tickets-table').DataTable({
// dom: "<'row'<'col-sm-1'f><'col-sm-11 text-right'B>>" + // Filter left, button right
// "<'row'<'col-sm-12'tr>>" +
// "<'row'<'col-sm-5'i><'col-sm-7'p>>",
dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
text: '<i class="mdi mdi-plus"></i> <span class="btn-custom">Add</span>',
className: 'btn app-btn-primary',
action: function (e, dt, node, config) {
// ✅ Call your modal logic
callmodal();
}
}
],
language: {
search: `
<div class="datatable-search-wrapper" style="position:relative; display:inline-block;">
_INPUT_
<i class="mdi mdi-magnify datatable-search-icon"
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666;"></i>
<i class="mdi mdi-close-circle datatable-clear-icon"
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666; display:none;"></i>
</div>`,
searchPlaceholder: "Search",
emptyTable: '<div class="text-center text-muted">No Data found</div>'
},
paging: true
});
});
// ✅ Define your modal function separately
function callmodal() {
$('#add_image_id').val(0);
$('#advertise_add_edit').html('Add Advertise Image');
$('#uploadPreview').attr('src', '<?= base_url()."public/assets/images/avatar_2x.png" ?>');
$('#bike_model_login-modal').modal('show'); // ✅ this shows the modal
var myModal = new bootstrap.Modal(document.getElementById('bike_make_login-modal'));
myModal.show();
}
// $('#btnAdd').click(function () {
// $('#add_image_id').val(0);
// $('#advertise_add_edit').html('Add Advertise Image');
@ -299,28 +390,51 @@ function callmodal() {
// })
// })
$(document).on('click', '.advertise_image_edit', function (e) {
e.preventDefault();
e.preventDefault();
// 1. Clear fields first for a clean state (Good practice)
$('#add_image_id').val('');
$('#client_id').val('');
$('#advertise_image').val('');
// Reset preview to default before processing to avoid flicker/old image
$('#uploadPreview').attr('src', '<?= base_url("public/assets/images/avatar_2x.png") ?>');
let wholearray = JSON.parse($(this).attr('data-wholearray'));
let ad_name = wholearray.name;
let ad_id = wholearray.id;
let c_id = wholearray.client_id; // This holds the Client ID for the dropdown
console.log('Whole array:', wholearray);
console.log('Clicked ID:', c_id);
// 2. Set the data fields and title
$('#add_image_id').val(ad_id);
$('#advertise_add_edit').html('Edit Advertise Image');
// 🎯 CRITICAL FIX: Set the value of the Client SELECT dropdown
// This pre-selects the client associated with the image.
$('#client_id').val(c_id);
const id = $(this).data('id');
const name = $(this).data('name');
console.log('Clicked ID:', id);
console.log('<?= base_url(); ?>');
// 3. Construct the image URL
// NOTE: If this path fails (404/403), revert to the previous controller path:
const imgUrl = '<?= base_url("showAdvertiseImage/"); ?>' + ad_name;
// const imgUrl = '<?= base_url("writable/uploads/advertiseImage/"); ?>' + ad_name;
$('#add_image_id').val(id);
$('#advertise_image').val(name);
$('#advertise_add_edit').html('Edit Advertise Image');
const imgUrl = '<?= base_url("showAdvertiseImage/"); ?>' + name;
$('#uploadPreview').attr('src', imgUrl)
.on('error', function() {
$(this).attr('src', '<?= base_url()."public/assets/images/avatar_2x.png" ?>');
// 4. Set the image source AND add robust error handling for default image
$('#uploadPreview').attr('src', imgUrl).on('error', function() {
// Fallback: If the image fails to load, set the source to the default image.
$(this).attr('src', '<?= base_url("public/assets/images/avatar_2x.png") ?>');
});
// 5. Clear the file input
$('#advertise_image').val('');
// 6. Show the modal
var myModal = new bootstrap.Modal(document.getElementById('bike_make_login-modal'));
myModal.show();
});
});
</script>

View File

@ -20,12 +20,12 @@ table.dataTable tbody td {
<div class="col-12" id="inception_list">
<div class="card">
<div class="card-body">
<div class="row" style="margin-bottom:1rem;">
<div class="card-body" style="background-color: #F5FFFF !important; border-radius: 10px; box-shadow: 4px 4px 4px 4px #00000040;">
<!-- <div class="row" style="margin-bottom:1rem;">
<div class="col-6" style="align-self: center;">
<h4 style="position: relative;">Renewal Policy List</h4>
</div>
</div>
</div> -->
<div>
<div class="table-responsive">
<table data-custom-table-css="table" id="scroll-horizontal-datatable" class="table w-100 nowrap">

View File

@ -2047,6 +2047,12 @@
<span> Policy 2</span>
</a>
</li>
<li>
<a href="<?= base_url('/policy_tranction/endorsement/list2') ?>">
<i class="ri-file-edit-line"></i>
<span> Endorsement 2</span>
</a>
</li>
<?php } ?>
</ul>
</div>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -718,10 +718,9 @@
</div> -->
<div class="form-group col-md-3">
<label class="card_label_4">Base Premium</label>
<input type="text" class="form-control right-align-input" id="base_premium" name="base_premium" oninput="" onkeypress="return onlyNumbers(event)" onchange="setBPValue(this.value)">
<label class="card_label_4">Base Premium<span id="base_danger" class="text-danger">*</span></label>
<input type="text" class="form-control right-align-input" id="base_premium" name="base_premium" oninput="" onkeypress="return onlyNumbers(event)" onchange="setBPValue(this.value)" required>
</div>
<div class="form-group col-md-3 hidetp">
<label class="card_label_5">TP Premium</label>
@ -1831,11 +1830,6 @@
// $('#cd_ac_no_for_edit').val(res.data.cd_ac_no);
$('#cd_ac_pk_for_leader').val(res.data.cd_ac_pk);
// $('#entity_type_id').val(res.data.entity_type_id);
// getKYCEntityDocument(res.data.entity_type_id, res.data.client_id);
// appendKycTableListData(res.data.client_kyc);
// please don't forgot this ==> look at here please don't don't forgot
$('#docs_type_id').empty(); // ✅ clear old options
@ -1843,133 +1837,6 @@
$('#tbody').empty();
$('#tbody').append(res.data.client_kyc_single_table);
// let tbody = $('#tbody');
// tbody.empty(); // ✅ Always clear first
// let ckdlist = res.data.client_kyc_document_list;
// if (!ckdlist || ckdlist.length === 0) {
// // ✅ Show single merged row when no data
// let emptyRow = `
// <tr>
// <td colspan="4" class="text-center text-muted">
// No data found
// </td>
// </tr>
// `;
// tbody.append(emptyRow);
// // return; // ✅ Stop further execution
// }
// else{
// $.each(ckdlist, function (index, value) {
// let sno = index + 1;
// // ✅ If kyc_doc_type_id is null → use other_docs_name
// let docName = (value.kyc_doc_type_id === null || value.kyc_doc_type_id === '')
// ? value.other_docs_name
// : value.kyc_doc_type_id;
// let fileName = value.file_name ? value.file_name : '-';
// let downloadBtn = `
// <a id="download_${value.id}"
// data-id="${value.id}"
// data-file="${value.file_name}"
// class="mdi mdi-download mr-1 btn-download-kyc"
// style="font-size:18px;">
// </a>
// `;
// // Inside your $.each(list, function (index, value) { ... }) loop
// let editBtn = `<a href="javascript:void(0);"
// id="edit_${value.id}"
// class="mdi mdi-pencil mr-1 btn-edit-kyc"
// style="font-size:18px;"
// data-id="${value.id}"
// data-client_id="${value.client_id}"
// data-old_file_name="${value.file_name}"
// data-kyc_doc_type_id="${value.kyc_doc_type_id}">
// </a>`;
// // The edit UI block to be toggled
// let editUI = `
// <tr id="edit_row_${value.id}" class="d-none">
// <td colspan="4">
// <form id="kyc_form_${value.id}" class="kyc-edit-form">
// <input type="hidden" id="kyc_id_${value.id}" name="id" value="${value.id}">
// <input type="hidden" id="client_id_${value.id}" name="client_id" value="${value.client_id}">
// <input type="hidden" id="old_file_name_${value.id}" name="old_file_name" value="${value.file_name}">
// <div class="row align-items-end">
// <div class="col-md-8">
// <label for="kyc_docs_file_${value.id}">Change File - ${value.ui_docs_name} (${fileName}) </label>
// <input type="file"
// id="kyc_docs_file_${value.id}"
// name="file_name"
// class="form-control"
// style="box-shadow:none!important;
// outline:none!important;
// border:none;
// height:unset!important;
// padding:0!important;
// background:transparent!important;">
// </div>
// <div class="col-md-2">
// <button type="button"
// class="btn btn-primary btn-sm btn-update-kyc w-100"
// data-id="${value.id}">
// Update
// </button>
// </div>
// <div class="col-md-2">
// <button type="button"
// class="btn btn-secondary btn-sm btn-cancel-kyc w-100"
// data-id="${value.id}">
// Cancel
// </button>
// </div>
// </div>
// </form>
// </td>
// </tr>
// `;
// let deleteBtn = `
// <a id="delete_${value.id}"
// data-id="${value.id}"
// class="mdi mdi-delete mr-1 btn-delete-kyc"
// style="font-size:18px;"
// download>
// </a>`;
// let row = `
// <tr id="data_row_${value.id}"> <td>${sno}</td>
// <td>${value.ui_docs_name}</td>
// <td>${fileName}</td>
// <td>
// ${downloadBtn}
// ${editBtn}
// ${deleteBtn}
// </td>
// </tr>
// ${editUI} `;
// tbody.append(row);
// });
// }
// // docs_type_id
// // res.data.client_kyc_dd_data
// Setting values to correct fields
$('#policy_tranction_primarykey').val(res.data.id);
@ -2045,6 +1912,18 @@
setTimeout(function() {
// populateTable(res.data.pt_co_share_details, res.data.cd_ac_pk);
populateCards(res.data.pt_co_share_details, res.data.cd_ac_pk);
let s = res.data.policy_start_date.split('/'); // ["DD","MM","YYYY"]
let e = res.data.policy_end_date.split('/'); // ["DD","MM","YYYY"]
let start = new Date(s[2], s[1] - 1, s[0]); // YYYY, MM-1, DD
let end = new Date(e[2], e[1] - 1, e[0]);
let months = (end.getFullYear() - start.getFullYear()) * 12 + (end.getMonth() - start.getMonth());
if (end.getDate() >= start.getDate()) { months += 1; }
let yearDiff = Math.ceil(months / 12);
// let yearDiff = (parseInt(e[2]) - parseInt(s[2])) + 1;
console.log("yearDiff =", yearDiff);
if (yearDiff > 1) { updateInsurerTitles(yearDiff); }
}, 1000);
}
@ -3657,6 +3536,17 @@
co_share_type.forEach((value, index) => {
formData.append(`co_share_type[${index}]`, value);
});
let bp = document.getElementById("base_premium").value;
let tp = document.getElementById("tp_premium").value;
let ter = document.getElementById("ter_premium").value;
for (let i = 0; i < insurerCount; i++) {
formData.append(`base_premium[${i}]`, bp);
formData.append(`tp_premium[${i}]`, tp);
formData.append(`ter_premium[${i}]`, ter);
}
//covert date to mysql format
// alert(formData.get('policy_issue_date'));
@ -4427,7 +4317,7 @@
let cardHTML = `<div class="p-1 mb-2 insurer-card" id="insurerCardContainer_${insurerCount}" data-count="${insurerCount}">
<div class="d-flex justify-content-between align-items-center border-bottom pb-2 mb-3">
<div class="fw-bold text-primary">Insurer - ${insurerCount}</div>
<div class="fw-bold text-primary insurer-card-title">Insurer - ${insurerCount}</div>
<div class="d-flex align-items-center gap-2">
${showAdd}
@ -4492,7 +4382,7 @@
<div class="form-row mb-2">
<div class="col-md-4 mb-2 card_group_35">
<label class="card_label_35">Policy No</label>
<input type="text" class="form-control follower_policy_no" id="follower_policy_no_${insurerCount}" name="follower_policy_no[]" onchange="validateInput(this, 'client_policy', 'policy_no')" readonly>
<input type="text" class="form-control follower_policy_no" id="follower_policy_no_${insurerCount}" name="follower_policy_no[]" onchange="validateInput(this, 'client_policy', 'policy_no')">
</div>
<div class="col-md-4 mb-2 card_group_40">
<label class="card_label_40"> Policy Issue Date </label>
@ -4774,6 +4664,9 @@
</div>`;
$('#allInsurerCards').append(cardHTML);
setBPValue($('#base_premium').val());
setTEPValue($('#ter_premium').val());
setTPValue($('#tp_premium').val());
$('#follow_insurer_id_' + insurerCount).select2();
@ -4891,8 +4784,27 @@
}
console.log("UpdatedCa:", insurerCount);
updateInsurerTitles(yearDiff);
}
function updateInsurerTitles(yearDiff) {
$(".insurer-card-title").each(function (index) {
let cardIndex = index + 1;
// Base title: Insurer - X
let title = `Insurer - ${cardIndex}`;
// Add "(Year X)" only for the first yearDiff cards
if (cardIndex <= yearDiff) {
title += ` (Year ${cardIndex})`;
}
$(this).text(title);
});
}
function resetInsurerCards() {
@ -6714,9 +6626,11 @@
}
function setBPValue(inputValue) {
const bpValueField = document.querySelector('.bp_value');
if (bpValueField) {
bpValueField.value = inputValue;
let bpValueField = document.querySelectorAll('.bp_value');
if(bpValueField){
bpValueField.forEach((field) => { field.value = inputValue; });
console.log("Updated", bpValueField.length, "hidden base premiums");
} else {
console.error("Error: Element with class '.bp_value' not found.");
}
@ -6724,9 +6638,11 @@
}
function setTPValue(inputValue) {
const tpValueField = document.querySelector('.tp_value');
let tpValueField = document.querySelectorAll('.tp_value');
if (tpValueField) {
tpValueField.value = inputValue;
tpValueField.forEach((field) => { field.value = inputValue; });
console.log("Updated", tpValueFields.length, "hidden tp premiums");
} else {
console.error("Error: Element with class '.tp_value' not found.");
}
@ -6734,9 +6650,11 @@
}
function setTEPValue(inputValue) {
const tepValueField = document.querySelector('.tep_value');
let tepValueField = document.querySelectorAll('.ter_value');
tepValueField.forEach((field) => { field.value = inputValue; });
if (tepValueField) {
tepValueField.value = inputValue;
console.log("Updated", tepValueField.length, "hidden tep premiums");
} else {
console.error("Error: Element with class '.tep_value' not found.");
}

View File

@ -1,75 +1,80 @@
<div class="container-fluid-min">
<div class="container-fluid-min" style="margin-left: 30px;">
<div class="col-xl-12">
<div class="card-body">
<div id="accordion" class="mb-3">
<div class="card mb-1">
<h4 class="m-1">
<span>Filter</span>
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseOne"
aria-expanded="true">
<i id="icon" class="mdi mdi-chevron-down mr-1 text-primary" style="font-size: 28px;"></i>
</a>
</h4>
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
<div class="card-body">
<!-- <div class="text-center"> -->
<div class="form-row">
<div class="form-group col-md-3" id="date_div">
<label>Date<span class="text-danger"></span></label>
<!-- <div id="reportrange" class="form-control"
style="background: #fff; cursor: pointer; padding: 5px 10px; border: 1px solid #ccc; width: 100%">
<i class="mdi mdi-calendar-blank"></i>&nbsp;
<span></span> <i class="mdi mdi-menu-down"></i>
</div> -->
<div class="input-icon">
<input type="text" id="reportrange" class="form-control" readonly style="caret-color: transparent;">
<i class="mdi mdi-calendar-blank-outline additional-icon"></i>
</div>
<input type="hidden" id="startDate" value=<?= $default_start ?>>
<input type="hidden" id="endDate" value=<?= $default_end ?>>
<div id="accordion" class="mb-3">
<div class="card mb-1" style="background-color: #F5FFFF !important; border-radius: 10px; box-shadow: 4px 4px 4px 4px #00000040;">
<h4 class="m-1" style="display: flex;justify-content: space-between;padding: 12px;">
<span>Filter</span>
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseOne"
aria-expanded="true">
<i id="icon" class="mdi mdi-chevron-down mr-1 text-primary" style="font-size: 28px;"></i>
</a>
</h4>
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
<div class="card-body" style="margin-top: -30px;">
<!-- <div class="text-center"> -->
<div class="form-row">
<div class="form-group col-md-3" id="date_div">
<label>Date<span class="text-danger"></span></label>
<!-- <div id="reportrange" class="form-control"
style="background: #fff; cursor: pointer; padding: 5px 10px; border: 1px solid #ccc; width: 100%">
<i class="mdi mdi-calendar-blank"></i>&nbsp;
<span></span> <i class="mdi mdi-menu-down"></i>
</div> -->
<div class="input-icon">
<input type="text" id="reportrange" class="form-control" readonly style="caret-color: transparent;">
<i class="mdi mdi-calendar-blank-outline additional-icon"></i>
</div>
<input type="hidden" id="startDate" value=<?= $default_start ?>>
<input type="hidden" id="endDate" value=<?= $default_end ?>>
</div>
<div class="form-group col-md-3">
<label for="client_branch">Nhance Branch<span class="text-danger"></span></label>
<select class="form-control" id="issuer_branch" name="issuer_branch">
<option value="">Select Branch</option>
<?php
if (isset($issuer_branch) && count($issuer_branch)) {
foreach ($issuer_branch as $key => $value) {
echo "<option value=" . $value['id'] . ">" . $value['branch_name'] . "</option>";
}
<div class="form-group col-md-3">
<label for="client_branch">Nhance Branch<span class="text-danger"></span></label>
<select class="form-control" id="issuer_branch" name="issuer_branch">
<option value="">Select Branch</option>
<?php
if (isset($issuer_branch) && count($issuer_branch)) {
foreach ($issuer_branch as $key => $value) {
echo "<option value=" . $value['id'] . ">" . $value['branch_name'] . "</option>";
}
?>
</select>
</div>
<div class="form-group col-md-3 client_type_div">
<label for="client_type">Client Type<span class="text-danger"></span></label>
<select class="form-control" id="client_type" name="client_type">
<option value="">Select Client type</option>
<option value="1">Group</option>
<option value="2">Individual</option>
</select>
</div>
<div class="form-group col-md-3">
<label for="client_branch">Client<span class="text-danger"></span></label>
<select class="form-control" id="client_id" name="client_id">
<option value="">Select Client</option>
</select>
</div>
}
?>
</select>
</div>
<div class="row justify-content-end">
<div class="col-auto">
<a href="#" class="btn btn-primary waves-effect waves-light" id="get-report-page"
onclick="fetchReportPage(event);">Submit</a>
</div>
<div class="form-group col-md-3 client_type_div">
<label for="client_type">Client Type<span class="text-danger"></span></label>
<select class="form-control" id="client_type" name="client_type">
<option value="">Select Client type</option>
<option value="1">Group</option>
<option value="2">Individual</option>
</select>
</div>
<!-- </div> -->
<div class="form-group col-md-3">
<label for="client_branch">Client<span class="text-danger"></span></label>
<select class="form-control" id="client_id" name="client_id">
<option value="">Select Client</option>
<?php
if (isset($client_list) && count($client_list)) {
foreach ($client_list as $key => $value) {
echo "<option value=" . $value['id'] . ">" . $value['client_name'] . "</option>";
}
}
?>
</select>
</div>
</div>
<div class="row justify-content-end">
<div class="col-auto">
<a href="#" class="btn btn-primary waves-effect waves-light" id="get-report-page"
onclick="fetchReportPage(event);">Submit</a>
</div>
</div>
<!-- </div> -->
</div>
</div>
</div>
@ -85,8 +90,9 @@
let client_list = [];
$(document).ready(function() {
getClientAndBranchAndPolicy();
// getClientAndBranchAndPolicy();
$('#client_id').select2();
$('#issuer_branch').select2();
})
$(function() {
@ -173,9 +179,13 @@
//get client , branch, policy data
function getClientAndBranchAndPolicy() {
return_type = 'client';
$.ajax({
url: '<?= base_url("/util/getClientAndBranchAndPolicy") ?>',
type: "GET",
data:{ return_type : return_type},
dataType: 'json',
success: function(res) {