Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
0b04fdfa62
@ -427,7 +427,7 @@ $routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$routes->group("report", ["filter" => "authMVC"], function ($routes) {
|
$routes->group("report", ["filter" => "authMVC"], function ($routes) {
|
||||||
$routes->match(['get', 'post'],"list", "PolicyTransactionController::reportBDS");
|
$routes->match(['get', 'post'],"list", "PolicyTransactionController::reportBDSNew");
|
||||||
$routes->match(['get', 'post'],"listNew", "PolicyTransactionController::reportBDSNew");
|
$routes->match(['get', 'post'],"listNew", "PolicyTransactionController::reportBDSNew");
|
||||||
$routes->get("report-varience-list", "PolicyTransactionController::reportVarience");
|
$routes->get("report-varience-list", "PolicyTransactionController::reportVarience");
|
||||||
$routes->get("report-business-list", "PolicyTransactionController::reportBusinessList");
|
$routes->get("report-business-list", "PolicyTransactionController::reportBusinessList");
|
||||||
|
|||||||
@ -53,6 +53,7 @@ use Illuminate\Http\Request;
|
|||||||
|
|
||||||
use App\Controllers\EmployeeServiceController;
|
use App\Controllers\EmployeeServiceController;
|
||||||
use App\Models\ClaimFilesModel;
|
use App\Models\ClaimFilesModel;
|
||||||
|
use App\Models\TicketMailTemplateModel;
|
||||||
use Kreait\Firebase\Factory;
|
use Kreait\Firebase\Factory;
|
||||||
use Kreait\Firebase\Messaging\CloudMessage;
|
use Kreait\Firebase\Messaging\CloudMessage;
|
||||||
use Kreait\Firebase\Messaging\Notification;
|
use Kreait\Firebase\Messaging\Notification;
|
||||||
@ -90,6 +91,7 @@ class EmployeeRestController extends AdminController
|
|||||||
protected $hrAccessControlModel;
|
protected $hrAccessControlModel;
|
||||||
protected $insurerModel;
|
protected $insurerModel;
|
||||||
protected $hrFileUploadModel;
|
protected $hrFileUploadModel;
|
||||||
|
protected $ticketMailTemplateModel;
|
||||||
|
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
@ -122,6 +124,7 @@ class EmployeeRestController extends AdminController
|
|||||||
$this->hrAccessControlModel = new HRAccessControlModel();
|
$this->hrAccessControlModel = new HRAccessControlModel();
|
||||||
$this->insurerModel = new InsurerModel();
|
$this->insurerModel = new InsurerModel();
|
||||||
$this->hrFileUploadModel = new HrFileUploadModel();
|
$this->hrFileUploadModel = new HrFileUploadModel();
|
||||||
|
$this->ticketMailTemplateModel = new TicketMailTemplateModel();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4174,7 +4177,11 @@ class EmployeeRestController extends AdminController
|
|||||||
];
|
];
|
||||||
|
|
||||||
// Save into DB
|
// Save into DB
|
||||||
$this->hrFileUploadModel->insert($data);
|
$result = $this->hrFileUploadModel->insert($data);
|
||||||
|
|
||||||
|
if($result && $data['file_action'] == "addition"){
|
||||||
|
$this->giveNotificationToClientsAccountManager($data);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->respondCreated([
|
return $this->respondCreated([
|
||||||
'status' => true,
|
'status' => true,
|
||||||
@ -4188,6 +4195,51 @@ class EmployeeRestController extends AdminController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function giveNotificationToClientsAccountManager($data){
|
||||||
|
|
||||||
|
// $data = [
|
||||||
|
// 'client_id' => $this->request->getPost('client_id'),
|
||||||
|
// 'client_branch_id' => $this->request->getPost('client_branch_id'),
|
||||||
|
// 'policy_id' => $this->request->getPost('policy_id'),
|
||||||
|
// 'policy_no' => $this->request->getPost('policy_no'),
|
||||||
|
// 'file_name' => $newFileName,
|
||||||
|
// 'file_action' => $this->request->getPost('file_action'),
|
||||||
|
// 'status' => 'Yet to start',
|
||||||
|
// 'created_by' => $this->request->getPost('created_by'),
|
||||||
|
// 'updated_by' => $this->request->getPost('created_by'),
|
||||||
|
// ];
|
||||||
|
|
||||||
|
$client_name = $this->clientModel->where('id',$data['client_id'])->findAll()[0]['client_name'] ?? [] ;
|
||||||
|
|
||||||
|
$account_manager_email = $this->clientRMModel->findAccountManagerEmail($data['client_id']);
|
||||||
|
|
||||||
|
$templateName = "inception_addition";
|
||||||
|
|
||||||
|
$mailTemplate = $this->ticketMailTemplateModel->where('template_name', $templateName)->findAll()[0] ?? [];
|
||||||
|
|
||||||
|
if(empty($mailTemplate)){
|
||||||
|
//empty mail template please update the template in database or create one..!!
|
||||||
|
log_message("error","Empty mail template for inception_addition please update the template in database or create one..!!");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
$mailTemplate['mail_content'] = str_replace('%client_name%', $client_name ?? '', $mailTemplate['mail_content']);
|
||||||
|
$mailTemplate['mail_content'] = str_replace('%policy_no%', $data['policy_no'] ?? '', $mailTemplate['mail_content']);
|
||||||
|
|
||||||
|
$from_mail = "";
|
||||||
|
$to_mail = $account_manager_email;
|
||||||
|
$subject = $mailTemplate['subject'];
|
||||||
|
$message = $mailTemplate['content'];
|
||||||
|
$cc_string = "";
|
||||||
|
$attachments = "";
|
||||||
|
$reply_to = "";
|
||||||
|
$bcc_string = "";
|
||||||
|
|
||||||
|
|
||||||
|
MailHelper::send_email(['from_mail' => $from_mail, 'mail' => $to_mail, 'cc' => $cc_string, 'subject' => $subject, 'message' => $message, 'attachments' => $attachments, 'reply_to' => $reply_to, 'bcc' => $bcc_string]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function updateHrFileUploadData()
|
public function updateHrFileUploadData()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -2409,8 +2409,8 @@ class PolicyTransactionController extends BaseController
|
|||||||
|
|
||||||
// $client_name = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[3]); //clientname from excel
|
// $client_name = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[3]); //clientname from excel
|
||||||
|
|
||||||
$endorsement_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[2]); //policy_end_date from excel
|
$endorsement_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[2]??''); //policy_end_date from excel
|
||||||
$endorsement_no = preg_replace( '/[\x{200B}\x{200C}\x{200D}\x{FEFF}\x{00A0}\x{200E}\x{200F}\x{202A}-\x{202E}]/u', '', $excel_row[2]); //policy_end_date from excel
|
$endorsement_no = preg_replace( '/[\x{200B}\x{200C}\x{200D}\x{FEFF}\x{00A0}\x{200E}\x{200F}\x{202A}-\x{202E}]/u', '', $excel_row[2]??''); //policy_end_date from excel
|
||||||
|
|
||||||
// Kint::dump($excel_key,$policy_no,$endorsement_no,$policy_start_date,$policy_end_date);//die();
|
// Kint::dump($excel_key,$policy_no,$endorsement_no,$policy_start_date,$policy_end_date);//die();
|
||||||
foreach ($source_data as $source_key => $source_row) {
|
foreach ($source_data as $source_key => $source_row) {
|
||||||
|
|||||||
@ -1829,24 +1829,35 @@ class PolicyTransactionModel extends Model
|
|||||||
// ==============================
|
// ==============================
|
||||||
if ($date_type == 'statement_month' && $start_date != 0 && $end_date != 0) {
|
if ($date_type == 'statement_month' && $start_date != 0 && $end_date != 0) {
|
||||||
$date_condition = "
|
$date_condition = "
|
||||||
AND insurer_statements.month >= '{$start_date}'
|
AND insurer_statements_oq.month >= '{$start_date}'
|
||||||
AND insurer_statements.month <= '{$end_date}'
|
AND insurer_statements_oq.month <= '{$end_date}'
|
||||||
";
|
";
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==============================
|
// ==============================
|
||||||
// BASE QUERY
|
// BASE QUERY
|
||||||
// ==============================
|
// ==============================
|
||||||
$builder = $this->db->table('policy_transaction')
|
|
||||||
|
|
||||||
|
// ==============================
|
||||||
|
// Without Statement Upload
|
||||||
|
// ==============================
|
||||||
|
|
||||||
|
|
||||||
|
$builder2 = $this->db->table('policy_transaction')
|
||||||
->select("
|
->select("
|
||||||
policy_transaction.*,
|
policy_transaction.id AS id,
|
||||||
|
policy_transaction.endorsement_no AS endorsement_no,
|
||||||
|
policy_transaction.ref AS ref,
|
||||||
DATE_FORMAT(policy_transaction.policy_issue_date, '%d %b %Y') AS policy_issue_date,
|
DATE_FORMAT(policy_transaction.policy_issue_date, '%d %b %Y') AS policy_issue_date,
|
||||||
DATE_FORMAT(
|
|
||||||
IF(policy_transaction.month IS NULL,
|
DATE_FORMAT( policy_transaction.policy_issue_date,, '%b %Y') AS policy_issue_month,
|
||||||
policy_transaction.policy_issue_date,
|
|
||||||
policy_transaction.month
|
CASE
|
||||||
), '%b %Y'
|
WHEN 1 = 1 THEN 'no statement uploaded'
|
||||||
) AS policy_issue_month,
|
ELSE 'statement uploaded'
|
||||||
|
END AS statement_uploaded ,
|
||||||
|
|
||||||
|
|
||||||
CASE
|
CASE
|
||||||
WHEN clients.client_type = 1 THEN 'Group'
|
WHEN clients.client_type = 1 THEN 'Group'
|
||||||
@ -1898,89 +1909,15 @@ class PolicyTransactionModel extends Model
|
|||||||
|
|
||||||
-- ==============================
|
-- ==============================
|
||||||
-- SUBQUERY: Total IRDA Amount
|
-- SUBQUERY: Total IRDA Amount
|
||||||
|
-- Alias Agreed Amount ...!!
|
||||||
-- ==============================
|
-- ==============================
|
||||||
ROUND((
|
ROUND(pt_co_share_details.exp_amt, 2) AS total_irda_amt,
|
||||||
SELECT (
|
|
||||||
SUM(co_share_stmt_details.actual_bp_brokerage_amt) +
|
|
||||||
SUM(co_share_stmt_details.actual_tp_brokerage_amt) +
|
|
||||||
SUM(co_share_stmt_details.actual_tep_brokerage_amt) +
|
|
||||||
SUM(co_share_stmt_details.reward)
|
|
||||||
)
|
|
||||||
FROM co_share_stmt_details
|
|
||||||
JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id
|
|
||||||
WHERE co_share_stmt_details.co_share_id = pt_co_share_details.id
|
|
||||||
AND co_share_stmt_details.is_active = 1
|
|
||||||
AND insurer_statements.is_active = 1
|
|
||||||
{$date_condition}
|
|
||||||
), 2) AS total_irda_amt,
|
|
||||||
|
|
||||||
-- Reward Only
|
-- Reward Only
|
||||||
ROUND((
|
ROUND(0, 2) AS reward,
|
||||||
SELECT SUM(co_share_stmt_details.reward)
|
|
||||||
FROM co_share_stmt_details
|
|
||||||
JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id
|
|
||||||
WHERE co_share_stmt_details.co_share_id = pt_co_share_details.id
|
|
||||||
AND co_share_stmt_details.is_active = 1
|
|
||||||
AND insurer_statements.is_active = 1
|
|
||||||
{$date_condition}
|
|
||||||
), 2) AS reward,
|
|
||||||
|
|
||||||
-- Billed Amount
|
-- Billed Amount
|
||||||
ROUND((
|
ROUND(0, 2) AS billed_amt,
|
||||||
SELECT SUM(
|
|
||||||
COALESCE(co_share_stmt_details.actual_bp_brokerage_amt, 0) +
|
|
||||||
COALESCE(co_share_stmt_details.actual_tp_brokerage_amt, 0) +
|
|
||||||
COALESCE(co_share_stmt_details.actual_tep_brokerage_amt, 0) +
|
|
||||||
COALESCE(co_share_stmt_details.reward, 0)
|
|
||||||
)
|
|
||||||
FROM co_share_stmt_details
|
|
||||||
JOIN pt_co_share_details AS pt_table ON co_share_stmt_details.co_share_id = pt_table.id
|
|
||||||
JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id
|
|
||||||
WHERE co_share_stmt_details.co_share_id = pt_co_share_details.id
|
|
||||||
AND co_share_stmt_details.is_active = 1
|
|
||||||
AND pt_table.is_active = 1
|
|
||||||
AND insurer_statements.is_active = 1
|
|
||||||
AND insurer_statements.invoice_status IS NOT NULL
|
|
||||||
{$date_condition}
|
|
||||||
), 2) AS billed_amt,
|
|
||||||
|
|
||||||
-- Unbilled Amount
|
|
||||||
ROUND(
|
|
||||||
(
|
|
||||||
(
|
|
||||||
SELECT
|
|
||||||
SUM(
|
|
||||||
COALESCE(co_share_stmt_details.actual_bp_brokerage_amt, 0) +
|
|
||||||
COALESCE(co_share_stmt_details.actual_tp_brokerage_amt, 0) +
|
|
||||||
COALESCE(co_share_stmt_details.actual_tep_brokerage_amt, 0) +
|
|
||||||
COALESCE(co_share_stmt_details.reward, 0)
|
|
||||||
)
|
|
||||||
FROM co_share_stmt_details
|
|
||||||
JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id
|
|
||||||
WHERE co_share_stmt_details.co_share_id = pt_co_share_details.id
|
|
||||||
AND co_share_stmt_details.is_active = 1
|
|
||||||
{$date_condition}
|
|
||||||
)
|
|
||||||
-
|
|
||||||
(
|
|
||||||
SELECT
|
|
||||||
SUM(
|
|
||||||
COALESCE(co_share_stmt_details.actual_bp_brokerage_amt, 0) +
|
|
||||||
COALESCE(co_share_stmt_details.actual_tp_brokerage_amt, 0) +
|
|
||||||
COALESCE(co_share_stmt_details.actual_tep_brokerage_amt, 0) +
|
|
||||||
COALESCE(co_share_stmt_details.reward, 0)
|
|
||||||
)
|
|
||||||
FROM co_share_stmt_details
|
|
||||||
JOIN pt_co_share_details AS pt_table ON co_share_stmt_details.co_share_id = pt_table.id
|
|
||||||
JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id
|
|
||||||
WHERE co_share_stmt_details.co_share_id = pt_co_share_details.id
|
|
||||||
AND co_share_stmt_details.is_active = 1
|
|
||||||
AND pt_table.is_active = 1
|
|
||||||
AND insurer_statements.is_active = 1
|
|
||||||
AND insurer_statements.invoice_status IS NULL
|
|
||||||
{$date_condition}
|
|
||||||
)
|
|
||||||
), 2) AS unbilled_amt,
|
|
||||||
|
|
||||||
created_user.first_name AS user_name,
|
created_user.first_name AS user_name,
|
||||||
|
|
||||||
@ -2012,9 +1949,255 @@ class PolicyTransactionModel extends Model
|
|||||||
->join('tpa_branch', 'policy_transaction.tpa_branch_id = tpa_branch.id', 'left')
|
->join('tpa_branch', 'policy_transaction.tpa_branch_id = tpa_branch.id', 'left')
|
||||||
->join('user_profiles AS sales_user', 'policy_transaction.sales_generated_by = sales_user.id', 'left')
|
->join('user_profiles AS sales_user', 'policy_transaction.sales_generated_by = sales_user.id', 'left')
|
||||||
->join('user_profiles AS service_user', 'policy_transaction.serviced_by = service_user.id', 'left')
|
->join('user_profiles AS service_user', 'policy_transaction.serviced_by = service_user.id', 'left')
|
||||||
->join('user_profiles AS created_user', 'policy_transaction.created_by = created_user.id', 'left')
|
->join('user_profiles AS created_user', 'policy_transaction.created_by = created_user.id', 'left')
|
||||||
|
|
||||||
->where('policy_transaction.is_active', 1)
|
->where('policy_transaction.is_active', 1)
|
||||||
->where('pt_co_share_details.is_active', 1);
|
->where('pt_co_share_details.is_active', 1)
|
||||||
|
|
||||||
|
// ========================================================
|
||||||
|
// GROUP BY Insurer Statement Months
|
||||||
|
// =======================================================
|
||||||
|
->groupBy('policy_transaction.policy_no , pt_co_share_details.insurer_id ');
|
||||||
|
|
||||||
|
// ==============================
|
||||||
|
// ROLE-BASED FILTERS
|
||||||
|
// ==============================
|
||||||
|
if (
|
||||||
|
(!in_array(get_role_id(), [1, 5])) &&
|
||||||
|
!(
|
||||||
|
in_array(MANAGEMENT_TEAM_ID, user_team()) ||
|
||||||
|
in_array(FINANCE_TEAM_ID, user_team()) ||
|
||||||
|
in_array(BUSINESS_TEAM_ID, user_team())
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
if (get_role_id() == 4 && in_array(POS_TEAM_ID, user_team())) {
|
||||||
|
$builder2->where('policy_transaction.created_by', get_session_userid());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==============================
|
||||||
|
// ADDITIONAL FILTERS
|
||||||
|
// ==============================
|
||||||
|
if (!empty($where)) {
|
||||||
|
log_message('info', 'Where condition: ' . json_encode($where));
|
||||||
|
$builder2->where($where);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($start_date != 0 && $end_date != 0 && $date_type != 0 && $date_type != 'statement_month') {
|
||||||
|
$startDate = date('Y-m-d 00:00:00', strtotime($start_date));
|
||||||
|
$endDate = date('Y-m-d 23:59:59', strtotime($end_date));
|
||||||
|
|
||||||
|
$builder2->where("policy_transaction.{$date_type} >=", $startDate)
|
||||||
|
->where("policy_transaction.{$date_type} <=", $endDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ==============================
|
||||||
|
// FILTER BY IDs
|
||||||
|
// ==============================
|
||||||
|
if ($client_id != 0) $builder2->where('policy_transaction.client_id', $client_id);
|
||||||
|
if ($insurer_id != 0) $builder2->where('policy_transaction.insurer_id', $insurer_id);
|
||||||
|
if ($client_branch_id != 0) $builder2->where('policy_transaction.client_branch_id', $client_branch_id);
|
||||||
|
if ($insurer_branch_id != 0) $builder2->where('policy_transaction.insurer_branch_id', $insurer_branch_id);
|
||||||
|
if ($client_policy_id != 0) $builder2->where('policy_transaction.client_policy_id', $client_policy_id);
|
||||||
|
if ($user_id != 0) $builder2->where('policy_transaction.created_by', $user_id);
|
||||||
|
if ($policy_type_id != 0) $builder2->where('client_policy.policy_type_id', $policy_type_id);
|
||||||
|
if ($issuer != 0) $builder2->where('policy_transaction.issuer', $issuer);
|
||||||
|
|
||||||
|
// ==============================
|
||||||
|
// DEFAULT 90-DAY FILTER
|
||||||
|
// ==============================
|
||||||
|
if (
|
||||||
|
$client_id == 0 &&
|
||||||
|
$insurer_id == 0 &&
|
||||||
|
$policy_type_id == 0 &&
|
||||||
|
$date_type == 0 &&
|
||||||
|
$issuer == 0
|
||||||
|
) {
|
||||||
|
$fromDate = date('Y-m-d', strtotime('-90 days'));
|
||||||
|
$toDate = date('Y-m-d 23:59:59');
|
||||||
|
|
||||||
|
if (empty($where)) {
|
||||||
|
$builder2->where('policy_transaction.created_at >=', $fromDate)
|
||||||
|
->where('policy_transaction.created_at <=', $toDate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ==============================
|
||||||
|
// With Statement Upload
|
||||||
|
// ==============================
|
||||||
|
|
||||||
|
$builder = $this->db->table('policy_transaction')
|
||||||
|
->select("
|
||||||
|
policy_transaction.id AS id,
|
||||||
|
policy_transaction.endorsement_no AS endorsement_no,
|
||||||
|
policy_transaction.ref AS ref,
|
||||||
|
DATE_FORMAT(policy_transaction.policy_issue_date, '%d %b %Y') AS policy_issue_date,
|
||||||
|
DATE_FORMAT(
|
||||||
|
IF(insurer_statements_oq.month IS NULL,
|
||||||
|
policy_transaction.policy_issue_date,
|
||||||
|
insurer_statements_oq.month
|
||||||
|
), '%b %Y'
|
||||||
|
) AS policy_issue_month,
|
||||||
|
|
||||||
|
CASE
|
||||||
|
WHEN insurer_statements_oq.month IS NULL THEN 'no statement uploaded'
|
||||||
|
ELSE 'statement uploaded'
|
||||||
|
END AS statement_uploaded ,
|
||||||
|
|
||||||
|
|
||||||
|
CASE
|
||||||
|
WHEN clients.client_type = 1 THEN 'Group'
|
||||||
|
WHEN clients.client_type = 2 THEN 'Retail'
|
||||||
|
ELSE '-'
|
||||||
|
END AS client_type,
|
||||||
|
|
||||||
|
CASE
|
||||||
|
WHEN policy_transaction.revenue_type = 'NA' THEN 'Fresh'
|
||||||
|
ELSE 'Renewal'
|
||||||
|
END AS revenue_type,
|
||||||
|
|
||||||
|
CASE
|
||||||
|
WHEN policy_transaction.action_type = 'inception' THEN 'Policy'
|
||||||
|
ELSE 'Endorsement'
|
||||||
|
END AS action_type,
|
||||||
|
|
||||||
|
clients.client_name AS client_name,
|
||||||
|
clients.short_name AS client_short_name,
|
||||||
|
client_branch.branch_name AS client_branch_name,
|
||||||
|
client_branch.address1 AS client_address,
|
||||||
|
policy_type.policy_type,
|
||||||
|
policy_type.bap,
|
||||||
|
insurers.name AS insurer_name,
|
||||||
|
insurers.short_name AS insurer_short_name,
|
||||||
|
insurer_branch.branch_name AS insurer_branch_name,
|
||||||
|
insurer_branch.branch_code AS insurer_branch_code,
|
||||||
|
user_profiles.first_name AS user_name,
|
||||||
|
vehicle.vehicle_no,
|
||||||
|
tpa.name AS tpa_name,
|
||||||
|
pt_co_share_details.remark AS remarks,
|
||||||
|
pt_co_share_details.cop_amt AS bp_amt,
|
||||||
|
pt_co_share_details.exp_amt,
|
||||||
|
pt_co_share_details.id AS pt_id,
|
||||||
|
sales_user.first_name AS salse_person_name,
|
||||||
|
service_user.first_name AS service_person_name,
|
||||||
|
|
||||||
|
ROUND(pt_co_share_details.cop_amt + pt_co_share_details.cotp_amt + pt_co_share_details.cotep_amt, 2) AS premium_wo_gst,
|
||||||
|
ROUND((ROUND(pt_co_share_details.cop_amt + pt_co_share_details.cotp_amt + pt_co_share_details.cotep_amt, 2) * 18 / 100), 2) AS gst_amount,
|
||||||
|
ROUND(
|
||||||
|
ROUND(pt_co_share_details.cop_amt + pt_co_share_details.cotp_amt + pt_co_share_details.cotep_amt, 2) +
|
||||||
|
ROUND((ROUND(pt_co_share_details.cop_amt + pt_co_share_details.cotp_amt + pt_co_share_details.cotep_amt, 2) * 18 / 100), 2),
|
||||||
|
2) AS total_premium,
|
||||||
|
|
||||||
|
ROUND(pt_co_share_details.cotp_amt + pt_co_share_details.cotep_amt, 2) AS tp_or_ter,
|
||||||
|
DATEDIFF(policy_transaction.policy_end_date, CURDATE()) AS days,
|
||||||
|
(pt_co_share_details.agreed_tp_per + pt_co_share_details.agreed_tep_per) AS agreed_tp_or_ter_per,
|
||||||
|
pt_co_share_details.agreed_bp_per,
|
||||||
|
|
||||||
|
-- ==============================
|
||||||
|
-- SUBQUERY: Total IRDA Amount
|
||||||
|
-- Alias Agreed Amount ...!!
|
||||||
|
-- ==============================
|
||||||
|
ROUND(pt_co_share_details.exp_amt, 2) AS total_irda_amt,
|
||||||
|
-- Reward Only
|
||||||
|
ROUND((
|
||||||
|
SELECT SUM(co_share_stmt_details.reward)
|
||||||
|
FROM co_share_stmt_details
|
||||||
|
JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id
|
||||||
|
WHERE co_share_stmt_details.co_share_id = pt_co_share_details.id
|
||||||
|
AND co_share_stmt_details.is_active = 1
|
||||||
|
AND insurer_statements.is_active = 1
|
||||||
|
AND insurer_statements.month = insurer_statements_oq.month
|
||||||
|
{$date_condition}
|
||||||
|
GROUP BY('policy_transaction.policy_no , insurer_statements.month , pt_co_share_details.insurer_id')
|
||||||
|
), 2) AS reward,
|
||||||
|
|
||||||
|
-- Billed Amount
|
||||||
|
ROUND((
|
||||||
|
SELECT SUM(
|
||||||
|
COALESCE(co_share_stmt_details.actual_bp_brokerage_amt, 0) +
|
||||||
|
COALESCE(co_share_stmt_details.actual_tp_brokerage_amt, 0) +
|
||||||
|
COALESCE(co_share_stmt_details.actual_tep_brokerage_amt, 0) +
|
||||||
|
COALESCE(co_share_stmt_details.reward, 0)
|
||||||
|
)
|
||||||
|
FROM co_share_stmt_details
|
||||||
|
JOIN pt_co_share_details AS pt_table ON co_share_stmt_details.co_share_id = pt_table.id
|
||||||
|
JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id
|
||||||
|
WHERE co_share_stmt_details.co_share_id = pt_co_share_details.id
|
||||||
|
AND co_share_stmt_details.is_active = 1
|
||||||
|
AND pt_table.is_active = 1
|
||||||
|
AND insurer_statements.is_active = 1
|
||||||
|
AND insurer_statements.invoice_status IS NOT NULL
|
||||||
|
AND insurer_statements.month = insurer_statements_oq.month
|
||||||
|
{$date_condition}
|
||||||
|
GROUP BY('policy_transaction.policy_no , insurer_statements.month , pt_co_share_details.insurer_id')
|
||||||
|
), 2) AS billed_amt,
|
||||||
|
|
||||||
|
created_user.first_name AS user_name,
|
||||||
|
|
||||||
|
CASE
|
||||||
|
WHEN pt_co_share_details.co_share_type IN (0, 1) THEN policy_transaction.policy_no
|
||||||
|
WHEN pt_co_share_details.co_share_type > 1 THEN
|
||||||
|
CASE
|
||||||
|
WHEN pt_co_share_details.follower_policy_no IS NULL OR pt_co_share_details.follower_policy_no = ''
|
||||||
|
THEN policy_transaction.policy_no
|
||||||
|
ELSE pt_co_share_details.follower_policy_no
|
||||||
|
END
|
||||||
|
ELSE policy_transaction.policy_no
|
||||||
|
END AS policy_no
|
||||||
|
")
|
||||||
|
|
||||||
|
// ==============================
|
||||||
|
// JOINS
|
||||||
|
// ==============================
|
||||||
|
->join('pt_co_share_details', 'policy_transaction.id = pt_co_share_details.pt_id', 'left')
|
||||||
|
->join('clients', 'clients.id = policy_transaction.client_id')
|
||||||
|
->join('client_branch', 'policy_transaction.client_branch_id = client_branch.id', 'left')
|
||||||
|
->join('client_policy', 'policy_transaction.client_policy_id = client_policy.id', 'left')
|
||||||
|
->join('user_profiles', 'policy_transaction.created_by = user_profiles.id', 'left')
|
||||||
|
->join('vehicle', 'policy_transaction.vehicle_id = vehicle.id', 'left')
|
||||||
|
->join('policy_type', 'policy_transaction.policy_type_id = policy_type.id', 'left')
|
||||||
|
->join('insurers', 'pt_co_share_details.insurer_id = insurers.id', 'left')
|
||||||
|
->join('insurer_branch', 'pt_co_share_details.insurer_branch_id = insurer_branch.id', 'left')
|
||||||
|
->join('tpa', 'policy_transaction.tpa_id = tpa.id', 'left')
|
||||||
|
->join('tpa_branch', 'policy_transaction.tpa_branch_id = tpa_branch.id', 'left')
|
||||||
|
->join('user_profiles AS sales_user', 'policy_transaction.sales_generated_by = sales_user.id', 'left')
|
||||||
|
->join('user_profiles AS service_user', 'policy_transaction.serviced_by = service_user.id', 'left')
|
||||||
|
->join('user_profiles AS created_user', 'policy_transaction.created_by = created_user.id', 'left')
|
||||||
|
|
||||||
|
|
||||||
|
->join('co_share_stmt_details', 'pt_co_share_details.id = co_share_stmt_details.co_share_id','left')
|
||||||
|
->join('insurer_statements insurer_statements_oq','insurer_statements_oq.id = co_share_stmt_details.statement_id','left')
|
||||||
|
|
||||||
|
->where('policy_transaction.is_active', 1)
|
||||||
|
->where('pt_co_share_details.is_active', 1)
|
||||||
|
->where('insurer_statements_oq.id IS NOT NULL')
|
||||||
|
|
||||||
|
|
||||||
|
// ========================================================
|
||||||
|
// GROUP BY Insurer Statement Months
|
||||||
|
// =======================================================
|
||||||
|
->groupBy('policy_transaction.policy_no , pt_co_share_details.insurer_id ,insurer_statements_oq.month');
|
||||||
|
|
||||||
// ==============================
|
// ==============================
|
||||||
// ROLE-BASED FILTERS
|
// ROLE-BASED FILTERS
|
||||||
@ -2092,17 +2275,22 @@ class PolicyTransactionModel extends Model
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==============================
|
|
||||||
// ORDER & EXECUTION
|
|
||||||
// ==============================
|
|
||||||
$builder->orderBy('policy_transaction.id', 'desc');
|
|
||||||
|
|
||||||
$result = $builder->get()->getResultArray();
|
|
||||||
|
|
||||||
// Uncomment if you need to debug SQL
|
|
||||||
// dd($this->db->getLastQuery());
|
|
||||||
|
$sql1 = $builder2->getCompiledSelect();
|
||||||
|
$sql2 = $builder->getCompiledSelect();
|
||||||
|
|
||||||
|
$finalSql = "($sql1) UNION ALL ($sql2)
|
||||||
|
ORDER BY policy_no DESC, insurer_branch_name ASC, statement_uploaded ASC,
|
||||||
|
STR_TO_DATE(policy_issue_month, '%b %Y') ASC";
|
||||||
|
|
||||||
|
|
||||||
|
$result = $this->db->query($finalSql)->getResultArray();
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -113,8 +113,91 @@ table.dataTable tbody td {
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php if (isset($report_list)) { ?>
|
<?php if (isset($report_list)) {
|
||||||
<?php foreach($report_list as $index => $row){ ?>
|
|
||||||
|
// empty array to initialize for policies per insurer per month
|
||||||
|
|
||||||
|
$uniquePoliciesReport = [];
|
||||||
|
|
||||||
|
// irrespective of months or multiple months
|
||||||
|
$uniqueAgreedAmountList = [];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
foreach($report_list as $index => $row){
|
||||||
|
|
||||||
|
$policy_no = $row['policy_no'];
|
||||||
|
|
||||||
|
$policy_updated_month = $row['policy_issue_month'];
|
||||||
|
|
||||||
|
$policy_type = $row['policy_type'];
|
||||||
|
|
||||||
|
$statement_status = $row['statement_uploaded'];
|
||||||
|
|
||||||
|
$client_name = $row['client_name'];
|
||||||
|
|
||||||
|
$insurer_branch_name = $row['insurer_branch_name'];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$uniqueRecord = "$policy_no-$policy_updated_month-$policy_type-$client_name-$insurer_branch_name" ;
|
||||||
|
|
||||||
|
// irrespective of months or multiple months
|
||||||
|
$uniqueAgreedAmountPerInsurer = "$policy_no-$policy_type-$client_name-$insurer_branch_name" ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(isset($uniquePoliciesReport[$uniqueRecord]) && $statement_status == "no statement uploaded" ){
|
||||||
|
continue ;
|
||||||
|
}
|
||||||
|
else if(isset($uniquePoliciesReport[$uniqueRecord]) && $statement_status == "statement uploaded" ){
|
||||||
|
unset($uniquePoliciesReport[$uniqueRecord]);
|
||||||
|
}else{
|
||||||
|
|
||||||
|
if(isset($uniqueAgreedAmountList[$uniqueAgreedAmountPerInsurer]) ){
|
||||||
|
$uniqueAgreedAmountList[$uniqueAgreedAmountPerInsurer] -= $row['billed_amt'];
|
||||||
|
$row['total_irda_amt'] = 0;
|
||||||
|
$row['outstanding_amt'] = $uniqueAgreedAmountList[$uniqueAgreedAmountPerInsurer];
|
||||||
|
$row['multiple_months'] = true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$row['outstanding_amt'] = $row['total_irda_amt'] - $row['billed_amt'];
|
||||||
|
$uniqueAgreedAmountList[$uniqueAgreedAmountPerInsurer] = $row['total_irda_amt'] ;
|
||||||
|
$row['multiple_months'] = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$uniquePoliciesReport[$uniqueRecord] = $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$report_list = array_values($uniquePoliciesReport);
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<?php foreach($report_list as $index => $row){
|
||||||
|
|
||||||
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><?= $index + 1 ?> <a href="<?php
|
<td><?= $index + 1 ?> <a href="<?php
|
||||||
if($row['action_type'] == "inception"){
|
if($row['action_type'] == "inception"){
|
||||||
@ -123,8 +206,9 @@ table.dataTable tbody td {
|
|||||||
echo base_url('policy_tranction/endorsement/list') . '?pt_id=' . $row['id'] ;
|
echo base_url('policy_tranction/endorsement/list') . '?pt_id=' . $row['id'] ;
|
||||||
}
|
}
|
||||||
?>" class="mdi mdi-pencil" ></a> </td>
|
?>" class="mdi mdi-pencil" ></a> </td>
|
||||||
<td style="display: none;"><?php echo $row['user_name'] ?: 'N/A'; ?></td>
|
<td ><?php echo $row['statement_uploaded'] == 'statement uploaded' && $row['multiple_months'] == true ? 'rewards': $row['user_name']??'N/A' ; ?></td>
|
||||||
<td><?php echo $row['policy_issue_month'] ?: 'N/A'; ?></td>
|
<td><?php echo $row['policy_issue_month'] ?: 'N/A'; ?></td>
|
||||||
|
<td style="display: none;"><?php echo $row['statement_uploaded'] ?: 'N/A'; ?></td>
|
||||||
<!-- <td style="display: none;"><?php echo $row['revenue_type'] ?: 'N/A'; ?></td> -->
|
<!-- <td style="display: none;"><?php echo $row['revenue_type'] ?: 'N/A'; ?></td> -->
|
||||||
<td style="display: none;"><?php echo $row['client_type'] ?: 'N/A'; ?></td>
|
<td style="display: none;"><?php echo $row['client_type'] ?: 'N/A'; ?></td>
|
||||||
<td><?php echo $row['client_name'] ?: 'N/A'; ?></td>
|
<td><?php echo $row['client_name'] ?: 'N/A'; ?></td>
|
||||||
@ -149,17 +233,13 @@ table.dataTable tbody td {
|
|||||||
<td class="right-align-input"><?php echo $row['total_premium']; ?></td>
|
<td class="right-align-input"><?php echo $row['total_premium']; ?></td>
|
||||||
<td class="right-align-input"><?php echo $row['agreed_bp_per']; ?> %</td>
|
<td class="right-align-input"><?php echo $row['agreed_bp_per']; ?> %</td>
|
||||||
<td class="right-align-input"><?php echo $row['agreed_tp_or_ter_per'];?> %</td>
|
<td class="right-align-input"><?php echo $row['agreed_tp_or_ter_per'];?> %</td>
|
||||||
<td class="right-align-input" style="display: none;"><?php echo isset($row['reward']) ? $row['reward'] : '0.00'; ?></td>
|
<td class="right-align-input" ><?php echo isset($row['reward']) ? $row['reward'] : '0.00'; ?></td>
|
||||||
|
<!-- Agreed Amount as total_irda_amt -->
|
||||||
<?php $total_irda_amt = empty($row['total_irda_amt']) ? $row['exp_amt'] : $row['total_irda_amt']; ?>
|
<td class="right-align-input" onclick="showCoShareStatementDetails(this)" data-id="<?= $row['pt_id'] ?>"><?php echo $row['total_irda_amt']; ?></td>
|
||||||
<td class="right-align-input" onclick="showCoShareStatementDetails(this)" data-id="<?= $row['pt_id'] ?>"><?php echo $total_irda_amt; ?></td>
|
<!-- invoiced amount as billed_amt -->
|
||||||
<td class="right-align-input"><?php echo empty($row['billed_amt']) ? '0.00' : $row['billed_amt'] ?></td>
|
<td class="right-align-input"><?php echo empty($row['billed_amt']) ? '0.00' : $row['billed_amt'] ?></td>
|
||||||
<!-- <td class="right-align-input"><?php echo empty($row['unbilled_amt']) ? '0.00' : $row['unbilled_amt']?></td> -->
|
<!-- Outstanding Amount (Agreed amount - invoice amount) -->
|
||||||
<?php
|
<td class="right-align-input"><?php echo number_format((float)$row['outstanding_amt'],2, '.', '')?></td>
|
||||||
$unbilled_amt = $row['total_irda_amt'] - $row['billed_amt'];
|
|
||||||
$unbilled_amt = $unbilled_amt == 0 && $row['billed_amt'] == 0 ? $total_irda_amt : $unbilled_amt ;
|
|
||||||
?>
|
|
||||||
<td class="right-align-input"><?php echo number_format((float)$unbilled_amt,2, '.', '')?></td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
@ -394,7 +474,8 @@ $(document).ready(function() {
|
|||||||
$(sheet).find('sheetData').append(totalRow);
|
$(sheet).find('sheetData').append(totalRow);
|
||||||
},
|
},
|
||||||
exportOptions: {
|
exportOptions: {
|
||||||
orthogonal: 'sort'
|
orthogonal: 'sort' ,
|
||||||
|
columns: ':not(:eq(3))' // skip the same 4th column
|
||||||
},
|
},
|
||||||
customizeData: function (data) {
|
customizeData: function (data) {
|
||||||
for (var i = 0; i < data.body.length; i++) {
|
for (var i = 0; i < data.body.length; i++) {
|
||||||
|
|||||||
100
test.http
100
test.http
@ -1,100 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
POST https://testtips.vidalhealthtpa.com:7443/mobilerest/vidalbrokerservices/submitClaim
|
|
||||||
Authorization: Basic dmlkYWxicm9rZXJsb2dpbjp2aWRhbHN0YWdlQDEyMw==
|
|
||||||
Cookie: JSESSIONID=678ofNbsfB8svK1lyV6rON3w.worker1
|
|
||||||
Content-Type: multipart/form-data; boundary=WebApiBoundary
|
|
||||||
|
|
||||||
--WebApiBoundary
|
|
||||||
Content-Disposition: form-data; name="username"
|
|
||||||
|
|
||||||
Web_api
|
|
||||||
--WebApiBoundary
|
|
||||||
Content-Disposition: form-data; name="password"
|
|
||||||
|
|
||||||
Web@api
|
|
||||||
--WebApiBoundary
|
|
||||||
Content-Disposition: form-data; name="policyNo"
|
|
||||||
|
|
||||||
CI/TEST/POLICY/123456
|
|
||||||
--WebApiBoundary
|
|
||||||
Content-Disposition: form-data; name="enrollmentId"
|
|
||||||
|
|
||||||
BLR-RG-H0351-043-0000002-A
|
|
||||||
--WebApiBoundary
|
|
||||||
Content-Disposition: form-data; name="typeOfClaim"
|
|
||||||
|
|
||||||
Main hospitalization claim
|
|
||||||
--WebApiBoundary
|
|
||||||
Content-Disposition: form-data; name="claimSubType"
|
|
||||||
|
|
||||||
Hospitalization
|
|
||||||
--WebApiBoundary
|
|
||||||
Content-Disposition: form-data; name="requestedAmount"
|
|
||||||
|
|
||||||
4500
|
|
||||||
--WebApiBoundary
|
|
||||||
Content-Disposition: form-data; name="ailmentType"
|
|
||||||
|
|
||||||
Non covid
|
|
||||||
--WebApiBoundary
|
|
||||||
Content-Disposition: form-data; name="admissionDate"
|
|
||||||
|
|
||||||
20-03-2025
|
|
||||||
--WebApiBoundary
|
|
||||||
Content-Disposition: form-data; name="dischargeDate"
|
|
||||||
|
|
||||||
23-03-2025
|
|
||||||
--WebApiBoundary
|
|
||||||
Content-Disposition: form-data; name="hospitalName"
|
|
||||||
|
|
||||||
A G HOSPITAL NEW
|
|
||||||
--WebApiBoundary
|
|
||||||
Content-Disposition: form-data; name="empanelmentNo"
|
|
||||||
|
|
||||||
HOS-PON-010427
|
|
||||||
--WebApiBoundary
|
|
||||||
Content-Disposition: form-data; name="documentType"
|
|
||||||
|
|
||||||
Claim
|
|
||||||
--WebApiBoundary
|
|
||||||
Content-Disposition: form-data; name="ailmentName"
|
|
||||||
|
|
||||||
Cold
|
|
||||||
--WebApiBoundary
|
|
||||||
Content-Disposition: form-data; name="hospitalAddress"
|
|
||||||
|
|
||||||
abc
|
|
||||||
--WebApiBoundary
|
|
||||||
Content-Disposition: form-data; name="hospitalState"
|
|
||||||
|
|
||||||
karnataka
|
|
||||||
--WebApiBoundary
|
|
||||||
Content-Disposition: form-data; name="hospitalCity"
|
|
||||||
|
|
||||||
bangalore
|
|
||||||
--WebApiBoundary
|
|
||||||
Content-Disposition: form-data; name="hospitalPinCode"
|
|
||||||
|
|
||||||
560036
|
|
||||||
--WebApiBoundary
|
|
||||||
Content-Disposition: form-data; name="hospitalPhoneNo"
|
|
||||||
|
|
||||||
7656879899
|
|
||||||
--WebApiBoundary
|
|
||||||
Content-Disposition: form-data; name="File"; filename="tracker.pdf"
|
|
||||||
Content-Type: application/pdf
|
|
||||||
|
|
||||||
< ./C:\Users\jvadi\Downloads\Tickets - Business Show_ Chennai (India) (06_11_2025 14_00_00) - vadivel.pdf
|
|
||||||
--WebApiBoundary--
|
|
||||||
|
|
||||||
|
|
||||||
// claim
|
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user