FEAT_POLICY_TRANCTION_MODULE : RV
This commit is contained in:
parent
e8b0b85920
commit
e7bd7cec4b
@ -99,5 +99,5 @@ class Autoload extends AutoloadConfig
|
||||
* @var string[]
|
||||
* @phpstan-var list<string>
|
||||
*/
|
||||
public $helpers = ['uuid','session','utility', 'form', 'url', 'oauth', 'fileupload', 'excel_import_export', 'file'];
|
||||
public $helpers = ['uuid','session','utility', 'form', 'url', 'oauth', 'fileupload', 'excel_import_export', 'file', 'drive'];
|
||||
}
|
||||
|
||||
@ -278,6 +278,43 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->get("copy_insurer_templete/(:any)", "MasterController::copyInsurerTemplete/$1");
|
||||
$routes->get("get_single_excel_template/(:any)", "MasterController::getSingleExcelTemplate/$1");
|
||||
$routes->get("dublicate_template/(:any)", "MasterController::duplicateTemplate/$1");
|
||||
$routes->get("getBranchByClientID/(:any)", "ClientController::getBranchByClientID/$1");
|
||||
$routes->get("getPolicyDetailsByPolicyId/(:any)", "ClientController::getPolicyDetailsByPolicyId/$1");
|
||||
$routes->get("getClientAndBranchAndPolicy", "ClientController::getClientAndBranchAndPolicy");
|
||||
$routes->get("getCDAccNoByClientAndInsurer/(:any)", "ClientController::getCDAccNoByClientAndInsurer/$1");
|
||||
$routes->post("createClientWithMinimalData", "ClientController::createClientWithMinimalData");
|
||||
$routes->post("createVehicleWithMinimalData", "ClientController::createVehicleWithMinimalData");
|
||||
$routes->post("createClientBranchWithMinamalData", "ClientController::createClientBranchWithMinamalData");
|
||||
$routes->post("createClientPolicyWithMinimalData", "ClientController::createClientPolicyWithMinimalData");
|
||||
$routes->post("createCDAccountNumberUsingAjax", "MasterController::createCDAccountNumberUsingAjax");
|
||||
$routes->post("drive_file_upload", "PolicyTransactionController::uploadFile");
|
||||
$routes->post("updateInvoiceStatus", "PolicyTransactionController::updateInvoiceStatus");
|
||||
$routes->get("remove_co_share_data/(:any)", "PolicyTransactionController::removeCoShareData/$1");
|
||||
$routes->get("check_cost_center/(:any)", "ClientController::check_cost_center/$1");
|
||||
$routes->get("getPTCOShareCount/(:any)", "PolicyTransactionController::getPTCOShareCount/$1");
|
||||
});
|
||||
|
||||
|
||||
$routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) {
|
||||
|
||||
$routes->group("inception", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->get("list", "PolicyTransactionController::viewInception");
|
||||
$routes->post("create", "PolicyTransactionController::createInceptionPolicy");
|
||||
$routes->get("list/(:any)", "PolicyTransactionController::getInceptionDataForEdit/$1");
|
||||
$routes->get("remove/(:any)", "PolicyTransactionController::removeCDMaster/$1");
|
||||
});
|
||||
|
||||
$routes->group("endorsement", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->get("list", "PolicyTransactionController::viewEndorsement");
|
||||
$routes->post("create", "PolicyTransactionController::createEndorsementPolicy");
|
||||
$routes->get("list/(:any)", "PolicyTransactionController::getEndorsementDataForEdit/$1");
|
||||
$routes->get("remove/(:any)", "PolicyTransactionController::removeCDMaster/$1");
|
||||
});
|
||||
|
||||
$routes->group("report", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->get("list", "PolicyTransactionController::reportBDS");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$routes->cli('cli/processjob', 'JobWorker::processJob');
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Controllers;
|
||||
use App\Helpers\DepositHelper;
|
||||
use App\Helpers\MailHelper;
|
||||
use App\helpers\JWTToken;
|
||||
use CodeIgniter\HTTP\IncomingRequest;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
@ -33,10 +34,9 @@ use App\Models\EmployeePolicyModel;
|
||||
use App\Models\NotificationModel;
|
||||
use App\Models\CDMasterModel;
|
||||
use App\Models\PolicyTypeModel;
|
||||
|
||||
|
||||
|
||||
|
||||
use App\Models\PolicyTransactionModel;
|
||||
use App\Models\PolicyTransactionStatusModel;
|
||||
use App\Models\VehicleModel;
|
||||
|
||||
|
||||
class ClientController extends AdminController
|
||||
@ -68,6 +68,10 @@ class ClientController extends AdminController
|
||||
protected $notificationModel;
|
||||
protected $CDMasterModel;
|
||||
protected $policyTypeModel;
|
||||
protected $policyTransactionModel;
|
||||
protected $policyTransactionStatusModel;
|
||||
protected $vehicleModel;
|
||||
|
||||
|
||||
|
||||
public function __construct()
|
||||
@ -99,6 +103,10 @@ class ClientController extends AdminController
|
||||
$this->notificationModel = new NotificationModel();
|
||||
$this->CDMasterModel = new CDMasterModel();
|
||||
$this->policyTypeModel = new PolicyTypeModel();
|
||||
$this->policyTransactionModel = new PolicyTransactionModel();
|
||||
$this->policyTransactionStatusModel = new PolicyTransactionStatusModel();
|
||||
$this->vehicleModel = new VehicleModel();
|
||||
|
||||
|
||||
|
||||
|
||||
@ -108,43 +116,13 @@ class ClientController extends AdminController
|
||||
}
|
||||
|
||||
public function Testing() //this function for only tsesting some logics not use for business logic
|
||||
{
|
||||
$results = $this->clientPolicyModel
|
||||
->select('id, policy_terms')
|
||||
->where('policy_terms IS NOT NULL')
|
||||
->where('policy_terms <>', '')
|
||||
->whereNotIn('policy_type_id', [1, 6, 7])
|
||||
->orderBy('id', 'desc')
|
||||
->get()
|
||||
->getResultArray();
|
||||
|
||||
foreach ($results as $key => $result) {
|
||||
$client_policy_id = $result['id'];
|
||||
$policy_terms = json_decode($result['policy_terms'], true); // true to get associative array
|
||||
|
||||
if (isset($policy_terms['family_floaters'])) {
|
||||
$family_floaters = $policy_terms['family_floaters'];
|
||||
$parents = $family_floaters['parents'] ?? 0;
|
||||
$parents_in_law = $family_floaters['parents-in-law'] ?? 0;
|
||||
|
||||
if ($parents == 1 && $parents_in_law == 1) {
|
||||
$policy_terms['family_floaters']['parents'] = 0;
|
||||
$policy_terms['family_floaters']['parents-in-law'] = 0;
|
||||
$policy_terms['family_floaters']['either-parents-pil'] = 2;
|
||||
|
||||
{
|
||||
$params['mail'] = 'venkateshraman786@gmail.com';
|
||||
$params['subject'] = 'testing';
|
||||
$params['message'] = 'testing';
|
||||
|
||||
$results[$key]['policy_terms'] = json_encode($policy_terms);
|
||||
|
||||
// Update the policy_terms in the database
|
||||
$this->clientPolicyModel
|
||||
->where('id', $client_policy_id)
|
||||
->set('policy_terms', $results[$key]['policy_terms'])
|
||||
->update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dd($results);
|
||||
$result = MailHelper::send_email($params);
|
||||
dd($result);
|
||||
}
|
||||
|
||||
public function index()
|
||||
@ -289,6 +267,7 @@ class ClientController extends AdminController
|
||||
$data['policyGridData'] = $this->policyGridModel->findAll();
|
||||
$data['policy_types'] = $this->policyTypeModel->findAll();
|
||||
$data['policy_type'] = ['1'=>'Base Policy', '2' => 'SI Topup', '3' => 'Dependent Addon'];
|
||||
$data['client_type'] = ['1'=>'Group', '2' => 'Retail'];
|
||||
|
||||
// echo "<pre>";
|
||||
// print_r($data); die;
|
||||
@ -412,6 +391,7 @@ class ClientController extends AdminController
|
||||
$editData['policyGridData'] = $this->policyGridModel->findAll();
|
||||
$editData['policy_types'] = $this->policyTypeModel->findAll();
|
||||
$editData['policy_type'] = ['1'=>'Base Policy', '2' => 'SI Topup', '3' => 'Dependent Addon'];
|
||||
$editData['client_type'] = ['1'=>'Group', '2' => 'Retail'];
|
||||
|
||||
// dd($editData['policy_types']);
|
||||
|
||||
@ -451,6 +431,7 @@ class ClientController extends AdminController
|
||||
$data = $this->request->getPost();
|
||||
$data['created_by'] = get_session_userid();
|
||||
$data['client_logo'] = $file_name;
|
||||
$data['client_code'] = generate_client_code();
|
||||
|
||||
|
||||
if (!isset($data['is_download_btn'])) {
|
||||
@ -819,7 +800,6 @@ class ClientController extends AdminController
|
||||
$policy_type_id = $this->request->getPost('policy_type_id');
|
||||
$client_branch_id = $this->request->getPost('client_branch_id');
|
||||
$client_id = $this->request->getPost('client_id');
|
||||
$policy_type_id = $this->request->getPost('policy_type_id');
|
||||
$base_policy = $this->request->getPost('base_policy');
|
||||
|
||||
|
||||
@ -843,7 +823,6 @@ class ClientController extends AdminController
|
||||
$data['client_id'] = $client_id;
|
||||
$data['tpa_branch_id'] = $tpaBranchId;
|
||||
$data['tpa_id'] = $tpaId;
|
||||
// $data['policy_id'] = $this->request->getPost('policy_id');
|
||||
$data['policy_type_id'] = $this->request->getPost('policy_type_id');
|
||||
|
||||
$data['no_of_lives'] = $this->request->getPost('no_of_lives');
|
||||
@ -881,30 +860,6 @@ class ClientController extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
$policy_terms = $this->clientPolicyModel->where('id', $this->request->getPost('base_policy'))->first();
|
||||
|
||||
// if ($this->request->getPost('is_addon') == 2 || $this->request->getPost('is_addon') == 3) {
|
||||
|
||||
// if ($this->request->getPost('is_addon') == 3) {
|
||||
// $policyTerm = $policy_terms['policy_terms'];
|
||||
// $decoded_policyTerm = json_decode($policyTerm, true);
|
||||
// $decoded_policyTerm['family_floater'] = 0;
|
||||
// $decoded_policyTerm['family_floaters']['self'] = 0;
|
||||
// $decoded_policyTerm['family_floaters']['spouse'] = 0;
|
||||
// $decoded_policyTerm['family_floaters']['childrens'] = 0;
|
||||
// $decoded_policyTerm['family_floaters']['parents'] = 0;
|
||||
// $decoded_policyTerm['family_floaters']['parents-in-law'] = 0;
|
||||
// $decoded_policyTerm['family_floaters']['either-parents-pil'] = 0;
|
||||
|
||||
// $data['policy_terms'] = json_encode($decoded_policyTerm);
|
||||
// } else {
|
||||
|
||||
// if ($this->request->getPost('policy_type_id') != 3) {
|
||||
|
||||
// $data['policy_terms'] = $policy_terms['policy_terms'];
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
$data['policy_start_date'] = change_date_format($this->request->getPost('policy_start_date'), 'd-m-Y', 'Y-m-d');
|
||||
$data['policy_end_date'] = change_date_format($this->request->getPost('policy_end_date'), 'd-m-Y', 'Y-m-d');
|
||||
@ -922,8 +877,41 @@ class ClientController extends AdminController
|
||||
|
||||
$data['created_by'] = get_session_userid();
|
||||
|
||||
$policy_tranction_data = [
|
||||
|
||||
'issuer' => 2,
|
||||
'client_id' => $this->request->getPost('client_id'),
|
||||
'client_branch_id' => $this->request->getPost('client_branch_id'),
|
||||
'insurer_id' => $insurerId,
|
||||
'insurer_branch_id' => $insurerBranchId,
|
||||
'issue_type' => 1,
|
||||
'policy_no' => $this->request->getPost('policy_no'),
|
||||
'cd_ac_no' => $this->request->getPost('cd_ac_no'),
|
||||
'policy_issue_date' => date('Y-m-d'),
|
||||
'policy_start_date' => change_date_format($this->request->getPost('policy_start_date'), 'd-m-Y', 'Y-m-d'),
|
||||
'policy_end_date' => change_date_format($this->request->getPost('policy_end_date'), 'd-m-Y', 'Y-m-d'),
|
||||
'action_type' => 'inception',
|
||||
'status' => 'pending',
|
||||
'created_by' => get_session_userid(),
|
||||
];
|
||||
|
||||
|
||||
|
||||
$insert = $this->clientPolicyModel->insert($data);
|
||||
if($insert){
|
||||
|
||||
$policy_tranction_data['client_policy_id'] = $insert;
|
||||
$policy_tranction_data_insert = $this->policyTransactionModel->insert($data);
|
||||
if($policy_tranction_data_insert){
|
||||
$statusData = [
|
||||
'policy_tran_id' => $policy_tranction_data_insert,
|
||||
'status' => 'pending',
|
||||
'created_by' => get_session_userid(),
|
||||
];
|
||||
$this->policyTransactionStatusModel->insert($statusData);
|
||||
}
|
||||
|
||||
|
||||
$clientPoliceData = $this->clientPolicyModel->getClientPolicyByClientId($this->request->getPost('client_id'));
|
||||
$clientPoliceData['role'] = get_role_id();
|
||||
return $this->respond(['status' => true,'code' => 200,'data' => $clientPoliceData, 'method' => 'CERATE', 'post_data' => $data], 200);
|
||||
@ -2236,7 +2224,8 @@ class ClientController extends AdminController
|
||||
|
||||
}
|
||||
|
||||
public function fetchPolicyDataForPolicyType($client_policy_id){
|
||||
public function fetchPolicyDataForPolicyType($client_policy_id)
|
||||
{
|
||||
|
||||
$client_policy_id = $this->request->getGet('client_policy_id');
|
||||
$policy_type = $this->request->getGet('policy_type');
|
||||
@ -3011,4 +3000,261 @@ class ClientController extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
public function getBranchByClientID($client_id)
|
||||
{
|
||||
$branch_list = $this->clientBranchModel->where('client_id', $client_id)->where('is_active', 1)->findAll();
|
||||
$policy_list = [];
|
||||
foreach ($branch_list as $value)
|
||||
{
|
||||
$policy_data = $this->clientPolicyModel
|
||||
->select('client_policy.*, policy_type.policy_type')
|
||||
->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
|
||||
->where('client_policy.client_id', $value['client_id'])
|
||||
->where('client_policy.client_branch_id', $value['id'])
|
||||
->where('client_policy.is_active', 1)
|
||||
->findAll();
|
||||
$policy_list[$value['id']] = $policy_data;
|
||||
}
|
||||
|
||||
if($branch_list){
|
||||
return $this->respond(['status' => true, 'data' => $branch_list, 'policy_data' => $policy_list], 200);
|
||||
}else{
|
||||
return $this->respond(['status' => false], 200);
|
||||
}
|
||||
}
|
||||
|
||||
public function getClientAndBranchAndPolicy()
|
||||
{
|
||||
$clients = $this->clientModel->where('is_active', 1)->findAll();
|
||||
$vehicles = $this->vehicleModel
|
||||
->select('vehicle.*, clients.client_type')
|
||||
->join('clients', 'clients.id=vehicle.owner')
|
||||
->where('vehicle.is_active', 1)->findAll();
|
||||
$clientIds = array_column($clients, 'id');
|
||||
|
||||
// Fetch branches in a single query
|
||||
$branches = $this->clientBranchModel
|
||||
->whereIn('client_id', $clientIds)
|
||||
->where('is_active', 1)
|
||||
->findAll();
|
||||
|
||||
// Fetch policies in a single query
|
||||
$policies = $this->clientPolicyModel
|
||||
->select('
|
||||
client_policy.*,
|
||||
policy_type.policy_type,
|
||||
policy_type.ebp,
|
||||
policy_type.etp,
|
||||
policy_type.iep,
|
||||
policy_type.itp
|
||||
')
|
||||
->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
|
||||
->whereIn('client_policy.client_id', $clientIds)
|
||||
->where('client_policy.is_active', 1)
|
||||
->findAll();
|
||||
|
||||
$branchList = [];
|
||||
$policyList = [];
|
||||
$policyListByClient = [];
|
||||
$unitList = [];
|
||||
|
||||
foreach ($branches as $branch) {
|
||||
$branchList[$branch['client_id']][] = $branch;
|
||||
$unitList[$branch['id']][] = json_decode($branch['units']);
|
||||
}
|
||||
|
||||
foreach ($policies as $policy) {
|
||||
$policyList[$policy['client_branch_id']][] = $policy;
|
||||
$policyListByClient[$policy['client_id']][] = $policy;
|
||||
if (isset($policyCount[$policy['client_id']])) {
|
||||
$policyCount[$policy['client_id']]++;
|
||||
} else {
|
||||
$policyCount[$policy['client_id']] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($clients as &$client) {
|
||||
$client['client_policy_count'] = $policyCount[$client['id']] ?? 0;
|
||||
}
|
||||
|
||||
if (!empty($branchList)) {
|
||||
return $this->respond([
|
||||
'status' => true,
|
||||
'client_data' => $clients,
|
||||
'vehicle_data' => $vehicles,
|
||||
'branch_data' => $branchList,
|
||||
'policy_data' => $policyList,
|
||||
'policyListByClient' => $policyListByClient,
|
||||
'unit_data' => $unitList,
|
||||
], 200);
|
||||
} else {
|
||||
return $this->respond(['status' => false], 200);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getCDAccNoByClientAndInsurer($client, $insurer)
|
||||
{
|
||||
$cdmData = $this->CDMasterModel->where('client_id', $client)->where('insurer_id', $insurer)->findAll();
|
||||
|
||||
if($cdmData){
|
||||
return $this->respond(['status' => true, 'data' => $cdmData], 200);
|
||||
}else{
|
||||
return $this->respond(['status' => false], 200);
|
||||
}
|
||||
}
|
||||
|
||||
public function createClientWithMinimalData()
|
||||
{
|
||||
$postData = $this->request->getPost();
|
||||
// print_r($postData); die;
|
||||
$client_type = $postData['client_type'];
|
||||
$client_data = [
|
||||
'client_type' => $postData['client_type'],
|
||||
'client_name' => $postData['client_name'],
|
||||
'short_name' => $postData['short_name'],
|
||||
'pan' => $postData['pan'],
|
||||
'client_code' => generate_client_code(),
|
||||
];
|
||||
|
||||
// Add additional fields if client type is 2
|
||||
if($client_type == 2) {
|
||||
$client_data = array_merge($client_data, [
|
||||
'dob' => $postData['dob'],
|
||||
'aadhar' => $postData['aadhar'],
|
||||
'phone' => $postData['phone'],
|
||||
'email' => $postData['email'],
|
||||
]);
|
||||
} else {
|
||||
$client_data['entity_type_id'] = $postData['entity_type_id'];
|
||||
}
|
||||
|
||||
// Insert client data
|
||||
$client_insert = $this->clientModel->insert($client_data);
|
||||
|
||||
if(!$client_insert) {
|
||||
return $this->respond(['status' => false, 'message' => 'Failed to create client'], 200);
|
||||
}
|
||||
|
||||
// Additional logic for non-individual clients (client_type != 2)
|
||||
if($client_type != 2) {
|
||||
$unit = $postData['short_name'] . '-' . $postData['branch_code'];
|
||||
$branch_data = [
|
||||
'client_id' => $client_insert,
|
||||
'branch_name' => $postData['branch_name'],
|
||||
'branch_code' => $postData['branch_code'],
|
||||
'gst' => $postData['gst'],
|
||||
'units' => $unit,
|
||||
];
|
||||
|
||||
$branch_insert = $this->clientBranchModel->insert($branch_data);
|
||||
if ($branch_insert) {
|
||||
$contact_data = [
|
||||
'ref_id' => $branch_insert,
|
||||
'contact_type' => 'client',
|
||||
'name' => $postData['name'],
|
||||
'mobile' => $postData['mobile'],
|
||||
];
|
||||
$this->levelContactModel->insert($contact_data);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->respond([
|
||||
'status' => true,
|
||||
'client_id' => $client_insert,
|
||||
'branch_id' => $branch_insert ?? null,
|
||||
'message' => 'Client created successfully'
|
||||
], 200);
|
||||
}
|
||||
|
||||
public function createVehicleWithMinimalData()
|
||||
{
|
||||
$data = $this->request->getPost();
|
||||
|
||||
$vehicle_insert = $this->vehicleModel->insert($data);
|
||||
|
||||
if($vehicle_insert){
|
||||
$vehicles = $this->vehicleModel->where('is_active', 1)->findAll();
|
||||
return $this->respond([
|
||||
'status' => true,
|
||||
'vehicle_id' => $vehicle_insert,
|
||||
'owner_id' => $data['owner'],
|
||||
'owner_branch_id' => $data['branch_id'],
|
||||
'owner_type' => $data['Owner_type'],
|
||||
'vehicles' => $vehicles,
|
||||
'message' => 'Vehicle created successfully
|
||||
'], 200);
|
||||
}else{
|
||||
return $this->respond(['status' => false, 'message' => 'Failed to created vehicle'], 200);
|
||||
}
|
||||
}
|
||||
|
||||
public function createClientPolicyWithMinimalData()
|
||||
{
|
||||
$data = $this->request->getPost();
|
||||
|
||||
$insurerValue = (string) $this->request->getPost('insurer');
|
||||
list($insurerBranchId, $insurerId) = explode('-', $insurerValue);
|
||||
|
||||
$data['insurer_branch_id'] = $insurerBranchId;
|
||||
$data['insurer_id'] = $insurerId;
|
||||
$data['policy_status'] = 1;
|
||||
$data['is_addon'] = 1;
|
||||
$data['gst'] = 18;
|
||||
$data['created_by'] = get_session_userid();
|
||||
$data['policy_start_date'] = change_date_format($this->request->getPost('policy_start_date'), 'd-m-Y', 'Y-m-d');
|
||||
$data['policy_end_date'] = change_date_format($this->request->getPost('policy_end_date'), 'd-m-Y', 'Y-m-d');
|
||||
|
||||
|
||||
$insert = $this->clientPolicyModel->insert($data);
|
||||
|
||||
if($insert){
|
||||
|
||||
$policies = $this->clientPolicyModel
|
||||
->select('client_policy.*, policy_type.policy_type')
|
||||
->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
|
||||
->where('client_policy.client_id', $data['client_id'])
|
||||
->where('client_policy.client_branch_id', $data['client_branch_id'])
|
||||
->where('client_policy.is_active', 1)
|
||||
->findAll();
|
||||
|
||||
return $this->respond(['status' => true, 'data' => $policies, 'client_policy_id' => $insert, 'message' => 'Client policy created successfully'], 200);
|
||||
}else{
|
||||
return $this->respond(['status' => false, 'message' => 'Failed to created client policy'], 200);
|
||||
}
|
||||
}
|
||||
|
||||
public function getPolicyDetailsByPolicyId($id)
|
||||
{
|
||||
$policies = $this->clientPolicyModel
|
||||
->select('client_policy.*, policy_type.policy_type')
|
||||
->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
|
||||
->where('client_policy.id', $id)
|
||||
->where('client_policy.is_active', 1)
|
||||
->findAll();
|
||||
|
||||
if($policies){
|
||||
return $this->respond(['status' => true, 'data' => $policies, 'message' => 'Client policy created successfully'], 200);
|
||||
}else{
|
||||
return $this->respond(['status' => false, 'message' => 'Failed to created client policy'], 200);
|
||||
}
|
||||
}
|
||||
|
||||
public function check_cost_center($cost_center)
|
||||
{
|
||||
$uniqueAC = $this->clientModel
|
||||
->where('cost_center', $cost_center)
|
||||
->where('is_active', 1)
|
||||
->findAll();
|
||||
|
||||
if($uniqueAC != null){
|
||||
return $this->respond(['status' => true, 'message' => 'The Cost Center is Already Exist', 'code' => 200], 200);
|
||||
}else{
|
||||
return $this->respond(['status' => false, 'code' => 404], 200);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -40,7 +40,7 @@ class MasterController extends AdminController
|
||||
protected $userModel;
|
||||
protected $insurerBranchModel;
|
||||
protected $insurerKYCDocsModel;
|
||||
protected $insurerPolicyModel;
|
||||
protected $clientPolicyModel;
|
||||
protected $insurerRMModel;
|
||||
protected $kycDocsModel;
|
||||
protected $kycEntityTypeModel;
|
||||
@ -66,7 +66,7 @@ class MasterController extends AdminController
|
||||
$this->userModel = new UserModel();
|
||||
// $this->insurerBranchModel = new ClientBranchModel();
|
||||
$this->insurerKYCDocsModel = new ClientKYCDocsModel();
|
||||
$this->insurerPolicyModel = new ClientPolicyModel();
|
||||
$this->clientPolicyModel = new ClientPolicyModel();
|
||||
$this->insurerRMModel = new ClientRMModel();
|
||||
$this->insurerBranchModel = new InsurerBranchModel();
|
||||
$this->insurerModel = new InsurerModel();
|
||||
@ -1343,6 +1343,44 @@ class MasterController extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
public function createCDAccountNumberUsingAjax()
|
||||
{
|
||||
$data = $this->request->getPost();
|
||||
$date = (string) $this->request->getPost('opening_date');
|
||||
$data['opening_date'] = date('Y-m-d', strtotime($date));
|
||||
|
||||
|
||||
// array with data for CD Traction table
|
||||
$cd_tranction_data = [
|
||||
'amount' => $data['opening_bal'],
|
||||
'sub_type_id' => 7,
|
||||
'client_id' => $data['client_id'],
|
||||
'client_policy_id' => null,
|
||||
'cd_ac_no' => $data['cd_ac_no'],
|
||||
'endorsement_no' => null,
|
||||
'insurer_id' => (int) $data['insurer_id'],
|
||||
'description' => 'opening Amount',
|
||||
'transaction_type' => 'Credit',
|
||||
'event_name' => null,
|
||||
'updated_by' => 1,
|
||||
];
|
||||
|
||||
$loggedInUserID = get_session_userid();
|
||||
|
||||
$insert = $this->CDMasterModel->insert($data);
|
||||
|
||||
if ($insert) {
|
||||
|
||||
//for CD Tranction Table
|
||||
$response = DepositHelper::saveDeposit($cd_tranction_data, $loggedInUserID);
|
||||
|
||||
$cd_data = $this->CDMasterModel->where('client_id', $data['client_id'])->where('insurer_id', $data['insurer_id'])->findAll();
|
||||
|
||||
return $this->respond(['status' => true, 'data' => $cd_data, 'message' => 'CD Account number created successfully'], 200);
|
||||
}else{
|
||||
return $this->respond(['status' => false, 'message' => 'Failed to created CD Account number'], 200);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//excel export template
|
||||
|
||||
970
app/Controllers/PolicyTransactionController.php
Normal file
970
app/Controllers/PolicyTransactionController.php
Normal file
@ -0,0 +1,970 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Helpers\DepositHelper;
|
||||
use CodeIgniter\API\ResponseTrait;
|
||||
|
||||
use App\Models\PolicyTransactionModel;
|
||||
use App\Models\PolicyTransactionStatusModel;
|
||||
use App\Models\ClientModel;
|
||||
use App\Models\ClientBranchModel;
|
||||
use App\Models\ClientDepositModel;
|
||||
use App\Models\ClientPolicyModel;
|
||||
use App\Models\PolicyTypeModel;
|
||||
use App\Models\InsurerBranchModel;
|
||||
use App\Models\InsurerModel;
|
||||
use App\Models\KYCEntityTypeModel;
|
||||
use App\Models\ClientKYCDocsModel;
|
||||
use App\Models\TPABranchModel;
|
||||
use App\Models\TPAModel;
|
||||
use App\Models\PTFileModel;
|
||||
use App\Models\PTCOShareDetailsModel;
|
||||
use App\Models\EmployeeModel;
|
||||
use App\Models\UserTeamsModel;
|
||||
use App\Models\UserModel;
|
||||
use App\Models\EmployeePolicyModel;
|
||||
|
||||
|
||||
class PolicyTransactionController extends BaseController
|
||||
{
|
||||
use ResponseTrait;
|
||||
|
||||
protected $myLogger;
|
||||
protected $policyTransactionModel;
|
||||
protected $policyTransactionStatusModel;
|
||||
protected $clientModel;
|
||||
protected $clientPolicyModel;
|
||||
protected $clientBranchModel;
|
||||
protected $clientDepositModel;
|
||||
protected $policyTypeModel;
|
||||
protected $insurerBranchModel;
|
||||
protected $insurerModel;
|
||||
protected $kycEntityTypeModel;
|
||||
protected $clientKYCDocsModel;
|
||||
protected $tpaBranchModel;
|
||||
protected $tpaModel;
|
||||
protected $PTFileModel;
|
||||
protected $PTCOShareDetailsModel;
|
||||
protected $employeeModel;
|
||||
protected $userTeamsModel;
|
||||
protected $userModel;
|
||||
protected $employeePolicyModel;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
set_session_context('Policy Tranction');
|
||||
$this->myLogger = \Config\Services::mylogger();
|
||||
|
||||
$this->clientModel = new ClientModel();
|
||||
$this->clientBranchModel = new ClientBranchModel();
|
||||
$this->policyTypeModel = new PolicyTypeModel();
|
||||
$this->clientDepositModel = new ClientDepositModel();
|
||||
$this->clientPolicyModel = new ClientPolicyModel();
|
||||
$this->insurerBranchModel = new InsurerBranchModel();
|
||||
$this->insurerModel = new InsurerModel();
|
||||
$this->policyTransactionModel = new PolicyTransactionModel();
|
||||
$this->policyTransactionStatusModel = new PolicyTransactionStatusModel();
|
||||
$this->kycEntityTypeModel = new KYCEntityTypeModel();
|
||||
$this->clientKYCDocsModel = new ClientKYCDocsModel();
|
||||
$this->tpaBranchModel = new TPABranchModel();
|
||||
$this->tpaModel = new TPAModel();
|
||||
$this->PTFileModel = new PTFileModel();
|
||||
$this->PTCOShareDetailsModel = new PTCOShareDetailsModel();
|
||||
$this->employeeModel = new EmployeeModel();
|
||||
$this->userTeamsModel = new UserTeamsModel();
|
||||
$this->userModel = new UserModel();
|
||||
$this->employeePolicyModel = new EmployeePolicyModel();
|
||||
}
|
||||
|
||||
// Policy Transaction Inception
|
||||
public function viewInception()
|
||||
{
|
||||
$data['issuer'] = [1 => 'JIBS', 2 => 'Nhance'];
|
||||
$data['client_type'] = [1 => 'Group', 2 => 'Individual'];
|
||||
$data['issuing_type'] = [1 => 'Fresh', 2 => 'Renewal', 3 => 'Roll Over'];
|
||||
// $data['policy_status'] = [
|
||||
// 'pending' => 'Pending',
|
||||
// 'exported_to_insurer' => 'Exported to Insurer',
|
||||
// 'imported_from_insurer' => 'Imported from Insurer',
|
||||
// 'exported_to_tpa' => 'Exported to TPA',
|
||||
// 'imported_from_tpa' => 'Imported from TPA',
|
||||
// 'completed' => 'Completed'
|
||||
// ];
|
||||
$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_array'] = [
|
||||
'yet_to_generate' => 'Pending',
|
||||
'generated' => 'Generated',
|
||||
'send' => 'Sent',
|
||||
'recived' => 'Payment Received',
|
||||
];
|
||||
$data['vehicle_type'] = [
|
||||
'two_wheeler' => 'Two Wheeler',
|
||||
'four_wheeler' => 'Four Wheeler',
|
||||
'truck' => 'Truck',
|
||||
'bus' => 'Bus',
|
||||
'van' => 'Van',
|
||||
'suv' => 'SUV',
|
||||
'motorcycle' => 'Motorcycle',
|
||||
'bicycle' => 'Bicycle'
|
||||
];
|
||||
$data['vehicle_des'] = [
|
||||
'commercial' => 'Commercial',
|
||||
'private' => 'Private',
|
||||
];
|
||||
|
||||
$data['inception_data_list'] = $this->policyTransactionModel
|
||||
->select('
|
||||
policy_transaction.*,
|
||||
clients.short_name AS client_short_name,
|
||||
clients.client_code,
|
||||
clients.client_type,
|
||||
clients.client_name,
|
||||
client_branch.branch_name AS client_branch_name,
|
||||
insurers.name AS insurer_name,
|
||||
policy_type.policy_type,
|
||||
pt_co_share_details.agreed_amt AS amount,
|
||||
pt_co_share_details.bp_amt AS bp,
|
||||
pt_co_share_details.tp_amt AS tp
|
||||
')
|
||||
->join('pt_co_share_details', 'policy_transaction.id = pt_co_share_details.pt_id', 'left')
|
||||
->join('clients', 'clients.id = policy_transaction.client_id', 'left')
|
||||
->join('client_branch', 'policy_transaction.client_branch_id = client_branch.id', 'left')
|
||||
->join('insurers', 'policy_transaction.insurer_id = insurers.id', 'left')
|
||||
->join('client_policy', 'policy_transaction.client_policy_id = client_policy.id', 'left')
|
||||
->join('policy_type', 'client_policy.policy_type_id = policy_type.id', 'left')
|
||||
->where('policy_transaction.is_active', 1)
|
||||
->where('policy_transaction.action_type', 'inception')
|
||||
->orderBy('policy_transaction.id', 'desc')
|
||||
->findAll();
|
||||
|
||||
$data['client'] = $this->clientModel->where('is_active', 1)->findAll();
|
||||
$data['policy_type'] = $this->policyTypeModel->where('is_active', 1)->findAll();
|
||||
$data['insurer'] = $this->insurerModel->where('is_active', 1)->findAll();
|
||||
$data['entity'] = $this->kycEntityTypeModel->where('is_active', 1)->findAll();
|
||||
$data['policy_types'] = $this->policyTypeModel->where('is_active', 1)->findAll();
|
||||
$data['insurer_branch'] = $this->insurerBranchModel ->getInsurerBranchesWithInsurerNames();
|
||||
$data['tpa'] = $this->tpaBranchModel ->getTpaBranchesWithTpaNames();
|
||||
$data['salse_team'] = $this->userModel
|
||||
->select('user_profiles.*')
|
||||
->join('user_teams', 'user_profiles.id = user_teams.user_id')
|
||||
->where('user_teams.team_id', 5)
|
||||
->where('user_teams.is_active', 1)
|
||||
->where('user_profiles.is_active', 1)
|
||||
->findAll();
|
||||
|
||||
$data['ACM'] = $this->userModel
|
||||
->where('user_profiles.role', 3)
|
||||
->where('user_profiles.is_active', 1)
|
||||
->findAll();
|
||||
|
||||
$this->loadLayout('policy_transaction_inception_list', $data);
|
||||
}
|
||||
|
||||
// policy Transaction Create function start
|
||||
public function createInceptionPolicy()
|
||||
{
|
||||
// print_r($this->request->getPost()); die;
|
||||
$id = $this->request->getPost('id');
|
||||
$data = $this->preparePolicyData();
|
||||
// print_r($this->request->getPost()); die;
|
||||
|
||||
|
||||
if (!$id) {
|
||||
return $this->insertInceptionPolicy($data);
|
||||
} else {
|
||||
return $this->updateInceptionPolicy($id, $data);
|
||||
}
|
||||
}
|
||||
|
||||
private function preparePolicyData()
|
||||
{
|
||||
$data = $this->request->getPost();
|
||||
|
||||
// print_r($data); die;
|
||||
|
||||
// Format dates
|
||||
$data['policy_issue_date'] = date('Y-m-d', strtotime($data['policy_issue_date'])) ?? null;
|
||||
$data['policy_start_date'] = date('Y-m-d', strtotime($data['policy_start_date'])) ?? null;
|
||||
$data['policy_end_date'] = date('Y-m-d', strtotime($data['policy_end_date'])) ?? null;
|
||||
$data['renewal_date'] = date('Y-m-d', strtotime($data['renewal_date'])) ?? null;
|
||||
$data['rollover_date'] = date('Y-m-d', strtotime($data['rollover_date'])) ?? null;
|
||||
|
||||
// Separate Insurer and TPA Branch IDs and IDs
|
||||
if(isset($data['insurer_id']) && !empty($data['insurer_id'])){
|
||||
list($data['insurer_branch_id'], $data['insurer_id']) = explode('-', $data['insurer_id']);
|
||||
if ($data['tpa']) {
|
||||
list($data['tpa_branch_id'], $data['tpa_id']) = explode('-', $data['tpa']);
|
||||
}
|
||||
}
|
||||
|
||||
$data['tsi'] = generate_tsi_code($data['issue_type']);
|
||||
$data['action_type'] = 'inception';
|
||||
|
||||
if (!isset($data['co_share'])) {
|
||||
$data['co_share'] = 0;
|
||||
} elseif ($data['co_share']) {
|
||||
$data['co_share'] = 1;
|
||||
}
|
||||
|
||||
if (!isset($data['bro_payable_by'])) {
|
||||
$data['bro_payable_by'] = 0;
|
||||
} elseif ($data['bro_payable_by']) {
|
||||
$data['bro_payable_by'] = 1;
|
||||
}
|
||||
|
||||
if (!isset($data['same_as_proposer'])) {
|
||||
$data['same_as_proposer'] = 0;
|
||||
} elseif ($data['same_as_proposer']) {
|
||||
$data['same_as_proposer'] = 1;
|
||||
}
|
||||
|
||||
// Determine $is_addon value
|
||||
$data['is_addon'] = in_array($data['policy_type_id'], [1, 2, 6, 7]) ? 1 :
|
||||
(in_array($data['policy_type_id'], [4, 5]) ? 2 : ($data['policy_type_id'] == 3 && $data['base_policy'] ? 3 : 1));
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function insertInceptionPolicy($data)
|
||||
{
|
||||
// print_r($data); die;
|
||||
|
||||
$insert = $this->policyTransactionModel->insert($data);
|
||||
if ($insert) {
|
||||
$this->insertTransactionStatus($insert, $data['status'], 1);
|
||||
$emp_data = $this->processInsertIndividualMemberInEmpTable($data);
|
||||
|
||||
if(isset($data['follow_insurer_id']) && !empty($data['follow_insurer_id'][0])){
|
||||
|
||||
$pt_co_share_details = $this->insertOrUpdateCoShareDetails($data, $insert);
|
||||
|
||||
$client_policy_insert_data = $this->prepareClientPolicyInsertData($data);
|
||||
$client_policy_id = $this->clientPolicyModel->insert($client_policy_insert_data);
|
||||
$this->policyTransactionModel->update($insert, ['client_policy_id' => $client_policy_id]);
|
||||
$emp_policy_insert = $this->InsertIndividualEmpPolicyTable($emp_data, $client_policy_id);
|
||||
|
||||
if ($data['status'] == 'completed') {
|
||||
$this->processCompletedStatus($data, $client_policy_id, $data['insurer_id']);
|
||||
}
|
||||
|
||||
$data['pt_co_share_details'] = $this->PTCOShareDetailsModel->where('pt_id', $insert)->where('is_active', 1)->findAll();
|
||||
}
|
||||
|
||||
return $this->respondSuccess($insert, "Policy transaction created successfully", $data);
|
||||
}
|
||||
return $this->respondError("Failed to create policy transaction");
|
||||
}
|
||||
|
||||
private function updateInceptionPolicy($id, $data)
|
||||
{
|
||||
if ($this->policyTransactionModel->update($id, $data)) {
|
||||
|
||||
$this->insertTransactionStatus($id, $data['status'], 1);
|
||||
$emp_data = $this->processInsertIndividualMemberInEmpTable($data);
|
||||
|
||||
if (isset($data['follow_insurer_id']) && !empty($data['follow_insurer_id'][0])) {
|
||||
|
||||
$this->insertOrUpdateCoShareDetails($data, $id);
|
||||
|
||||
if (empty($data['client_policy_id']) || $data['client_policy_id'] == 0) {
|
||||
|
||||
$client_policy_insert_data = $this->prepareClientPolicyInsertData($data);
|
||||
// print_r($client_policy_insert_data); die;
|
||||
$client_policy_id = $this->clientPolicyModel->insert($client_policy_insert_data);
|
||||
|
||||
$this->policyTransactionModel->update($id, ['client_policy_id' => $client_policy_id]);
|
||||
|
||||
$this->InsertIndividualEmpPolicyTable($emp_data, $client_policy_id);
|
||||
|
||||
} else {
|
||||
if (isset($data['emp_policy_id']) && !empty($data['emp_policy_id'][0])) {
|
||||
$this->InsertIndividualEmpPolicyTable($emp_data, $data['client_policy_id']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($data['status'] == 'completed') {
|
||||
$this->processCompletedStatus($data, $data['client_policy_id'], $data['insurer_id']);
|
||||
}
|
||||
|
||||
$data['pt_co_share_details'] = $this->PTCOShareDetailsModel->where('pt_id', $id)->where('is_active', 1)->findAll();
|
||||
}
|
||||
|
||||
return $this->respondSuccess($id, "Policy transaction updated successfully", $data);
|
||||
}
|
||||
|
||||
return $this->respondError("Failed to update policy transaction");
|
||||
}
|
||||
|
||||
|
||||
private function insertOrUpdateCoShareDetails($data, $pt_id)
|
||||
{
|
||||
// Prepare data for insertion and updating
|
||||
$coShareDetails = [];
|
||||
|
||||
// print_r($data);
|
||||
// die;
|
||||
|
||||
foreach ($data['follow_insurer_id'] as $index => $insurer) {
|
||||
// Separate the insurer and insurer branch
|
||||
list($insurer_branch_id, $insurer_id) = explode('-', $insurer);
|
||||
|
||||
// Prepare each co-share detail entry
|
||||
$coShareDetails[] = [
|
||||
'pt_id' => $pt_id,
|
||||
'insurer_id' => $insurer_id ?? 0,
|
||||
'insurer_branch_id' => $insurer_branch_id ?? 0,
|
||||
'co_share_type' => isset($data['co_share_type'][$index]) ? 2 : 1,
|
||||
'co_share_per' => $data['co_share_per'][$index] ?? 0,
|
||||
'bp_amt' => $data['base_premium'][$index] ?? 0,
|
||||
'bp_gst_amt' => $data['gst_amount'][$index] ?? 0,
|
||||
'bp_igst' => $data['igst'][$index] ?? 0,
|
||||
'bp_sgst' => $data['sgst'][$index] ?? 0,
|
||||
'bp_cgst' => $data['cgst'][$index] ?? 0,
|
||||
'tp_amt' => $data['tp_ter_premium'][$index] ?? 0,
|
||||
'tep_amt' => $data['tp_ter_premium'][$index] ?? 0,
|
||||
'agreed_amt' => $data['agreed_amount'][$index] ?? 0,
|
||||
'agreed_bp_per' => $data['agreed_bp'][$index] ?? 0,
|
||||
'agreed_tp_per' => $data['agreed_tp_ter'][$index] ?? 0,
|
||||
'agreed_tep_per' => $data['agreed_tp_ter'][$index] ?? 0,
|
||||
'standerd_bp_per' => $data['standard_bp'][$index] ?? 0,
|
||||
'standerd_tp_per' => $data['standard_tp'][$index] ?? 0,
|
||||
'standerd_tep_per' => $data['standard_tep'][$index] ?? 0,
|
||||
'actual_bp_amt' => $data['actual_bp_amt'][$index] ?? 0,
|
||||
'actual_tp_amt' => $data['actual_tp_amt'][$index] ?? 0,
|
||||
'actual_tep_amt' => $data['actual_tep_amt'][$index] ?? 0,
|
||||
'actual_bp_per' => $data['actual_bp_per'][$index] ?? 0,
|
||||
'actual_tp_per' => $data['actual_tp_per'][$index] ?? 0,
|
||||
'actual_tep_per' => $data['actual_tep_per'][$index] ?? 0,
|
||||
'exp_amt' => $data['exp_amt'][$index] ?? 0,
|
||||
'amount' => $data['total'][$index] ?? 0,
|
||||
'stamp_duty' => $data['stamp_duty'][$index] ?? 0,
|
||||
'cop_amt' => $data['co_premium'][$index] ?? 0,
|
||||
'variance' => $data['variance'][$index] ?? 0,
|
||||
'remark' => $data['remark'][$index] ?? null,
|
||||
'created_by' => get_session_userid() ?? null,
|
||||
'updated_by' => get_session_userid() ?? null,
|
||||
'id' => $data['co_share_id'][$index] ?? null, // Assuming this is the ID to identify existing records
|
||||
];
|
||||
}
|
||||
|
||||
// print_r($coShareDetails); die;
|
||||
|
||||
// Separate data into insert and update batches
|
||||
$insertData = array_filter($coShareDetails, function($detail) {
|
||||
return empty($detail['id']); // Only insert new records
|
||||
});
|
||||
|
||||
$updateData = array_filter($coShareDetails, function($detail) {
|
||||
return !empty($detail['id']); // Only update existing records
|
||||
});
|
||||
|
||||
// Insert new records
|
||||
if (!empty($insertData)) {
|
||||
$this->PTCOShareDetailsModel->insertBatch($insertData);
|
||||
}
|
||||
|
||||
// Update existing records
|
||||
if (!empty($updateData)) {
|
||||
$this->PTCOShareDetailsModel->updateBatch($updateData, 'id'); // Assuming 'id' is the unique identifier
|
||||
}
|
||||
|
||||
// print_r($this->PTCOShareDetailsModel->getLastQuery()); die;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private function prepareClientPolicyInsertData($data)
|
||||
{
|
||||
return [
|
||||
'client_id' => $data['client_id'] ?? null,
|
||||
'insurer_id' => $data['insurer_id'] ?? null,
|
||||
'insurer_branch_id' => $data['insurer_branch_id'] ?? null,
|
||||
'tpa_id' => $data['tpa_id'] ?? null,
|
||||
'tpa_branch_id' => $data['tpa_branch_id'] ?? null,
|
||||
'policy_type_id' => $data['policy_type_id'] ?? null,
|
||||
'policy_start_date' => $data['policy_start_date'] ?? null,
|
||||
'policy_end_date' => $data['policy_end_date'] ?? null ,
|
||||
'policy_status' => 1,
|
||||
'is_addon' => $data['is_addon'] ?? null,
|
||||
'base_policy' => $data['base_policy'] ?? 0,
|
||||
'created_by' => get_session_userid(),
|
||||
'policy_no' => $data['policy_no'] ?? null,
|
||||
'client_branch_id' => $data['client_branch_id'] ?? 0,
|
||||
'cd_ac_no' => $data['cd_ac_no'] ?? null,
|
||||
'gst' => 18,
|
||||
];
|
||||
}
|
||||
|
||||
private function insertTransactionStatus($policyTranId, $status, $statusType)
|
||||
{
|
||||
$statusData = [
|
||||
'policy_tran_id' => $policyTranId,
|
||||
'status' => $status,
|
||||
'status_type' => $statusType,
|
||||
'created_by' => get_session_userid(),
|
||||
];
|
||||
$this->policyTransactionStatusModel->insert($statusData);
|
||||
}
|
||||
|
||||
private function processCompletedStatus($data, $client_policy_id, $insurer_id)
|
||||
{
|
||||
$totalAmount = (int)$data['total'][0] ?? 0;
|
||||
$description = 'The following amount of Rs. ' . $totalAmount . '/- has been debited for the ' . $data['emp_count'] . ' employees at Inception.';
|
||||
|
||||
$cdTransactionData = [
|
||||
'amount' => $totalAmount,
|
||||
'sub_type_id' => 4,
|
||||
'client_id' => $data['client_id'],
|
||||
'client_policy_id' => $client_policy_id ?? 0,
|
||||
'endorsement_no' => null,
|
||||
'cd_ac_no' => $data['cd_ac_no'] ?? null,
|
||||
'insurer_id' => $insurer_id,
|
||||
'description' => $description,
|
||||
'transaction_type' => 'Debit',
|
||||
'updated_by' => get_session_userid(),
|
||||
'event_name' => 'inception',
|
||||
'is_active' => 1,
|
||||
];
|
||||
|
||||
DepositHelper::saveDeposit($cdTransactionData, get_session_userid());
|
||||
}
|
||||
|
||||
private function processInsertIndividualMemberInEmpTable($data)
|
||||
{
|
||||
// print_r($data);
|
||||
if(isset($data['family_name']) && !empty($data['family_name'])){
|
||||
|
||||
$emp_data = [];
|
||||
$emp_ids = [];
|
||||
$random_code = generateRandomCode(); // Generate random code once
|
||||
|
||||
foreach ($data['family_name'] as $index => $val) {
|
||||
|
||||
// Determine the gender based on the relationship
|
||||
$relationship = $data['relationship'][$index] ?? '';
|
||||
$gender = 'M'; // Default to Male
|
||||
|
||||
// Set gender based on relationship
|
||||
if (in_array($relationship, ['Mother', 'Daughter', 'Mother in law', 'Spouse'])) {
|
||||
$gender = 'F';
|
||||
}
|
||||
|
||||
$emp_data[] = [
|
||||
'client_id' => $data['client_id'] ?? 0,
|
||||
'client_branch_id' => $data['client_branch_id'] ?? 0,
|
||||
'name' => $val,
|
||||
'relationship' => $relationship,
|
||||
'gender' => $gender,
|
||||
'emp_status' => 'active',
|
||||
'created_by' => get_session_userid(),
|
||||
'emp_code' => $random_code, // Use the same random code for all
|
||||
'id' => $data['emp_id'][$index] ?? null
|
||||
];
|
||||
|
||||
$emp_ids[] = $data['emp_id'][$index] ?? 0;
|
||||
}
|
||||
|
||||
|
||||
// print_r($emp_data); die;
|
||||
|
||||
// Separate data into insert and update batches
|
||||
$insertData = array_filter($emp_data, function($detail) {
|
||||
return empty($detail['id']); // Only insert new records
|
||||
});
|
||||
|
||||
$updateData = array_filter($emp_data, function($detail) {
|
||||
return !empty($detail['id']); // Only update existing records
|
||||
});
|
||||
|
||||
// Insert new records
|
||||
if (!empty($insertData)) {
|
||||
$this->employeeModel->insertBatch($insertData);
|
||||
}
|
||||
|
||||
// Update existing records
|
||||
if (!empty($updateData)) {
|
||||
$this->employeeModel->updateBatch($updateData, 'id'); // Assuming 'id' is the unique identifier
|
||||
}
|
||||
|
||||
return $emp_ids;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private function InsertIndividualEmpPolicyTable($emp_ids, $client_policy_id)
|
||||
{
|
||||
if(!empty($emp_ids)){
|
||||
|
||||
$emp_policy_data = [];
|
||||
|
||||
foreach ($emp_ids as $index => $emp_id) {
|
||||
|
||||
$emp_policy_data[] = [
|
||||
'employee_id' => $emp_id ?? 0,
|
||||
'client_policy_id' => $client_policy_id ?? 0,
|
||||
'created_by' => get_session_userid(),
|
||||
'status' => 'active',
|
||||
];
|
||||
}
|
||||
|
||||
print_r($emp_policy_data); die;
|
||||
|
||||
// Insert new records
|
||||
if (!empty($emp_policy_data)) {
|
||||
$this->employeePolicyModel->insertBatch($emp_policy_data);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private function respondSuccess($id, $message, $data)
|
||||
{
|
||||
return $this->respond(['status' => true, 'pt_id' => $id, 'message' => $message, 'data' =>$data], 200);
|
||||
}
|
||||
|
||||
private function respondError($message)
|
||||
{
|
||||
return $this->respond(['status' => false, 'message' => $message], 200);
|
||||
}
|
||||
// policy Transaction Create function End
|
||||
|
||||
// Get the Single Inception Tranction data for edit
|
||||
public function getInceptionDataForEdit($id)
|
||||
{
|
||||
$data = $this->policyTransactionModel
|
||||
->select('
|
||||
policy_transaction.*,
|
||||
clients.short_name as client_short_name,
|
||||
clients.client_type,
|
||||
policy_type.policy_type,
|
||||
client_policy.tpa_id as master_tpa_id,
|
||||
client_policy.tpa_branch_id as master_tpa_branch_id,
|
||||
client_policy.policy_type_id as master_policy_type_id,
|
||||
client_policy.is_addon,
|
||||
client_policy.base_policy,
|
||||
')
|
||||
->join('clients', 'clients.id = policy_transaction.client_id')
|
||||
->join('client_policy', 'policy_transaction.client_policy_id = client_policy.id', 'left')
|
||||
->join('policy_type', 'client_policy.policy_type_id = policy_type.id', 'left')
|
||||
->where('policy_transaction.id', $id)
|
||||
->first();
|
||||
|
||||
$data['policy_issue_date'] = !empty($data['policy_issue_date']) ? date('d-m-Y', strtotime($data['policy_issue_date'])) : null;
|
||||
$data['policy_start_date'] = !empty($data['policy_start_date']) ? date('d-m-Y', strtotime($data['policy_start_date'])) : null;
|
||||
$data['policy_end_date'] = !empty($data['policy_end_date']) ? date('d-m-Y', strtotime($data['policy_end_date'])) : null;
|
||||
$data['renewal_date'] = !empty($data['renewal_date']) ? date('d-m-Y', strtotime($data['renewal_date'])) : null;
|
||||
$data['rollover_date'] = !empty($data['rollover_date']) ? date('d-m-Y', strtotime($data['rollover_date'])) : null;
|
||||
$data['created_at'] = !empty($data['created_at']) ? date('d-m-Y h:i:s A', strtotime($data['created_at'])) : null;
|
||||
$data['updated_at'] = !empty($data['updated_at']) ? date('d-m-Y h:i:s A', strtotime($data['updated_at'])) : null;
|
||||
|
||||
// print_r($data); die;
|
||||
|
||||
$data['renewal_policy'] = $this->clientPolicyModel
|
||||
->select('client_policy.*, policy_type.policy_type')
|
||||
->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
|
||||
->where('client_policy.client_id', $data['client_id'])
|
||||
->where('client_policy.client_branch_id', $data['client_branch_id'])
|
||||
->where('client_policy.is_active', 1)
|
||||
->findAll();
|
||||
|
||||
$data['base_policy_data'] = $this->clientPolicyModel
|
||||
->select('client_policy.*, policy_type.policy_type')
|
||||
->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
|
||||
->where('client_policy.client_id', $data['client_id'])
|
||||
->where('client_policy.client_branch_id', $data['client_branch_id'])
|
||||
->where('client_policy.policy_type_id', 2)
|
||||
->where('client_policy.is_active', 1)
|
||||
->findAll();
|
||||
|
||||
$data['pt_files'] = $this->PTFileModel->where('pt_id', $id)->where('is_active', 1)->findAll();
|
||||
$data['pt_co_share_details'] = $this->PTCOShareDetailsModel->where('pt_id', $id)->where('is_active', 1)->findAll();
|
||||
$data['emp_data'] = $this->employeeModel
|
||||
->select('employees.*, employee_polices.id as emp_policy_id')
|
||||
->join('employee_polices', 'employees.id = employee_polices.employee_id', 'left')
|
||||
->where('employees.client_id', $data['client_id'])
|
||||
->where('employees.is_active', 1)->findAll();
|
||||
|
||||
// print_r( $data['pt_co_share_details']); die;
|
||||
|
||||
if($data){
|
||||
return $this->respond(['status' => true, 'data' => $data], 200);
|
||||
}else{
|
||||
return $this->respond(['status' => false], 200);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
|
||||
// Policy Transaction Endorsement
|
||||
public function viewEndorsement()
|
||||
{
|
||||
$data['issuer'] = [1 => 'JIBS', 2 => 'Nhance'];
|
||||
$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['endorsement_data_list'] = $this->policyTransactionModel
|
||||
->select('
|
||||
policy_transaction.*,
|
||||
clients.short_name as client_short_name,
|
||||
clients.client_code,
|
||||
client_branch.branch_name as client_branch_name,
|
||||
insurers.name as insurer_name,
|
||||
policy_type.policy_type
|
||||
')
|
||||
->join('clients', 'policy_transaction.client_id = clients.id', 'left')
|
||||
->join('client_branch', 'policy_transaction.client_branch_id = client_branch.id', 'left')
|
||||
->join('insurers', 'policy_transaction.insurer_id = insurers.id','left')
|
||||
->join('client_policy', 'policy_transaction.client_policy_id = client_policy.id', 'left')
|
||||
->join('policy_type', 'client_policy.policy_type_id = policy_type.id', 'left')
|
||||
->where('policy_transaction.is_active', 1)
|
||||
->where('policy_transaction.action_type !=', 'inception')
|
||||
->orderBy('policy_transaction.id', 'desc')
|
||||
->findAll();
|
||||
|
||||
$data['client'] = $this->clientModel->where('is_active', 1)->findAll();
|
||||
$data['policy_type'] = $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();
|
||||
|
||||
|
||||
$this->loadLayout('policy_transaction_endorsement_list', $data);
|
||||
}
|
||||
|
||||
|
||||
public function createEndorsementPolicy()
|
||||
{
|
||||
$id = $this->request->getPost('id');
|
||||
$data = $this->preparePolicyTransactionData();
|
||||
|
||||
if (!$id) {
|
||||
return $this->insertEndorsementTransaction($data);
|
||||
} else {
|
||||
return $this->updateEndorsementTransaction($id, $data);
|
||||
}
|
||||
}
|
||||
|
||||
private function preparePolicyTransactionData()
|
||||
{
|
||||
$data = $this->request->getPost();
|
||||
// print_r($data);
|
||||
|
||||
$data_received_date = (string)$this->request->getPost('data_received_date');
|
||||
$closure_date = (string)$this->request->getPost('closure_date');
|
||||
$data['data_received_date'] = date('Y-m-d', strtotime($data_received_date));
|
||||
$data['closure_date'] = date('Y-m-d', strtotime($closure_date));
|
||||
|
||||
// Separate Insurer and TPA Branch IDs and IDs
|
||||
if(isset($data['insurer_id']) && !empty($data['insurer_id'])){
|
||||
list($data['insurer_branch_id'], $data['insurer_id']) = explode('-', $data['insurer_id']);
|
||||
if ($data['tpa']) {
|
||||
list($data['tpa_branch_id'], $data['tpa_id']) = explode('-', $data['tpa']);
|
||||
}
|
||||
}
|
||||
|
||||
$issue_type = $this->policyTransactionModel
|
||||
->where('action_type', 'inception')
|
||||
->where('client_id', $this->request->getPost('client_id'))
|
||||
->where('client_branch_id', $this->request->getPost('client_branch_id'))
|
||||
->first();
|
||||
$data['tsi'] = generate_tsi_code($issue_type['issue_type'] ?? 1);
|
||||
|
||||
// print_r($data); die;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function insertEndorsementTransaction($data)
|
||||
{
|
||||
$insert = $this->policyTransactionModel->insert($data);
|
||||
|
||||
if ($insert) {
|
||||
$this->insertTransactionStatus($insert, $data['status'], 1);
|
||||
$this->handleCompletedStatus($data, $insert);
|
||||
$this->insertOrUpdateCoShareDetails($data, $insert);
|
||||
|
||||
|
||||
return $this->respond(['status' => true, 'message' => 'Endorsement transaction created successfully'], 200);
|
||||
}
|
||||
|
||||
return $this->respond(['status' => false, 'message' => 'Endorsement transaction creation failed'], 400);
|
||||
}
|
||||
|
||||
private function updateEndorsementTransaction($id, $data)
|
||||
{
|
||||
$update = $this->policyTransactionModel->where('id', $id)->set($data)->update();
|
||||
|
||||
if ($update) {
|
||||
$this->insertTransactionStatus($id, $data['status'], 1);
|
||||
$this->handleCompletedStatus($data, $id);
|
||||
$this->insertOrUpdateCoShareDetails($data, $id);
|
||||
|
||||
|
||||
return $this->respond(['status' => true, 'message' => 'Endorsement transaction updated successfully'], 200);
|
||||
}
|
||||
|
||||
return $this->respond(['status' => false, 'message' => 'Endorsement transaction update failed'], 400);
|
||||
}
|
||||
|
||||
private function handleCompletedStatus($data, $policy_tran_id)
|
||||
{
|
||||
if ($data['status'] == 'completed') {
|
||||
|
||||
$tolamt = $data['total'][0];
|
||||
|
||||
$description = 'The following amount of Rs. ' . round($tolamt, 2) . '/- has been' .
|
||||
($data['action_type'] == 'deletion' ? ' Credit ' : ' Debit ') . 'from the policy transaction';
|
||||
|
||||
$cd_tranction_data = [
|
||||
'amount' => $tolamt,
|
||||
'sub_type_id' => $data['action_type'] == 'deletion' ? 3 : 4,
|
||||
'client_id' => $data['client_id'],
|
||||
'client_policy_id' => $data['client_policy_id'],
|
||||
'endorsement_no' => null,
|
||||
'cd_ac_no' => $data['cd_ac_no'] ?? null,
|
||||
'insurer_id' => $data['insurer_id'],
|
||||
'description' => $description,
|
||||
'transaction_type' => $data['action_type'] == 'deletion' ? 'Credit' : 'Debit',
|
||||
'updated_by' => get_session_userid(),
|
||||
'event_name' => $data['action_type'],
|
||||
'is_active' => 1,
|
||||
];
|
||||
|
||||
DepositHelper::saveDeposit($cd_tranction_data, get_session_userid());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getEndorsementDataForEdit($id)
|
||||
{
|
||||
$data = $this->policyTransactionModel
|
||||
->select('
|
||||
policy_transaction.*,
|
||||
clients.short_name as client_short_name,
|
||||
clients.client_type,
|
||||
client_policy.policy_start_date as s_date,
|
||||
client_policy.policy_end_date as e_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)
|
||||
->first();
|
||||
|
||||
$data['policy_start_date'] = date('d-m-Y', strtotime($data['s_date']));
|
||||
$data['policy_end_date'] = date('d-m-Y', strtotime($data['e_date']));
|
||||
$data['data_received_date'] = date('d-m-Y', strtotime($data['data_received_date']));
|
||||
$data['closure_date'] = date('d-m-Y', strtotime($data['closure_date']));
|
||||
|
||||
$data['pt_co_share_details'] = $this->PTCOShareDetailsModel->where('pt_id', $id)->where('is_active', 1)->findAll();
|
||||
|
||||
|
||||
if($data){
|
||||
return $this->respond(['status' => true, 'data' => $data], 200);
|
||||
}else{
|
||||
return $this->respond(['status' => false], 200);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
|
||||
//file upload function
|
||||
public function uploadFile()
|
||||
{
|
||||
$files = $this->request->getFiles();
|
||||
$doc_name = $this->request->getPost('doc_name[]');
|
||||
$pt_id = $this->request->getPost('pt_id');
|
||||
|
||||
$uploadData = uploadFilesToGoogleDrive($files['file'], $doc_name, $pt_id);
|
||||
$insert = false;
|
||||
if(!isset($uploadData['status'])){
|
||||
$this->PTFileModel->insertBatch($uploadData);
|
||||
$insert = true;
|
||||
}
|
||||
|
||||
if ($insert) {
|
||||
$data['pt_files'] = $this->PTFileModel->where('pt_id', $pt_id)->where('is_active', 1)->findAll();
|
||||
return $this->respond(['status' => true, 'message' => 'File uploaded successfully in G-Drive', 'data' => $data]);
|
||||
} else {
|
||||
return $this->respond(['status' => false, 'message' => 'Failed to upload file in G-Drive']);
|
||||
}
|
||||
}
|
||||
|
||||
// update Invoice Status
|
||||
public function updateInvoiceStatus()
|
||||
{
|
||||
$ids = $this->request->getPost('ids');
|
||||
$ids = json_decode($ids);
|
||||
|
||||
// var_dump($ids); die;
|
||||
|
||||
$data['invoice_status'] = $this->request->getPost('invoice_status');
|
||||
if($this->request->getPost('invoice_status') == 'generated'){
|
||||
$data['invoice_no'] = $this->request->getPost('invoice_no');
|
||||
}
|
||||
|
||||
|
||||
$update = $this->policyTransactionModel
|
||||
->whereIn('id', $ids)
|
||||
->set($data)
|
||||
->update();
|
||||
|
||||
|
||||
if ($update) {
|
||||
|
||||
return $this->respond(['status' => true, 'data' => $ids, 'message' => 'Invoice status updated successfully'], 200);
|
||||
} else {
|
||||
return $this->respond(['status' => true, 'data' => $ids, 'message' => 'Failed to update invoice status'], 200);
|
||||
}
|
||||
}
|
||||
|
||||
public function removeCoShareData($id)
|
||||
{
|
||||
$this->myLogger->logme('error', 'PT Co Share Detailes Remove function called');
|
||||
|
||||
$data = [
|
||||
'updated_by' => get_session_userid(),
|
||||
'is_active' => 0
|
||||
];
|
||||
|
||||
$update = $this->PTCOShareDetailsModel->where('id', $id)->set($data)->update();
|
||||
|
||||
if ($update) {
|
||||
return $this->respond(['status' => true, 'code' => 200, 'message' => 'Data removed successfully'], 200);
|
||||
} else {
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to remove data'], 200);
|
||||
}
|
||||
}
|
||||
|
||||
public function getPTCOShareCount($client_id, $client_policy_id)
|
||||
{
|
||||
$totalCount = $this->PTCOShareDetailsModel
|
||||
->select('pt_co_share_details.*')
|
||||
->join('policy_transaction', 'policy_transaction.id = pt_co_share_details.pt_id')
|
||||
->where('policy_transaction.client_id', $client_id)
|
||||
->where('policy_transaction.client_policy_id', $client_policy_id)
|
||||
->findAll();
|
||||
|
||||
if ($totalCount) {
|
||||
return $this->respond(['status' => true, 'code' => 200, 'data' => $totalCount], 200);
|
||||
} else {
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to get data'], 200);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
|
||||
//get BDS Reports data
|
||||
public function reportBDS()
|
||||
{
|
||||
|
||||
$data['issuer'] = [1 => 'JIBS', 2 => 'Nhance'];
|
||||
$data['client_type'] = [1 => 'Group', 2 => 'Individual'];
|
||||
$data['issuing_type'] = [1 => 'Fresh', 2 => 'Renewal', 3 => 'Roll Over'];
|
||||
$data['policy_status'] = [
|
||||
'pending' => 'Pending',
|
||||
'exported_to_insurer' => 'Exported to Insurer',
|
||||
'imported_from_insurer' => 'Imported from Insurer',
|
||||
'exported_to_tpa' => 'Exported to TPA',
|
||||
'imported_from_tpa' => 'Imported from TPA',
|
||||
'completed' => 'Completed'
|
||||
];
|
||||
$data['invoice_status_array'] = [
|
||||
'yet_to_generate' => 'Yet to Generate',
|
||||
'generated' => 'Generated',
|
||||
'send' => 'Send',
|
||||
'recived' => 'Recived',
|
||||
];
|
||||
$data['date_type'] = [
|
||||
'policy_issue_date' => 'Policy Issue Date',
|
||||
'policy_start_date' => 'Policy Start Date',
|
||||
'policy_end_date' => 'Policy End Date',
|
||||
'data_received_date' => 'Data Received Date',
|
||||
'closure_date' => 'Closure Date',
|
||||
];
|
||||
|
||||
$data['insurer'] = $this->insurerModel->where('is_active', 1)->findAll();
|
||||
$data['policy_types'] = $this->policyTypeModel->where('is_active', 1)->findAll();
|
||||
$data['clients'] = $this->clientModel->where('is_active', 1)->findAll();
|
||||
|
||||
|
||||
//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');
|
||||
|
||||
$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;
|
||||
|
||||
|
||||
//Actual data for the list
|
||||
$data['report_list'] = $this->policyTransactionModel->getBDSReportList($start_date, $end_date, $client_id, $insurer_id, $policy_type_id, $date_type, $issuer);
|
||||
// dd($data);
|
||||
|
||||
$this->loadLayout('report_bds_filter', $data);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -64,17 +64,28 @@ class UserController extends AdminController
|
||||
|
||||
if ($insert) {
|
||||
|
||||
$teamData['user_id'] = $insert;
|
||||
foreach ($teams as $value) {
|
||||
$teamData['team_id'] = $value;
|
||||
$teamData['created_by'] = get_session_userid();
|
||||
$this->userTeamsModel->insert($teamData);
|
||||
}
|
||||
|
||||
if ($userData['role'] == 3) {
|
||||
|
||||
$db = \Config\Database::connect();
|
||||
$tableName = 'hdz_staff';
|
||||
$admin = 1;
|
||||
$admin = 0;
|
||||
$acm = 1;
|
||||
$acm_id = $insert;
|
||||
|
||||
$password = '12345678'; //Default password
|
||||
$hashedPassword = password_hash($password, PASSWORD_DEFAULT);
|
||||
|
||||
foreach ($temp_team as $key => $value) {
|
||||
|
||||
$team = $this->teamModel->where('id', $value)->first();
|
||||
|
||||
if ($team['name'] == 'Claims') {
|
||||
$hdz_staff = [
|
||||
'emp_code' => $userData['emp_code'],
|
||||
@ -82,6 +93,8 @@ class UserController extends AdminController
|
||||
'username' => strtolower($userData['first_name']),
|
||||
'email' => $userData['email'],
|
||||
'admin' => $admin,
|
||||
'acm' => $acm,
|
||||
'acm_id' => $acm_id,
|
||||
'registration' => time(),
|
||||
'password' => $hashedPassword,
|
||||
'active' => 1,
|
||||
@ -90,13 +103,6 @@ class UserController extends AdminController
|
||||
$db->table($tableName)->insert($hdz_staff);
|
||||
}
|
||||
}
|
||||
|
||||
$teamData['user_id'] = $insert;
|
||||
foreach ($teams as $value) {
|
||||
$teamData['team_id'] = $value;
|
||||
$teamData['created_by'] = get_session_userid();
|
||||
$this->userTeamsModel->insert($teamData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -117,12 +123,12 @@ class UserController extends AdminController
|
||||
|
||||
public function edit()
|
||||
{
|
||||
$teams = $this->request->getPost('team');
|
||||
|
||||
if (!$this->request->getPost()) {
|
||||
return redirect()->to(base_url('/user/list'));
|
||||
} else {
|
||||
$id = $this->request->getPost('PrimaryKey');
|
||||
$teams = $this->request->getPost('team');
|
||||
$userData = $this->request->getPost();
|
||||
unset($userData['csrf_test_name']);
|
||||
unset($userData['PrimaryKey']);
|
||||
@ -133,6 +139,16 @@ class UserController extends AdminController
|
||||
|
||||
if ($update) {
|
||||
|
||||
if ($teams) {
|
||||
$this->userTeamsModel->where('user_id', $id)->delete();
|
||||
$teamData['user_id'] = $id;
|
||||
foreach ($teams as $value) {
|
||||
$teamData['team_id'] = $value;
|
||||
$teamData['created_by'] = get_session_userid();
|
||||
$this->userTeamsModel->insert($teamData);
|
||||
}
|
||||
}
|
||||
|
||||
if ($userData['role'] == 3) {
|
||||
|
||||
$db = \Config\Database::connect();
|
||||
@ -152,7 +168,6 @@ class UserController extends AdminController
|
||||
'active' => 1,
|
||||
];
|
||||
|
||||
|
||||
$db->table($tableName)->where('emp_code', $userData['emp_code'])
|
||||
->where('email', $userData['email'])
|
||||
->set($hdz_staff)
|
||||
@ -160,16 +175,6 @@ class UserController extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
$this->userTeamsModel->where('user_id', $id)->delete();
|
||||
|
||||
if ($teams) {
|
||||
$teamData['user_id'] = $id;
|
||||
foreach ($teams as $value) {
|
||||
$teamData['team_id'] = $value;
|
||||
$teamData['created_by'] = get_session_userid();
|
||||
$this->userTeamsModel->insert($teamData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -201,4 +206,4 @@ class UserController extends AdminController
|
||||
$teamData = $this->teamModel->select('id, name')->findAll();
|
||||
echo json_encode(array("status" => true , 'roleData' => $roleData, 'teamData' => $teamData,));
|
||||
}
|
||||
}
|
||||
}
|
||||
150
app/Helpers/drive_helper.php
Normal file
150
app/Helpers/drive_helper.php
Normal file
@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
use Google\Client as GoogleClient;
|
||||
use Google\Service\Drive;
|
||||
|
||||
if (!function_exists('uploadFilesToGoogleDrive')) {
|
||||
function uploadFilesToGoogleDrive(array $files, $doc_name, $pt_id)
|
||||
{
|
||||
$appName = getenv('GOOGLE_OAUTH_APP_NAME');
|
||||
$clientID = getenv('GOOGLE_OAUTH_CLIENT_ID');
|
||||
$clientSecret = getenv('GOOGLE_OAUTH_CLIENT_SECRET');
|
||||
$redirectUri = getenv('GOOGLE_OAUTH_REDIRECT_URI');
|
||||
$scopes = explode(',', getenv('GOOGLE_OAUTH_SCOPES'));
|
||||
$accessToken = session()->get('access_token');
|
||||
log_message('error', '////////////// --- G-Drive Access Token {data}', ['data' => $accessToken]);
|
||||
|
||||
// Initialize Google Client
|
||||
$client = new GoogleClient();
|
||||
$client->setApplicationName($appName);
|
||||
$client->setClientId($clientID);
|
||||
$client->setClientSecret($clientSecret);
|
||||
$client->setRedirectUri($redirectUri);
|
||||
$client->addScope($scopes);
|
||||
// $client->setApprovalPrompt('force');
|
||||
$client->setPrompt('consent');
|
||||
$client->setAccessType('offline');
|
||||
|
||||
|
||||
if ($accessToken) {
|
||||
|
||||
$client->setAccessToken($accessToken);
|
||||
log_message('error', '////////////// --- G-Drive Access Token expired : {data}', ['data' => $client->isAccessTokenExpired()]);
|
||||
|
||||
if ($client->isAccessTokenExpired()) {
|
||||
|
||||
$refreshToken = session()->get('refresh_token');
|
||||
log_message('error', '////////////// --- G-Drive Refresh Token : {data}', ['data' => $refreshToken]);
|
||||
|
||||
if ($refreshToken) {
|
||||
$client->fetchAccessTokenWithRefreshToken($refreshToken);
|
||||
$token = $client->getAccessToken();
|
||||
|
||||
if (isset($token['access_token'])) {
|
||||
session()->set('access_token', $token['access_token']);
|
||||
// $client->setAccessToken($token);
|
||||
log_message('error', '////////////// --- G-Drive Access Token refreshed and stored successfully.');
|
||||
} else {
|
||||
log_message('error', '////////////// --- G-Drive Access Token not available after refresh.');
|
||||
}
|
||||
|
||||
if (isset($token['refresh_token'])) {
|
||||
session()->set('refresh_token', $token['refresh_token']);
|
||||
log_message('error', '////////////// --- G-Drive Refresh Token updated successfully.');
|
||||
} else {
|
||||
log_message('error', '////////////// --- G-Drive Refresh Token not available after refresh.');
|
||||
}
|
||||
|
||||
} else {
|
||||
log_message('error', '////////////// --- G-Drive Refresh Token Not Available');
|
||||
redirect()->to(filter_var($client->createAuthUrl(), FILTER_SANITIZE_URL));
|
||||
}
|
||||
} else {
|
||||
log_message('error', '////////////// --- G-Drive Access Token is still valid.');
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
|
||||
$driveService = new Drive($client);
|
||||
$folderName = 'New Folder';
|
||||
|
||||
// Check if the folder already exists
|
||||
$response = $driveService->files->listFiles([
|
||||
'q' => "mimeType='application/vnd.google-apps.folder' and name='{$folderName}' and trashed=false",
|
||||
'fields' => 'files(id, name)'
|
||||
]);
|
||||
|
||||
$filesList = $response->getFiles();
|
||||
$folderId = null;
|
||||
|
||||
if (count($filesList) > 0) {
|
||||
// Folder already exists
|
||||
$folderId = $filesList[0]->getId();
|
||||
} else {
|
||||
// Create a new folder
|
||||
$folder = new Drive\DriveFile();
|
||||
$folder->setName($folderName);
|
||||
$folder->setMimeType('application/vnd.google-apps.folder');
|
||||
|
||||
$createdFolder = $driveService->files->create($folder, [
|
||||
'fields' => 'id'
|
||||
]);
|
||||
|
||||
$folderId = $createdFolder->id;
|
||||
}
|
||||
|
||||
$uploadedFiles = [];
|
||||
|
||||
foreach ($files as $key => $file) {
|
||||
|
||||
if (!empty($file)) {
|
||||
|
||||
$dname = $doc_name[$key];
|
||||
|
||||
$driveFile = new Drive\DriveFile();
|
||||
$driveFile->setName($file->getClientName());
|
||||
$driveFile->setParents([$folderId]);
|
||||
|
||||
$result = $driveService->files->create(
|
||||
$driveFile,
|
||||
[
|
||||
'data' => file_get_contents($file->getTempName()),
|
||||
'mimeType' => $file->getClientMimeType(),
|
||||
'uploadType' => 'multipart'
|
||||
]
|
||||
);
|
||||
|
||||
$uploadedFiles[] = [
|
||||
'file_name' => $file->getClientName(),
|
||||
'drive_id' => $result->id,
|
||||
'doc_name' => $dname,
|
||||
'pt_id' => $pt_id,
|
||||
'created_by' => get_session_userid(),
|
||||
'url' => "https://drive.google.com/file/d/{$result->id}/view",
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $uploadedFiles;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
|
||||
$errorDetails = [
|
||||
'status' => 'error',
|
||||
'error_message' => 'Error uploading files: ' . $e->getMessage(),
|
||||
'error_code' => $e->getCode(),
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
'stack_trace' => $e->getTraceAsString()
|
||||
];
|
||||
|
||||
return $errorDetails;
|
||||
}
|
||||
} else {
|
||||
|
||||
$url = $client->createAuthUrl();
|
||||
return redirect()->to(filter_var($url, FILTER_SANITIZE_URL));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -27,13 +27,21 @@ if (!function_exists('googleOauthLogin')) {
|
||||
$client->setClientSecret($clientSecret);
|
||||
$client->setRedirectUri($redirectUri);
|
||||
$client->addScope($scopesArray);
|
||||
// $client->setApprovalPrompt('force');
|
||||
$client->setPrompt('consent');
|
||||
$client->setAccessType('offline');
|
||||
|
||||
// Check if an OAuth token is provided
|
||||
if ($oauthToken) {
|
||||
try {
|
||||
// Attempt to fetch the access token with the provided OAuth token
|
||||
$token = $client->fetchAccessTokenWithAuthCode($oauthToken);
|
||||
session()->set('access_token', $token['access_token']);
|
||||
if(isset($token['refresh_token'])){
|
||||
session()->set('refresh_token', $token['refresh_token']);
|
||||
}
|
||||
$client->setAccessToken($token);
|
||||
|
||||
$oauth = new Oauth2($client);
|
||||
|
||||
// Get user information using the OAuth2 service
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
<?php
|
||||
use App\Models\ClientModel;
|
||||
|
||||
|
||||
// File: app/Helpers/Uuid_helper.php
|
||||
|
||||
@ -65,8 +67,6 @@ if (!function_exists('file_unlink')) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!function_exists('compressImage')) {
|
||||
function compressImage($file, $destinationPath, $newWidth = 100, $newHeight = 100)
|
||||
{
|
||||
@ -82,9 +82,7 @@ if (!function_exists('compressImage')) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('fancy_date_time_format'))
|
||||
{
|
||||
if (!function_exists('fancy_date_time_format')) {
|
||||
function fancy_date_time_format($datetime,$return_type = 'fancy') {
|
||||
date_default_timezone_set('Asia/Kolkata');
|
||||
|
||||
@ -118,9 +116,7 @@ if (!function_exists('fancy_date_time_format'))
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(!function_exists('check_string_date'))
|
||||
{
|
||||
if(!function_exists('check_string_date')){
|
||||
function check_string_date($str)
|
||||
{
|
||||
if (DateTime::createFromFormat('Y-m-d H:i:s', $str) !== false) {
|
||||
@ -130,8 +126,6 @@ if(!function_exists('check_string_date'))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!function_exists('generate_download_link')) {
|
||||
|
||||
function generate_download_link($rand_string) {
|
||||
@ -145,8 +139,6 @@ if (!function_exists('generate_download_link')) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!function_exists('generate_random_alphanumeric')) {
|
||||
function generate_random_alphanumeric($length = 6) {
|
||||
$random_string = '';
|
||||
@ -165,8 +157,6 @@ if (!function_exists('generate_random_alphanumeric')) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!function_exists('get_base64_image')) {
|
||||
|
||||
function get_base64_image($path)
|
||||
@ -184,7 +174,6 @@ if (!function_exists('get_base64_image')) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('format_indian_number')) {
|
||||
function format_indian_number($number) {
|
||||
// Round the number to two decimal places
|
||||
@ -218,7 +207,6 @@ if (!function_exists('format_indian_number')) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('get_username')) {
|
||||
function get_username($user_id) {
|
||||
// Connect to the database
|
||||
@ -238,7 +226,6 @@ if (!function_exists('get_username')) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('get_role_id')) {
|
||||
function get_role_id() {
|
||||
|
||||
@ -247,6 +234,61 @@ if (!function_exists('get_role_id')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('generate_client_code')) {
|
||||
function generate_client_code($string = 'GC') {
|
||||
|
||||
$clientModel = new \App\Models\ClientModel();
|
||||
|
||||
$latestClient = $clientModel->select('id')->orderBy('id', 'DESC')->first();
|
||||
$id = $latestClient ? $latestClient['id'] : 0;
|
||||
|
||||
$year = date('y');
|
||||
|
||||
$newId = $id + 1;
|
||||
|
||||
$client_code = $year . $string . $newId;
|
||||
|
||||
return $client_code;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('generate_tsi_code')) {
|
||||
function generate_tsi_code($type) {
|
||||
|
||||
$PolicyTransactionModel = new \App\Models\PolicyTransactionModel();
|
||||
|
||||
$latestClient = $PolicyTransactionModel->select('id')->orderBy('id', 'DESC')->first();
|
||||
$id = $latestClient ? $latestClient['id'] : 0;
|
||||
|
||||
$year = date('y');
|
||||
$month = date('m');
|
||||
$string = 'P';
|
||||
|
||||
if($type == 2){
|
||||
$string2 = 'R';
|
||||
}else{
|
||||
$string2 = 'F';
|
||||
}
|
||||
|
||||
$newId = $id + 1;
|
||||
|
||||
$tsi_code = $string2 . $month . $year . $string . $newId;
|
||||
|
||||
return $tsi_code;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('generateRandomCode')) {
|
||||
function generateRandomCode($prefix = 'RTL-', $length = 6) {
|
||||
// Generate a random number with the specified length
|
||||
$randomNumber = str_pad(mt_rand(0, pow(10, $length)-1), $length, '0', STR_PAD_LEFT);
|
||||
|
||||
// Return the code with the prefix
|
||||
return $prefix . $randomNumber;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function numberToWords($number)
|
||||
{
|
||||
|
||||
@ -13,6 +13,7 @@ class ClientModel extends Model
|
||||
protected $allowedFields = [
|
||||
"id",
|
||||
"entity_type_id",
|
||||
"client_type",
|
||||
"client_name",
|
||||
"short_name",
|
||||
"pan",
|
||||
@ -28,7 +29,14 @@ class ClientModel extends Model
|
||||
"updated_by",
|
||||
"is_active",
|
||||
"common_mails",
|
||||
"hr_mails"
|
||||
"hr_mails",
|
||||
"client_code",
|
||||
"cost_center",
|
||||
"dob",
|
||||
"aadhar",
|
||||
"reference",
|
||||
"phone",
|
||||
"email",
|
||||
];
|
||||
|
||||
|
||||
|
||||
64
app/Models/PTCOShareDetailsModel.php
Normal file
64
app/Models/PTCOShareDetailsModel.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class PTCOShareDetailsModel extends Model
|
||||
{
|
||||
protected $table = 'pt_co_share_details';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = false;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
'id',
|
||||
'pt_id',
|
||||
'insurer_id',
|
||||
'insurer_branch_id',
|
||||
'co_share_type',
|
||||
'co_share_per',
|
||||
'bp_amt',
|
||||
'bp_gst_amt',
|
||||
'bp_igst',
|
||||
'bp_sgst',
|
||||
'bp_cgst',
|
||||
'tp_amt',
|
||||
'tp_gst_amt',
|
||||
'tp_igst',
|
||||
'tp_sgst',
|
||||
'tp_cgst',
|
||||
'tep_amt',
|
||||
'tep_gst_amt',
|
||||
'tep_igst',
|
||||
'tep_sgst',
|
||||
'tep_cgst',
|
||||
'agreed_amt',
|
||||
'agreed_bp_per',
|
||||
'agreed_tp_per',
|
||||
'agreed_tep_per',
|
||||
'standerd_bp_per',
|
||||
'standerd_tp_per',
|
||||
'standerd_tep_per',
|
||||
'actual_bp_amt',
|
||||
'actual_tp_amt',
|
||||
'actual_tep_amt',
|
||||
'actual_bp_per',
|
||||
'actual_tp_per',
|
||||
'actual_tep_per',
|
||||
'exp_amt',
|
||||
'variance',
|
||||
'remark',
|
||||
'created_at',
|
||||
'created_by',
|
||||
'updated_at',
|
||||
'updated_by',
|
||||
'is_active',
|
||||
'cd_ac_no',
|
||||
'amount',
|
||||
'stamp_duty',
|
||||
'cop_amt',
|
||||
];
|
||||
|
||||
}
|
||||
29
app/Models/PTFileModel.php
Normal file
29
app/Models/PTFileModel.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class PTFileModel extends Model
|
||||
{
|
||||
protected $table = 'pt_files';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = false;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
|
||||
'id',
|
||||
'pt_id',
|
||||
'doc_name',
|
||||
'file_name',
|
||||
'url',
|
||||
'is_active',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
209
app/Models/PolicyTransactionModel.php
Normal file
209
app/Models/PolicyTransactionModel.php
Normal file
@ -0,0 +1,209 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class PolicyTransactionModel extends Model
|
||||
{
|
||||
protected $table = 'policy_transaction';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = false;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
'id',
|
||||
'issuer',
|
||||
'client_id',
|
||||
'client_branch_id',
|
||||
'insurer_id',
|
||||
'insurer_branch_id',
|
||||
'tpa_id',
|
||||
'tpa_branch_id',
|
||||
'client_policy_id',
|
||||
'vehicle_id',
|
||||
'issue_type',
|
||||
'source_client_policy_id',
|
||||
'policy_no',
|
||||
'cd_ac_no',
|
||||
'policy_issue_date',
|
||||
'policy_start_date',
|
||||
'policy_end_date',
|
||||
'action_type',
|
||||
'endorsement_no',
|
||||
'data_received_date',
|
||||
'closure_date',
|
||||
'emp_count',
|
||||
'dependent_count',
|
||||
'status',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'is_active',
|
||||
'invoice_status',
|
||||
'invoice_no',
|
||||
'revenue_type',
|
||||
'tsi',
|
||||
'co_share',
|
||||
'pre_payable_by',
|
||||
'bro_payable_by',
|
||||
'ct_status',
|
||||
'co_broking_status',
|
||||
'installment',
|
||||
'installment_data',
|
||||
'location',
|
||||
'links',
|
||||
'stage',
|
||||
'etat',
|
||||
'etat_band',
|
||||
'edate',
|
||||
'renewal_date',
|
||||
'rollover_date',
|
||||
'policy_holder_name',
|
||||
'same_as_proposer',
|
||||
'ref',
|
||||
'spl',
|
||||
'fund_received',
|
||||
'listed_insurers',
|
||||
'ppteam',
|
||||
'policy_type_id',
|
||||
'endorse_eff_date',
|
||||
'sales_generated_by',
|
||||
'serviced_by',
|
||||
];
|
||||
|
||||
|
||||
|
||||
// Callbacks
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = ["checkAndADDCreatedByValue"];
|
||||
protected $afterInsert = [];
|
||||
protected $beforeUpdate = ["checkAndUpdateUpdatedByValue"];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
|
||||
protected function checkAndADDCreatedByValue(array $data)
|
||||
{
|
||||
// Check if 'updated_by' value is null or empty
|
||||
if (empty($data['data']['created_by'])) {
|
||||
// Set 'updated_by' value to the current session user ID
|
||||
$data['data']['created_by'] = get_session_userid();
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function checkAndUpdateUpdatedByValue(array $data)
|
||||
{
|
||||
// Check if 'updated_by' value is null or empty
|
||||
if (empty($data['data']['updated_by'])) {
|
||||
// Set 'updated_by' value to the current session user ID
|
||||
$data['data']['updated_by'] = get_session_userid();
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
// public function getBDSReportList($client_id, $policy_id, $branch_id, $issuer)
|
||||
public function getBDSReportList($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0)
|
||||
{
|
||||
$builder = $this->db->table('policy_transaction')
|
||||
->select("
|
||||
policy_transaction.*,
|
||||
DATE_FORMAT(policy_transaction.policy_issue_date, '%d %b %Y') AS policy_issue_date,
|
||||
DATE_FORMAT(policy_transaction.policy_issue_date, '%b') AS policy_issue_month,
|
||||
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.bp_amt,
|
||||
sales_user.first_name as salse_person_name,
|
||||
service_user.first_name as service_person_name,
|
||||
|
||||
ROUND((pt_co_share_details.bp_amt + pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 2) AS premium_wo_gst,
|
||||
ROUND((ROUND((pt_co_share_details.bp_amt + pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 2) * 18 / 100), 2) AS gst_amount,
|
||||
ROUND((ROUND((pt_co_share_details.bp_amt + pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 2) + ROUND((ROUND((pt_co_share_details.bp_amt + pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 2) * 18 / 100), 2)), 2) AS total_premium,
|
||||
ROUND((pt_co_share_details.tp_amt + pt_co_share_details.tep_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,
|
||||
ROUND((pt_co_share_details.bp_amt * pt_co_share_details.agreed_bp_per + (pt_co_share_details.tp_amt + pt_co_share_details.tep_amt) * (pt_co_share_details.agreed_tp_per + pt_co_share_details.agreed_tep_per)), 2) AS total_irda,
|
||||
ROUND((ROUND((pt_co_share_details.bp_amt * pt_co_share_details.agreed_bp_per + (pt_co_share_details.tp_amt + pt_co_share_details.tep_amt) * (pt_co_share_details.agreed_tp_per + pt_co_share_details.agreed_tep_per)), 2) * 18 / 100), 2) AS gst_on_revenue,
|
||||
ROUND(
|
||||
(ROUND((pt_co_share_details.bp_amt * pt_co_share_details.agreed_bp_per + (pt_co_share_details.tp_amt + pt_co_share_details.tep_amt) * (pt_co_share_details.agreed_tp_per + pt_co_share_details.agreed_tep_per)), 2) +
|
||||
ROUND((ROUND((pt_co_share_details.bp_amt * pt_co_share_details.agreed_bp_per + (pt_co_share_details.tp_amt + pt_co_share_details.tep_amt) * (pt_co_share_details.agreed_tp_per + pt_co_share_details.agreed_tep_per)), 2) * 18 / 100), 2)),
|
||||
2) AS total_amt_received
|
||||
")
|
||||
->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', 'client_policy.policy_type_id = policy_type.id', 'left')
|
||||
->join('insurers', 'policy_transaction.insurer_id = insurers.id', 'left')
|
||||
->join('insurer_branch', 'policy_transaction.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')
|
||||
->where('policy_transaction.is_active', 1);
|
||||
|
||||
// Check if the start date and end date are provided
|
||||
if ($start_date != 0 && $end_date != 0 && $date_type != 0) {
|
||||
|
||||
$startDate = date('Y-m-d 00:00:00', strtotime($start_date));
|
||||
$endDate = date('Y-m-d 23:59:59', strtotime($end_date));
|
||||
|
||||
$builder->where('policy_transaction.'.$date_type.'>=', $startDate)
|
||||
->where('policy_transaction.'.$date_type.'<=', $endDate);
|
||||
}
|
||||
|
||||
if ($client_id != 0) {
|
||||
$builder->where('policy_transaction.client_id', $client_id);
|
||||
}
|
||||
|
||||
if ($insurer_id != 0) {
|
||||
$builder->where('policy_transaction.insurer_id', $insurer_id);
|
||||
}
|
||||
|
||||
if ($policy_type_id != 0) {
|
||||
$builder->where('client_policy.policy_type_id', $policy_type_id);
|
||||
}
|
||||
|
||||
if ($issuer != 0) {
|
||||
$builder->where('policy_transaction.issuer', $issuer);
|
||||
}
|
||||
|
||||
return $builder->get()->getResultArray();
|
||||
}
|
||||
|
||||
}
|
||||
58
app/Models/PolicyTransactionStatusModel.php
Normal file
58
app/Models/PolicyTransactionStatusModel.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class PolicyTransactionStatusModel extends Model
|
||||
{
|
||||
protected $table = 'policy_transaction_status';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = false;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
'id',
|
||||
'policy_tran_id',
|
||||
'status',
|
||||
'status_type',
|
||||
'created_at',
|
||||
'created_by',
|
||||
'is_active',
|
||||
];
|
||||
|
||||
// Callbacks
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = ["checkAndADDCreatedByValue"];
|
||||
protected $afterInsert = [];
|
||||
protected $beforeUpdate = ["checkAndUpdateUpdatedByValue"];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
|
||||
protected function checkAndADDCreatedByValue(array $data)
|
||||
{
|
||||
// Check if 'updated_by' value is null or empty
|
||||
if (empty($data['data']['created_by'])) {
|
||||
// Set 'updated_by' value to the current session user ID
|
||||
$data['data']['created_by'] = get_session_userid();
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function checkAndUpdateUpdatedByValue(array $data)
|
||||
{
|
||||
// Check if 'updated_by' value is null or empty
|
||||
if (empty($data['data']['updated_by'])) {
|
||||
// Set 'updated_by' value to the current session user ID
|
||||
$data['data']['updated_by'] = get_session_userid();
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
@ -18,5 +18,9 @@ class PolicyTypeModel extends Model
|
||||
"updated_by",
|
||||
"is_active",
|
||||
"long_name",
|
||||
"ebp",
|
||||
"etp",
|
||||
"iep",
|
||||
"itp",
|
||||
];
|
||||
}
|
||||
|
||||
64
app/Models/VehicleModel.php
Normal file
64
app/Models/VehicleModel.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class VehicleModel extends Model
|
||||
{
|
||||
protected $table = 'vehicle';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = false;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
|
||||
'id',
|
||||
'vehicle_no',
|
||||
'type',
|
||||
'description',
|
||||
'owner',
|
||||
'branch_id',
|
||||
'old_onwer',
|
||||
'rc',
|
||||
'is_active',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
];
|
||||
|
||||
|
||||
// Callbacks
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = ["checkAndADDCreatedByValue"];
|
||||
protected $afterInsert = [];
|
||||
protected $beforeUpdate = ["checkAndUpdateUpdatedByValue"];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
|
||||
protected function checkAndADDCreatedByValue(array $data)
|
||||
{
|
||||
// Check if 'updated_by' value is null or empty
|
||||
if (empty($data['data']['created_by'])) {
|
||||
// Set 'updated_by' value to the current session user ID
|
||||
$data['data']['created_by'] = get_session_userid();
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function checkAndUpdateUpdatedByValue(array $data)
|
||||
{
|
||||
// Check if 'updated_by' value is null or empty
|
||||
if (empty($data['data']['updated_by'])) {
|
||||
// Set 'updated_by' value to the current session user ID
|
||||
$data['data']['updated_by'] = get_session_userid();
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
115
app/Views/drive_file_upload.php
Normal file
115
app/Views/drive_file_upload.php
Normal file
@ -0,0 +1,115 @@
|
||||
<div class="tab-pane fade" id="fileupload">
|
||||
<div class="row">
|
||||
<div class="col-xl-12">
|
||||
<div id="accordion" class="mb-3">
|
||||
<div class="card mb-1">
|
||||
<h5 class="m-1">
|
||||
<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>
|
||||
</h5>
|
||||
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
|
||||
<div class="card-body">
|
||||
<form class="parsley-examples" id="drive_file_upload_form" method="post"
|
||||
enctype="multipart/form-data" onsubmit="return validateForm();">
|
||||
|
||||
<input type="hidden" id="policy_tranction_primarykey_for_file_upload" name="pt_id">
|
||||
|
||||
<div class="form-group">
|
||||
|
||||
<div id="dynamic-form-container"></div>
|
||||
|
||||
<div class="form-group text-right m-b-0">
|
||||
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
|
||||
id="g_drive_file_upload_sbt_btn">Submit</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="file_table" class="card">
|
||||
<div class="card-body">
|
||||
<div class="row" style="padding-bottom: 10px;">
|
||||
<div class="col-6" style="align-self: center;">
|
||||
<h4 style="position: relative;">File List</h4>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="table-responsive" style="overflow-x: auto;">
|
||||
<table id="scroll-horizontal-datatable" class="table w-100 nowrap">
|
||||
<thead class="bg-light">
|
||||
<tr>
|
||||
<th>S.No</th>
|
||||
<th>Docs Name</th>
|
||||
<th>File Name</th>
|
||||
<th>Drive File Location</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="table_bd">
|
||||
</tbody>
|
||||
</table>
|
||||
<div>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- end col -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
$("#drive_file_upload_form").submit(function(event) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
var isValid = $('#drive_file_upload_form').parsley().validate();
|
||||
if (!isValid) {
|
||||
console.log('Form is Empty', 'Warning');
|
||||
return ;
|
||||
}
|
||||
|
||||
form_action = '<?php echo base_url() . 'util/drive_file_upload' ?>';
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
var formData = new FormData($('#drive_file_upload_form')[0]);
|
||||
|
||||
$.ajax({
|
||||
data:formData,
|
||||
url: form_action,
|
||||
type: "POST",
|
||||
dataType: 'json',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(res) {
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
if(res.status == true){
|
||||
toastr.success(res.message, 'Success');
|
||||
appendFileTableBody(res.data.pt_files);
|
||||
}else{
|
||||
toastr.error(res.message, 'Error');
|
||||
}
|
||||
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
@ -48,7 +48,7 @@
|
||||
<div class="tab-pane fade" id="template-tab">
|
||||
|
||||
<input type="hidden" id="insurer_templete_count" value="<?= isset($insurer_templete_count) ? $insurer_templete_count : ''?>">
|
||||
<input type="hidden" id="insurer_id" value="<?= $insurer['id'] ?>">
|
||||
<input type="hidden" id="insurer_id" value="<?= isset($insurer['id']) ? $insurer['id'] : '' ?>">
|
||||
|
||||
<div class="row">
|
||||
<div class="form-group col-md-4">
|
||||
@ -122,7 +122,7 @@
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form class="parsley-examples" method="post" id="templateForm" enctype="multipart/form-data">
|
||||
<input type="hidden" name="insurer_id" value="<?= $insurer['id'] ?>">
|
||||
<input type="hidden" name="insurer_id" value="<?= isset($insurer['id']) ? $insurer['id'] : '' ?>">
|
||||
<input type="hidden" name="template_id" id="template_id">
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
|
||||
@ -89,6 +89,11 @@
|
||||
<script src="<?= base_url() . "public"; ?>/assets/libs/pdfmake/build/vfs_fonts.js"></script>
|
||||
<!-- third party js ends -->
|
||||
|
||||
<script src="<?= base_url() . "public"; ?>/assets/libs/bootstrap-datepicker/js/bootstrap-datepicker.min.js"></script>
|
||||
<script src="<?= base_url() . "public"; ?>/assets/libs/moment/min/moment.min.js"></script>
|
||||
<script src="<?= base_url() . "public"; ?>/assets/libs/bootstrap-daterangepicker/daterangepicker.js"></script>
|
||||
|
||||
|
||||
<!-- Datatables init -->
|
||||
<!-- <script src="<?= base_url() . "public"; ?>/assets/js/pages/datatables.init.js"></script> -->
|
||||
|
||||
|
||||
@ -34,6 +34,10 @@
|
||||
<!-- icons -->
|
||||
<link href="<?= base_url() . "public"; ?>/assets/css/icons.min.css" rel="stylesheet" type="text/css" />
|
||||
|
||||
<link href="<?= base_url() . "public"; ?>/assets/libs/bootstrap-datepicker/css/bootstrap-datepicker.min.css" rel="stylesheet" type="text/css" />
|
||||
<link href="<?= base_url() . "public"; ?>/assets/libs/bootstrap-daterangepicker/daterangepicker.css" rel="stylesheet" type="text/css">
|
||||
<link href="<?= base_url() . "public"; ?>/assets/libs/bootstrap-daterangepicker/daterangepicker.css" rel="stylesheet" type="text/css">
|
||||
|
||||
|
||||
<!-- <link href="<?= base_url() . "public"; ?>/assets/css/bootstrap-material.min.css" rel="stylesheet" type="text/css" id="bs-default-stylesheet" /> -->
|
||||
<!-- <link href="<?= base_url() . "public"; ?>/assets/css/app-material.min.css" rel="stylesheet" type="text/css" id="app-default-stylesheet" /> -->
|
||||
@ -541,18 +545,21 @@
|
||||
<!--- Sidemenu -->
|
||||
<div id="sidebar-menu">
|
||||
<ul id="side-menu">
|
||||
|
||||
<li>
|
||||
<a href="<?= base_url('/dashboard/view') ?>">
|
||||
<i class="ri-dashboard-line"></i>
|
||||
<span> Dashboard </span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="<?= base_url('/client/list') ?>">
|
||||
<i class="mdi mdi-domain"></i>
|
||||
<span> Clients </span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="#sidebarDashboards" data-toggle="collapse" class="waves-effect">
|
||||
<i class="fas fa-user-tie"></i>
|
||||
@ -626,16 +633,11 @@
|
||||
<span> Tickets </span>
|
||||
</a>
|
||||
</li>
|
||||
<!-- <li>
|
||||
<a href="<?= base_url('/user/list') ?>">
|
||||
<i class=" ri-user-3-line"></i>
|
||||
<span> Users </span>
|
||||
</a>
|
||||
</li> -->
|
||||
|
||||
<li>
|
||||
<a id="app_content_management" href="#sidebarDashboardsmenu" data-toggle="collapse" class="waves-effect" style="color: grey;">
|
||||
<i class="fa fa-info-circle" aria-hidden="true"></i>
|
||||
<span class="badge badge-success badge-pill float-right">2</span>
|
||||
<i class="fa fa-info-circle" aria-hidden="true"></i>
|
||||
<span class="badge badge-success badge-pill float-right">2</span>
|
||||
<span> App Content Management </span>
|
||||
</a>
|
||||
<div class="collapse" id="sidebarDashboardsmenu">
|
||||
@ -646,15 +648,31 @@
|
||||
<li>
|
||||
<a href="<?= base_url('/frontend_content') ?>">Front-end Content</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
|
||||
<li>
|
||||
<a href="#sidebarDashboards" data-toggle="collapse" class="waves-effect">
|
||||
<i class="mdi mdi-format-list-bulleted"></i>
|
||||
<span class="badge badge-success badge-pill float-right">2</span>
|
||||
<span> Policy Transactions </span>
|
||||
</a>
|
||||
<div class="collapse" id="sidebarDashboards">
|
||||
<ul class="nav-second-level">
|
||||
<li>
|
||||
<a href="<?= base_url('/policy_tranction/inception/list') ?>">Policy</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/policy_tranction/endorsement/list') ?>">Endorsement</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/policy_tranction/report/list') ?>">BDS</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<!-- <li class="menu-title mt-2">Apps</li> -->
|
||||
</ul>
|
||||
</div>
|
||||
<!-- End Sidebar -->
|
||||
|
||||
@ -32,73 +32,55 @@
|
||||
}
|
||||
|
||||
|
||||
/* .auth-fluid {
|
||||
.auth-fluid {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
flex-direction: row;
|
||||
align-items: stretch;
|
||||
background: url("<?= base_url()."public"; ?>/assets/images/login_bg.png") center !important;
|
||||
background-size: cover;
|
||||
} */
|
||||
background: url("<?= base_url('public/assets/images/login_bg.jpg') ?>") center center !important;
|
||||
background-size: cover !important;
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
|
||||
</head>
|
||||
|
||||
<body class="loading auth-fluid-pages pb-0">
|
||||
|
||||
<div class="auth-fluid">
|
||||
<!-- Auth fluid right content -->
|
||||
<div class="auth-fluid-right bg-transparent">
|
||||
<div class="auth-user-testimonial">
|
||||
<h3 class="mb-3 text-white">Very elegant & impressive!</h3>
|
||||
<p class="lead font-weight-normal"><i class="mdi mdi-format-quote-open"></i> I've been using this theme
|
||||
for a while and I must say that whenever I am looking for a design - I refer to this theme for
|
||||
specifics & implementation. With wide arrays of components, designs, charts - I would highly
|
||||
recommend this theme for anyone using it for dashboard or project management usage.. <i
|
||||
class="mdi mdi-format-quote-close"></i>
|
||||
</p>
|
||||
<h5 class="text-white">
|
||||
- Admin User
|
||||
</h5>
|
||||
</div> <!-- end auth-user-testimonial-->
|
||||
<div class="row">
|
||||
<div class="col-lg-8 auth-fluid">
|
||||
<!-- Auth fluid right content -->
|
||||
<div class="auth-fluid-right bg-transparent">
|
||||
<img src="<?= base_url()."public"; ?>/assets/images/Nhance-Logo-Final.png" width="200">
|
||||
</div>
|
||||
<!-- end Auth fluid right content -->
|
||||
</div>
|
||||
<!-- end Auth fluid right content -->
|
||||
<div class="col-lg-4 align-items-center d-flex">
|
||||
|
||||
<!--Auth fluid left content -->
|
||||
<div class="auth-fluid-form-box">
|
||||
<div class="align-items-center d-flex h-100">
|
||||
<div class="card-body">
|
||||
<!--Auth fluid left content -->
|
||||
<div class="auth-fluid-form-box" style="margin-left: 10%;">
|
||||
<div class="h-100">
|
||||
<div class="card-body">
|
||||
<div class="form-group mb-0 text-center">
|
||||
|
||||
<!-- Logo -->
|
||||
<div class="auth-brand text-center">
|
||||
<div class="auth-logo">
|
||||
<a href="index.html" class="logo logo-dark text-center">
|
||||
<span class="logo-lg">
|
||||
</span>
|
||||
</a>
|
||||
<a href="<?= base_url('auth/google'); ?>"><img
|
||||
src="<?= base_url()."public"; ?>/assets/images/googleButton.svg" width="300"></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group mb-0 text-center">
|
||||
<?php if (session()->getFlashdata('error')) : ?>
|
||||
<span class="widget-simple text-center">
|
||||
<div class="media-body align-self-center font-24 avatar-title">
|
||||
<p style="color: #f1556c!important;" class="mt-0" style><?= session('error') ?></p>
|
||||
</div>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
|
||||
<a href="<?= base_url('auth/google'); ?>"><img
|
||||
src="<?= base_url()."public"; ?>/assets/images/googleButton.svg" width="300"></a>
|
||||
</div>
|
||||
|
||||
<?php if (session()->getFlashdata('error')) : ?>
|
||||
<span class="widget-simple text-center">
|
||||
<div class="media-body align-self-center font-24 avatar-title">
|
||||
<p style="color: #f1556c!important;" class="mt-0" style><?= session('error') ?></p>
|
||||
</div>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
|
||||
</div> <!-- end .card-body -->
|
||||
</div> <!-- end .align-items-center.d-flex.h-100-->
|
||||
</div> <!-- end .card-body -->
|
||||
</div> <!-- end .align-items-center.d-flex.h-100-->
|
||||
</div>
|
||||
<!-- end auth-fluid-form-box-->
|
||||
</div>
|
||||
<!-- end auth-fluid-form-box-->
|
||||
</div>
|
||||
<!-- end auth-fluid-->
|
||||
|
||||
|
||||
@ -3354,7 +3354,6 @@ function appendNewTab(tabNameData = null, data = null)
|
||||
</form>`;
|
||||
tabContent.appendChild(newTabPane);
|
||||
|
||||
|
||||
applyStyles(tabId);
|
||||
|
||||
var policy_grid_id = null;
|
||||
|
||||
1068
app/Views/policy_transaction_endorsement_form.php
Normal file
1068
app/Views/policy_transaction_endorsement_form.php
Normal file
File diff suppressed because it is too large
Load Diff
500
app/Views/policy_transaction_endorsement_list.php
Normal file
500
app/Views/policy_transaction_endorsement_list.php
Normal file
@ -0,0 +1,500 @@
|
||||
<style>
|
||||
.table th,
|
||||
.table td {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
table.dataTable tbody td {
|
||||
padding: 4px 4px !important;
|
||||
}
|
||||
/*
|
||||
table.dataTable thead th {
|
||||
padding: 4px 4px !important;
|
||||
} */
|
||||
|
||||
.col-12 {
|
||||
|
||||
max-width: 98% !important;
|
||||
}
|
||||
|
||||
.dataTables_filter{
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.readonly-select {
|
||||
pointer-events: none;
|
||||
background-color: #f0f0f0;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.column-header {
|
||||
margin-right: 10px; /* Adjust this value as needed */
|
||||
}
|
||||
|
||||
.form-section {
|
||||
border: 1px solid #ccc;
|
||||
padding: 15px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.row-box {
|
||||
border: 1px solid #ccc;
|
||||
padding: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="row" id="endorsement_list">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="row" style="margin-bottom:1rem;">
|
||||
<div class="col-6" style="align-self: center;">
|
||||
<h4 style="position: relative;">Endorsement List</h4>
|
||||
</div>
|
||||
<div class="col-2" id="add_div" style="text-align: right; position: relative;top: 56px; left: 314px;">
|
||||
<button type="button" id="change_status" class="btn btn-primary waves-effect waves-light" onclick="changeInvoiceStatus(this)">Invoice Status</button>
|
||||
</div>
|
||||
|
||||
<div class="col-1" id="status_change" style="text-align: right; position: relative;top: 56px; left: 291px;">
|
||||
<button type="button" id="btnAdd" class="btn btn-primary waves-effect waves-light" onclick="hide_list_show_add()">Add</button>
|
||||
</div>
|
||||
</div>
|
||||
<div style="overflow-x: auto;">
|
||||
<table class="table table-striped mb-0 nowrap" cellspacing="0" id="tickets-table">
|
||||
<thead class="bg-light">
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>Issuer</th>
|
||||
<th>Client</th>
|
||||
<th>Branch</th>
|
||||
<th>Policy</th>
|
||||
<th>Endorsement Type</th>
|
||||
<th>Endorsement No</th>
|
||||
<th>Data Recived Date</th>
|
||||
<th>No of Employees</th>
|
||||
<th>No of Dependence</th>
|
||||
<th>Closure Date</th>
|
||||
<th>Status</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach($endorsement_data_list as $row){ ?>
|
||||
<tr>
|
||||
<td><input type="checkbox" class="row-select" data-id="<?= $row['id']; ?>"></td>
|
||||
<td><?php $issuer[$row['issuer']] ?? ''; ?></td>
|
||||
<td><?php echo $row['client_short_name']; ?></td>
|
||||
<td><?php echo $row['client_branch_name']; ?></td>
|
||||
<td><?php echo $row['policy_type']; ?></td>
|
||||
<td><?php echo $row['action_type']; ?></td>
|
||||
<td><?php echo $row['endorsement_no']; ?></td>
|
||||
<td><?php echo date('d-m-Y', strtotime($row['data_received_date'])); ?></td>
|
||||
<td><?php echo $row['emp_count']; ?></td>
|
||||
<td><?php echo $row['dependent_count']; ?></td>
|
||||
<td><?php echo date('d-m-Y', strtotime($row['closure_date'])); ?></td>
|
||||
<td><?php echo $policy_status[$row['status']]; ?></td>
|
||||
|
||||
<td>
|
||||
<div class="btn-group dropdown">
|
||||
<a href="javascript: void(0);"class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<a class="dropdown-item btnEdit" data-id="<?= $row['id'];?>" onclick="getPolicyTransactionDataForEndorsementEdit(this)"> <i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- end col -->
|
||||
</div>
|
||||
<!-- end table row -->
|
||||
|
||||
<?php include('policy_transaction_endorsement_form.php'); ?>
|
||||
|
||||
<!-- Invoice status content modal-->
|
||||
<div class="modal fade" id="invoice_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="title">Update Invoice Status</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
|
||||
<div class="modal-body p-4">
|
||||
<div class="">
|
||||
|
||||
<form role="form" class="parsley-examples" method="post" id="invoiceForm" enctype="multipart/form-data">
|
||||
|
||||
<div class="form-group">
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
<label for="addon_policy"> Invoice Status <spanclass="text-danger">*</spanclass=></label>
|
||||
<select class="form-control" id="invoice_status_modal" name="invoice_status" required>
|
||||
<option value="" selected>Select Invoice Status</option>
|
||||
<?php
|
||||
if (isset($invoice_status) && count($invoice_status)) {
|
||||
foreach ($invoice_status as $key => $value) {
|
||||
echo "<option value=" . $key . ">" . $value . "</option>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-12" style="display: none;" id="invoice_no_div_modal">
|
||||
<label for="invoice_no">Invoice Number<span id="base_danger" class="text-danger"></span></label>
|
||||
<input type="text" class="form-control" id="invoice_no_modal" name="invoice_no" placeholder="Enter Invoice Number" required>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-group text-right m-b-0">
|
||||
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
|
||||
id="btnSubmit">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
var client_list = ''; // local variable for storing the client branch list
|
||||
var branch_list = ''; // local variable for storing the client branch list
|
||||
var policy_list = ''; // local variable for storing the client policy list
|
||||
var policyListByClient = ''; // local variable for storing the client policy list
|
||||
var branch_policy = '';
|
||||
var unit_list = '';
|
||||
|
||||
// select2 document ready
|
||||
$(document).ready(function(){
|
||||
|
||||
getClientAndBranchAndPolicy()
|
||||
|
||||
<?php if (session()->has('create_failed')) : ?>
|
||||
toastr.error('<?= session()->getFlashdata('create_failed') ?>', 'Failed');
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (session()->has('update_failed')) : ?>
|
||||
toastr.error('<?= session()->getFlashdata('update_failed') ?>', 'Failed');
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (session()->has('create_success')) : ?>
|
||||
toastr.success('<?= session()->getFlashdata('create_success') ?>', 'success');
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (session()->has('update_success')) : ?>
|
||||
toastr.success('<?= session()->getFlashdata('update_success') ?>', 'success');
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
$('#client_id').select2();
|
||||
$('#client_branch_id').select2();
|
||||
$('#client_policy_id').select2();
|
||||
|
||||
})
|
||||
|
||||
//DataTable document ready
|
||||
$(document).ready(function() {
|
||||
var ticketsTable = $('#tickets-table');
|
||||
|
||||
if (ticketsTable.length) {
|
||||
ticketsTable.DataTable({
|
||||
dom: "<'row'<'col-sm-6'f><'col-sm-3 text-right'B>>" + // Filter left, buttons right
|
||||
"<'row'<'col-sm-12'tr>>" +
|
||||
"<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
|
||||
buttons: [{
|
||||
extend: 'csv',
|
||||
text: 'CSV',
|
||||
title: 'Policy-Tranction-Endorsement-List',
|
||||
exportOptions: {
|
||||
columns: ':not(:last-child)'
|
||||
},
|
||||
}],
|
||||
language: {
|
||||
search: "_INPUT_",
|
||||
searchPlaceholder: "Search..."
|
||||
},
|
||||
paging: true, // Enable pagination
|
||||
pageLength: 25 // Set default number of rows per page (optional)
|
||||
});
|
||||
} else {
|
||||
console.error("Table not found.");
|
||||
}
|
||||
});
|
||||
|
||||
// Date document ready
|
||||
$(document).ready(function(){
|
||||
|
||||
var today = new Date();
|
||||
|
||||
var data_received_date = flatpickr("#data_received_date", {
|
||||
dateFormat: "d-m-Y",
|
||||
allowInput: false
|
||||
});
|
||||
|
||||
var closure_date = flatpickr("#closure_date", {
|
||||
dateFormat: "d-m-Y",
|
||||
allowInput: false
|
||||
});
|
||||
|
||||
var start_date = flatpickr("#policy_start_date", {
|
||||
dateFormat: "d-m-Y",
|
||||
allowInput: false
|
||||
});
|
||||
|
||||
var end_date = flatpickr("#policy_end_date", {
|
||||
dateFormat: "d-m-Y",
|
||||
allowInput: false
|
||||
});
|
||||
|
||||
var endorse_eff_date = flatpickr("#endorse_eff_date", {
|
||||
dateFormat: "d-m-Y",
|
||||
allowInput: false
|
||||
});
|
||||
|
||||
})
|
||||
|
||||
function hide_list_show_add()
|
||||
{
|
||||
removeAllColumnsExceptFirst('insurerTable');
|
||||
$('#endorsement_form_id')[0].reset();
|
||||
$('#client_id').val('').change();
|
||||
$('#client_policy_id').val('').change();
|
||||
$('#endorsement_form').show()
|
||||
$('#endorsement_list').hide()
|
||||
$('#invoice_no_div').hide()
|
||||
$('#invoice_no').attr('required', false)
|
||||
}
|
||||
|
||||
function show_list_hide_add()
|
||||
{
|
||||
$('#endorsement_form').hide()
|
||||
$('#endorsement_list').show()
|
||||
|
||||
}
|
||||
|
||||
function getClientAndBranchAndPolicy()
|
||||
{
|
||||
$.ajax({
|
||||
url: '<?= base_url("/util/getClientAndBranchAndPolicy") ?>',
|
||||
type: "GET",
|
||||
dataType: 'json',
|
||||
success: function(res) {
|
||||
|
||||
console.log('getClientAndBranchAndPolicy', res);
|
||||
|
||||
if(res.status == true){
|
||||
branch_list = res.branch_data;
|
||||
policy_list = res.policy_data;
|
||||
policyListByClient = res.policyListByClient;
|
||||
client_list = res.client_data;
|
||||
unit_list = res.unit_data;
|
||||
appendClients(res.client_data);
|
||||
}else{
|
||||
console.log('No data found');
|
||||
}
|
||||
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function appendClients(data)
|
||||
{
|
||||
$('#client_id').empty();
|
||||
|
||||
$('#client_id').append($('<option>', {
|
||||
value: '',
|
||||
text: 'Select Client'
|
||||
}));
|
||||
|
||||
$('#client_id').append($('<option>', {
|
||||
value: 'add_client',
|
||||
text: '+ Add Client'
|
||||
}));
|
||||
|
||||
$.each(data, function(index, item) {
|
||||
|
||||
if(item.client_policy_count > 0){
|
||||
|
||||
var option = $('<option>', {
|
||||
value: item.id,
|
||||
text: item.client_name
|
||||
});
|
||||
$('#client_id').append(option);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function appendBranch(data)
|
||||
{
|
||||
|
||||
$('#client_branch_id').empty();
|
||||
|
||||
$('#client_branch_id').append($('<option>', {
|
||||
value: '',
|
||||
text: 'Select Branch'
|
||||
}));
|
||||
|
||||
$.each(data, function(index, item) {
|
||||
|
||||
var option = $('<option>', {
|
||||
value: item.id,
|
||||
text: item.branch_name
|
||||
});
|
||||
$('#client_branch_id').append(option);
|
||||
});
|
||||
}
|
||||
|
||||
function appendPolicies(data)
|
||||
{
|
||||
console.log('appendPolicies', data);
|
||||
console.log('appendPolicies', $('#client_policy_id'));
|
||||
|
||||
$('#client_policy_id').empty();
|
||||
$('#client_policy_id').append($('<option>', {
|
||||
value: '',
|
||||
text: 'Select Policy',
|
||||
}));
|
||||
|
||||
$.each(data, function(index, item) {
|
||||
var option = $('<option>', {
|
||||
value: item.id,
|
||||
text: item.policy_type + '-' + item.policy_no,
|
||||
'data-sd' : item.policy_start_date,
|
||||
'data-ed' : item.policy_end_date,
|
||||
'data-insurer' : item.insurer_branch_id + '-' + item.insurer_id,
|
||||
'data-policy' : item.policy_no,
|
||||
'data-cd' : item.cd_ac_no,
|
||||
'data-ebp' : item.ebp,
|
||||
'data-etp' : item.etp,
|
||||
'data-iep' : item.iep,
|
||||
'data-itp' : item.itp,
|
||||
'data-tpa' : item.tpa_branch_id + '-' + item.tpa_id,
|
||||
});
|
||||
$('#client_policy_id').append(option);
|
||||
});
|
||||
}
|
||||
|
||||
function changeInvoiceStatus()
|
||||
{
|
||||
var ids = logSelectedIds();
|
||||
|
||||
console.log('changeInvoiceStatus Selected IDs:', ids);
|
||||
|
||||
if(ids.length > 0){
|
||||
|
||||
var myModal = new bootstrap.Modal(document.getElementById('invoice_modal'));
|
||||
myModal.show();
|
||||
|
||||
} else {
|
||||
toastr.warning('Please select the transaction', 'Warning')
|
||||
}
|
||||
}
|
||||
|
||||
function logSelectedIds()
|
||||
{
|
||||
var selectedIds = [];
|
||||
$('.row-select:checked').each(function() {
|
||||
selectedIds.push($(this).data('id'));
|
||||
});
|
||||
|
||||
console.log('Selected IDs:', selectedIds);
|
||||
|
||||
return selectedIds;
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------
|
||||
|
||||
$("#invoiceForm").submit(function(event) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
var isValid = $('#invoiceForm').parsley().validate();
|
||||
if (!isValid) {
|
||||
console.log('Form is Empty', 'Warning');
|
||||
return ;
|
||||
}
|
||||
|
||||
form_action = '<?= base_url("util/updateInvoiceStatus"); ?>';
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
var ids = logSelectedIds();
|
||||
console.log(ids);
|
||||
|
||||
var formData = new FormData($('#invoiceForm')[0]);
|
||||
formData.append('ids', JSON.stringify(ids));
|
||||
|
||||
$.ajax({
|
||||
data:formData,
|
||||
url: form_action,
|
||||
type: "POST",
|
||||
dataType: 'json',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(res) {
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
if(res.status == true){
|
||||
toastr.success(res.message, 'Success');
|
||||
}else{
|
||||
toastr.error(res.message, 'Error');
|
||||
}
|
||||
|
||||
window.location.reload();
|
||||
$('.close').click();
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#invoice_status').change(function(){
|
||||
|
||||
let value = $(this).val()
|
||||
|
||||
if(value == 'generated'){
|
||||
$('#invoice_no_div').show()
|
||||
$('#invoice_no').attr('required', true)
|
||||
}else{
|
||||
$('#invoice_no_div').hide()
|
||||
$('#invoice_no').attr('required', false)
|
||||
}
|
||||
})
|
||||
|
||||
$('#invoice_status_modal').change(function(){
|
||||
|
||||
let value = $(this).val()
|
||||
|
||||
if(value == 'generated'){
|
||||
$('#invoice_no_div_modal').show()
|
||||
$('#invoice_no_modal').attr('required', true)
|
||||
}else{
|
||||
$('#invoice_no_div_modal').hide()
|
||||
$('#invoice_no_modal').attr('required', false)
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
</script>
|
||||
2191
app/Views/policy_transaction_inception_form.php
Normal file
2191
app/Views/policy_transaction_inception_form.php
Normal file
File diff suppressed because it is too large
Load Diff
1267
app/Views/policy_transaction_inception_list.php
Normal file
1267
app/Views/policy_transaction_inception_list.php
Normal file
File diff suppressed because it is too large
Load Diff
44
app/Views/pt_form_file_upload_tab.php
Normal file
44
app/Views/pt_form_file_upload_tab.php
Normal file
@ -0,0 +1,44 @@
|
||||
<div class="row" id="pt_onboarding" style="position: relative; bottom: 25px; display:none;">
|
||||
<div class="col-xl-12">
|
||||
<div class="card-body">
|
||||
<ul class="nav nav-pills navtab-bg">
|
||||
<li class="nav-item">
|
||||
<a href="#form" data-toggle="tab" aria-expanded="false" class="nav-link px-3 py-2 active" id="general_tab">
|
||||
<span class="mr-1"><i class="mdi mdi-contacts"></i></span>
|
||||
<span class="d-none d-sm-inline-block">Policy</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="#fileupload" data-toggle="tab" aria-expanded="true" class="nav-link px-3 py-2" id="kyc_tab">
|
||||
<span class="mr-1"><i class="fa fa-file"></i></span>
|
||||
<span class="d-none d-sm-inline-block">File Upload</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<?php include('policy_transaction_inception_form.php'); ?>
|
||||
<?php include('drive_file_upload.php'); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#kyc_tab').on('click', function(e) {
|
||||
var ptId = $('#policy_tranction_primarykey').val();
|
||||
|
||||
if (!ptId) { // Check if ptId is empty or null
|
||||
e.preventDefault(); // Prevent the tab from opening
|
||||
$('#g_drive_file_upload_sbt_btn').hide()
|
||||
toastr.warning('Please create Policy before proceeding to File Upload.');
|
||||
}else{
|
||||
$('#g_drive_file_upload_sbt_btn').show()
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
174
app/Views/report_bds.php
Normal file
174
app/Views/report_bds.php
Normal file
@ -0,0 +1,174 @@
|
||||
<style>
|
||||
.table th,
|
||||
.table td {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
table.dataTable tbody td {
|
||||
padding: 4px 4px !important;
|
||||
}
|
||||
|
||||
.col-12 {
|
||||
|
||||
max-width: 98% !important;
|
||||
}
|
||||
|
||||
.dataTables_filter {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<div class="col-12" id="second_page">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="row" style="padding-bottom: 10px;">
|
||||
<div class="col-6" style="align-self: center;">
|
||||
<h4 style="position: relative;">BDS Report</h4>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="table-responsive" style="overflow-x: auto;">
|
||||
<table id="scroll-horizontal-datatable" class="table w-100 nowrap">
|
||||
<thead class="bg-light">
|
||||
<tr>
|
||||
<th>S. No</th>
|
||||
<th>User Name</th>
|
||||
<th>Month</th>
|
||||
<th>Business Type</th>
|
||||
<th>Date</th>
|
||||
<th>Sales Generated By (Name)</th>
|
||||
<th>Branch (JIBS)</th>
|
||||
<th>Serviced By (Name)</th>
|
||||
<th>Client Name</th>
|
||||
<th>Client Address</th>
|
||||
<th>Client Type</th>
|
||||
<th>Payment From</th>
|
||||
<th>Reference</th>
|
||||
<th>Remarks</th>
|
||||
<th>Policy/Endorsement</th>
|
||||
<th>Policy No</th>
|
||||
<th>Endorsement No</th>
|
||||
<th>Insurer Name</th>
|
||||
<th>Insurer Branch</th>
|
||||
<th>TPA</th>
|
||||
<th>Days Until Expiry</th>
|
||||
<th>Endorsement Effective Date</th>
|
||||
<th>Policy Effective Date</th>
|
||||
<th>Policy Expiry Date</th>
|
||||
<th>Policy Type</th>
|
||||
<th>BAP Group</th>
|
||||
<th>Vehicle Number</th>
|
||||
<th>Base Premium</th>
|
||||
<th>Terrorism/TP</th>
|
||||
<th>Premium (without GST)</th>
|
||||
<th>GST @ 18%</th>
|
||||
<th>Total Premium</th>
|
||||
<th>Base Revenue %</th>
|
||||
<th>TP / Terrorism Revenue %</th>
|
||||
<th>Total IRDA Revenue INR</th>
|
||||
<th>GST on Revenue</th>
|
||||
<th>Total Amount Receivable</th>
|
||||
<th>Rewards %</th>
|
||||
<th>Rewards</th>
|
||||
<th>Total Brokerage</th>
|
||||
<th>Payment Ref</th>
|
||||
<th>Invoice Number</th>
|
||||
<th>Invoice Date</th>
|
||||
<th>Invoice Amount</th>
|
||||
<th>Payment Status</th>
|
||||
<th>UTR</th>
|
||||
<th>Payment Date</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (isset($report_list)) { ?>
|
||||
<?php foreach($report_list as $index => $row){ ?>
|
||||
<tr>
|
||||
<td><?= $index + 1 ?></td>
|
||||
<td><?php echo $row['user_name']; ?></td>
|
||||
<td><?php echo $row['policy_issue_month']; ?></td>
|
||||
<td><?php echo $row['revenue_type']; ?></td>
|
||||
<td><?php echo $row['policy_issue_date']; ?></td>
|
||||
<td><?php echo $row['salse_person_name']; ?></td> <!-- Sales Generated By (Name) -->
|
||||
<td><?php echo 'Chennai'; ?></td>
|
||||
<td><?php echo $row['service_person_name']; ?></td>
|
||||
<td><?php echo $row['client_name']; ?></td>
|
||||
<td><?php echo $row['client_address']; ?></td>
|
||||
<td><?php echo $row['client_type']; ?></td>
|
||||
<td></td> <!-- Payment From -->
|
||||
<td><?php echo $row['ref']; ?></td>
|
||||
<td><?php echo $row['remarks']; ?></td>
|
||||
<td><?php echo $row['action_type']; ?></td>
|
||||
<td><?php echo $row['policy_no']; ?></td>
|
||||
<td><?php echo $row['endorsement_no']; ?></td>
|
||||
<td><?php echo $row['insurer_name']; ?> </td>
|
||||
<td><?php echo $row['insurer_branch_name']; ?></td>
|
||||
<td><?php echo $row['tpa_name']; ?></td>
|
||||
<td><?php echo $row['days']; ?></td>
|
||||
<td><?php echo $row['endorse_eff_date']; ?></td>
|
||||
<td><?php echo date('d-m-Y', strtotime($row['policy_start_date'])); ?></td>
|
||||
<td><?php echo date('d-m-Y', strtotime($row['policy_end_date'])); ?></td>
|
||||
<td><?php echo $row['policy_type']; ?></td>
|
||||
<td><?php echo $row['bap']; ?></td>
|
||||
<td><?php echo $row['vehicle_no'] ?? 'N.A'; ?></td>
|
||||
<td><?php echo $row['bp_amt']; ?></td>
|
||||
<td><?php echo $row['tp_or_ter']; ?></td>
|
||||
<td><?php echo $row['premium_wo_gst']; ?></td>
|
||||
<td><?php echo $row['gst_amount']; ?></td>
|
||||
<td><?php echo $row['total_premium']; ?></td>
|
||||
<td><?php echo $row['agreed_bp_per']; ?></td>
|
||||
<td><?php echo $row['agreed_tp_or_ter_per']; ?></td>
|
||||
<td><?php echo $row['total_irda']; ?></td>
|
||||
<td><?php echo $row['gst_on_revenue']; ?></td>
|
||||
<td><?php echo $row['total_amt_received']; ?></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- end col -->
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
// Datatable document ready
|
||||
$(document).ready(function() {
|
||||
|
||||
var ticketsTable = $('#scroll-horizontal-datatable');
|
||||
|
||||
if (ticketsTable.length) {
|
||||
ticketsTable.DataTable({
|
||||
dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // Filter left, buttons right
|
||||
"<'row'<'col-sm-12'tr>>" +
|
||||
"<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
|
||||
buttons: [{
|
||||
extend: 'csv',
|
||||
text: 'CSV',
|
||||
title: 'Policy-Tranction-BDS-List',
|
||||
}, ],
|
||||
language: {
|
||||
search: "_INPUT_",
|
||||
searchPlaceholder: "Search..."
|
||||
},
|
||||
paging: true, // Enable pagination
|
||||
pageLength: 25 // Set default number of rows per page (optional)
|
||||
});
|
||||
} else {
|
||||
console.error("Table not found.");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
282
app/Views/report_bds_filter.php
Normal file
282
app/Views/report_bds_filter.php
Normal file
@ -0,0 +1,282 @@
|
||||
<style>
|
||||
.col-12 {
|
||||
|
||||
max-width: 98% !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12" style="margin-top: -12px;">
|
||||
<div id="accordion" class="mb-3">
|
||||
<div class="card mb-1">
|
||||
<h5 class="m-1">
|
||||
<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>
|
||||
</h5>
|
||||
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
|
||||
<div class="card-body">
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
|
||||
<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="0">Select Client</option>
|
||||
<?php
|
||||
if (isset($clients) && count($clients)) {
|
||||
foreach ($clients as $key => $value) {
|
||||
echo "<option value='" . $value['id'] . "'>" . $value['client_name'] . "</option>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="addon_policy"> Insurer <span id="base_danger" class="text-danger"></span></label>
|
||||
<select class="form-control" id="insurer_id" name="insurer_id" >
|
||||
<option value="0" selected>Select Insurer</option>
|
||||
<?php foreach ($insurer as $value) { ?>
|
||||
<option value="<?= $value['id']?>"><?= $value['name']?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="email"> Policy Type <span class="text-danger"></span></label>
|
||||
<select class="form-control" id="policy_type_id" name="policy_type_id" >
|
||||
<option value="0">Select Policy Type</option>
|
||||
<?php
|
||||
if (isset($policy_types) && count($policy_types)) {
|
||||
foreach ($policy_types as $key => $value) {
|
||||
echo "<option value='" . $value['id'] . "'>" . $value['policy_type'] . "</option>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="client_branch">Issuer<span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="issuer" name="issuer" required>
|
||||
<option value="0">Select Issure</option>
|
||||
<?php
|
||||
if (isset($issuer) && count($issuer)) {
|
||||
foreach ($issuer as $key => $value) {
|
||||
echo "<option value=" . $key . ">" . $value . "</option>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label>Date Type<span class="text-danger"></span></label>
|
||||
<select class="form-control" id="date_type" name="date_type" onchange="hideDateField()">
|
||||
<option value="0">Select Date Type</option>
|
||||
<?php
|
||||
if (isset($date_type) && count($date_type)) {
|
||||
foreach ($date_type as $key => $value) {
|
||||
echo "<option value='" . $key . "'>" . $value . "</option>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3" style="display: none;" 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="fa fa-calendar"></i>
|
||||
<span></span> <i class="fa fa-caret-down"></i>
|
||||
</div>
|
||||
<input type="hidden" id="startDate">
|
||||
<input type="hidden" id="endDate">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-group text-right m-b-0">
|
||||
<button type="button" class="btn btn-secondary" id="clear-filters">Clear</button>
|
||||
<a href="<?= base_url("/policy_tranction/report/list"); ?>"
|
||||
class="btn btn-primary waves-effect waves-light" id="get-emp-list"
|
||||
onclick="fetchEmpolyeeList(event);">Submit</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- end page title -->
|
||||
<div class="row" id="file_list">
|
||||
<?php include('report_bds.php'); ?>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
getURLParams()
|
||||
$('#client_id').select2();
|
||||
$('#insurer_id').select2();
|
||||
$('#policy_type_id').select2();
|
||||
})
|
||||
|
||||
function fetchEmpolyeeList(event)
|
||||
{
|
||||
event.preventDefault(); // Prevent default action
|
||||
|
||||
var start_date = $('#startDate').val();
|
||||
var end_date = $('#endDate').val();
|
||||
var client_id = $('#client_id').val();
|
||||
var insurer_id = $('#insurer_id').val();
|
||||
var policy_type_id = $('#policy_type_id').val();
|
||||
var date_type = $('#date_type').val();
|
||||
var issuer = $('#issuer').val();
|
||||
|
||||
console.log(start_date + '-' + end_date);
|
||||
|
||||
var queryParams = {
|
||||
start_date: start_date,
|
||||
end_date: end_date,
|
||||
client_id: client_id,
|
||||
insurer_id: insurer_id,
|
||||
policy_type_id: policy_type_id,
|
||||
date_type: date_type,
|
||||
issuer: issuer,
|
||||
};
|
||||
|
||||
const queryString = objectToQueryString(queryParams);
|
||||
const apiURL = $('#get-emp-list').attr('href') + "?" + queryString;
|
||||
console.log(apiURL);
|
||||
window.location.href = apiURL;
|
||||
}
|
||||
|
||||
function objectToQueryString(obj)
|
||||
{
|
||||
return Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join('&');
|
||||
}
|
||||
|
||||
function getURLParams()
|
||||
{
|
||||
const url = new URL(window.location.href);
|
||||
const params = new URLSearchParams(url.search);
|
||||
|
||||
const startDate = params.get('start_date') || 0; // Default to 0 if not found
|
||||
const endDate = params.get('end_date') || 0; // Default to 0 if not found
|
||||
const client_id = params.get('client_id') || 0; // Default to 0 if not found
|
||||
const insurer_id = params.get('insurer_id') || 0; // Default to 0 if not found
|
||||
const policy_type_id = params.get('policy_type_id') || 0; // Default to 0 if not found
|
||||
const date_type = params.get('date_type') || 0; // Default to 0 if not found
|
||||
const issuer = params.get('issuer') || 0; // Default to 0 if not found
|
||||
|
||||
hideDateField(date_type)
|
||||
|
||||
console.log('startDate', startDate)
|
||||
console.log('endDate', endDate)
|
||||
console.log('client_id', client_id)
|
||||
console.log('insurer_id', insurer_id)
|
||||
console.log('policy_type_id', policy_type_id)
|
||||
console.log('date_type', date_type)
|
||||
console.log('issuer', issuer)
|
||||
|
||||
// Log the values or use them as needed
|
||||
console.log('Start Date:', startDate);
|
||||
console.log('End Date:', endDate);
|
||||
|
||||
if (startDate != 0 && endDate != 0) {
|
||||
setTimeout(function(){
|
||||
$('#start_date').val(startDate)
|
||||
$('#end_date').val(endDate)
|
||||
$('#client_id').val(client_id).change()
|
||||
$('#insurer_id').val(insurer_id).change()
|
||||
$('#policy_type_id').val(policy_type_id).change()
|
||||
$('#date_type').val(date_type)
|
||||
$('#issuer').val(issuer)
|
||||
},1000)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$(function() {
|
||||
|
||||
const url = new URL(window.location.href);
|
||||
const params = new URLSearchParams(url.search);
|
||||
|
||||
// Get start and end dates from URL parameters, or use default values
|
||||
const startDateParam = params.get('start_date') || moment().subtract(29, 'days').format('DD-MM-YYYY');
|
||||
const endDateParam = params.get('end_date') || moment().format('DD-MM-YYYY');
|
||||
|
||||
// Parse the dates to moment objects
|
||||
var start = moment(startDateParam, 'DD-MM-YYYY');
|
||||
var end = moment(endDateParam, 'DD-MM-YYYY');
|
||||
|
||||
// var start = moment().subtract(29, 'days');
|
||||
// var end = moment();
|
||||
|
||||
function cb(start, end) {
|
||||
$('#reportrange span').html(start.format('D-MM-YYYY') + ' - ' + end.format('D-MM-YYYY'));
|
||||
$('#startDate').val(start.format('DD-MM-YYYY'));
|
||||
$('#endDate').val(end.format('DD-MM-YYYY'));
|
||||
}
|
||||
|
||||
$('#reportrange').daterangepicker({
|
||||
startDate: start,
|
||||
endDate: end,
|
||||
ranges: {
|
||||
'Today': [moment(), moment()],
|
||||
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
|
||||
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
|
||||
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
|
||||
'This Month': [moment().startOf('month'), moment().endOf('month')],
|
||||
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
|
||||
}
|
||||
}, cb);
|
||||
|
||||
cb(start, end);
|
||||
|
||||
$('#clear-filters').on('click', function() {
|
||||
// Reset all select dropdowns to the first option
|
||||
$('#client_id').val('0').change();
|
||||
$('#insurer_id').val('0').change();
|
||||
$('#policy_type_id').val('0').change();
|
||||
$('#date_type').val('0');
|
||||
$('#issuer').val('0');
|
||||
$('#date_div').hide()
|
||||
|
||||
// Reset the date range picker to default
|
||||
$('#reportrange').data('daterangepicker').setStartDate(moment().subtract(29, 'days'));
|
||||
$('#reportrange').data('daterangepicker').setEndDate(moment());
|
||||
cb(start, end); // Update the displayed date range
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function hideDateField(input = null)
|
||||
{
|
||||
let val = $('#date_type').val();
|
||||
|
||||
if(input){
|
||||
val = input;
|
||||
}
|
||||
|
||||
if(val != 0){
|
||||
$('#date_div').show()
|
||||
}else{
|
||||
$('#date_div').hide()
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
400
app/Views/vehicle_details.php
Normal file
400
app/Views/vehicle_details.php
Normal file
@ -0,0 +1,400 @@
|
||||
|
||||
|
||||
<div class="tab-pane fade active show" id="vehicle-tab">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card-body">
|
||||
<form role="form" class="parsley-examples" method="post" id="general_form"
|
||||
enctype="multipart/form-data">
|
||||
|
||||
<input type="hidden" name="client_id" id="client_id" />
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
|
||||
<div class="form-row">
|
||||
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label for="cost_center">Type<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="type"
|
||||
value="<?= isset($client['phone']) ? $client['phone'] : '' ?>" name="type" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label for="cost_center">Description<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="description" placeholder="Enter Description"
|
||||
value="<?= isset($client['email']) ? $client['email'] : '' ?>" name="description" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label for="owner">Owner Name <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="owner" placeholder="Enter Owner Name"
|
||||
value="<?= isset($client['reference']) ? $client['reference'] : '' ?>"
|
||||
name="owner" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label for="old_onwer">Old Owner Name (if any) <span class="text-danger"></span></label>
|
||||
<input type="text" class="form-control" id="old_onwer" placeholder="Enter Old Owner Name"
|
||||
value="<?= isset($client['reference']) ? $client['reference'] : '' ?>"
|
||||
name="old_onwer" >
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label for="rc">RC Book <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="rc" placeholder="Enter RC Book No"
|
||||
value="<?= isset($client['reference']) ? $client['reference'] : '' ?>"
|
||||
name="rc" >
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-group text-right m-b-0">
|
||||
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
|
||||
id="btnSubmit">Submit</button>
|
||||
<button type="button" class="btn btn-secondary waves-effect btnBack"
|
||||
id="btnBack">Cancel</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div> <!-- end col-->
|
||||
</div>
|
||||
</div>
|
||||
<!-- end -->
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
var PrimaryKey = $('#general_PrimaryKey').val();
|
||||
var form_action = '';
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#client_logo').change(function() {
|
||||
validateFile(this);
|
||||
});
|
||||
|
||||
var la_date = flatpickr("#dob", {
|
||||
dateFormat: "d-m-Y",
|
||||
allowInput: false
|
||||
});
|
||||
|
||||
var client_type = '<?= $client['client_type'] ?>';
|
||||
|
||||
if(client_type){
|
||||
|
||||
if(client_type == 2){
|
||||
$('#client_name_txt').text('Proposer/Policy holder Name');
|
||||
$('#short_name_txt').text('Policyholder Short Name');
|
||||
$('#documents_tab_txt').text('Other Docs');
|
||||
$('#retaildiv').show();
|
||||
$('#dob').prop('required', true);
|
||||
$('#gst').prop('required', true);
|
||||
$('#aadhar').prop('required', true);
|
||||
$('#phone').prop('required', true);
|
||||
$('#email').prop('required', true);
|
||||
$('#reference').prop('required', true);
|
||||
$('#address1').prop('required', true);
|
||||
$('#branch_tab_li').hide();
|
||||
$('#notifi_tab_li').hide();
|
||||
$('#veh_tab_li').show();
|
||||
|
||||
}else{
|
||||
$('#client_name_txt').text('Client Name');
|
||||
$('#short_name_txt').text('Client Short Name');
|
||||
$('#documents_tab_txt').text('KYC Docs');
|
||||
$('#retaildiv').hide()
|
||||
$('#dob').prop('required', false);
|
||||
$('#gst').prop('required', false);
|
||||
$('#aadhar').prop('required', false);
|
||||
$('#phone').prop('required', false);
|
||||
$('#email').prop('required', false);
|
||||
$('#reference').prop('required', false);
|
||||
$('#address1').prop('required', false);
|
||||
$('#branch_tab_li').show();
|
||||
$('#notifi_tab_li').show();
|
||||
$('#veh_tab_li').hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$("#general_form").submit(function(event) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
var $submitButton = $('#general_form').find('button[type="submit"]');
|
||||
$submitButton.prop('disabled', true); // Disable the submit button
|
||||
|
||||
var isValid = $('#general_form').parsley().validate();
|
||||
if (!isValid) {
|
||||
$submitButton.prop('disabled', false);
|
||||
console.log('Form is Empty', 'Warning');
|
||||
return;
|
||||
}
|
||||
|
||||
if (PrimaryKey === '') {
|
||||
form_action = '<?= base_url("client/general/create"); ?>';
|
||||
} else {
|
||||
form_action = '<?= base_url("client/general/edit"); ?>';
|
||||
}
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
var formData = new FormData($('#general_form')[0]);
|
||||
var OptionsHTML1 = ''
|
||||
|
||||
$.ajax({
|
||||
data: formData,
|
||||
url: form_action,
|
||||
type: "POST",
|
||||
dataType: 'json',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(res) {
|
||||
|
||||
console.log(res);
|
||||
console.log($('#general_PrimaryKey').val());
|
||||
|
||||
if ($('#general_PrimaryKey').val() == "") {
|
||||
|
||||
window.location.href = '<?= base_url("client/list/"); ?>' + res.data.id;
|
||||
}
|
||||
|
||||
|
||||
if (res) {
|
||||
setTimeout(function() {
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
$('#kyc_tab').click();
|
||||
|
||||
$('#btnBranchAdd').show();
|
||||
$('#BtnAdd').show();
|
||||
$('#relation_form').show();
|
||||
$('#btnBranchAdd').show();
|
||||
|
||||
var message = (PrimaryKey === '') ?
|
||||
'Client General Info Created successfully' :
|
||||
'Client General Info Updated successfully';
|
||||
toastr.success(message, 'Success');
|
||||
$submitButton.prop('disabled', false);
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
var idToUse = res.data.id ? res.data.id : res.data.PrimaryKey;
|
||||
|
||||
$('#client_id').val(idToUse);
|
||||
$('#general_PrimaryKey').val(idToUse);
|
||||
$('#client_id_relation').val(idToUse);
|
||||
$('#relation_PrimaryKey').val(idToUse);
|
||||
$('#client_id_branch').val(idToUse);
|
||||
$('#client_id_for_client_branch').val(idToUse);
|
||||
$('#client_id_policy').val(idToUse);
|
||||
$('#policy_PrimaryKey').val(idToUse);
|
||||
$('#client_id_kyc').val(idToUse);
|
||||
$('#kyc_PrimaryKey').val(idToUse);
|
||||
$('#Client_id').val(idToUse);
|
||||
|
||||
$('#entity_type').val(res.data.entity_type_id);
|
||||
|
||||
|
||||
var client_id_for_file = res.data.id;
|
||||
|
||||
if (PrimaryKey === '') {
|
||||
$.ajax({
|
||||
url: '<?= base_url("client/kyc/list/"); ?>' + res.data
|
||||
.entity_type_id,
|
||||
type: "GET",
|
||||
dataType: 'json',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(res) {
|
||||
|
||||
console.log('kyc docs', res);
|
||||
var tbody = $('#tbody');
|
||||
tbody.empty();
|
||||
|
||||
$.each(res.data, function(index, item) {
|
||||
var row = `<tr>
|
||||
<td> ${item.file_name}</td>
|
||||
<td id="form_${item.id}" style=""><form class="ajax" ><input class="file-input__input" type="file" name="file_name">
|
||||
<input type="hidden" class="form-control" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
|
||||
<input type="hidden" class="form-control" value="${item.id}" name="kyc_doc_type_id" />
|
||||
<input type="hidden" name="client_id" id="id_for_kyc_file" value="${client_id_for_file}"/>
|
||||
<button class="btn btn-sm btn-primary submit" style="position: relative;right: 80px;">Submit</button></form></td>
|
||||
<td id="name_${item.id}" style="display:none;"></td>
|
||||
<td><i data-id="${item.id}" class="mdi mdi-delete btnKycDelete" style="font-size:18px;"></i></td>
|
||||
</tr>`;
|
||||
tbody.append(row);
|
||||
});
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
setTimeout(function() {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
$submitButton.prop('disabled', false);
|
||||
if (xhr.status === 404) {
|
||||
toastr.warning('Resource not found', 'Warning');
|
||||
} else if (xhr.status === 500) {
|
||||
toastr.warning('Internal server error', 'Warning');
|
||||
} else {
|
||||
toastr.warning('Unknown error occurred', 'Warning');
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function onlyNumbers(event) {
|
||||
var charcode;
|
||||
charcode = event.which || event.keyCode;
|
||||
if (charcode >= 48 && charcode <= 57) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function PreviewImage() {
|
||||
console.log('function called');
|
||||
var fileInput = document.getElementById("client_logo");
|
||||
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 =
|
||||
"http://ssl.gstatic.com/accounts/ui/avatar_2x.png"; // Remove the preview image
|
||||
} else {
|
||||
var reader = new FileReader();
|
||||
reader.readAsDataURL(file);
|
||||
|
||||
reader.onload = function(event) {
|
||||
document.getElementById("uploadPreview").src = event.target.result;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function validateFile(input) {
|
||||
|
||||
const file = input.files[0];
|
||||
const allowedExtensions = ["jpg", "jpeg", "png"];
|
||||
const fileExtension = file.name.split(".").pop().toLowerCase();
|
||||
|
||||
// Check if the file extension is allowed
|
||||
if (!allowedExtensions.includes(fileExtension)) {
|
||||
toastr.warning('Only JPG, JPEG, PNG files are allowed.', 'Invalid file type.');
|
||||
$("#uploadPreview").attr("src", "http://ssl.gstatic.com/accounts/ui/avatar_2x.png");
|
||||
input.value = "";
|
||||
}
|
||||
|
||||
|
||||
// Check file size
|
||||
const fileSize = file.size / 1024; // in KB
|
||||
if (fileSize > 200) {
|
||||
toastr.warning('Maximum file size allowed is 200KB.', 'File size exceeds limit.');
|
||||
$("#uploadPreview").attr("src", "http://ssl.gstatic.com/accounts/ui/avatar_2x.png");
|
||||
input.value = "";
|
||||
}
|
||||
|
||||
// Check image dimensions
|
||||
const img = new Image();
|
||||
img.onload = function() {
|
||||
if (this.width !== 100 || this.height !== 100) {
|
||||
toastr.warning('Image dimensions should be 100x100 pixels.', 'Invalid image dimensions.');
|
||||
$("#uploadPreview").attr("src", "http://ssl.gstatic.com/accounts/ui/avatar_2x.png");
|
||||
}
|
||||
// If both size and dimensions are valid, you can proceed with your logic here
|
||||
// For example, you can display the image
|
||||
const reader = new FileReader();
|
||||
reader.onload = function(e) {
|
||||
document.getElementById("uploadPreview").src = e.target.result;
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
};
|
||||
img.src = URL.createObjectURL(file);
|
||||
}
|
||||
|
||||
$('#client_type').change(function() {
|
||||
var val = $(this).val();
|
||||
if(val == 2){
|
||||
$('#client_name_txt').text('Proposer/Policy holder Name');
|
||||
$('#short_name_txt').text('Policyholder Short Name');
|
||||
$('#documents_tab_txt').text('Other Docs');
|
||||
$('#retaildiv').show();
|
||||
$('#dob').prop('required', true);
|
||||
$('#gst').prop('required', true);
|
||||
$('#aadhar').prop('required', true);
|
||||
$('#phone').prop('required', true);
|
||||
$('#email').prop('required', true);
|
||||
$('#reference').prop('required', true);
|
||||
$('#address1').prop('required', true);
|
||||
$('#branch_tab_li').hide();
|
||||
$('#notifi_tab_li').hide();
|
||||
$('#veh_tab_li').show();
|
||||
}else{
|
||||
$('#client_name_txt').text('Client Name');
|
||||
$('#short_name_txt').text('Client Short Name');
|
||||
$('#documents_tab_txt').text('KYC Docs');
|
||||
$('#retaildiv').hide()
|
||||
$('#dob').prop('required', false);
|
||||
$('#gst').prop('required', false);
|
||||
$('#aadhar').prop('required', false);
|
||||
$('#phone').prop('required', false);
|
||||
$('#email').prop('required', false);
|
||||
$('#reference').prop('required', false);
|
||||
$('#address1').prop('required', false);
|
||||
$('#branch_tab_li').show();
|
||||
$('#notifi_tab_li').show();
|
||||
$('#veh_tab_li').hide();
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
$('#cost_center').change(function() {
|
||||
|
||||
var cost_center = $(this).val();
|
||||
console.log(cost_center + '-' + cost_center.length);
|
||||
cost_center = cost_center.trim();
|
||||
console.log(cost_center + '-' + cost_center.length);
|
||||
|
||||
|
||||
$.ajax({
|
||||
url: '<?php echo base_url('util/check_cost_center/');?>' + cost_center,
|
||||
type: "GET",
|
||||
dataType: 'json',
|
||||
success: function(res) {
|
||||
|
||||
console.log(res)
|
||||
if (res.status == true) {
|
||||
toastr.warning(res.message, 'warning');
|
||||
$('#cost_center').val('');
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
}
|
||||
});
|
||||
|
||||
})
|
||||
</script>
|
||||
BIN
public/assets/images/login_bg.jpg
Normal file
BIN
public/assets/images/login_bg.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 219 KiB |
Loading…
Reference in New Issue
Block a user