MERGE_TEST_BDS&MINOR

This commit is contained in:
Ubuntu 2025-11-26 18:24:10 +05:30
commit 199b3e830e
112 changed files with 14105 additions and 2556 deletions

View File

@ -13,6 +13,8 @@ use App\Filters\AuthMVC;
use App\Filters\HttpRequestLog;
use App\Filters\CloseDbConnection;
use App\Filters\AuthClientApi;
use App\Filters\CommissionApiFilter;
use App\Filters\Cors;
use App\Filters\AuthJWT;
@ -36,7 +38,9 @@ class Filters extends BaseConfig
'HttpRequestLog' => HttpRequestLog::class,
'authJWT' => AuthJWT::class,
'AuthClientApi' => AuthClientApi::class,
'CloseDbConnection' => CloseDbConnection::class
'CloseDbConnection' => CloseDbConnection::class,
'CommissionApiFilter' => CommissionApiFilter::class,
'Cors' => Cors::class
];
/**
@ -49,11 +53,13 @@ class Filters extends BaseConfig
public array $globals = [
'before' => [
'HttpRequestLog' => ['except' => 'cli/*'],
'Cors',
// 'csrf',
// 'invalidchars',
],
'after' => [
'CloseDbConnection'
'CloseDbConnection',
'Cors',
// 'secureheaders',
],
];

View File

@ -3,6 +3,13 @@
use CodeIgniter\Router\RouteCollection;
// Allow OPTIONS for all routes
$routes->options('(:any)', function() {
// This will never be called because the CORS filter returns early
// But having this route ensures OPTIONS isn't rejected as 404
});
/**
* @var RouteCollection $routes
*/
@ -12,6 +19,8 @@ $routes->get('/chatbottest', 'ChatbotControllerNew::chatbotest');
$routes->get('/chatbot', 'ChatbotControllerNew::chatbot');
$routes->get('/swagger', 'SwaggerController::index', ['filter' => 'authMVC']);
$routes->get('/fedeploy', 'DeployController::fedeploy_view', ['filter' => 'authMVC']);
$routes->post('/fedeploy', 'DeployController::fedeploy', ['filter' => 'authMVC']);
// Reminder Mail Notification
@ -34,6 +43,8 @@ $routes->get("updateRenewalData", "ClientController::updateRenewalData");
$routes->get("updateRenewalDataNotExistingClient", "ClientController::updateRenewalDataNotExistingClient");
$routes->get("updateRenewalInsurerData", "ClientController::updateRenewalInsurerData");
$routes->get("sendMutipleToEmails", "MasterController::sendMutipleToEmails");
$routes->post("getCommission", "InsuranceCommissionController::initiateCommissionCalc",['filter' => 'CommissionApiFilter']);
$routes->get("importRules", "RuleImportController::upload");
// $routes->post("iAgreeForAddOn", "EmployeeRestController::iAgreeForAddOn");
// $routes->get("sendCroneRemainderMail", "DashboardController::sendCroneRemainderMail");
// $routes->post("employeeUpload", "EmployeeRestController::employeeUpload");
@ -549,7 +560,7 @@ $routes->post("employeeRest/getPostEmployeeDataForAuth", "RestAuthenticationCont
$routes->get("employeeRest/getClientDetails", "EmployeeRestController::getClientDetails");
$routes->get("employeeRest/getAdvertisementImage", "EmployeeRestController::getAdvertisementImage");
$routes->get("getSSORedirectUrl", "ApiServiceController::getSSORedirectUrl");
$routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
@ -736,7 +747,6 @@ $routes->get('testTracelog','TestBusinessController::a');
$routes->get("claimView", "EmployeeRestController::claimView");
// General Tickets
$routes->post("ticketSave", "ThzController::ticketSave");
$routes->get("ticketList", "ThzController::ticketList");
$routes->post("ticketConversationSave", "ThzController::ticketConversationSave");
@ -766,3 +776,33 @@ $routes->group('test', function($routes) {
});
$routes->cli('cli/testcli', 'TestingController::testcli');
//PARTNER PAYOUT
$routes->group('payout', function($routes) {
$routes->match (['get','post'],'list',"PayoutController::payoutList");
$routes->post('fetchUtrDetails',"PayoutController::fetchUtrDetails");
$routes->post('saveUtrDetails',"PayoutController::saveUtrDetails");
$routes->post('removeUtrDetails',"PayoutController::removeUtrDetails");
// invoice policy mapping
$routes->get('invoices', 'PayoutController::invoices');
$routes->post('invoices/save', 'PayoutController::saveInvoice');
$routes->get('invoices/history', 'PayoutController::auditHistory');
$routes->get('invoices/preview', 'PayoutController::preview');
$routes->get('invoices/downloadPdf/(:any)', 'PayoutController::downloadPdf/$1');
$routes->get('invoice/generate-number/(:num)', 'PayoutController::generateInvoiceNumberAjax/$1');
});
//PARTNER COMMISSION
$routes->group('commission', function($routes) {
$routes->match (['get','post'],'list',"RuleImportController::commissionFileUploadList");
$routes->post('upload',"RuleImportController::upload");
$routes->get('sample_file',"RuleImportController::downloadSampleCommissionFileUploadExcel");
$routes->get('downloadErrorFile',"RuleImportController::downloadErrorFile");
$routes->get("deleteCommissionData/(:any)", "RuleImportController::deleteCommissionData/$1");
$routes->get('checkSameEntry',"RuleImportController::checkSameEntry");
$routes->get('rules/list/(:any)',"RuleImportController::ruleList/$1");
$routes->post('rules/save/',"RuleImportController::saveRule");
$routes->post('rules/remove/',"RuleImportController::removeRule");
$routes->get('checkRuleUsage',"RuleImportController::checkRuleUsage");
});

View File

@ -7,6 +7,7 @@ use App\Libraries\Slug;
use App\Libraries\MyLogger;
use App\Libraries\GmailAPI;
use App\Libraries\MyGoogleDrive;
use App\Libraries\RuleImportService;
use App\Libraries\DataServiceSqlite;
use App\Controllers\Home;
@ -80,5 +81,14 @@ class Services extends BaseService
return new MyGoogleDrive();
}
public static function ruleImportService($getShared = true)
{
if ($getShared) {
return static::getSharedInstance('ruleImportService');
}
return new RuleImportService();
}
}

View File

@ -79,6 +79,7 @@ class ApiServiceController extends BaseController
$client_policy_id = $params['client_policy_id'] ?? null;
$policy_no = $params['policy_no'] ?? null;
$type = $params['type'] ?? 'download';
$all_member = $params['all_member'] ?? null;
log_message('error', 'Received Payload INTERNAL : '. json_encode($params ?? ""));
@ -107,10 +108,16 @@ class ApiServiceController extends BaseController
// direct download
$data['eCardDownload'] = base_url('download-e-card/') . $employee_policy[0]['rand_string'].'/1';
}else{
// view and download
$data['eCardDownload'] = base_url('download-e-card/') . $employee_policy[0]['rand_string'].'/0/1';
if(isset($all_member) && !empty($all_member)){
// view and download all members
$data['eCardDownload'] = base_url('download-e-card/') . $employee_policy[0]['rand_string'].'/1/1';
}else{
// view and download single member
$data['eCardDownload'] = base_url('download-e-card/') . $employee_policy[0]['rand_string'].'/0/1';
}
}
}
$data['message'] = "E-card generated";
if(empty($data['eCardDownload'])){
$data['message'] = "E-card not generated";
@ -213,7 +220,7 @@ class ApiServiceController extends BaseController
}
public function getWellnessUrl()
public function getWellnessUrl()
{
$emp_id = $this->request->getGet('emp_id');
@ -238,8 +245,8 @@ class ApiServiceController extends BaseController
$data = $db->table('employee_polices ep')
->select('pt.policy_type,
e.name, e.email_corporate as email, e.mobile as phone, e.emp_code as memberId, e.gender, e.dob, e.relationship as relation,
cp.policy_no as policyNumber, cp.policy_no as employeeId, cp.policy_start_date as policyStartDate, cp.policy_end_date as policyEndDate, cp.wellness_plan_id as planId')
e.name, e.email_corporate as email, e.mobile as phone, e.emp_code as memberId, e.gender, e.dob, e.relationship as relation, e.id as employeeId
cp.policy_no as policyNumber, cp.policy_start_date as policyStartDate, cp.policy_end_date as policyEndDate, cp.wellness_plan_id as planId')
->join('employees e', 'e.id = ep.employee_id')
->join('client_policy cp', 'ep.client_policy_id = cp.id')
->join('policy_type pt', 'cp.policy_type_id = pt.id')
@ -258,12 +265,12 @@ class ApiServiceController extends BaseController
$userParams['name'] = $data->name;
$userParams['email'] = $data->email;
$userParams['phone'] = $data->phone;
$userParams['memberId'] = $data->memberId;
$userParams['memberId'] = $data->employeeId; // memberId is unique primary key.
$userParams['gender'] = $data->gender;
$userParams['dob'] = $data->dob;
$userParams['relation'] = $data->relation;
$userParams['policyNumber'] = $data->policyNumber;
$userParams['employeeId'] = $data->employeeId;
$userParams['employeeId'] = $data->memberId;
$userParams['policyStartDate']= $data->policyStartDate;
$userParams['policyEndDate'] = $data->policyEndDate;
$userParams['policyName'] = 'Nhance ' . $data->policy_type;
@ -310,6 +317,87 @@ class ApiServiceController extends BaseController
function getSSORedirectUrl($email = 'user@example.com')
{
// ---------- CONFIG ----------
$authUrl = env('VIDAL_WELLNESS_BASE_URL'); // Authentication API URL
$subscriptionKey = env('VIDAL_WELLNESS_SUBSCRIPTION_KEY');
$apiVersion = "1";
// Provided Base64 AES key
$base64Key = env('VIDAL_WELLNESS_BASE64_KEY');
$key = base64_decode($base64Key);
// ---------- STEP 1: Build plaintext payload ----------
$plainPayload = json_encode([
"email" => $email,
"corporateId" => env('VIDAL_WELLNESS_CORPORATE_ID'),
"urlIdentifier" => env('VIDAL_WELLNESS_URL_IDENTIFIER')
]);
// ---------- STEP 2: Encrypt payload ----------
$iv = random_bytes(16);
$encryptedRaw = openssl_encrypt($plainPayload, "AES-256-CBC", $key, OPENSSL_RAW_DATA, $iv);
$encryptedPayload = base64_encode($iv) . ":" . base64_encode($encryptedRaw);
// ---------- STEP 3: Call Authentication API ----------
$requestBody = json_encode([
"payload" => $encryptedPayload,
"source" => "portal",
"subPartnerId" => env('VIDAL_WELLNESS_SUB_PARTNER_ID')
]);
$headers = [
"Ocp-Apim-Subscription-Key: $subscriptionKey",
"apiver: $apiVersion",
"mode: encrypt",
"Content-Type: application/json"
];
$ch = curl_init($authUrl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $requestBody);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$apiResponse = curl_exec($ch);
curl_close($ch);
$jsonResponse = json_decode($apiResponse, true);
dd($jsonResponse);
if (!isset($jsonResponse["data"])) {
return ["error" => "Invalid API response", "response" => $apiResponse];
}
// ---------- STEP 4: Decrypt response ----------
list($ivBase64, $cipherBase64) = explode(":", $jsonResponse["data"]);
$respIv = base64_decode($ivBase64);
$respCipher = base64_decode($cipherBase64);
$decryptedJson = openssl_decrypt($respCipher, "AES-256-CBC", $key, OPENSSL_RAW_DATA, $respIv);
$decryptedData = json_decode($decryptedJson, true);
if (!isset($decryptedData["redirectUrl"])) {
return ["error" => "redirectUrl missing", "decrypted" => $decryptedData];
}
// ---------- FINAL ----------
return $decryptedData["redirectUrl"];
}

View File

@ -792,6 +792,7 @@ class ClientController extends AdminController
$editData['RM'] = $this->userModel->where('is_active', 1)->findAll();
$editData['tpa'] = $this->tpaBranchModel->getTpaBranchesWithTpaNames();
$editData['tpa_list'] = $this->tpaModel->where('is_active', 1)->findAll();
$editData['state'] = $this->stateModel->getAllStates();
$editData['police'] = $this->policesModel->findAll();
$editData['entity'] = $this->kycEntityTypeModel->findAll();
@ -1439,7 +1440,9 @@ class ClientController extends AdminController
$data['is_member_modify_allowed'] = $this->request->getPost('is_member_modify_allowed') ? 1 : 0;
$data['enrolment_visibility'] = $this->request->getPost('enrolment_visibility') ? 1 : 0;
$data['is_lgbtq'] = $this->request->getPost('is_lgbtq') ? 1 : 0;
$data['wellness_plan_id'] = $this->request->getPost('wellness_plan_id');
$data['wellness_vendor_id'] = $this->request->getPost('wellness_vendor_id');
$data['wellness_vendor_id'] = !empty($data['wellness_vendor_id']) ? $data['wellness_vendor_id'] : null;
if ($policy_type_id == 1 || $policy_type_id == 2 || $policy_type_id == 6 || $policy_type_id == 7) {
@ -1536,10 +1539,14 @@ class ClientController extends AdminController
$data['cd_ac_pk'] = $this->request->getPost('cd_ac_no');
$data['gst'] = $this->request->getPost('gst');
$data['disclaimer'] = $this->request->getPost('disclaimer');
$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');
$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');
$data['is_member_modify_allowed'] = $this->request->getPost('is_member_modify_allowed') ? 1 : 0;
$data['is_lgbtq'] = $this->request->getPost('is_lgbtq') ? 1 : 0;
$data['is_lgbtq'] = $this->request->getPost('is_lgbtq') ? 1 : 0;
$data['wellness_plan_id'] = $this->request->getPost('wellness_plan_id');
$data['wellness_vendor_id'] = $this->request->getPost('wellness_vendor_id');
$data['wellness_vendor_id'] = !empty($data['wellness_vendor_id']) ? $data['wellness_vendor_id'] : null;
if ($data['inception_type'] == 2) {
$data['open_date'] = change_date_format($this->request->getPost('open_date'), 'd-m-Y', 'Y-m-d');
$data['close_date'] = change_date_format($this->request->getPost('close_date'), 'd-m-Y', 'Y-m-d');
@ -5645,11 +5652,9 @@ class ClientController extends AdminController
public function sendextraparam()
{
// $data = db_connect()->table('jobs')->where('id', 1677)->get()->getRowArray();
// // dd($data);
// $return = db_connect()->table('jobs')->where('id', 1677)->get()->getRowArray();
// $return = $this->updatePolicyTransactionDataWhileClinetPolicyUpdate(json_decode($data['payload'], true));
// dd($return);
// die;
// $ticket_id = 515;
// $apiServiceController = new ApiServiceController();
@ -5673,12 +5678,19 @@ class ClientController extends AdminController
// $response = $ticketServiceController->extractExcelData("claims_dump_form_client.xlsx");
// dd($response);
// ---------- TICKET SERVICE CONTROLLER --------------------------------------------------------------------------------
$TicketController = new TicketController();
// $response = $TicketController->getMoreInfo($requestFrom = 'rest', $ticket_id = 70);
// dd($response);
// ---------- EMP SERVICE CONTROLLER --------------------------------------------------------------------------------
$empServiceController = new EmployeeServiceController();
// $res = $empServiceController->excelFileFormatValidation(['file_id' => '1126']);
// $res = $empServiceController->excelFileDataValidation(['file_id' => '865']);
// $res = $empServiceController->employeesOnboardPreprocess(['file_id' => 726]);
// $res = $empServiceController->employeesOnboardPreprocess(['file_id' => 1183]);
// $res = $empServiceController->employeesOnboardPreprocess(['file_id' => 1169]);
// $res = $empServiceController->employeesOnboardProcess(['file_id' => 835]);
// $res = $empServiceController->employeesEnrollmentInsert(['file_id' => 836]);
// $res = $empServiceController->employeesSIEnhanceProcess(['file_id' => '1131']);
@ -5687,13 +5699,13 @@ class ClientController extends AdminController
// $res = $empServiceController->compareMemberDataAndInceptionData(['file_id' => '1126']);
// dd($res);
// ---------- EMP MULTI EVENT SERVICE CONTROLLER --------------------------------------------------------------------------------
$EmployeeMultiEventServiceController = new EmployeeMultiEventServiceController();
// $res = $EmployeeMultiEventServiceController->constructMultiEventData(['file_id' => '1069']);
// $res = $EmployeeMultiEventServiceController->excelMultieventFileFormateValidation(['file_id' => '2373']);
// $res = $EmployeeMultiEventServiceController->excelMultieventFileDataValidation(['file_id' => '2373']);
// $res = $EmployeeMultiEventServiceController->excelMultieventFileOnBoard(['file_id' => '1069']);
// dd($res);
// $res = $EmployeeMultiEventServiceController->getExcelErrorData(1069, $res);
// $res['file_id'] = 1069;
// echo view('excel_errors', $res);
@ -6022,8 +6034,8 @@ class ClientController extends AdminController
->where('employees.is_active', 1)
->where('employees.relationship', "Self")
->where('employee_polices.is_active', 1)
->whereIn('employees.emp_status', ['active'])
->whereIn('employee_polices.status', ['active'])
->whereIn('employees.emp_status', ['active', 'expired'])
->whereIn('employee_polices.status', ['active', 'expired'])
->where('employees.is_active', 1)
->where('client_policy.id', $param)
->groupBy('employees.emp_code')
@ -6136,10 +6148,10 @@ class ClientController extends AdminController
->where('insurers.is_active', 1)
->where('tpa.is_active', 1)
->where('employees.is_active', 1)
->where('employees.emp_status', "active")
->whereIn('employees.emp_status', ['active', 'expired'])
->where('employees.relationship', "Self")
->where('employee_polices.is_active', 1)
->where('employee_polices.status', "active")
->whereIn('employee_polices.status', ['active', 'expired'])
->where($field_name, $param);
if (!empty($client_id)) {

View File

@ -0,0 +1,286 @@
<?php
namespace App\Controllers;
use CodeIgniter\Controller;
use CodeIgniter\API\ResponseTrait;
class DeployController extends AdminController
{
use ResponseTrait;
protected $myLogger;
public function __construct()
{
$this->myLogger = \Config\Services::mylogger();
}
// public function fedeploy()
// {
// $request = $this->request;
// // Multiple zip files: <input type="file" name="zip_files[]" multiple>
// // $zipFiles = $this->request->getFileMultiple('zip_files');
// $zipFiles = $this->request->getFile('zip_files');//('zip_files');
// // print_r($zipFiles);die();
// // Matching dropdown/text values (arrays, indexed same as zip_files[])
// $zipFolders = (array) $request->getPost('zip_folder'); // e.g. ["web/", "dist/"]
// $s3Buckets = (array) $request->getPost('s3_bucket'); // e.g. ["benefits-app-bucket", ...]
// $s3Prefixes = (array) $request->getPost('s3_prefix'); // e.g. ["hr/", "payroll/"]
// $cfDistributions = (array) $request->getPost('cf_distribution_id'); // e.g. ["DIST1", "DIST1", "DIST2"]
// $cfPathsList = (array) $request->getPost('cf_paths'); // e.g. ["/hr/*", "/hr/special/*", "/payroll/*"]
// // Path to Python interpreter and deploy_assets.py script
// $pythonBin = getenv('PY_PATH'); // adjust if needed
// $scriptPath = getenv('PY_SCRIPT_PATH'); // full path to your script
// $results = [];
// if (empty($zipFiles)) {
// return $this->response->setJSON([
// 'status' => 'error',
// 'message' => 'No zip files uploaded',
// ]);
// }
// // --------------------------------------------------------
// // 1) Pre-process distribution IDs → group by distribution
// // - So we can run ONE invalidation per distribution
// // - And merge all paths into a single JSON array
// // --------------------------------------------------------
// $distGroups = []; // [distId => ['indexes' => [...], 'paths' => [...], 'firstIndex' => int]]
// foreach ($cfDistributions as $i => $distId) {
// $distId = trim((string) $distId);
// $path = trim((string) ($cfPathsList[$i] ?? ''));
// // Only consider entries where both distribution ID and path are set
// if ($distId === '' || $path === '') {
// continue;
// }
// if (!isset($distGroups[$distId])) {
// $distGroups[$distId] = [
// 'indexes' => [],
// 'paths' => [],
// ];
// }
// $distGroups[$distId]['indexes'][] = $i;
// $distGroups[$distId]['paths'][] = $path;
// }
// // Set firstIndex and unique paths per distribution
// foreach ($distGroups as $distId => $info) {
// $distGroups[$distId]['firstIndex'] = $info['indexes'][0]; // first file index for this dist
// $distGroups[$distId]['paths'] = array_values(array_unique($info['paths'])); // unique paths
// }
// // --------------------------------------------------------
// // 2) Process each uploaded file
// // --------------------------------------------------------
// foreach ($zipFiles as $index => $file) {
// if (!$file->isValid() || $file->hasMoved()) {
// $results[] = [
// 'file' => $file->getName(),
// 'status' => 'error',
// 'message' => 'Invalid file or already moved.',
// ];
// continue;
// }
// // Read matching form values (or fallback)
// $zipFolder = $zipFolders[$index] ?? 'web/'; // default example
// $s3Bucket = $s3Buckets[$index] ?? '';
// $s3Prefix = $s3Prefixes[$index] ?? '';
// $cfDistribution = $cfDistributions[$index] ?? '';
// $cfDistribution = trim((string) $cfDistribution);
// // Move file into a known directory (keep original name)
// // $uploadDir = WRITEPATH . 'uploads/deploy';
// $uploadDir = '/home/ubuntu/py';
// if (!is_dir($uploadDir)) {
// mkdir($uploadDir, 0775, true);
// }
// $originalName = $file->getName();
// $file->move($uploadDir, $originalName);
// $zipPath = $uploadDir . DIRECTORY_SEPARATOR . $originalName;
// // --------------------------------------------------------
// // Decide whether THIS file should trigger invalidation
// // - Only firstIndex of each distribution will do it
// // - cf-paths-json = JSON array of all unique paths for that dist
// // --------------------------------------------------------
// $doInvalidation = false;
// $cfPathsJson = '';
// if ($cfDistribution !== '' && isset($distGroups[$cfDistribution])) {
// $group = $distGroups[$cfDistribution];
// if ($group['firstIndex'] === $index) {
// // This is the first file for this distribution ID → do invalidation ONCE
// $doInvalidation = true;
// // Build CloudFront paths JSON array (AWS syntax: ["path1", "path2", ...])
// $cfPathsJson = json_encode($group['paths']); // e.g. ["\/hr\/*","\/hr\/special\/*"]
// }
// // Else: same distribution ID but NOT first index → no invalidation
// }
// // --------------------------------------------------------
// // Build the python command safely using escapeshellarg
// // --------------------------------------------------------
// $cmdParts = [
// escapeshellarg($pythonBin),
// escapeshellarg($scriptPath),
// '--zip-path', escapeshellarg($zipPath),
// '--zip-folder', escapeshellarg($zipFolder),
// '--s3-bucket', escapeshellarg($s3Bucket),
// '--s3-prefix', escapeshellarg($s3Prefix),
// '--do-webhook', // always send webhook after success
// ];
// if ($doInvalidation) {
// $cmdParts[] = '--do-invalidation';
// $cmdParts[] = '--cf-distribution-id';
// $cmdParts[] = escapeshellarg($cfDistribution);
// $cmdParts[] = '--cf-paths-json';
// $cmdParts[] = escapeshellarg($cfPathsJson); // e.g. '["/hr/*","/hr/special/*"]'
// }
// // Final command string (2>&1 to capture stderr too)
// $cmd = implode(' ', $cmdParts) . ' 2>&1';
// print_r($cmd);die();
// $output = [];
// $returnVar = 0;
// exec($cmd, $output, $returnVar);
// $results[] = [
// 'file' => $originalName,
// 'zip_path' => $zipPath,
// 'command' => $cmd,
// 'output' => $output,
// 'exit_code' => $returnVar,
// 'status' => $returnVar === 0 ? 'success' : 'error',
// ];
// }
// return $this->response->setJSON([
// 'status' => 'completed',
// 'results' => $results,
// ]);
// }
public function fedeploy()
{
$request = $this->request;
// Single zip file: <input type="file" name="zip_file">
$file = $request->getFile('zip_file');
if (!$file || !$file->isValid()) {
return $this->response->setJSON([
'status' => 'error',
'message' => 'No valid zip file uploaded',
]);
}
// Read scalar form values
$zipFolder = (string) $request->getPost('zip_folder') ?: 'web/';
$s3Bucket = (string) $request->getPost('s3_bucket') ?: '';
$s3Prefix = (string) $request->getPost('s3_prefix') ?: '';
$cfDistribution = trim((string) $request->getPost('cf_distribution_id'));
$cfPathsRaw = (string) $request->getPost('cf_paths');
// Python interpreter and script path from env
$pythonBin = getenv('PY_PATH'); // e.g. /usr/bin/python3
$scriptPath = getenv('PY_SCRIPT_PATH'); // e.g. /home/ubuntu/deploy_assets.py
if (empty($pythonBin) || empty($scriptPath)) {
return $this->response->setJSON([
'status' => 'error',
'message' => 'Python path or script path not configured in environment.',
]);
}
// Move file into known directory (keep original name)
$uploadDir = '~/py';
if (!is_dir($uploadDir)) {
mkdir($uploadDir, 0775, true);
}
$originalName = $file->getName();
$file->move($uploadDir, $originalName);
$zipPath = $uploadDir . DIRECTORY_SEPARATOR . $originalName;
// -----------------------------
// CloudFront invalidation data
// -----------------------------
$doInvalidation = false;
$cfPathsJson = '';
// Allow comma or newline separated paths: "/hr/*,/hr/special/*" or
// "/hr/*\n/hr/special/*"
$paths = array_filter(
array_map('trim', preg_split('/[\r\n,]+/', $cfPathsRaw)),
'strlen'
);
if ($cfDistribution !== '' && !empty($paths)) {
$doInvalidation = true;
$cfPathsJson = json_encode($paths); // e.g. ["\/hr\/*","\/hr\/special\/*"]
}
// -----------------------------
// Build python command
// -----------------------------
$cmdParts = [
escapeshellarg($pythonBin),
escapeshellarg($scriptPath),
'--zip-path', escapeshellarg($zipPath),
'--zip-folder', escapeshellarg($zipFolder),
'--s3-bucket', escapeshellarg($s3Bucket),
'--s3-prefix', escapeshellarg($s3Prefix),
'--do-webhook', // always send webhook after success
];
if ($doInvalidation) {
$cmdParts[] = '--do-invalidation';
$cmdParts[] = '--cf-distribution-id';
$cmdParts[] = escapeshellarg($cfDistribution);
$cmdParts[] = '--cf-paths-json';
$cmdParts[] = escapeshellarg($cfPathsJson);
}
// Final command string (2>&1 to capture stderr too)
$cmd = implode(' ', $cmdParts) . ' 2>&1';
$output = [];
$returnVar = 0;
print_r($cmd);die();
exec($cmd, $output, $returnVar);
$result = [
'file' => $originalName,
'zip_path' => $zipPath,
'command' => $cmd,
'output' => $output,
'exit_code' => $returnVar,
'status' => $returnVar === 0 ? 'success' : 'error',
];
return $this->response->setJSON([
'status' => 'completed',
'result' => $result,
]);
}
public function fedeploy_view()
{
// $this->load->view('fedeploy');
$this->loadLayout('fedeploy');
}
}

View File

@ -4968,6 +4968,10 @@ class EmpDataServiceController extends BaseController
'client_policy_id' => $emp_details['client_policy_id'],
];
if(empty($single_mail)){
$params['all_member'] = 1;
}
$params['common'] = [
'client_id' => $emp_details['client_id'],
'client_branch_id' => $emp_details['client_branch_id'],

File diff suppressed because it is too large Load Diff

View File

@ -1387,10 +1387,16 @@ class EmployeeServiceController extends AdminController
$family = array_merge($family,$existing_famility_details);
$family = data_group_by_family($family)[ $emp_id ];// reason to call this again is bring self to first index of the array
// dd($family);
$self = current(array_filter($family, fn($r) => strtolower($r[5] ?? '') === 'self'));
$premium = (int)($self['temp']['rata_premimum'] ?? 0);
foreach ($family as &$r) if (strtolower($r[5] ?? '') !== 'self') $r['self_rata_premium'] = $premium;
}
// Kint::dump($family);
$data = calculate_premium_new(family_data:$family,policy_terms: $policy_terms,slab_details : $slab_details,fileArr: $file, existing_units:$existing_units);
// if($file['action'] == 'dependent_addition') {
// $data = validatet_family_floter_rata_premium($data);
// }
// dd($data);
$employee_data_group_by_family[$emp_id] = $data;
$this->employeesOnboardProcess(['familiy_data' => $data,'file' => $file]);

View File

@ -0,0 +1,279 @@
<?php
namespace App\Controllers;
use CodeIgniter\Controller;
use CodeIgniter\API\ResponseTrait;
class InsuranceCommissionController extends AdminController
{
use ResponseTrait;
private $rules = [];
public function __construct()
{
set_session_context('InsuranceCommissionController');
$this->myLogger = \Config\Services::mylogger();
// Load rules file if present in writable config path
// $rulesPath = WRITEPATH . 'config/insurance_rules.json';
// if (file_exists($rulesPath)) {
// $this->loadRulesFromFile($rulesPath);
// }
}
/**
* POST /insurance/calculate
* Accepts JSON body with policy data and returns commission calculation
*/
public function initiateCommissionCalc()
{
// Accept POST params (JSON, form-data, x-www-form-urlencoded)
$input = $this->request->getPost();
if (empty($input)) {
$json = $this->request->getJSON(true);
if ($json) {
$input = $json;
}
}
if (empty($input)) {
return $this->failValidationError('No input data received');
}
// -------- Required Params Check --------
if (empty($input['policy_issue_date'])) {
return $this->failValidationError('policy_issue_date is required');
}
if (empty($input['department'])) {
return $this->failValidationError('department is required');
}
if (empty($input['insurer_id'])) {
return $this->failValidationError('insurer_id is required');
}
// -------- Build Dynamic Rules Path --------
$policyDate = strtotime($input['policy_issue_date']);
if (!$policyDate) {
return $this->failValidationError('Invalid policy_issue_date');
}
$month = strtoupper(date('M', $policyDate)); // SEP
$year = date('Y', $policyDate); // 2025
$folderName = $month . $year; // SEP2025
$insurerId = $input['insurer_id']; // 5
$department = ucfirst(strtolower($input['department'])); // Motor, Health, Fire
// Final Path: WRITEPATH/rules/SEP2025/5_Motor.json
$rulesPath = WRITEPATH . "uploads/commission/rules/{$folderName}/{$insurerId}_{$department}.json";
// echo $rulesPath;die();
if (!file_exists($rulesPath)) {
return $this->fail("Rules file not found at: {$rulesPath}");
}
// Load the dynamic rule set
$this->loadRulesFromFile($rulesPath);
// -------- Execute Rule Matching & Commission Calculation --------
try {
$result = $this->calculateCommission($input);
$comment = isset($result['rule']['name'])
? "Matched rule: " . $result['rule']['name']
: "Matched rule: (unnamed rule)";
return $this->respond([
'success' => true,
'data' => [
'payout' => $result['payout'],
'rule' => $result['rule'],
'comment' => $comment,
// 'rules_path_used' => $rulesPath
]
]);
} catch (\Exception $e) {
return $this->fail($e->getMessage());
}
}
/**
* Load rules JSON and normalise department keys to lowercase for lookups
*/
private function loadRulesFromFile(string $filePath)
{
if (!file_exists($filePath)) {
throw new \Exception("Rules file not found: {$filePath}");
}
$json = file_get_contents($filePath);
$parsed = json_decode($json, true);
if (json_last_error() !== JSON_ERROR_NONE) {
throw new \Exception('Invalid JSON in rules file: ' . json_last_error_msg());
}
// print_r($parsed);die();
// Normalise department keys to lowercase for consistent lookups
$this->rules = [];
foreach ($parsed as $dept => $rules) {
if($rules['is_deleted'] === false)
{
$this->rules[strtolower($dept)] = $rules;
}
}
// print_r($this->rules);die();
}
public function calculateCommission(array $policyData)
{
$department = $policyData['department'] ?? '';
$deptKey = strtolower($department);
// print_r($this->rules);die();
// if (!isset($this->rules[$deptKey])) {
// throw new \Exception("No rules found for department: {$department}");
// }
$matchingRules = [];
foreach ($this->rules as $rule) {
if ($this->evaluateConditions($rule['conditions'] ?? [], $policyData)) {
$matchingRules[] = $rule;
}
}
if (empty($matchingRules)) {
throw new \Exception('No matching rules found for the policy data');
}
// print_r($matchingRules);die;
// Use the first matching rule. In future you can implement priority/weighting
$applicableRule = $matchingRules[0];
$payout = $this->applyCalculation($applicableRule['calculation'], $policyData);
return ['rule' => $applicableRule, 'payout' => $payout];
}
private function evaluateConditions(array $conditions, array $data): bool
{
foreach ($conditions as $condition) {
$field = $condition['field'];
$operator = $condition['operator'];
$expectedValue = $condition['value'];
if (!array_key_exists($field, $data)) {
return false;
}
$actualValue = $data[$field];
if (!$this->compareValues($actualValue, $operator, $expectedValue)) {
return false;
}
}
return true;
}
private function compareValues($actual, string $operator, $expected): bool
{
switch ($operator) {
case '==':
return $actual == $expected;
case '!=':
return $actual != $expected;
case '>':
return $actual > $expected;
case '>=':
return $actual >= $expected;
case '<':
return $actual < $expected;
case '<=':
return $actual <= $expected;
case 'between':
return is_array($expected) && $actual >= $expected[0] && $actual <= $expected[1];
case 'in':
return is_array($expected) && in_array($actual, $expected);
default:
throw new \Exception("Unsupported operator: {$operator}");
}
}
private function applyCalculation(array $calculation, array $policyData)
{
$type = $calculation['type'] ?? null;
switch ($type) {
case 'percentage':
$percentage = $calculation['value'] ?? 0;
$base = $calculation['on'] ?? null;
if ($base === null || !isset($policyData[$base])) {
throw new \Exception("Base value for calculation not found: {$base}");
}
return ($percentage / 100) * $policyData[$base];
case 'composite':
$total = 0;
foreach ($calculation['components'] as $component) {
$percentage = $component['percentage'] ?? 0;
$base = $component['on'] ?? null;
if ($base === null || !isset($policyData[$base])) {
throw new \Exception("Base value for calculation not found: {$base}");
}
if (!empty($component['only_first_year'])) {
if (!empty($policyData['is_renewal'])) {
continue; // Skip this component for renewals
}
}
$total += ($percentage / 100) * $policyData[$base];
}
return $total;
case 'fixed':
$fixedAmount = $calculation['value'] ?? 0;
// If 'on' specified but not needed, return fixed amount as-is
return $fixedAmount;
default:
throw new \Exception('Unsupported calculation type: ' . $type);
}
}
public function getVolumeReward(array $premiumData)
{
$annualPremium = $premiumData['annual_premium'] ?? 0;
$department = $premiumData['department'] ?? '';
if ($department === 'Fire' || $department === 'Marine' || $department === 'Engineering') {
if ($annualPremium > 20000000) {
return 0.01 * $annualPremium;
} elseif ($annualPremium > 10000000) {
return 0.005 * $annualPremium;
} elseif ($annualPremium > 5000000) {
return 0.0025 * $annualPremium;
}
} elseif ($department === 'Motor') {
if ($annualPremium > 15000000) {
return 0.02 * $annualPremium;
} elseif ($annualPremium > 7500000) {
return 0.01 * $annualPremium;
}
}
return 0;
}
}

View File

@ -1976,6 +1976,9 @@ class MasterController extends AdminController
'lead_files' => WRITEPATH . 'uploads/lead_files/',
'claim_files' => WRITEPATH . 'uploads/claim_files/',
'claim_dump_excel' => WRITEPATH . 'uploads/claim_dump_excel/',
'commission' => WRITEPATH . 'uploads/commission/',
'files' => WRITEPATH . 'uploads/commission/files',
'rules' => WRITEPATH . 'uploads/commission/rules',
'claim_sample_forms' => ROOTPATH . 'public/claim_sample_forms/',
];

View File

@ -331,6 +331,7 @@ class MediAssistApiController extends BaseController
$db = \Config\Database::connect();
$updated = 0;
$employee_policy_ids = [];
foreach ($employeePolicyData as $policy_data) {
foreach ($allBenef as $row) {
@ -370,6 +371,10 @@ class MediAssistApiController extends BaseController
WHERE id = ?";
$db->query($sql, [$row['benefMediAssistID'], $policy_data['emp_policy_id']]);
// for e-card send
if(strtolower(trim($policy_data['relationship'])) == 'self'){
$employee_policy_ids[] = $policy_data['emp_policy_id'];
}
if ($db->affectedRows() > 0) {
$updated++;
@ -384,6 +389,12 @@ class MediAssistApiController extends BaseController
}
}
// send e-card
if(!empty($employee_policy_ids)){
log_message('error', "sendMailForDownloadingECard JOB PUSHED.");
Jobs::addJob(['job_name' => 'sendMailForDownloadingECard', 'payload' => $employee_policy_ids]);
}
// update file table status after the tpa id successfully updated
if (isset($requestData['file_id']) && !empty($requestData['file_id'])) {
$file_model = new BatchFileModel();

View File

@ -258,7 +258,7 @@ class NotificationController extends AdminController
$template_id = $this->request->getPost('template_id');
$test_mail = $this->request->getPost('test_mail');
// $test_mail = $this->request->getPost('test_mail');
$test_mail_list = $this->request->getPost('test_mail_list');
@ -268,27 +268,67 @@ class NotificationController extends AdminController
if(!empty($notification_data)){
$params = [
'client_data' => $client_data,
'notification_data' => $notification_data,
'test_mail' => $test_mail,
'test_mail_list' => $test_mail_list
];
// First Index as test mail all are testmaillist
// $params = [
// 'client_data' => $client_data,
// 'notification_data' => $notification_data,
// 'test_mail' => $test_mail,
// 'test_mail_list' => $test_mail_list
// ];
// $testMailData = sendMailNotification::sendMailNotificationForTesting($notification_data['template_name'], $params);
// if (!empty($testMailData)) {
// $mail_send_return1 = MailHelper::send_email($testMailData);
// $this->myLogger->logme("info", $mail_send_return1);
// $this->myLogger->logme("info", $mail_send_return1);
// return $this->respond(['status' => true,'code' => 200, 'respond' => json_decode($mail_send_return1)]);
// }else{
// return $this->respond(['status' => false,'code' => 200, 'message' => 'Test Mail Data Does Not Exist']);
// }
$testMailData = sendMailNotification::sendMailNotificationForTesting($notification_data['template_name'], $params);
// print_r($testMailData); die;
if (!empty($testMailData)) {
$mail_send_return1 = MailHelper::send_email($testMailData);
$this->myLogger->logme("info", $mail_send_return1);
$this->myLogger->logme("info", $mail_send_return1);
$mailArray = explode(',', $test_mail_list);
$successMails = [];
$failedMails = [];
return $this->respond(['status' => true,'code' => 200, 'respond' => json_decode($mail_send_return1)]);
foreach ($mailArray as $singleMail) {
$singleMail = trim($singleMail);
}else{
$params = [
'client_data' => $client_data,
'notification_data' => $notification_data,
'test_mail' => $singleMail,
'test_mail_list' => "" // optional
];
$testMailData = sendMailNotification::sendMailNotificationForTesting($notification_data['template_name'], $params);
if (!empty($testMailData)) {
$mail_send_return1 = MailHelper::send_email($testMailData);
if ($mail_send_return1) {
$successMails[] = $singleMail;
} else {
$failedMails[] = $singleMail;
}
$this->myLogger->logme("info", "Mail attempt to {$singleMail}: " . $mail_send_return1);
} else {
$failedMails[] = $singleMail;
$this->myLogger->logme("info", "Test Mail Data Does Not Exist for {$singleMail}");
}
}
// Prepare final response
if (!empty($successMails)) {
$responseMessage = "Count " . count($successMails) . " mail(s) sent successfully: \n" . implode("\n", $successMails);
if (!empty($failedMails)) {
$responseMessage .= "\nCount " . count($failedMails) . " mail(s) failed: \n" . implode("\n", $failedMails);
}
return $this->respond(['status' => true,'code' => 200,'message' => $responseMessage]);
} else {
return $this->respond(['status' => false,'code' => 200,'message' => 'All mails failed to send: ' . implode(", ", $failedMails)]);
}
return $this->respond(['status' => false,'code' => 200, 'message' => 'Test Mail Data Does Not Exist']);
}
}else{
return $this->respond(['status' => false,'code' => 200, 'message' => 'Notification Template not enabled']);

View File

@ -0,0 +1,616 @@
<?php
namespace App\Controllers;
use App\Controllers\BaseController;
use CodeIgniter\HTTP\ResponseInterface;
use CodeIgniter\API\ResponseTrait;
use App\Models\InvoiceItemModel;
use App\Models\InvoiceModel;
use App\Models\InvoiceUtrModel;
use App\Models\PolicyTransactionModel;
use App\Models\AuditHistoryModel;
use Dompdf\Dompdf;
use Dompdf\Options;
class PayoutController extends BaseController
{
use ResponseTrait;
protected $myLogger;
protected $invoiceItemModel;
protected $invoiceModel;
protected $invoiceUtrModel;
protected $policyTransactionModel;
protected $payout_status;
protected $auditHistory;
public function __construct()
{
set_session_context('PayoutController');
$this->myLogger = \Config\Services::mylogger();
$this->payout_status = [
1 => "Pending",
2 => "Completed",
];
$this->invoiceItemModel = new InvoiceItemModel();
$this->invoiceModel = new InvoiceModel();
$this->invoiceUtrModel = new InvoiceUtrModel();
$this->policyTransactionModel = new PolicyTransactionModel();
$this->auditHistory = new AuditHistoryModel();
}
public function payoutList()
{
// for filtering list
if($this->request->is('post')){
try{
$data = $this->request->getPost();
// print_r($data); die;
$agent_id = $data['agent_id'] ?? null;
$status_id = $data['status_id'] ?? null;
$start_date = $data['start_date'] ?? null;
$end_date = $data['end_date'] ?? null;
$payout_data = $this->invoiceModel->invoiceList($agent_id, $status_id, $start_date, $end_date);
$payout_data['payout_list_data'] = $payout_data;
$payout_data = view('payout_list', $payout_data);
if(!empty($payout_data)){
return $this->respond(['status' => true, 'code' => 200, 'data' => $payout_data], 200);
}else{
return $this->respond(['status' => false, 'code' => 400, 'data' => $payout_data, "message" => "No data found"], 200);
}
}catch (\Throwable $th) {
$this->myLogger->logme("error", "PayoutController - payoutList: Exception: " . $th->getMessage() . " --- Line: " . $th->getLine() . " --- Trace: " . $th->getTraceAsString());
$errorData = [
'message' => $th->getMessage(),
'file' => $th->getFile(),
'line' => $th->getLine(),
'code' => $th->getCode(),
'trace' => $th->getTraceAsString(),
'trace_array' => $th->getTrace(), // full array version (optional)
'function' => $th->getTrace()[0]['function'] ?? null,
'class' => $th->getTrace()[0]['class'] ?? null,
];
$payout_data = view('payout_list');
return $this->respond(['status' => false, 'code' => 500, 'data' => $payout_data, "message" => "No data found", 'error_data' => $errorData], 500);
}
}
// for list
$data['payout_status'] = $this->payout_status;
$data['agent_list'] = $this->invoiceModel->agentList();
$data['page_name'] = "Invoices";
$payout_data['payout_list_data'] = $this->invoiceModel->invoiceList();
$data['payout_list'] = view('payout_list', $payout_data);
// dd($data);
return $this->loadLayout('payout_list_handler', $data);
}
public function fetchUtrDetails()
{
$invoice_id = $this->request->getPost('invoice_id') ?? null;
$payout_data = $this->constructUtrDetails($invoice_id);
if(!empty($payout_data)){
return $this->respond(['status' => true, 'code' => 200, 'data' => $payout_data], 200);
}else{
return $this->respond(['status' => false, 'code' => 400, 'data' => $payout_data, "message" => "No data found"], 200);
}
}
public function constructUtrDetails($invoice_id)
{
$utr_data = $this->invoiceUtrModel->where('is_active', 1)->where('invoice_id', $invoice_id)->findAll();
$summary_data = $this->invoiceModel->utrSummary($invoice_id);
if($summary_data['invoice_amount'] == $summary_data['total_utr_amount']) {
$data['invoice_completed'] = true;
}
$data['utr_list_data'] = $utr_data;
$data['summary'] = $summary_data;
$data = view('payout_utr_details', $data);
return $data;
}
public function saveUtrDetails()
{
$data = $this->request->getPost();
$invoice_id = $this->request->getPost('invoice_id') ?? null;
$utr_id = $this->request->getPost('utr_pk') ?? null;
if(isset($data['utr_date'])){
$data['utr_date'] = change_date_format($data['utr_date']);
}
if(!empty($utr_id)){
$update = $this->invoiceUtrModel->where('id', $utr_id)->set($data)->update();
$payout_edit_data = $this->constructUtrDetails($invoice_id);
if($update){
$summary_data = $this->invoiceModel->utrSummary($invoice_id);
if($summary_data['invoice_amount'] == $summary_data['total_utr_amount']){
$sql = "UPDATE partner_invoice SET payout_status = 2 WHERE id = ?";
db_connect()->query($sql, [$invoice_id]);
}
return $this->respond(['status' => true, 'code' => 200, 'data' => $payout_edit_data, "message" => "UTR successfully updated"], 200);
}else{
return $this->respond(['status' => false, 'code' => 400, 'data' => $payout_edit_data, "message" => "Failed to update UTR"], 200);
}
}else{
unset($data['utr_pk']);
$insert_id = $this->invoiceUtrModel->insert($data);
$payout_data = $this->constructUtrDetails($invoice_id);
if($insert_id){
$summary_data = $this->invoiceModel->utrSummary($invoice_id);
if($summary_data['invoice_amount'] == $summary_data['total_utr_amount']){
$sql = "UPDATE partner_invoice SET payout_status = 2 WHERE id = ?";
db_connect()->query($sql, [$invoice_id]);
}
return $this->respond(['status' => true, 'code' => 200, 'data' => $payout_data, "message" => "UTR added successfully"], 200);
}else{
return $this->respond(['status' => false, 'code' => 400, 'data' => $payout_data, "message" => "Failed to add UTR"], 200);
}
}
}
public function removeUtrDetails()
{
$data = $this->request->getPost();
if(isset($data['utr_id'])){
$sql = "UPDATE partner_invoice_utr SET is_active = 0 WHERE id = ?";
$update = db_connect()->query($sql, [$data['utr_id']]);
$payout_data = $this->constructUtrDetails($data['invoice_id'] ?? "");
if($update){
return $this->respond(['status' => true, 'code' => 200, 'data' => $payout_data, "message" => "UTR removed successfully"], 200);
}else{
return $this->respond(['status' => false, 'code' => 400, 'data' => $payout_data, "message" => "Failed to remove UTR"], 200);
}
}else {
return $this->respond(['status' => false, 'code' => 500, 'data' => "", "message" => "Failed to remove UTR"], 200);
}
}
/*************************************************************************************************************/
//... Payout-invoice Mapping Commission's amount and Adjustment's Amount - Data Display
public function invoices()
{
$type = $this->request->getGet('type');
$title = $type === 'add' ? 'Add Payouts'
: ($type === 'edit' ? 'Edit Payouts'
: ($type === 'adjustment' ? 'Payouts Adjustment'
: 'Payouts'));
$data['tab_name'] = $title;
$data['page_name'] = $title;
$id = $this->request->getGet('id');
if($type == 'add')
{
$data['agents'] = $this->invoiceModel->agentList(['is_active' => 1]); // common both add and edit
}
else
{
$data['agents'] = $this->invoiceModel->agentList(); // common both add and edit
}
// $data['checked_policy_numbers'] = [];
// $data['invoice'] = [];
// $data['extra_payouts'] = [];
//... Now Seperated add => 'policy_transaction_payouts1'
//... Now Seperated edit and adjustment => 'policy_transaction_payouts' old file
//... Reason : Due Datatable issues Export button Searching like that so seperated
if ($type === 'add') {
// $invoiceNo = $this->generateInvoiceNumber();
$data['payouts'] = $this->invoiceModel->payoutList(1);
// print_rr($data['payouts']);die();
// print_rr($this->invoiceModel->getLastQuery());die();
// $data['invoice_number'] = $invoiceNo;
return $this->loadLayout('invoice_policy_mapping_add', $data);
}
if (($type === 'edit' || $type === 'adjustment') && !empty($id)) {
$invoice = $this->invoiceModel->where('id', $id)->first();
$data['freeze_edit'] = $this->auditHistory->where('table_name', 'partner_invoice')->where('pk', $id)->countAllResults();
$agentId = $invoice['agent_id'] ?? null;
$data['payouts'] = $this->invoiceModel->payoutList(2 ,$agentId,$id);
$data['extra_payouts'] = $agentId ? $this->invoiceModel->payoutList(3, $agentId) : [];
$invoice_items = $this->invoiceItemModel->where('invoice_id', $id)->findAll();
if (!$invoice) { return redirect()->to('payout/invoices')->with('error', 'Invoice not found'); }
$data['invoice'] = $invoice;
$data['invoice_items'] = $invoice_items;
// Initialize array for policy numbers
$data['checked_policy_numbers'] = array_column(array_filter($invoice_items, fn($ii) => isset($ii['is_active']) && $ii['is_active'] == 1),'policy_no');
$data['invoice_number']= $invoice['invoice_no'];
$data['type'] = $type;
$data['payout_status'] = $invoice['payout_status'] ;
// dd($data);
return $this->loadLayout('invoice_policy_mapping', $data);
}
}
//... Payout-invoice Mapping - Save/update/soft Delete/Hard Delete Data
public function saveInvoice()
{
$json = $this->request->getJSON(true);
// print_rr($json);die();
if (!$json) {
return $this->response->setJSON(['error' => 'Invalid JSON','message' => 'Invalid JSON received.'])->setStatusCode(400);
}
$id = $json['invoice_id'] ?? null;
try {
//... ADD Part
if (empty($id)) {
$exists = $this->invoiceModel
->where('invoice_no', $json['invoice_no'])
->first();
if ($exists) {
$InvNum = $this->generateInvoiceNumber($json['agent_id']);
} else {
$InvNum = $json['invoice_no'];
}
$invoiceData = [
'invoice_no' => $InvNum,
'agent_id' => $json['agent_id'],
'invoice_date' => $json['invoice_date'],
'invoice_amount' => $json['invoice_amount'],
'payout_status' => 1
];
$invoiceId = $this->invoiceModel->insert($invoiceData);
foreach ($json['policies'] as $p) {
$this->invoiceItemModel->insert([
'invoice_id' => $invoiceId,
'policy_id' => $p['partner_policy_id'],
'policy_no' => $p['policy_no'],
'commission_amount' => $p['commission_amount'],
'is_active' => 1
]);
}
$message = "Invoice created successfully.\nInvoice No: " . $json['invoice_no'];
}
// ... EDIT part
if (!empty($id)) {
$invoiceId = $id;
$invoiceData = [
'invoice_no' => $json['invoice_no'],
'agent_id' => $json['agent_id'],
'invoice_date' => $json['invoice_date'],
'invoice_amount' => $json['invoice_amount'],
];
$this->invoiceModel->update($invoiceId, $invoiceData);
//... Fetch existing invoice item rows
$existingItems = $this->invoiceItemModel
->where('invoice_id', $invoiceId)
->findAll();
//... Create map by policy_no
$existingMap = [];
foreach ($existingItems as $item) {
$existingMap[$item['policy_no']] = $item;
}
$newPolicyNos = [];
//... Loop new JSON policies
foreach ($json['policies'] as $p) {
$newPolicyNos[] = $p['policy_no'];
if (isset($existingMap[$p['policy_no']])) {
//... Update existing item
$this->invoiceItemModel
->where('id', $existingMap[$p['policy_no']]['id'])
->set([
'commission_amount' => $p['commission_amount'],
'is_active' => 1
])
->update();
} else {
//... Insert new item
$this->invoiceItemModel->insert([
'invoice_id' => $invoiceId,
'policy_id' => $p['policy_id'],
'policy_no' => $p['policy_no'],
'commission_amount' => $p['commission_amount'],
'is_active' => 1,
]);
}
}
//... Delete items removed in JSON (hard delete)
foreach ($existingItems as $old) {
if (!in_array($old['policy_no'], $newPolicyNos)) {
$this->invoiceItemModel
->where('id', $old['id'])
->delete();
}
}
//... Delete items removed in JSON (soft delete REF : SVM )
// foreach ($existingItems as $old) {
// if (!in_array($old['policy_no'], $newPolicyNos)) {
// $this->invoiceItemModel
// ->where('id', $old['id'])
// ->set(['is_active' => 0])
// ->update();
// }
// }
$message = "Invoice updated successfully.";
}
return $this->response->setJSON([
'status' => 'success',
'message' => $message,
'invoice_id' => $invoiceId
]);
} catch (\Exception $e) {
return $this->response->setJSON([
'status' => 'error',
'message' => 'Unexpected error occurred: ' . $e->getMessage()
]);
}
}
//... Payout-invoice Mapping - Invoice number is auto-generated only for the Add mode.
// Note New Pattern : INV/AG001/20251101/xx (REF:SVM)
public function generateInvoiceNumberAjax($agentId)
{
if (!$agentId) {
return $this->response->setJSON([
'status' => 'error',
'message' => 'Agent ID missing'
]);
}
$invoiceNo = $this->generateInvoiceNumber($agentId);
return $this->response->setJSON([
'status' => 'success',
'invoice_no' => $invoiceNo
]);
}
//... Payout-invoice Mapping - Invoice number is auto-generated only for the Add mode.
// Note New Pattern : INV/AG001/20251101/xx (REF:SVM)
private function generateInvoiceNumber($agentId)
{
$agent = $this->invoiceModel->agentListById($agentId);
$agentCode = $agent["agent_code"];
$today = date("Ymd");
$likePattern = "INV/$agentCode/$today/%";
$count = $this->invoiceModel
->like("invoice_no", $likePattern)
->countAllResults();
$nextNumber = $count + 1;
return "INV/$agentCode/$today/$nextNumber";
}
// private function generateInvoiceNumber()
// {
// $year = date('Y');
// $month = date('m');
// do {
// // random 3-digit number
// $random = str_pad(rand(1, 999), 3, '0', STR_PAD_LEFT);
// $invoiceNo = "INV{$year}{$month}{$random}";
// // check main invoice table
// $existsMain = $this->invoiceModel
// ->where('invoice_no', $invoiceNo)
// ->first();
// // check partner invoice table
// $existsPartner = $this->invoiceModel
// ->where('invoice_no', $invoiceNo)
// ->first();
// } while ($existsMain || $existsPartner); // regenerate if duplicate found
// return $invoiceNo;
// }
//... Payout-invoice Mapping Audit History Based on "Adjustment" value (REF: KV,SVM)
public function auditHistory()
{
$iid = $this->request->getGet('id');
$details['invoice'] = $this->auditHistory
->select('auditing_history.*,partner_invoice.invoice_no, user_profiles.first_name as created_name')
->join('user_profiles', 'user_profiles.id = auditing_history.created_by', 'left')
->join('partner_invoice', 'partner_invoice.id = auditing_history.pk', 'left')
->where('auditing_history.table_name', 'partner_invoice') // ok
->where('auditing_history.pk', $iid)
->orderBy('auditing_history.created_at', 'desc')
->get()
->getResultArray();
$details['invoice_child'] = $this->auditHistory
->select('auditing_history.*,partner_invoice.invoice_no, user_profiles.first_name as created_name,partner_invoice_items.policy_no')
->join('user_profiles', 'user_profiles.id = auditing_history.created_by', 'left')
->join('partner_invoice_items', 'partner_invoice_items.id = auditing_history.pk', 'left')
->join('partner_invoice', 'partner_invoice.id = partner_invoice_items.invoice_id', 'left')
->where('auditing_history.table_name', 'partner_invoice_items') // FIXED
->where('partner_invoice.id', $iid)
->orderBy('auditing_history.created_at', 'desc')
->get()
->getResultArray();
return $this->response->setJSON([
'status' => 'success',
'data' => $details
]);
}
// ****************************************************************************************************************************************************************
public function preview($invoiceId = null)
{
$invoiceId = $this->request->getGet('invoice_id');
// Get invoice data from database
$invoiceData = $this->getInvoiceData($invoiceId);
if (empty($invoiceData)) {
return $this->respond([
'status' => false,
'code' => 404,
'data' => '',
'message' => 'Invoice not found'
], 200);
}
// Load view with data
$html = view('invoice_template_2', $invoiceData);
// echo $html; die;
return $this->respond([
'status' => true,
'code' => 200,
'data' => $html
], 200);
}
public function downloadPdf($invoiceId = null, $type = 0)
{
// Get invoice data from database
$invoiceData = $this->getInvoiceData($invoiceId);
if (empty($invoiceData)) {
return redirect()->back()->with('error', 'Invoice not found');
}
// Generate HTML
$html = view('invoice_template_2', $invoiceData);
// Configure Dompdf
$options = new Options();
$options->set('isHtml5ParserEnabled', true);
$options->set('isPhpEnabled', true);
$options->set('isRemoteEnabled', true);
$options->set('defaultFont', 'Arial');
$options->set('chroot', FCPATH);
// Initialize Dompdf
$dompdf = new Dompdf($options);
// Load HTML
$dompdf->loadHtml($html);
// Set paper size and orientation
$dompdf->setPaper('A4', 'portrait');
// Render PDF
$dompdf->render();
// Generate filename
$filename = 'Invoice_' . $invoiceData['invoice_no'] . '_' . date('Ymd') . '.pdf';
if($type == 0){
// Download PDF
return $this->response
->setHeader('Content-Type', 'application/pdf')
->setHeader('Content-Disposition', 'attachment; filename="' . $filename . '"')
->setBody($dompdf->output());
}else{
// View PDF
return $this->response
->setHeader('Content-Type', 'application/pdf')
->setHeader('Content-Disposition', 'inline; filename="' . $filename . '"')
->setBody($dompdf->output());
}
}
private function getInvoiceData($invoiceId)
{
$invoice_data = $this->invoiceModel
->select('
partner_invoice.*,
pa.name as agent_name,
pa.email as agent_email,
pa.mobile as agent_mobile,
pa.address as agent_address,
pa.agent_code,
pa.certificate_file_name,
pa.commission_retain
')
->join('partner_agent pa', 'partner_invoice.agent_id = pa.id')
->where('partner_invoice.is_active', 1)
->where('partner_invoice.id', $invoiceId)
->first();
return $invoice_data;
}
}

View File

@ -496,12 +496,18 @@
$cop_amt = $data['co_premium'][$index] ?? 0;
}
if(isset($data['calc_policy_issue_date'][$index])){
$data['calc_policy_issue_date'][$index] = change_date_format($data['calc_policy_issue_date'][$index]);
}
$co_share_type_value = $data['co_share'] == 1 ? $data['co_share_type'][$index] ?? 1 : 1;
// 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' => $data['co_share_type'][$index] ?? 1,
'co_share_type' => $co_share_type_value,
'co_share_per' => $data['co_share_per'][$index] ?? 0,
'bp_amt' => $data['base_premium'][$index] ?? 0,
'bp_gst_amt' => $data['gst_amount'][$index] ?? 0,
@ -539,6 +545,7 @@
'id' => $data['co_share_id'][$index] ?? null, // Assuming this is the ID to identify existing records
'follower_policy_no' => $data['follower_policy_no'][$index] ?? null,
'non_comm_per_amt' => $data['non_comm_per_amt'][$index] ?? null,
'pt_policy_issue_date' => $data['calc_policy_issue_date'][$index] ?? null,
];
}
@ -1001,7 +1008,9 @@
co_share_id = pt_co_share_details.id
AND is_active = 1
) AS actual_tep_brokerage_amount
) AS actual_tep_brokerage_amount,
DATE_FORMAT(pt_policy_issue_date, '%d/%m/%Y') AS pt_policy_issue_date
")
->where('pt_id', $id)
@ -1590,7 +1599,9 @@
co_share_id = pt_co_share_details.id
AND is_active = 1
) AS actual_tep_brokerage_amount
) AS actual_tep_brokerage_amount,
DATE_FORMAT(pt_policy_issue_date, '%d/%m/%Y') AS pt_policy_issue_date
")
->where('pt_id', $id)
@ -3197,116 +3208,116 @@
}
public function reportBDSNew()
{
// 🧭 Basic Page Info
$data['tab_name'] = 'BDS Report';
$data['page_name'] = 'BDS Report';
public function reportBDSNew()
{
// 🧭 Basic Page Info
$data['tab_name'] = 'BDS Report';
$data['page_name'] = 'BDS Report';
// 📋 Dropdown Data
$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',
'statement_month' => 'Statement Month',
];
// 📋 Dropdown Data
$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',
'statement_month' => 'Statement Month',
];
// 🏢 Fetch Active Data
$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();
$data['users'] = $this->userModel->where('is_active', 1)->findAll();
$data['policy_count'] = $this->policyTransactionModel->where('is_active', 1)->countAllResults();
// 🏢 Fetch Active Data
$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();
$data['users'] = $this->userModel->where('is_active', 1)->findAll();
$data['policy_count'] = $this->policyTransactionModel->where('is_active', 1)->countAllResults();
// 🕐 Filters
$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');
$client_branch_id = $this->request->getGet('client_branch_id');
$insurer_branch_id = $this->request->getGet('insurer_branch_id');
$client_policy_id = $this->request->getGet('client_policy_id');
$user_id = $this->request->getGet('user_id');
// 🕐 Filters
$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');
$client_branch_id = $this->request->getGet('client_branch_id');
$insurer_branch_id = $this->request->getGet('insurer_branch_id');
$client_policy_id = $this->request->getGet('client_policy_id');
$user_id = $this->request->getGet('user_id');
// Handle statement month range
if ($date_type == 'statement_month') {
$start_date = (string) date('Y-m-01', strtotime($start_date));
$end_date = (string) date('Y-m-31', strtotime($end_date));
}
// Handle statement month range
if ($date_type == 'statement_month') {
$start_date = (string) date('Y-m-01', strtotime($start_date));
$end_date = (string) date('Y-m-31', strtotime($end_date));
}
// Ensure default values
$start_date = $start_date ?: 0;
$end_date = $end_date ?: 0;
$client_id = $client_id ?: 0;
$insurer_id = $insurer_id ?: 0;
$policy_type_id = $policy_type_id ?: 0;
$date_type = $date_type ?: 0;
$issuer = $issuer ?: 0;
$client_branch_id = $client_branch_id ?: 0;
$insurer_branch_id = $insurer_branch_id ?: 0;
$client_policy_id = $client_policy_id ?: 0;
$user_id = $user_id ?: 0;
// Ensure default values
$start_date = $start_date ?: 0;
$end_date = $end_date ?: 0;
$client_id = $client_id ?: 0;
$insurer_id = $insurer_id ?: 0;
$policy_type_id = $policy_type_id ?: 0;
$date_type = $date_type ?: 0;
$issuer = $issuer ?: 0;
$client_branch_id = $client_branch_id ?: 0;
$insurer_branch_id = $insurer_branch_id ?: 0;
$client_policy_id = $client_policy_id ?: 0;
$user_id = $user_id ?: 0;
// 🧾 Handle POST requests (Dashboard filters)
if ($this->request->is('post')) {
$isFromDashboard = $this->request->getPost('is_dashboard');
// 🧾 Handle POST requests (Dashboard filters)
if ($this->request->is('post')) {
$isFromDashboard = $this->request->getPost('is_dashboard');
if (!empty($isFromDashboard) && $isFromDashboard == 1) {
$ids = array_filter(explode(',', $this->request->getPost('ids')));
if (!empty($isFromDashboard) && $isFromDashboard == 1) {
$ids = array_filter(explode(',', $this->request->getPost('ids')));
if (!empty($ids)) {
$idsStr = implode(',', array_map('intval', $ids)); // sanitize IDs
$where = "policy_transaction.id IN ($idsStr)";
} else {
$where = []; // No valid IDs
if (!empty($ids)) {
$idsStr = implode(',', array_map('intval', $ids)); // sanitize IDs
$where = "policy_transaction.id IN ($idsStr)";
} else {
$where = []; // No valid IDs
}
}
}
// 📊 Fetch report data
$data['report_list'] = $this->policyTransactionModel->reportBDSNew(
$start_date,
$end_date,
$client_id,
$insurer_id,
$policy_type_id,
$date_type,
$issuer,
$client_branch_id,
$insurer_branch_id,
$client_policy_id,
$user_id,
$where ?? ''
);
$data['list_new'] = true;
// 🧩 Load View
$this->loadLayout('report_bds_filter', $data);
}
// 📊 Fetch report data
$data['report_list'] = $this->policyTransactionModel->reportBDSNew(
$start_date,
$end_date,
$client_id,
$insurer_id,
$policy_type_id,
$date_type,
$issuer,
$client_branch_id,
$insurer_branch_id,
$client_policy_id,
$user_id,
$where ?? ''
);
$data['list_new'] = true;
// 🧩 Load View
$this->loadLayout('report_bds_filter', $data);
}
}

View File

@ -0,0 +1,844 @@
<?php
namespace App\Controllers;
use CodeIgniter\API\ResponseTrait;
use App\Models\CommissionFilesModel;
use App\Models\InsurerModel;
use App\Models\PartnerPolicyModel;
class RuleImportController extends AdminController
{
use ResponseTrait;
protected $myLogger;
protected $ruleImportService;
protected $commissionFilesModel;
protected $departments;
protected $departmentFields;
protected $insurerModel;
protected $partnerPolicyModel;
public function __construct()
{
set_session_context('RuleImportController');
$this->myLogger = \Config\Services::mylogger();
$this->ruleImportService = \Config\Services::ruleImportService();
$this->partnerPolicyModel = new partnerPolicyModel();
$this->commissionFilesModel = new CommissionFilesModel();
$this->insurerModel = new InsurerModel();
$this->departments = [
'motor' => 'Motor',
'health' => 'Health',
];
$this->departmentFields = [
'motor' => [
'department',
'vehicle_type',
'vehicle_sub_type',
'policy_type',
'vehicle_age',
'is_new_vehicle',
'cubic_capacity',
'policy_business_type',
'fuel_type',
'produt',
'geo_rto_state',
'geo_rto_city',
'model',
'make',
'weight',
'renewal_type',
'renewal_sub_type',
'premium',
'od_premium',
'tp_premium',
'product'
],
];
}
public function commissionFileUploadList()
{
$data['page_name'] = "Commision File Upload";
$data['departments'] = $this->departments;
$data['insurers'] = $this->insurerModel->where('is_active', 1)->findAll();
$data['commission_file_list'] = $this->commissionFilesModel
->select('commission_files.*, insurers.short_name as insurer_name, user_profiles.first_name as created_user_name')
->join('insurers', 'commission_files.insurer_id = insurers.id')
->join('user_profiles', 'commission_files.created_by = user_profiles.id')
->where('commission_files.is_active', 1)
->orderBy('commission_files.id', 'desc')
->findAll();
// dd( $data);
return $this->loadLayout('commission_file_upload', $data);
}
/**
* Upload endpoint for form (POST)
* Input form field: 'rules_file'
*/
public function uploadORI()
{
// echo 'hi';
!dd($result = $this->ruleImportService->processUpload(['id' => 1,'file_name' => 'sample_commission.csv','insurer_id' => 5, 'department' => 'motor' ,'commission_month' => '2025-11-10']));die;
try {
$file = $this->request->getFile('rules_file');
if (!$file || !$file->isValid()) {
return $this->response->setJSON(['status'=>false,'message'=>'No file uploaded or upload error']);
}
// Move uploaded file to writable temp location
$tmpPath = WRITEPATH . 'uploads/' . $file->getRandomName();
$file->move(WRITEPATH . 'uploads', $file->getName()); // keep original name inside uploads
$uploadedFullPath = $file->getTempName(); // Note: CI may store in tmp; we will use moved file path instead
$movedPath = WRITEPATH . 'uploads/' . $file->getName();
// Process file
$result = $this->ruleImportService->processUpload($movedPath, $file->getName());
// Return JSON with annotated file link if present
if (isset($result['annotated_file']) && $result['annotated_file']) {
$annotUrl = base_url('writable/uploads/annotated/' . basename($result['annotated_file']));
$result['annotated_url'] = $annotUrl;
}
return $this->response->setJSON($result);
} catch (\Throwable $e) {
$this->myLogger->logme('error', 'RuleImportController::upload ' . $e->getMessage());
return $this->response->setJSON(['status'=>false,'message'=>$e->getMessage()]);
}
}
public function upload()
{
try {
// ---------------------------------------------------------
// 1. Get uploaded file
// ---------------------------------------------------------
$file = $this->request->getFile('rules_file');
if (!$file || !$file->isValid()) {
$this->myLogger->logme('error', 'RuleImportController::upload - No file or invalid upload.');
return $this->respond(['status' => false, 'code' => 404, 'message' => 'No file uploaded or upload error.'], 200);
}
// ---------------------------------------------------------
// 2. Read POST fields
// ---------------------------------------------------------
// print_r($this->request->getPost()); die;
$insurerId = $this->request->getPost('insurer_id');
$department = $this->request->getPost('department');
$commissionMonth = $this->request->getPost('commission_month');
$overwrite = $this->request->getPost('overwrite') ?? 1;
$createdBy = get_session_userid();
if (empty($insurerId) || empty($department) || empty($commissionMonth)) {
$this->myLogger->logme('error', 'RuleImportController::upload - Missing required POST data.' . json_encode($this->request->getPost() ?? []));
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Missing required fields: insurer_id, department, commission_month'], 200);
}
$commissionMonth = $commissionMonth . '-01';
$commissionMonth = change_date_format($commissionMonth, 'Y-M-d', 'Y-m-d');
// Optional / default fields
$postedFileName = $this->request->getPost('file_name') ?: $file->getClientName();
$fileStatus = $this->request->getPost('file_status') ?: 'pending';
$isActive = $this->request->getPost('is_active') !== null ? (int)$this->request->getPost('is_active') : 1;
// rules_count is given by user but we will override it after processing on success
$postedRulesCount = $this->request->getPost('rules_count') !== null
? (int)$this->request->getPost('rules_count')
: 0;
// ---------------------------------------------------------
// 3. Move file to WRITEPATH/uploads/commission/files using user filename
// (no random name as per your requirement)
// ---------------------------------------------------------
$uploadDir = WRITEPATH . 'uploads/commission/files/';
if (!is_dir($uploadDir)) {
if (!mkdir($uploadDir, 0755, true) && !is_dir($uploadDir)) {
throw new \RuntimeException("Failed to create upload directory: {$uploadDir}");
}
}
// sanitize user file name but keep it deterministic (no random, no timestamp)
$safeName = preg_replace('/[^a-zA-Z0-9_\-\.]/', '_', $postedFileName);
// $movedFullPath = $uploadDir . $safeName;
$file->move($uploadDir, $safeName);
$targetFileName = $file->getName();
$movedFullPath = $uploadDir . $targetFileName;
if (!file_exists($movedFullPath)) {
$this->myLogger->logme('error', "RuleImportController::upload - Failed to move uploaded file to {$movedFullPath}");
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to store uploaded file.'], 500);
}
$this->myLogger->logme('info', "RuleImportController::upload - File moved to {$movedFullPath}");
// ---------------------------------------------------------
// 4. Insert commission_files row with status pending
// ---------------------------------------------------------
$insertData = [
'file_name' => $targetFileName,
'insurer_id' => (int)$insurerId,
'department' => $department,
'commission_month' => $commissionMonth,
'rules_count' => 0, // will update on success
'file_status' => $fileStatus, // 'pending' by default
'is_active' => $isActive,
'created_by' => (int)$createdBy,
'created_at' => date('Y-m-d H:i:s'),
];
$this->commissionFilesModel->insert($insertData);
$insertId = $this->commissionFilesModel->getInsertID();
if (empty($insertId)) {
$this->myLogger->logme('error', 'RuleImportController::upload - Failed to insert commission_files record', ['data' => $insertData]);
return $this->respond([
'status' => false,
'code' => 404,
'message' => 'Failed to record upload in database.'
], 200);
}
$this->myLogger->logme('info', "RuleImportController::upload - commission_files inserted id={$insertId}", $insertData);
// ---------------------------------------------------------
// 5. Call ruleImportService->processUpload with inserted file info
// As per your spec:
// $this->ruleImportService->processUpload([
// 'id' => 1,
// 'file_name' => 'sample_commission.csv',
// 'insurer_id' => 5,
// 'department' => 'motor',
// 'commission_month' => '2025-11-10'
// ])
// ---------------------------------------------------------
$payload = [
'id' => (int)$insertId,
'file_name' => $targetFileName,
'insurer_id' => (int)$insurerId,
'department' => $department,
'commission_month' => $commissionMonth,
'created_by' => (int)$createdBy,
];
$this->myLogger->logme('info', 'RuleImportController::upload - Calling ruleImportService->processUpload', ['payload' => $payload]);
$result = $this->ruleImportService->processUpload($payload);
if (!is_array($result) || !isset($result['status'])) {
$this->myLogger->logme('error', 'RuleImportController::upload - Invalid service response', ['response' => $result]);
// update file status as failed
$this->commissionFilesModel->update($insertId, [
'file_status' => 'failed',
'updated_by' => (int)$createdBy,
'updated_at' => date('Y-m-d H:i:s'),
]);
return $this->respond([
'status' => false,
'code' => 404,
'message' => 'Invalid response from import service.'
], 200);
}
// ---------------------------------------------------------
// 6. Handle SUCCESS
// - result['rules'] exists
// - result['errors'] empty
// - NO annotated_file
// - Save rules as JSON in WRITEPATH/uploads/commission/json/{insurer_id}_{department}.json
// ---------------------------------------------------------
if ($result['status'] === 'success') {
$rulesArray = isset($result['rules']) && is_array($result['rules']) ? $result['rules'] : [];
$rulesCount = count($rulesArray);
// Save JSON to WRITEPATH . 'uploads/commission/json/{insurer_id}_{department}.json'
$month_path = strtoupper(date('M', strtotime($commissionMonth))) . date('Y', strtotime($commissionMonth));
$jsonDir = WRITEPATH . 'uploads/commission/rules/'.$month_path . '/';
if (!is_dir($jsonDir)) {
if (!mkdir($jsonDir, 0755, true) && !is_dir($jsonDir)) {
throw new \RuntimeException("Failed to create JSON output directory: {$jsonDir}");
}
}
$this->myLogger->logme('error', 'RuleImportController::jsonDir' . $jsonDir);
$deptSlug = preg_replace('/[^a-zA-Z0-9_\-]/', '_', strtolower($department));
$jsonName = (int)$insurerId . '_' . $deptSlug . '.json';
$jsonPath = $jsonDir . $jsonName;
$jsonData = json_encode($rulesArray, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
if ($jsonData === false) {
$this->myLogger->logme('error', 'RuleImportController::upload - json_encode failed for rules', [
'last_error' => json_last_error_msg()
]);
// mark as failed since we cannot save rules
$this->commissionFilesModel->update($insertId, [
'file_status' => 'failed',
'updated_by' => (int)$createdBy,
'updated_at' => date('Y-m-d H:i:s'),
]);
return $this->respond([
'status' => false,
'code' => 404,
'message' => 'Failed to encode rules as JSON.'
], 200);
}
// handle existing JSON file based on $override (bool)
if (file_exists($jsonPath)) {
if ($overwrite) {
// rename existing file before overwrite
if (file_exists($jsonPath)) {
$backupPath = $jsonPath . '.' . date('YmdHis') . '.bak';
if (!@rename($jsonPath, $backupPath)) {
$this->myLogger->logme(
'warning',
'RuleImportController::upload - Failed to rename existing JSON before overwrite',
[
'json_path' => $jsonPath,
'backup_path' => $backupPath
]
);
// continue anyway; writing to same path will overwrite
}
}
$finalJson = $jsonData;
} else {
// append: merge existing JSON with new JSON data
$existingRaw = @file_get_contents($jsonPath);
if ($existingRaw === false) {
$this->myLogger->logme('warning', 'RuleImportController::upload - Could not read existing JSON, will replace with new data', ['json_path' => $jsonPath]);
$finalJson = $jsonData;
} else {
$existingDecoded = json_decode($existingRaw, true);
$newDecoded = json_decode($jsonData, true);
// if decoding fails, treat as empty array/object and log
if (json_last_error() !== JSON_ERROR_NONE && !is_array($existingDecoded) && !is_object($existingDecoded)) {
$this->myLogger->logme('warning', 'RuleImportController::upload - Existing JSON decode failed; replacing with new data', ['json_path' => $jsonPath, 'json_error' => json_last_error_msg()]);
$finalJson = $jsonData;
} else {
// normalize to PHP arrays for easy merging
if (!is_array($existingDecoded)) {
$existingDecoded = [$existingDecoded];
}
if (!is_array($newDecoded)) {
$newDecoded = [$newDecoded];
}
// merge arrays (preserves numeric keys by reindexing)
$merged = array_merge($existingDecoded, $newDecoded);
$this->myLogger->logme('error', 'RuleImportController::JSON MERGED');
$finalJson = json_encode($merged, JSON_PRETTY_PRINT);
if ($finalJson === false) {
$this->myLogger->logme('error', 'RuleImportController::upload - Failed to encode merged JSON', ['json_path' => $jsonPath, 'merge_count' => count($merged)]);
$this->commissionFilesModel->update($insertId, [
'file_status' => 'failed',
'updated_by' => (int)$createdBy,
'updated_at' => date('Y-m-d H:i:s'),
]);
return $this->respond([
'status' => false,
'code' => 500,
'message' => 'Failed to encode merged rules JSON.'
], 500);
}
}
}
}
} else {
// file doesn't exist, just write new data
$finalJson = $jsonData;
}
// write final JSON to disk with exclusive lock
if (file_put_contents($jsonPath, $finalJson, LOCK_EX) === false) {
$this->myLogger->logme('error', 'RuleImportController::upload - Failed to write rules JSON file', ['json_path' => $jsonPath]);
$this->commissionFilesModel->update($insertId, [
'file_status' => 'failed',
'updated_by' => (int)$createdBy,
'updated_at' => date('Y-m-d H:i:s'),
]);
return $this->respond([
'status' => false,
'code' => 404,
'message' => 'Failed to store rules JSON file.'
], 500);
}
// success continues...
$this->myLogger->logme('info', 'RuleImportController::upload - Rules JSON file written', ['json_path' => $jsonPath, 'overwrite' => (bool)$overwrite]);
$this->myLogger->logme('info', 'RuleImportController::upload - Rules JSON written', [
'file_id' => $insertId,
'json_path' => $jsonPath,
'rules_cnt' => $rulesCount,
]);
// Update DB: status, rules_count, updated_by
$this->commissionFilesModel->update($insertId, [
'file_status' => 'success',
'rules_count' => $rulesCount,
'updated_by' => (int)$createdBy,
'updated_at' => date('Y-m-d H:i:s'),
// If you have a column for JSON path, uncomment:
// 'json_file_path' => $jsonPath,
]);
return $this->respond([
'status' => true,
'code' => 200,
'message' => 'File processed successfully.',
'file_id' => $insertId,
'rules_count' => $rulesCount,
'json_file' => $jsonPath,
'service' => $result, // optional: return full service response if you want
], 200);
}
// ---------------------------------------------------------
// 7. Handle ERROR (validation failed etc.)
// - Do NOT save any rules JSON
// - Update file_status to validation_failed
// - Store annotated_file path if you have such a column
// ---------------------------------------------------------
if ($result['status'] === 'error') {
$annotatedPath = $result['annotated_file'] ?? null;
$errors = $result['errors'] ?? [];
$updateData = [
'file_status' => 'failed',
'rules_count' => 0, // do not save rules
'updated_by' => (int)$createdBy,
'updated_at' => date('Y-m-d H:i:s'),
];
// If you have a column for annotated file path, e.g. annotated_file_path
if ($annotatedPath) {
$updateData['annotated_file_path'] = $annotatedPath;
}
$this->commissionFilesModel->update($insertId, $updateData);
$this->myLogger->logme('error', "RuleImportController::upload - Validation failed for file_id={$insertId}", [
'errors' => $errors,
'annotated_file' => $annotatedPath
]);
return $this->respond([
'status' => false,
'code' => 404,
'message' => 'Validation failed. No rules saved.',
'file_id' => $insertId,
'errors' => $errors,
'annotated_file' => $annotatedPath,
], 422);
}
// ---------------------------------------------------------
// 8. Unexpected status
// ---------------------------------------------------------
$this->myLogger->logme('error', 'RuleImportController::upload - Unexpected result status from service', ['result' => $result]);
$this->commissionFilesModel->update($insertId, [
'file_status' => 'failed',
'updated_by' => (int)$createdBy,
'updated_at' => date('Y-m-d H:i:s'),
]);
return $this->respond([
'status' => false,
'code' => 404,
'message' => $result['message']
], 200);
} catch (\Throwable $ex) {
$this->myLogger->logme('error', 'RuleImportController::upload exception: ' . $ex->getMessage(), [
'trace' => $ex->getTraceAsString()
]);
// Try to update the commission_files record if insertId exists
if (isset($insertId) && !empty($insertId)) {
try {
$this->commissionFilesModel->update($insertId, [
'file_status' => 'failed',
'updated_by' => get_session_userid(),
'updated_at' => date('Y-m-d H:i:s'),
'notes' => 'Upload exception: ' . $ex->getMessage(),
]);
} catch (\Throwable $e2) {
$this->myLogger->logme('error', 'RuleImportController::upload - failed to update commission_files after exception: ' . $e2->getMessage());
}
}
return $this->respond([
'status' => false,
'code' => 500,
'message' => $ex->getMessage(),
], 500);
}
}
public function downloadSampleCommissionFileUploadExcel()
{
$filePath = ROOTPATH . 'public/sample_excel/sample_commission.csv';
// Check if the file exists
if (file_exists($filePath)) {
// Set the appropriate MIME type
$mimeType = mime_content_type($filePath);
// Send the file to the client for download
return $this->response->download($filePath, null, $mimeType);
} else {
// File not found, show an error message or redirect
echo view('errors/html/production');
}
}
public function downloadErrorFile()
{
$file_id = $this->request->getGet('file_id');
$file_data = $this->commissionFilesModel->where('id', $file_id)->where('is_active', 1)->first();
$filePath = WRITEPATH . 'uploads/commission/files/annotated_' . $file_data['file_name'];
// Check if the file exists
if (file_exists($filePath)) {
// Set the appropriate MIME type
$mimeType = mime_content_type($filePath);
// Send the file to the client for download
return $this->response->download($filePath, null, $mimeType);
} else {
// File not found, show an error message or redirect
$data['message'] = 'The Physical File Not Found';
echo view('errors/404', $data);
}
}
public function deleteCommissionData($id)
{
$return = $this->updateCommissionRules($id);
// dd($return);
if($return['status'] == true){
$this->commissionFilesModel->where('id', $id)->set(['is_active' => 0])->update();
return $this->respond(['status' => true, 'code' => 200, 'message' => "File removed successfully"], 200);
}else{
return $this->respond(['status' => false, 'code' => 400, 'message' => "Failed to remove file"], 200);
}
}
public function updateCommissionRules($id, $post_data = null)
{
// 1. Fetch commission record
$commission_data = $this->commissionFilesModel
->where('is_active', 1)
->where('id', $id)
->first();
if (!$commission_data) {
$this->myLogger->logme("error", "Commission record not found for ID: $id");
return ['status' => false, 'message' => 'Commission record not found'];
}
// 2. Convert commission_month → OCT2025
$month = date("M", strtotime($commission_data['commission_month']));
$year = date("Y", strtotime($commission_data['commission_month']));
$monthFolder = strtoupper($month . $year);
// 3. Path
$fileName = $commission_data['insurer_id'] . '_' . $commission_data['department'] . '.json';
$filePath = WRITEPATH . "uploads/commission/rules/" . $monthFolder . "/" . $fileName;
if (!file_exists($filePath)) {
$this->myLogger->logme("error", "Rule file not found: $filePath");
return ['status' => false, 'message' => 'Rule file not found'];
}
// 4. Read JSON
$json = file_get_contents($filePath);
$rules = json_decode($json, true);
// print_rr($rules); die;
if (!is_array($rules)) {
$this->myLogger->logme("error", "Invalid JSON structure in file: $filePath");
return ['status' => false, 'message' => 'Invalid rule file'];
}
// 5. Mark matching rule as deleted
$ruleFound = false;
$log_message = "Rule file updated successfully";
if(empty($post_data)){
foreach ($rules as &$rule) {
if (isset($rule['file_id']) && $rule['file_id'] == $id && isset($rule['is_deleted']) && $rule['is_deleted'] == false) {
$rule['is_deleted'] = true;
$ruleFound = true;
}
}
$log_message = "Rule marked as deleted and file updated successfully";
} else {
foreach ($rules as &$rule) {
// Match rules for the same file and not deleted
if (isset($rule['file_id']) && $rule['file_id'] == $id && $rule['is_deleted'] == false)
{
// 1. DELETE RULE
if (!empty($post_data['rule_id']) && $post_data['rule_id'] == $rule['id'] && isset($post_data['is_deleted']))
{
$rule['is_deleted'] = true;
$ruleFound = true;
break;
}
// 2. UPDATE RULE
if (!empty($post_data['rule_id']) && $post_data['rule_id'] == $rule['id'])
{
$rule['conditions'] = $post_data['rule_data']['conditions'];
$rule['calculation'] = $post_data['rule_data']['calculation'];
$rule['name'] = $post_data['rule_data']['name'];
$ruleFound = true;
break;
}
}
}
// 3. CREATE NEW RULE (only if not found)
if (empty($post_data['rule_id']) && !$ruleFound) {
$newRuleId = 'rule_' . substr(md5(json_encode($post_data['rule_data']) . time()), 0, 13) . '_' . $id . '_' . strtolower($monthFolder);
$newRule = [
'id' => $newRuleId,
'name' => $post_data['rule_data']['name'],
"department" => $post_data['rule_data']['department'] ?? "motor",
'is_deleted' => false,
'file_id' => $id,
'conditions' => $post_data['rule_data']['conditions'],
'calculation' => $post_data['rule_data']['calculation'],
];
$rules[] = $newRule; // correctly push new rule
$ruleFound = true;
}
}
if (!$ruleFound) {
$this->myLogger->logme("error", "No rule found with file_id: $id in file: $filePath");
return ['status' => false, 'message' => 'Rule not found in file'];
}
// 6. Always save file back (No unlink)
file_put_contents($filePath, json_encode($rules, JSON_PRETTY_PRINT));
$this->myLogger->logme("error", $log_message);
return [
'status' => true,
'message' => $log_message
];
}
public function removeCommissionRules($id)
{
// 1. Fetch commission record
$commission_data = $this->commissionFilesModel
->where('is_active', 1)
->where('id', $id)
->first();
if (!$commission_data) {
$this->myLogger->logme("error","Commission record not found for ID: $id");
return ['status' => false, 'message' => 'Commission record not found'];
}
// 2. Convert commission_month → OCT2025
$month = date("M", strtotime($commission_data['commission_month']));
$year = date("Y", strtotime($commission_data['commission_month']));
$monthFolder = strtoupper($month . $year); // OCT2025
// 3. Build file name & path
$fileName = $commission_data['insurer_id'] . '_' . $commission_data['department'] . '.json';
$filePath = WRITEPATH . "uploads/commission/rules/" . $monthFolder . "/" . $fileName;
if (!file_exists($filePath)) {
$this->myLogger->logme("error","Rule file not found: $filePath");
return ['status' => false, 'message' => 'Rule file not found'];
}
// 4. Read file
$json = file_get_contents($filePath);
$rules = json_decode($json, true);
// dd($rules);
if (!is_array($rules)) {
$this->myLogger->logme("error","Invalid JSON structure in file: $filePath");
return ['status' => false, 'message' => 'Invalid rule file'];
}
// 5. Remove rule where file_id == commission_data id
$updatedRules = array_filter($rules, function ($rule) use ($id) {
return isset($rule['file_id']) && $rule['file_id'] != $id;
});
$updatedRules = array_values($updatedRules);
// 6. If empty → delete file
if (empty($updatedRules)) {
unlink($filePath);
$this->myLogger->logme("error","Rule removed. File deleted because no rules left: $filePath");
return [
'status' => true,
'message' => 'Rule deleted and file removed (no rules left)'
];
}
// 7. Write updated JSON
file_put_contents($filePath, json_encode($updatedRules, JSON_PRETTY_PRINT));
$this->myLogger->logme("error","Rule removed successfully and file updated: $filePath");
return [
'status' => true,
'message' => 'Rule removed and file updated successfully'
];
}
public function checkSameEntry()
{
$data = $this->request->getGet();
$commissionMonth = $data['commission_month'] . '-01';
$data['commission_month'] = change_date_format($commissionMonth, 'Y-M-d', 'Y-m-d');
$count = $this->commissionFilesModel->where($data)->where('is_active', 1)->countAllResults();
if($count > 0){
return $this->respond(['status' => true, 'code' => 200, 'data' => $count, 'message' => ""], 200);
}else{
return $this->respond(['status' => false, 'code' => 404, 'data' => $count, 'message' => ""], 200);
}
}
public function ruleList($id)
{
$data['page_name'] = "Rule Manager";
$data['departments'] = $this->departments;
$data['commission_file_id'] = $id;
$data['departmentFields'] = json_encode($this->departmentFields);
$data['rules'] = $this->getRuleJson($id);
return $this->loadLayout('commission_rules_list', $data);
}
public function getRuleJson($id)
{
// 1. Fetch commission record
$commission_data = $this->commissionFilesModel
->where('is_active', 1)
->where('id', $id)
->first();
if (!$commission_data) {
$this->myLogger->logme("error", "Commission record not found for ID: $id");
return [];
}
// 2. Convert commission_month → OCT2025
$month = date("M", strtotime($commission_data['commission_month']));
$year = date("Y", strtotime($commission_data['commission_month']));
$monthFolder = strtoupper($month . $year);
// 3. Path
$fileName = $commission_data['insurer_id'] . '_' . $commission_data['department'] . '.json';
$filePath = WRITEPATH . "uploads/commission/rules/" . $monthFolder . "/" . $fileName;
if (!file_exists($filePath)) {
$this->myLogger->logme("error", "Rule file not found: $filePath");
return [];
}
// 4. Read JSON
$json = file_get_contents($filePath);
$rules = json_decode($json, true);
if(!empty($rules)){
return $rules;
}else{
return [];
}
}
public function saveRule()
{
$post_data = $this->request->getPost();
$file_id = $post_data['file_id'];
$return = $this->updateCommissionRules($file_id, $post_data);
// print_r($return); die;
if(empty($post_data['rule_id'])){
$success_message = "New rule created successfully";
$error_message = "Failed to created the new rule";
}else{
$success_message = "Rule updated successfully";
$error_message = "Failed to update the rule";
}
if($return['status'] == true){
$data = $this->getRuleJson($file_id);
return $this->respond(['status' => true, 'code' => 200, 'data' => $data, 'message' => $success_message], 200);
}else{
return $this->respond(['status' => false, 'code' => 400, 'message' => $error_message], 200);
}
}
public function removeRule()
{
$post_data = $this->request->getPost();
$file_id = $post_data['file_id'];
$return = $this->updateCommissionRules($file_id, $post_data);
// print_r($return); die;
$success_message = "Rule deleted successfully";
$error_message = "Failed to delete the rule";
if($return['status'] == true){
$data = $this->getRuleJson($file_id);
return $this->respond(['status' => true, 'code' => 200, 'data' => $data, 'message' => $success_message], 200);
}else{
return $this->respond(['status' => false, 'code' => 400, 'message' => $error_message], 200);
}
}
public function checkRuleUsage()
{
$rule_id = $this->request->getGet('rule_id');
$count = $this->partnerPolicyModel->where('commission_applied_rule', $rule_id)
->countAllResults();
// $count = 1;
return $this->respond(['status' => true, 'code' => 200, 'count' => $count, 'message' => ""], 200);
}
}

View File

@ -102,16 +102,19 @@ class ThzController extends BaseController
public function ticketList()
{
try {
// try {
$returnType = strtolower($this->request->getGet('return_type') ?? 'api');
$data = $this->request->getGet();
if ($returnType === 'web' && in_array(get_role_id(), [3, 4])) {
if ($returnType === 'web' && in_array(get_role_id(), [4])) {
$data['assign_to'] = $data['assign_to'] ?? get_session_userid();
}
if ($returnType === 'web' && in_array(get_role_id(), [3])) {
$data['clientIds'] = $this->clientModel->getClientIdBasedonLoggedInSessionID();
}
$tickets = $this->fetchTicketsBasedOnrole($data);
@ -124,8 +127,9 @@ class ThzController extends BaseController
} else {
$data['ticket_data'] = $tickets;
$data['assignee'] = $this->userModel->where('is_active', 1)->whereIn('role', ['3', '4'])->findAll();
// enga 5-"head" and 1-"admin" assign pannvaga so dropdown la varakudhathu , 2-"manager l2 " - ivangalum assign pannalam
// 3,4 remain person varannum.
// enga 5-"head" and 1-"admin" assign pannvaga so dropdown la varakudhathu , 2-"manager l2 " - ivangalum assign pannalam. 3,4 remain person varannum dropdown la.
// Roles - 5 (Head) , 1 (Admin) and 2 (Manager) are already assigned to others, so the dropdown should not be shown.
// 3 (Account Manager) and 4 (Staff) should be selectable, so have to show in dropdown .
$data['client_list'] = $this->clientModel->getCreatedByUserName();
$data['ticket_type'] = $this->thzTypeModel->where('is_active', 1)->findAll();
$data['tab_name'] = "Tickets";
@ -138,9 +142,9 @@ class ThzController extends BaseController
'status' => 'success',
'data' => $tickets,
])->setStatusCode(200);
} catch (\Throwable $e) {
return handle_exception($e, $this->myLogger, $this->response);
}
// } catch (\Throwable $e) {
// return handle_exception($e, $this->myLogger, $this->response);
// }
}
public function ticketConversationSave()
@ -348,6 +352,7 @@ class ThzController extends BaseController
// $id = $data['thz_id'] ?? null;
$assign_to = $data['assign_to'] ?? null;
$mobile = $data['mobile'] ?? null;
$clientIds = $data['clientIds'] ?? null;
if (!empty($assign_to)) {
// Tickets assigned to a staff
@ -371,6 +376,17 @@ class ThzController extends BaseController
->findAll();
}
if (!empty($clientIds)) {
return $this->thzMasterModel
->select('thz_master.*, user_profiles.first_name as assignee_name')
->join('user_profiles', 'user_profiles.id = thz_master.assign_to', 'left')
->whereIn('thz_master.client_id', $clientIds)
->orderBy('thz_master.created_at', 'desc')
->findAll();
}
// All tickets (e.g., for managers)
return $this->thzMasterModel
->select('thz_master.*, user_profiles.first_name as assignee_name')

View File

@ -26,6 +26,7 @@ use App\Models\VehicleModel;
use App\Models\PartnerPolicyModel;
use DOMDocument;
use DOMXPath;
use Psr\Log\LoggerInterface;
use Kint\Kint;
@ -1313,7 +1314,7 @@ class TicketController extends BaseController
}
}
public function convertHtmlToText($html)
public function convertHtmlToTextOld($html)
{
if(!empty($html)){
$dom = new DOMDocument();
@ -1324,6 +1325,36 @@ class TicketController extends BaseController
}
}
public function convertHtmlToText($html)
{
if (empty($html)) {
return '';
}
// Remove BOM / strange characters
$html = preg_replace('/[\x00-\x1F\x80-\xFF]/', ' ', $html);
// Load HTML safely
$dom = new DOMDocument();
libxml_use_internal_errors(true);
$dom->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'));
// Remove style and script tags
$xpath = new DOMXPath($dom);
foreach ($xpath->query('//style|//script') as $node) {
$node->parentNode->removeChild($node);
}
// Extract clean text
$text = $dom->textContent;
// Clean extra spaces
$text = preg_replace('/\s+/', ' ', $text);
return trim($text);
}
public function removeTicket()
{
$ticket_id = $this->request->getGet('ticket_id');
@ -2011,6 +2042,7 @@ class TicketController extends BaseController
{
$received_data = $this->request->getPost();
$ticket_type_id = $this->request->getPost('ticket_type_id') ?? null;
$client_id = $this->request->getPost('client_id') ?? null;
$emp_id = $received_data['emp_id'];
// Get all client policy IDs for the given employee
@ -2027,6 +2059,9 @@ class TicketController extends BaseController
$builder->where('e.is_active', 1);
$builder->where('ep.is_active', 1);
$builder->where('e.emp_code', $self_data['emp_code']);
if(!empty($client_id)){
$builder->where('e.client_id', $client_id);
}
$builder->groupBy('client_policy_id');
$query = $builder->get();
@ -2064,7 +2099,7 @@ class TicketController extends BaseController
->join('policy_type', 'policy_type.id = client_policy.policy_type_id AND policy_type.is_active = 1')
->join('insurers', 'insurers.id = client_policy.insurer_id AND insurers.is_active = 1', 'left')
->join('tpa', 'tpa.id = client_policy.tpa_id AND tpa.is_active = 1', 'left')
->where('client_policy.policy_status', 1)
// ->where('client_policy.policy_status', 1)
->whereIn('client_policy.id', $policy_ids)
->findAll();

View File

@ -0,0 +1,55 @@
<?php
namespace App\Filters;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use CodeIgniter\Filters\FilterInterface;
class CommissionApiFilter implements FilterInterface
{
public function before(RequestInterface $request, $arguments = null)
{
// Read API key from header
// $authHeader = $request->getHeaderLine('X');
$authHeader = $_SERVER['REDIRECT_HTTP_AUTHORIZATION'];
// echo $authHeader;die();
if (empty($authHeader)) {
return service('response')->setJSON([
'success' => false,
'error' => 'Authorization header missing'
])->setStatusCode(403);
}
// Expected format: Bearer YOUR_API_KEY
if (stripos($authHeader, 'Bearer ') !== 0) {
return service('response')->setJSON([
'success' => false,
'error' => 'Invalid Authorization format. Expected: Bearer <token>'
])->setStatusCode(403);
}
$apiKey = trim(substr($authHeader, 7)); // extract token after 'Bearer '
$envKeys = getenv('ALLOWED_COMMISSION_API_KEYS');
// Convert CSV -> Array
$allowedKeys = array_map('trim', explode(',', $envKeys));
// print_r($allowedKeys);die();
// Validate
if (!in_array($apiKey, $allowedKeys, true)) {
return service('response')->setJSON([
'success' => false,
'error' => 'Invalid API Key'
])->setStatusCode(403);
}
// Allow request to proceed
return null;
}
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
{
// Not needed
}
}

422
app/Filters/Cors.php Normal file
View File

@ -0,0 +1,422 @@
<?php
namespace App\Filters;
use CodeIgniter\Filters\FilterInterface;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Config\Services;
/**
* CORS (Cross-Origin Resource Sharing) Filter
*
* Handles CORS preflight requests and adds appropriate CORS headers to responses.
* Configurable via environment variables for flexibility across different environments.
*
* @package App\Filters
*/
class Cors implements FilterInterface
{
/**
* List of allowed origins (domains that can access this API)
* Can include wildcards like *.example.com
*
* @var array<string>
*/
protected array $allowedOrigins = [];
/**
* Whether to allow credentials (cookies, authorization headers) in CORS requests
* WARNING: Cannot be true if using wildcard (*) origin
*
* @var bool
*/
protected bool $allowCredentials = false;
/**
* HTTP methods allowed for CORS requests
*
* @var string
*/
protected string $allowedMethods = 'GET,POST,PUT,PATCH,DELETE,OPTIONS';
/**
* HTTP headers allowed in CORS requests
*
* @var string
*/
protected string $allowedHeaders = 'Content-Type,Authorization,X-Requested-With,Accept,Origin';
/**
* Headers exposed to the client (accessible via JavaScript)
*
* @var string
*/
protected string $exposeHeaders = '';
/**
* How long (in seconds) the preflight response can be cached
* Default: 24 hours (86400 seconds)
*
* @var int
*/
protected int $maxAge = 86400;
/**
* Whether to enable debug logging for CORS requests
*
* @var bool
*/
protected bool $debug = false;
/**
* Initialize CORS configuration from environment variables
*
* @throws \RuntimeException If configuration is invalid
*/
protected $myLogger;
public function __construct()
{
$this->myLogger = \Config\Services::mylogger();
// Parse allowed origins from environment variable
// Format: comma or semicolon separated list
// Examples: "https://example.com,https://app.example.com" or "*.example.com"
$raw = env('CORS_ALLOWED_ORIGINS', '*');
$parts = preg_split('/\s*[,;]\s*/', trim($raw));
$this->allowedOrigins = array_filter(array_map('trim', $parts));
// Load other configuration from environment
$this->allowCredentials = filter_var(
env('CORS_ALLOW_CREDENTIALS', false),
FILTER_VALIDATE_BOOLEAN
);
$this->allowedMethods = env('CORS_ALLOWED_METHODS', $this->allowedMethods);
$this->allowedHeaders = env('CORS_ALLOWED_HEADERS', $this->allowedHeaders);
$this->exposeHeaders = env('CORS_EXPOSE_HEADERS', $this->exposeHeaders);
$this->maxAge = (int) env('CORS_MAX_AGE', $this->maxAge);
$this->debug = filter_var(env('CORS_DEBUG', false), FILTER_VALIDATE_BOOLEAN);
// Security validation: wildcard origin cannot be used with credentials
// This is a browser security requirement, not just a best practice
if ($this->allowCredentials && in_array('*', $this->allowedOrigins, true)) {
throw new \RuntimeException(
'CORS configuration error: Cannot use wildcard (*) origin with credentials enabled. ' .
'This violates browser security policies. Either disable credentials or specify explicit origins.'
);
}
$this->log('CORS filter initialized', [
'allowed_origins' => $this->allowedOrigins,
'allow_credentials' => $this->allowCredentials,
'allowed_methods' => $this->allowedMethods,
]);
}
/**
* Check if a given origin is allowed to access this API
*
* Supports:
* - Exact matches: https://example.com
* - Wildcard origins: *.example.com
* - Scheme-less matching: example.com (matches http and https)
* - Universal wildcard: *
*
* @param string|null $origin The Origin header from the request
* @return bool True if origin is allowed, false otherwise
*/
protected function isOriginAllowed(?string $origin): bool
{
// Reject empty origins
if (empty($origin)) {
$this->log('Origin rejected: empty origin header');
return false;
}
// Validate origin format - must include scheme (http:// or https://)
// This prevents malformed origins from being accepted
if (!preg_match('#^https?://#i', $origin)) {
$this->log('Origin rejected: invalid format (missing scheme)', ['origin' => $origin]);
return false;
}
// If wildcard present in configuration, allow any origin
if (in_array('*', $this->allowedOrigins, true)) {
$this->log('Origin allowed: wildcard match', ['origin' => $origin]);
return true;
}
// Parse the host from the origin for wildcard matching
// Example: https://app.example.com:8080 → app.example.com
$originHost = parse_url($origin, PHP_URL_HOST) ?: $origin;
foreach ($this->allowedOrigins as $allowed) {
if ($allowed === '') {
continue;
}
// 1. Exact match (including scheme and port)
// Example: https://example.com matches https://example.com
if (strcasecmp($allowed, $origin) === 0) {
$this->log('Origin allowed: exact match', [
'origin' => $origin,
'matched_rule' => $allowed
]);
return true;
}
// 2. Handle scheme-less and wildcard patterns
// If the allowed entry doesn't contain ://, it's either a host-only or wildcard pattern
if (strpos($allowed, '://') === false) {
// 2a. Wildcard subdomain pattern: *.example.com
// Matches: app.example.com, api.example.com, dev.app.example.com
// Does NOT match: example.com (use explicit entry for root domain)
if (strpos($allowed, '*.') === 0) {
$allowedRoot = substr($allowed, 2); // Remove *. prefix
// Check if origin host ends with the allowed root domain
if ($originHost === $allowedRoot || str_ends_with($originHost, '.' . $allowedRoot)) {
$this->log('Origin allowed: wildcard subdomain match', [
'origin' => $origin,
'matched_rule' => $allowed,
'origin_host' => $originHost
]);
return true;
}
}
// 2b. Direct host match (scheme-less)
// Allows both http and https for the same host
// Example: example.com matches both http://example.com and https://example.com
else {
if (strcasecmp($allowed, $originHost) === 0) {
$this->log('Origin allowed: host match (scheme-less)', [
'origin' => $origin,
'matched_rule' => $allowed,
'origin_host' => $originHost
]);
return true;
}
}
}
}
// No match found - reject this origin
$this->log('Origin rejected: no matching rule', [
'origin' => $origin,
'checked_rules' => $this->allowedOrigins
]);
return false;
}
/**
* Build the Access-Control-Allow-Origin header value
*
* Returns either:
* - '*' if wildcard is configured and credentials are disabled
* - The actual origin value if credentials are enabled or specific origins configured
*
* Note: When credentials are enabled, you MUST echo back the specific origin,
* browsers reject wildcard with credentials.
*
* @param string $origin The validated origin
* @return string The value for Access-Control-Allow-Origin header
*/
protected function buildAllowOriginHeader(string $origin): string
{
// If wildcard configured and credentials NOT required, can safely return '*'
// This allows any origin to access the resource
if (in_array('*', $this->allowedOrigins, true) && !$this->allowCredentials) {
return '*';
}
// Otherwise, must return the specific origin
// This is required when allow-credentials is true
return $origin;
}
/**
* Add all CORS headers to the response
*
* This method is called for both preflight and actual requests
* to ensure consistent CORS headers across all responses.
*
* @param ResponseInterface $response The response object to add headers to
* @param RequestInterface $request The original request
* @param string $origin The validated origin
* @param bool $isPreflight Whether this is a preflight OPTIONS request
* @return void
*/
protected function addCorsHeaders(
ResponseInterface $response,
RequestInterface $request,
string $origin,
bool $isPreflight = false
): void {
// CRITICAL: Vary header prevents caching issues
// Without this, a cached response for origin A might be served to origin B,
// causing CORS errors because the Access-Control-Allow-Origin won't match
$response->setHeader('Vary', 'Origin');
// Set the allowed origin
$allowOrigin = $this->buildAllowOriginHeader($origin);
$response->setHeader('Access-Control-Allow-Origin', $allowOrigin);
// If credentials are allowed, set the header
// This allows cookies, authorization headers, and TLS client certificates
if ($this->allowCredentials) {
$response->setHeader('Access-Control-Allow-Credentials', 'true');
}
// Allowed HTTP methods
$response->setHeader('Access-Control-Allow-Methods', $this->allowedMethods);
// Handle allowed headers
if ($isPreflight) {
// For preflight: respect what the browser is asking for
// The browser sends Access-Control-Request-Headers to ask permission
$requestedHeaders = $request->getHeaderLine('Access-Control-Request-Headers');
$response->setHeader(
'Access-Control-Allow-Headers',
$requestedHeaders ?: $this->allowedHeaders
);
} else {
// For actual requests: use configured headers
// Access-Control-Request-Headers is only for preflight
$response->setHeader('Access-Control-Allow-Headers', $this->allowedHeaders);
}
// Expose additional headers to the client (accessible via JavaScript)
// Without this, only simple headers are accessible: Cache-Control, Content-Language,
// Content-Type, Expires, Last-Modified, Pragma
if (!empty($this->exposeHeaders)) {
$response->setHeader('Access-Control-Expose-Headers', $this->exposeHeaders);
}
// Cache duration for preflight responses
// Reduces preflight requests by allowing browser to cache the permissions
if ($this->maxAge > 0) {
$response->setHeader('Access-Control-Max-Age', (string) $this->maxAge);
}
}
/**
* Execute before the controller
*
* Handles preflight OPTIONS requests by returning early with appropriate headers.
* For other requests, allows them to proceed to the controller.
*
* @param RequestInterface $request The request object
* @param mixed $arguments Optional arguments
* @return ResponseInterface|null Response for preflight, null for other requests
*/
public function before(RequestInterface $request, $arguments = null)
{
$origin = $request->getHeaderLine('Origin') ?: '';
$method = strtoupper($request->getMethod());
// Handle preflight OPTIONS requests
// Preflight is sent by browsers before actual cross-origin requests
// to check if the actual request is safe to send
if ($method === 'OPTIONS') {
$this->log('Preflight request received', [
'origin' => $origin,
'method' => $method,
'uri' => (string) $request->getUri()
]);
// Validate origin - reject if not allowed
if (empty($origin) || !$this->isOriginAllowed($origin)) {
$this->log('Preflight rejected: origin not allowed', ['origin' => $origin]);
// Return 403 Forbidden for rejected origins
// Some prefer 200 with no CORS headers, but 403 is more explicit
return Services::response()
->setStatusCode(403)
->setJSON(['error' => 'Origin not allowed']);
}
// Origin is valid - build preflight response
$response = Services::response();
$this->addCorsHeaders($response, $request, $origin, true);
// 204 No Content is the standard response for successful preflight
// It indicates "permission granted, but no data to return"
$response->setStatusCode(204);
$response->setBody('');
$this->log('Preflight approved', [
'origin' => $origin,
'allowed_methods' => $this->allowedMethods
]);
return $response;
}
// For non-OPTIONS requests, don't return a response
// Let the request proceed to the controller
// CORS headers will be added in after() method
return null;
}
/**
* Execute after the controller
*
* Adds CORS headers to the response for actual (non-preflight) requests.
* This ensures all API responses include proper CORS headers.
*
* @param RequestInterface $request The request object
* @param ResponseInterface $response The response object
* @param mixed $arguments Optional arguments
* @return void
*/
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
{
$origin = $request->getHeaderLine('Origin') ?: '';
// Only add CORS headers if origin is present and allowed
// No origin header means it's a same-origin request (no CORS needed)
if (empty($origin)) {
return;
}
if (!$this->isOriginAllowed($origin)) {
$this->log('Response blocked: origin not allowed', [
'origin' => $origin,
'uri' => (string) $request->getUri()
]);
return;
}
// Add CORS headers to the response
$this->addCorsHeaders($response, $request, $origin, false);
$this->log('CORS headers added to response', [
'origin' => $origin,
'status' => $response->getStatusCode()
]);
}
/**
* Log debug information if debug mode is enabled
*
* Logs to CodeIgniter's log system at 'info' level.
* Enable with CORS_DEBUG=true in .env file.
*
* @param string $message The log message
* @param array $context Additional context data
* @return void
*/
protected function log(string $message, array $context = []): void
{
if (!$this->debug) {
return;
}
// $logger = Services::logger();
$contextString = !empty($context) ? json_encode($context, JSON_UNESCAPED_SLASHES) : '';
$this->myLogger->logme('error','[CORS] ' . $message . ($contextString ? ' | ' . $contextString : ''));
// $logger->info('[CORS] ' . $message . ($contextString ? ' | ' . $contextString : ''));
}
}

View File

@ -318,7 +318,7 @@ class MailHelper
$attachments = isset($params['attachments']) ? $params['attachments'] : [];
$common = isset($params['common']) ? $params['common'] : '';
$bcc = isset($params['bcc']) ? $params['bcc'] : '';
$cc = isset($params['cc']) ? $params['cc'] : '';
$cc = (isset($params['cc']) && !empty($params['cc'])) ? $params['cc'] : '';
$from_address = isset($params['from_mail']) && !empty($params['from_mail']) ? $params['from_mail'] : getenv('email.fromEmail');
// $from_address = "claims@nhanceindia.in";

View File

@ -50,7 +50,6 @@ if (!function_exists('check_columns_name')) {
}
}
if (!function_exists('check_row_is_empty_or_null')) {
function check_row_is_empty_or_null($arr)
@ -89,7 +88,6 @@ if (!function_exists('check_excel_date_format')) {
}
}
if (!function_exists('check_relationship')) {
function check_relationship($row, $relationship, $policy_terms)
{
@ -132,7 +130,6 @@ if (!function_exists('check_relationship')) {
}
}
if (!function_exists('check_doj')) {
function check_doj($row)
@ -179,7 +176,6 @@ if (!function_exists('check_doc')) {
}
}
if (!function_exists('check_employee_band')) {
function check_employee_band($row, $policy_terms, $slab_details)
{
@ -218,7 +214,6 @@ if (!function_exists('check_employee_band')) {
}
}
if (!function_exists('check_si')) {
function check_si($row, $policy_details, $slab_details)
{
@ -326,7 +321,6 @@ if (!function_exists('check_basic_pay')) {
}
}
if (!function_exists('check_dob_diff')) {
function check_dob_diff($row, $relationships, $default_age_ratio, $policy_details)
{
@ -464,8 +458,6 @@ if (!function_exists('check_self_available_in_family')) {
}
}
if (!function_exists('name_and_empid_check_in_db')) {
function name_and_empid_check_in_db($family_data, $actionArr)
{
@ -955,7 +947,6 @@ if (!function_exists('calculate_premium_new')) {
}
}
if (!function_exists('transform_excel_data_to_db')) {
function transform_excel_data_to_db($memArr, $actionArr)
{
@ -1022,12 +1013,15 @@ if (!function_exists('transform_excel_data_to_db')) {
$result['temp']['rata_premimum'] = isset($memArr['temp']['rata_premimum']) ? $memArr['temp']['rata_premimum'] : 0;
$result['policy_details'] = $policy;
if(isset($memArr['self_rata_premium'])){
$result['self_rata_premium'] = $memArr['self_rata_premium'] ?? 0;
}
return $result;
}
}
}
if (!function_exists('premium_calculation_manager')) {
function premium_calculation_manager($emp_data, $policy_terms, $slab_details, $default_si = null)
{
@ -1435,6 +1429,432 @@ if (!function_exists('premium_calculation_manager')) {
}
}
if (!function_exists('premium_calculation_manager_new')) {
function premium_calculation_manager_new($emp_data, $policy_terms, $slab_details, $default_si = null)
{
// dd($emp_data,$policy_terms,$slab_details,$default_si);
$myLogger = \Config\Services::mylogger();
// grid type
// 1 = premium => si
// Kint::dump($emp_data);
//check if the data comes from enrollment (DB) and status is draft then fetch original data of employee from
//audit history table then initiate calculation with it. so this data again get updated in emp table
//check emp records
if ($emp_data['file_id'] == null && $emp_data['temp']['emp_status'] == 'draft' && $emp_data['temp']['policy_status'] == 'draft') {
// $original_emp_records = get_emp_records_from_audit_history($emp_data['temp']['emp_id']);
// if(is_array($original_emp_records))
// {
// // Kint::dump($original_emp_records);
// // $emp_data = replace_original_data(original_data:$original_emp_records,current_data:$emp_data);
// // Kint::dump($value);
// }
}
//check emp policy records
if ($emp_data['file_id'] == null && $emp_data['temp']['emp_status'] == 'draft' && $emp_data['temp']['policy_status'] == 'draft') {
// $original_emp_policy_records = get_emp_policy_records_from_audit_history($emp_data['temp']['emp_policy_id']);
// if(is_array($original_emp_policy_records))
// {
// // Kint::dump($original_emp_records);
// $emp_data['policy_details'] = replace_original_data(original_data:$original_emp_policy_records,current_data:$emp_data['policy_details']);
// // Kint::dump($policy_data);
// }
} //end of fetching data from audit history table
//gird and calculation start
$slug = \Config\Services::slug();
$grid_type = $emp_data['temp']['grid_id'];
$slab_index = isset($emp_data['temp']['grid_name']) ? $emp_data['temp']['grid_name'] : false;
// echo $emp_data['name'];
// kint::dump($slab_index);
if ($slab_index === false) {
// echo 'not set';
return false;
}
$temp_slab_rates = $slab_details[$slab_index]['slab_rates'];
//if curent action is dependent addition OR addition then pull insurer master to set whether add one day from employee date of coverage
if ($emp_data['temp']['action'] == 'DA' || $emp_data['temp']['action'] == 'A') {
$insurer = new InsurerModel();
$insurer = ($insurer->find($policy_terms['insurer_id']));
if (isset($insurer['addition_add_day']) && $insurer['addition_add_day'] == true) {
// $emp_data['policy_details']['date_coverage'] = (new DateTime($emp_data['policy_details']['date_coverage']))->modify('+1 day')->format('Y-m-d');
$emp_data['policy_details']['date_coverage'] = isset($emp_data['policy_details']['date_coverage']) && $emp_data['policy_details']['date_coverage'] != '' && $emp_data['policy_details']['date_coverage'] != null ?
(new DateTime($emp_data['policy_details']['date_coverage']))->modify('+1 day')->format('Y-m-d') : null;
}
}
// dd($emp_data);
$is_match_found = false;
$gst = isset($policy_terms['gst']) && $policy_terms['gst'] != 0 ? $policy_terms['gst'] : 18;
switch ($grid_type) {
case "1":
//GPA - Sum Insured (SI) * Multiplier
$employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si;
$employee_received_band = $emp_data['temp']['band'];
foreach ($temp_slab_rates as $skey => $slab_value) {
if (($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit']) || ($slab_value['grade'] != null && $slab_value['grade'] == $employee_received_band && $slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'])) {
$emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
$emp_data['policy_details']['date_coverage'] = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$emp_data['policy_details']['policy_end_date'] = $policy_terms['policy_end_date'];
$emp_data['policy_details']['days'] = (calculate_days_bw_dates($emp_data['policy_details']['date_coverage'], $policy_terms['policy_end_date'])->days + 1);
$emp_data['policy_details']['premium'] = $slab_value['premium'];
$emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($emp_data['policy_details']['premium'], $emp_data['policy_details']['days'], (calculate_days_bw_dates($policy_terms['policy_start_date'], $policy_terms['policy_end_date'])->days + 1));
$emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * ($gst / 100)), 2, '.', '');
$is_match_found = true;
break;
}
}
//auto calculate of SI and premium for basic pay type
if (!$is_match_found) {
if ($temp_slab_rates[0]['si_or_bp'] == 2) {
$temp_si = $emp_data['basic_pay'] * $temp_slab_rates[0]['basic_multiplier'];
$temp_premium = ($temp_si * $temp_slab_rates[0]['multiplier']) / 1000;
$emp_data['policy_details']['basic_cover_si'] = $temp_si;
$emp_data['policy_details']['date_coverage'] = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$emp_data['policy_details']['policy_end_date'] = $policy_terms['policy_end_date'];
$emp_data['policy_details']['days'] = (calculate_days_bw_dates($emp_data['policy_details']['date_coverage'], $policy_terms['policy_end_date'])->days + 1);
$emp_data['policy_details']['premium'] = $temp_premium;
$emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($emp_data['policy_details']['premium'], $emp_data['policy_details']['days'], (calculate_days_bw_dates($policy_terms['policy_start_date'], $policy_terms['policy_end_date'])->days + 1));
$emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * ($gst / 100)), 2, '.', '');
$is_match_found = true;
$log_message = 'Pre defined SI not found. auto calc SI & premium for -' . $emp_data['emp_code'] . ' - ' . $emp_data['name'] . ' - ' . $temp_si . ' - ' . $temp_premium;
$myLogger->logme('error', $log_message);
}
}
break;
case "2":
//GPA - Flat Rate for all SI
$employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si;
foreach ($temp_slab_rates as $skey => $slab_value) {
if ($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit']) {
$emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
$emp_data['policy_details']['date_coverage'] = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$emp_data['policy_details']['policy_end_date'] = $policy_terms['policy_end_date'];
$emp_data['policy_details']['days'] = (calculate_days_bw_dates($emp_data['policy_details']['date_coverage'], $policy_terms['policy_end_date'])->days + 1);
$emp_data['policy_details']['premium'] = $slab_value['premium'];
$emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($emp_data['policy_details']['premium'], $emp_data['policy_details']['days'], (calculate_days_bw_dates($policy_terms['policy_start_date'], $policy_terms['policy_end_date'])->days + 1));
$emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * ($gst / 100)), 2, '.', '');
$is_match_found = true;
break;
}
}
break;
case "3":
//GMC - SI
$employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si;
foreach ($temp_slab_rates as $skey => $slab_value) {
if ($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit']) {
$emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
$emp_data['policy_details']['date_coverage'] = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$emp_data['policy_details']['policy_end_date'] = $policy_terms['policy_end_date'];
$emp_data['policy_details']['days'] = (calculate_days_bw_dates($emp_data['policy_details']['date_coverage'], $policy_terms['policy_end_date'])->days + 1);
$emp_data['policy_details']['premium'] = $slab_value['premium'];
$emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($emp_data['policy_details']['premium'], $emp_data['policy_details']['days'], (calculate_days_bw_dates($policy_terms['policy_start_date'], $policy_terms['policy_end_date'])->days + 1));
$emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * ($gst / 100)), 2, '.', '');
$is_match_found = true;
break;
}
}
break;
case "4":
//GMC - Employees Age band
$employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si;
// dd($employee_received_si);
$temp_date = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$age = calculate_days_bw_dates(from_date: $emp_data['dob'], to_date: $temp_date)->y;
foreach ($temp_slab_rates as $skey => $slab_value) {
if ($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age)) {
// dd($slab_value);
$emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
$emp_data['policy_details']['date_coverage'] = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$emp_data['policy_details']['policy_end_date'] = $policy_terms['policy_end_date'];
$emp_data['policy_details']['days'] = (calculate_days_bw_dates($emp_data['policy_details']['date_coverage'], $policy_terms['policy_end_date'])->days + 1);
$emp_data['policy_details']['premium'] = $slab_value['premium'];
$emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($emp_data['policy_details']['premium'], $emp_data['policy_details']['days'], (calculate_days_bw_dates($policy_terms['policy_start_date'], $policy_terms['policy_end_date'])->days + 1));
$emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * ($gst / 100)), 2, '.', '');
$emp_data['policy_details']['age_band'] = $slab_value['age_from'] . '-' . $slab_value['age_to'];
$is_match_found = true;
break;
}
}
break;
case "5":
//GMC - Employees Age + SI
$employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si;
$temp_date = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$age = calculate_days_bw_dates(from_date: $emp_data['dob'], to_date: $temp_date)->y;
// kint::dump($age);
foreach ($temp_slab_rates as $skey => $slab_value) {
// dd($slab_value);
if ($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age)) {
$emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
$emp_data['policy_details']['date_coverage'] = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$emp_data['policy_details']['policy_end_date'] = $policy_terms['policy_end_date'];
$emp_data['policy_details']['days'] = (calculate_days_bw_dates($emp_data['policy_details']['date_coverage'], $policy_terms['policy_end_date'])->days + 1);
$emp_data['policy_details']['premium'] = $slab_value['premium'];
$emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($emp_data['policy_details']['premium'], $emp_data['policy_details']['days'], (calculate_days_bw_dates($policy_terms['policy_start_date'], $policy_terms['policy_end_date'])->days + 1));
$emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * ($gst / 100)), 2, '.', '');
$emp_data['policy_details']['age_band'] = $slab_value['age_from'] . '-' . $slab_value['age_to'];
$is_match_found = true;
break;
}
}
break;
case "6":
//GMC - Employees + Dependent Age band
$employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si;
$temp_date = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$age = calculate_days_bw_dates(from_date: $emp_data['dob'], to_date: $temp_date)->y;
foreach ($temp_slab_rates as $skey => $slab_value) {
if ($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age)) {
// echo $emp_data['name']; die;
$emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
$emp_data['policy_details']['date_coverage'] = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$emp_data['policy_details']['policy_end_date'] = $policy_terms['policy_end_date'];
$emp_data['policy_details']['days'] = (calculate_days_bw_dates($emp_data['policy_details']['date_coverage'], $policy_terms['policy_end_date'])->days + 1);
$emp_data['policy_details']['premium'] = $slab_value['premium'];
$emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($emp_data['policy_details']['premium'], $emp_data['policy_details']['days'], (calculate_days_bw_dates($policy_terms['policy_start_date'], $policy_terms['policy_end_date'])->days + 1));
$emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * ($gst / 100)), 2, '.', '');
$emp_data['policy_details']['age_band'] = $slab_value['age_from'] . '-' . $slab_value['age_to'];
$is_match_found = true;
break;
}
}
break;
case "7":
//GMC - Employees + Dependent Age + SI
$employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si;
$temp_date = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$age = calculate_days_bw_dates(from_date: $emp_data['dob'], to_date: $temp_date)->y;
foreach ($temp_slab_rates as $skey => $slab_value) {
if ($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age)) {
$emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
$emp_data['policy_details']['date_coverage'] = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$emp_data['policy_details']['policy_end_date'] = $policy_terms['policy_end_date'];
$emp_data['policy_details']['days'] = (calculate_days_bw_dates($emp_data['policy_details']['date_coverage'], $policy_terms['policy_end_date'])->days + 1);
$emp_data['policy_details']['premium'] = $slab_value['premium'];
$emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($emp_data['policy_details']['premium'], $emp_data['policy_details']['days'], (calculate_days_bw_dates($policy_terms['policy_start_date'], $policy_terms['policy_end_date'])->days + 1));
$emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * ($gst / 100)), 2, '.', '');
$emp_data['policy_details']['age_band'] = $slab_value['age_from'] . '-' . $slab_value['age_to'];
$is_match_found = true;
break;
}
}
break;
case "8":
//GMC - SI as per Grade or Band
$employee_received_band = $emp_data['temp']['band'];
$employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si;
foreach ($temp_slab_rates as $skey => $slab_value) {
if ($slab_value['grade'] == $employee_received_band && $slab_value['unit'] == $emp_data['unit'] && $slab_value['si'] == $employee_received_si) {
// $emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
$emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
$emp_data['policy_details']['date_coverage'] = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$emp_data['policy_details']['policy_end_date'] = $policy_terms['policy_end_date'];
$emp_data['policy_details']['days'] = (calculate_days_bw_dates($emp_data['policy_details']['date_coverage'], $policy_terms['policy_end_date'])->days + 1);
$emp_data['policy_details']['premium'] = $slab_value['premium'];
$emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($emp_data['policy_details']['premium'], $emp_data['policy_details']['days'], (calculate_days_bw_dates($policy_terms['policy_start_date'], $policy_terms['policy_end_date'])->days + 1));
$emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * ($gst / 100)), 2, '.', '');
$is_match_found = true;
break;
}
}
break;
case "9":
//GMC - Flat Rate for all
$employee_received_band = $emp_data['temp']['band'];
$employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si;
foreach ($temp_slab_rates as $skey => $slab_value) {
if ($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit']) {
$emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
$emp_data['policy_details']['date_coverage'] = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$emp_data['policy_details']['policy_end_date'] = $policy_terms['policy_end_date'];
$emp_data['policy_details']['days'] = (calculate_days_bw_dates($emp_data['policy_details']['date_coverage'], $policy_terms['policy_end_date'])->days + 1);
$emp_data['policy_details']['premium'] = $slab_value['premium'];
$emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($emp_data['policy_details']['premium'], $emp_data['policy_details']['days'], (calculate_days_bw_dates($policy_terms['policy_start_date'], $policy_terms['policy_end_date'])->days + 1));
$emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * ($gst / 100)), 2, '.', '');
$is_match_found = true;
break;
}
}
break;
case "10":
//GMC - Maximum age of Dependents
$max_age = $emp_data['temp']['max_age'];
$employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si;
// echo $emp_data['name'].'-'.$employee_received_si.'<br>';
// echo $emp_data['temp']['grid_type'].'<br>';
$emp_data['policy_details']['basic_cover_si'] = null;
foreach ($temp_slab_rates as $skey => $slab_value) {
// echo $slab_value['si'].'-'.$slab_value['age_from'].'-'.$slab_value['age_to'].'-'.$max_age.'<br>';
if (
$slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $max_age && $slab_value['age_to'] >= $max_age)
) {
$emp_data['policy_details']['basic_cover_si'] = $employee_received_si;
$emp_data['policy_details']['date_coverage'] = isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date'];
$emp_data['policy_details']['policy_end_date'] = $policy_terms['policy_end_date'];
$emp_data['policy_details']['days'] = (calculate_days_bw_dates($emp_data['policy_details']['date_coverage'], $policy_terms['policy_end_date'])->days + 1);
$emp_data['policy_details']['premium'] = $slab_value['premium'];
$emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($emp_data['policy_details']['premium'], $emp_data['policy_details']['days'], (calculate_days_bw_dates($policy_terms['policy_start_date'], $policy_terms['policy_end_date'])->days + 1));
$emp_data['policy_details']['gst'] = ((float) number_format(($emp_data['policy_details']['rata_premimum'] * ($gst / 100)), 2, '.', ''));
$emp_data['policy_details']['age_band'] = $slab_value['age_from'] . '-' . $slab_value['age_to'];
$is_match_found = true;
break;
}
}
break;
case "11":
//GMC - Maximum count per Family
$max_count = $emp_data['temp']['max_count'];
$employee_received_band = $emp_data['band'];
// echo $employee_received_band;
$employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si;
$emp_data['policy_details']['basic_cover_si'] = null;
foreach ($temp_slab_rates as $skey => $slab_value) {
if ($slab_value['si'] == $employee_received_si && $slab_value['grade'] == $employee_received_band && $slab_value['unit'] == $emp_data['unit']) {
//calculate premium based on count
// echo $emp_data['name'];
$familiy_si_covered = $employee_received_si * $max_count;
$familiy_si_covered = ($familiy_si_covered >= $slab_value['max_si'] ? $slab_value['max_si'] : $familiy_si_covered);
$emp_data['policy_details']['basic_cover_si'] = $familiy_si_covered;
$emp_data['policy_details']['date_coverage'] = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$emp_data['policy_details']['policy_end_date'] = $policy_terms['policy_end_date'];
$emp_data['policy_details']['days'] = (calculate_days_bw_dates($emp_data['policy_details']['date_coverage'], $policy_terms['policy_end_date'])->days + 1);
$emp_data['policy_details']['premium'] = get_premium_for_si(slab_details: $temp_slab_rates, si_amount: $familiy_si_covered, band: $employee_received_band, unit: $emp_data['unit']);
$emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($emp_data['policy_details']['premium'], $emp_data['policy_details']['days'], (calculate_days_bw_dates($policy_terms['policy_start_date'], $policy_terms['policy_end_date'])->days + 1));
$emp_data['policy_details']['gst'] = ((float) number_format(($emp_data['policy_details']['rata_premimum'] * ($gst / 100)), 2, '.', ''));
$is_match_found = true;
break;
}
}
break;
case "12":
//GMC - Employee + relationship
$employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si;
$employee_relationship = $slug->slugify($emp_data['relationship']);
$employee_relationship = ($employee_relationship == 'daughter' || $employee_relationship == 'son' ? $employee_relationship = 'child' : $employee_relationship);
$emp_data['policy_details']['basic_cover_si'] = null;
foreach ($temp_slab_rates as $skey => $slab_value) {
if ($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && $slab_value['relationship'] == $employee_relationship) {
$emp_data['policy_details']['basic_cover_si'] = $employee_received_si;
$emp_data['policy_details']['date_coverage'] = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$emp_data['policy_details']['policy_end_date'] = $policy_terms['policy_end_date'];
$emp_data['policy_details']['days'] = (calculate_days_bw_dates($emp_data['policy_details']['date_coverage'], $policy_terms['policy_end_date'])->days + 1);
$emp_data['policy_details']['premium'] = $slab_value['premium'];
$emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($emp_data['policy_details']['premium'], $emp_data['policy_details']['days'], (calculate_days_bw_dates($policy_terms['policy_start_date'], $policy_terms['policy_end_date'])->days + 1));
$emp_data['policy_details']['gst'] = ((float) number_format(($emp_data['policy_details']['rata_premimum'] * ($gst / 100)), 2, '.', ''));
$is_match_found = true;
break;
}
}
break;
case "13":
//GMC - Employee + relationship + age
$employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si;
$employee_relationship = $slug->slugify($emp_data['relationship']);
$employee_relationship = ($employee_relationship == 'daughter' || $employee_relationship == 'son' ? $employee_relationship = 'child' : $employee_relationship);
$emp_data['policy_details']['basic_cover_si'] = null;
$temp_date = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$age = calculate_days_bw_dates(from_date: $emp_data['dob'], to_date: $temp_date)->y;
foreach ($temp_slab_rates as $skey => $slab_value) {
if ($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && $slab_value['relationship'] == $employee_relationship) {
$emp_data['policy_details']['basic_cover_si'] = $employee_received_si;
$emp_data['policy_details']['date_coverage'] = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$emp_data['policy_details']['policy_end_date'] = $policy_terms['policy_end_date'];
$emp_data['policy_details']['days'] = (calculate_days_bw_dates($emp_data['policy_details']['date_coverage'], $policy_terms['policy_end_date'])->days + 1);
$emp_data['policy_details']['premium'] = $slab_value['premium'];
$emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($emp_data['policy_details']['premium'], $emp_data['policy_details']['days'], calculate_days_bw_dates($policy_terms['policy_start_date'], $policy_terms['policy_end_date'])->days);
$emp_data['policy_details']['gst'] = ((float) number_format(($emp_data['policy_details']['rata_premimum'] * ($gst / 100)), 2, '.', ''));
$emp_data['policy_details']['age_band'] = $slab_value['age_from'] . '-' . $slab_value['age_to'];
$is_match_found = true;
break;
}
}
break;
default:
$myLogger->logme('error', ($emp_data['emp_code'] . '-' . $emp_data['name'] . ' - grid type not found'));
}
//this if condition for premium calculated & premium type 3 (familiy floater but premium calculated every individual implemented later) then remove si amount only for dependents (not self)
if ($is_match_found && strtolower($emp_data['relationship']) != 'self' && $temp_slab_rates[0]['premium_type'] == 3 && $policy_terms['is_addon'] != 3) {
//set dependent si to 0
$emp_data['policy_details']['basic_cover_si'] = 0;
}
if (!$is_match_found) {
$temp_date = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$age = calculate_days_bw_dates(from_date: $emp_data['dob'], to_date: $temp_date)->y;
$log_message = '[ client_policy_id : ' . $emp_data['policy_details']['client_policy_id'] . ' - ' . $emp_data['emp_code'] . ' - ' . $emp_data['name'] . ' - ' . $emp_data['policy_details']['basic_cover_si'] . ', Age : ' . $age . ' ]';
if ($temp_slab_rates[0]['premium_type'] == 1) {
$log_message .= ' - skipping, calculating only self..!';
//reset emp si and others policy level data if premium only for self
// $emp_data['policy_details']['policy_end_date'] = $policy_terms['policy_end_date'];
$emp_data['policy_details']['basic_cover_si'] = 0;
$emp_data['policy_details']['premium'] = 0;
$emp_data['policy_details']['rata_premimum'] = 0;
$emp_data['policy_details']['gst'] = 0;
$emp_data['policy_details']['days'] = 0;
$emp_data['policy_details']['policy_end_date'] = $policy_terms['policy_end_date'];
} else {
$log_message .= '- skipping, slab rate not found';
}
$myLogger->logme('error', $log_message);
// echo $log_message;
}
// if the family floater case first self add first the process completed, after spouse or any dependent add the rata premium not added this change will handle this
if (strtolower($emp_data['relationship']) != 'self' && $temp_slab_rates[0]['premium_type'] == 1 && $emp_data['temp']['action'] == 'DA') {
//set dependent si to 0
$emp_data['policy_details']['basic_cover_si'] = 0;
$emp_data['policy_details']['premium'] = 0;
if(isset($emp_data['self_rata_premium']) && !empty($emp_data['self_rata_premium'])){
$self_rata_premium = (int)($emp_data['self_rata_premium'] ?? 0);
$dependent_rata_premium = (int)($emp_data['policy_details']['rata_premimum'] ?? 0);
$actual_rata_premium = abs($dependent_rata_premium - $self_rata_premium);
$emp_data['policy_details']['rata_premimum'] = $actual_rata_premium;
$emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * ($gst / 100)), 2, '.', '');
}
}else if(strtolower($emp_data['relationship']) != 'self' && $temp_slab_rates[0]['premium_type'] == 1 && ($emp_data['temp']['action'] == 'I' || $emp_data['temp']['action'] == 'A' || $emp_data['temp']['action'] == 'MI')){
$emp_data['policy_details']['basic_cover_si'] = 0;
$emp_data['policy_details']['premium'] = 0;
$emp_data['policy_details']['rata_premimum'] = 0;
$emp_data['policy_details']['gst'] = 0;
$emp_data['policy_details']['days'] = 0;
$emp_data['policy_details']['policy_end_date'] = $policy_terms['policy_end_date'];
}
return $emp_data;
}
}
if (!function_exists('calculate_pro_rata_premimum')) {
function calculate_pro_rata_premimum($premium, $employee_policy_coverage_days, $policy_coverage_days)
@ -1558,7 +1978,6 @@ if (!function_exists('get_emp_policy_records_from_audit_history')) {
}
}
if (!function_exists('replace_original_data')) {
function replace_original_data(array $original_data, array $current_data)
{
@ -1630,7 +2049,6 @@ if (!function_exists('remap_default_age_ratio_into_relationship')) {
}
}
if (!function_exists('check_dup_mobileno')) {
function check_dup_mobileno(array $row, array $existing_mobilenos)
{
@ -1760,7 +2178,6 @@ if (!function_exists('convert_string_to_date')) {
}
}
if (!function_exists('transform_enrollment_row_to_inception_row')) {
function transform_enrollment_row_to_inception_row($row)
{
@ -1996,7 +2413,6 @@ if (!function_exists('check_unit')) {
}
}
if (!function_exists('transform_si_excel_row_to_calculatable_format')) {
function transform_si_excel_row_to_calculatable_format(array $employee, array $employee_policy, array $maxage_and_maxcount, array $slab_details, string $applicable_slab_name, string $augmented_si, array $grid_master)
{
@ -2456,3 +2872,36 @@ if (!function_exists('is_valid_or_empty_email')) {
}
}
if (!function_exists('validatet_family_floter_rata_premium')) {
function validatet_family_floter_rata_premium($family){
if (count($family) === 2) {
return $family; // skip if only two members
}
$dependentRataGiven = false;
foreach ($family as &$row) {
// Skip if the member is self
if (strtolower($row['relationship']) == 'self') {
continue;
}
// For dependents
if (isset($row['temp']['premium_type']) && $row['temp']['premium_type'] == 1) {
if (!$dependentRataGiven) {
// First eligible dependent keeps premium
$dependentRataGiven = true;
} else {
$row['policy_details']['rata_premimum'] = 0;
$row['policy_details']['gst'] = 0;
}
}
}
return $family;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -90,7 +90,7 @@ class ClientModel extends Model
->join('policy_type pt','client_policy.policy_type_id = pt.id')
->where('client_policy.client_id',$client['id'])
->where('client_policy.is_active', 1)
->where('client_policy.policy_status', 1)
// ->where('client_policy.policy_status', 1)
->findAll();
$client['policies'] = $clientPolicies;
@ -239,5 +239,24 @@ class ClientModel extends Model
return $builder->getNumRows() > 0 ? true : false;
}
public function getClientIdBasedonLoggedInSessionID()
{
$user_id = get_session_userid();
$builder = $this->db->table('client_rm rm')
->select('c.id AS client_id')
->join('clients c', 'c.id = rm.client_id', 'inner')
->where('rm.is_active', 1)
->where('c.is_active', 1)
->where('rm.user_id', $user_id)
->get();
$result = $builder->getResultArray();
$clientIds = !empty($result) ? array_column($result, 'client_id') : [];
// print_r($clientIds);die;
return $clientIds;
}
}

View File

@ -57,6 +57,8 @@ class ClientPolicyModel extends Model
"placement_json",
"policy_entry_from",
"is_from_lead",
"wellness_plan_id",
"wellness_vendor_id",
];
// Callbacks
@ -131,7 +133,7 @@ class ClientPolicyModel extends Model
->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
->join('client_branch', 'client_branch.id = client_policy.client_branch_id')
->where('client_policy.client_id', $client_id)
->where('client_policy.policy_status', 1)
// ->where('client_policy.policy_status', 1)
->where('client_policy.is_active', 1)
->get()
->getResult();

View File

@ -0,0 +1,101 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class CommissionFilesModel extends Model
{
protected $table = 'commission_files';
protected $primaryKey = 'id';
protected $returnType = 'array';
protected $useSoftDeletes = false;
protected $allowedFields = [
'file_name',
'insurer_id',
'department',
'commission_month',
'file_status',
'is_active',
'created_by',
'updated_by',
'rules_count',
];
// Auto timestamps by CI4
protected $useTimestamps = true;
protected $createdField = 'created_at';
protected $updatedField = 'updated_at';
// 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;
}
// Validation rules (optional)
// protected $validationRules = [
// 'file_name' => 'required|min_length[1]|max_length[100]',
// 'insurer_id' => 'permit_empty|integer',
// 'department' => 'permit_empty|max_length[45]',
// 'commission_month' => 'permit_empty|valid_date',
// 'file_status' => 'permit_empty|max_length[10]',
// 'is_active' => 'permit_empty|in_list[0,1]'
// ];
protected $validationMessages = [];
protected $skipValidation = false;
/**
* Get files with optional filters
*/
// public function getFiles($filters = [])
// {
// if (!empty($filters['insurer_id'])) {
// $this->where('insurer_id', $filters['insurer_id']);
// }
// if (!empty($filters['department'])) {
// $this->where('department', $filters['department']);
// }
// if (!empty($filters['file_status'])) {
// $this->where('file_status', $filters['file_status']);
// }
// if (isset($filters['is_active'])) {
// $this->where('is_active', $filters['is_active']);
// }
// return $this->orderBy('id', 'DESC')->findAll();
// }
}

View File

@ -275,8 +275,8 @@ class EmployeeModel extends Model
->join('employee_polices', 'employees.id = employee_polices.employee_id', 'left')
->where('employees.is_active', 1)
->where('employee_polices.is_active', 1)
->where('employees.emp_status', "active")
->where('employee_polices.status', "active")
->whereIn('employees.emp_status', ['active', 'expired'])
->whereIn('employee_polices.status', ['active', 'expired'])
->where('employees.emp_code', $emp_code);
if(!empty($client_id)){

View File

@ -0,0 +1,66 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class InvoiceItemModel extends Model
{
protected $table = 'partner_invoice_items';
protected $primaryKey = 'id';
protected $useAutoIncrement = true;
protected $returnType = 'array';
protected $useSoftDeletes = false;
protected $allowedFields = [
'invoice_id',
'policy_id',
'policy_no',
'commission_amount',
'is_active',
'created_at',
'created_by',
'updated_at',
'updated_by'
];
protected $useTimestamps = false;
protected $createdField = 'created_at';
protected $updatedField = 'updated_at';
protected $validationRules = [
'invoice_id' => 'required|integer',
'policy_id' => 'required|integer',
'policy_no' => 'required|max_length[100]',
'commission_amount' => 'decimal'
];
protected $validationMessages = [];
protected $skipValidation = false;
protected $beforeInsert = ["checkAndAddCreatedByValue"];
protected $beforeUpdate = ["checkAndUpdateUpdatedByValue"];
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;
}
}

256
app/Models/InvoiceModel.php Normal file
View File

@ -0,0 +1,256 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class InvoiceModel extends Model
{
protected $table = 'partner_invoice';
protected $primaryKey = 'id';
protected $useAutoIncrement = true;
protected $returnType = 'array';
protected $useSoftDeletes = false;
protected $allowedFields = [
'invoice_no',
'invoice_amount',
'agent_id',
'invoice_date',
'is_active',
'created_at',
'created_by',
'updated_at',
'payout_status',
];
// Timestamps
protected $useTimestamps = false;
protected $createdField = 'created_at';
protected $updatedField = 'updated_at';
// Validation (optional)
protected $validationRules = [
'invoice_no' => 'required|max_length[100]',
'invoice_amount' => 'decimal',
'agent_id' => 'required|integer',
'invoice_date' => 'required|valid_date',
];
protected $validationMessages = [];
protected $skipValidation = false;
// 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 invoiceList($agent_id = null, $status_id = null, $start_date = null, $end_date = null)
{
$data = $this->select("
partner_invoice.*,
-- Total UTR Amount
(SELECT SUM(piu.amount)
FROM partner_invoice_utr piu
WHERE piu.invoice_id = partner_invoice.id
AND piu.is_active = 1
) AS total_utr_amount,
-- Balance Amount
(partner_invoice.invoice_amount -
IFNULL(
(SELECT SUM(piu2.amount)
FROM partner_invoice_utr piu2
WHERE piu2.invoice_id = partner_invoice.id
AND piu2.is_active = 1
),
0)
) AS balance_amount,
-- Payout status
CASE
WHEN payout_status = 1 THEN 'Pending'
WHEN payout_status = 2 THEN 'Completed'
END AS status_text,
partner_agent.name as agent_name
")
->join('partner_agent', 'partner_invoice.agent_id = partner_agent.id')
->where('partner_invoice.is_active', 1);
if(!empty($agent_id)){
$data->where('partner_invoice.agent_id', $agent_id);
}
if(!empty($status_id)){
$data->where('partner_invoice.payout_status', $status_id);
}
if (!empty($start_date) && !empty($end_date)) {
$startDate = date('Y-m-d 00:00:00', strtotime($start_date));
$endDate = date('Y-m-d 23:59:59', strtotime($end_date));
$data->where('partner_invoice.invoice_date >=', $startDate)
->where('partner_invoice.invoice_date <=', $endDate);
}
if(!empty($agent_id) && !empty($status_id) && !empty($start_date) && !empty($end_date)){
$fromDate = date('Y-m-d', strtotime('-60 days'));
$toDate = date('Y-m-d 23:59:59');
$data->where('partner_invoice.created_at >=', $fromDate)
->where('partner_invoice.created_at <=', $toDate);
}
$return_data = $data->orderBy('partner_invoice.id','desc')->findAll();
// print_r($this->db->getLastQuery()); die;
return $return_data;
}
public function agentList($params = [])
{
if(isset($params['is_active'])){
return $this->db->table('partner_agent')->where('is_active', $params['is_active'])->get()->getResultArray();
}
return $this->db->table('partner_agent')->get()->getResultArray();
}
public function utrSummary($invoice_id)
{
$data = $this->select("
partner_invoice.*,
-- Total UTR Amount
(SELECT SUM(piu.amount)
FROM partner_invoice_utr piu
WHERE piu.invoice_id = partner_invoice.id
AND piu.is_active = 1
) AS total_utr_amount,
-- Balance Amount
(partner_invoice.invoice_amount -
IFNULL(
(SELECT SUM(piu2.amount)
FROM partner_invoice_utr piu2
WHERE piu2.invoice_id = partner_invoice.id
AND piu2.is_active = 1
),
0)
) AS balance_amount,
-- Payout status
CASE
WHEN payout_status = 1 THEN 'Pending'
WHEN payout_status = 2 THEN 'Completed'
END AS status_text,
partner_agent.name as agent_name
")
->join('partner_agent', 'partner_invoice.agent_id = partner_agent.id')
->where('partner_invoice.is_active', 1)
->where('partner_invoice.id', $invoice_id)
->first();
return $data;
}
public function payoutList($flag, $agentId = null, $invoiceId = null)
{
$builder = $this->db->table('policy_transaction pt')
->select('
pt.id,
pt.policy_no AS policyNo,
pt.agent_id AS agentId,
pp.insured_name AS customer,
pp.premium_amount AS premium,
COALESCE(pii.commission_amount, pp.commission_amount) AS commission,
pp.issued_date AS date_db,
DATE_FORMAT(pp.issued_date, "%d/%m/%Y") AS date,
pii.id AS invoiceItemId,
pii.commission_amount as paid_amount,
pi.payout_status,
pp.id as partner_policy_id,
pp.policy_transaction_id
')
->join('partner_invoice_items pii','pii.policy_no = pt.policy_no','left')
->join('partner_invoice pi','pi.id = pii.invoice_id','left')
->join('partner_policy pp','pt.policy_no = pp.policy_number AND pt.agent_id = pp.agent_id AND pt.id = pp.policy_transaction_id')
->where('pt.is_active',1)
->where('pt.agent_id IS NOT NULL');
if ($flag == 1) { // Add mode
// EXCLUDE all policies that exist in partner_invoice_items
$builder->where("pt.id NOT IN (SELECT policy_id FROM partner_invoice_items)", null, false);
}
if ($flag == 2) { // Edit mode
// Policies belonging to a specific invoice
$builder->where('pii.is_active',1);
if ($invoiceId) {
$builder->where('pi.id', $invoiceId); // only policies of this invoice
}
if ($agentId) {
$builder->where('pt.agent_id', $agentId);
}
}
if ($flag == 3) { // Extra policies
// Policies not assigned to any invoice
$builder->where('pii.id IS NULL', null, false);
if ($agentId) {
$builder->where('pt.agent_id', $agentId);
}
}
return $builder->get()->getResultArray();
}
public function agentListById($agentId)
{
return $this->db->table('partner_agent')
->where('id', $agentId)
->where('is_active', 1)
->get()
->getRowArray();
}
}

View File

@ -0,0 +1,73 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class InvoiceUtrModel extends Model
{
protected $table = 'partner_invoice_utr';
protected $primaryKey = 'id';
protected $useAutoIncrement = true;
protected $returnType = 'array';
protected $useSoftDeletes = false;
protected $allowedFields = [
'invoice_id',
'utr_no',
'amount',
'utr_date',
'is_active',
'created_at',
'created_by',
'updated_at',
'updated_by'
];
protected $useTimestamps = false;
protected $createdField = 'created_at';
protected $updatedField = 'updated_at';
protected $validationRules = [
'invoice_id' => 'required|integer',
'utr_no' => 'required|max_length[100]',
'amount' => 'decimal'
];
protected $validationMessages = [];
protected $skipValidation = false;
// 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;
}
}

View File

@ -68,6 +68,7 @@ class PTCOShareDetailsModel extends Model
'non_comm_per_amt',
'cotp_amt',
'cotep_amt',
'pt_policy_issue_date',
];
public function getNonReconcileredPolicyTransactions(string $insurer_id,string $insurer_branch_id)

View File

@ -826,8 +826,16 @@
$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);
// $builder->where('policy_transaction.' . $date_type . '>=', $startDate)
// ->where('policy_transaction.' . $date_type . '<=', $endDate);
if($date_type == "policy_issue_date"){
$builder->where("pt_co_share_details.pt_policy_issue_date >=", $startDate)
->where("pt_co_share_details.pt_policy_issue_date <=", $endDate);
}else{
$builder->where('policy_transaction.' . $date_type . '>=', $startDate)
->where('policy_transaction.' . $date_type . '<=', $endDate);
}
}
// if($date_type == 'statement_month' && $start_date != 0 && $end_date != 0){
@ -1043,8 +1051,18 @@
// Optimize Date Filtering
if (!empty($start_date) && !empty($end_date) && !empty($date_type)) {
$builder->where("policy_transaction.$date_type >=", date('Y-m-d 00:00:00', strtotime($start_date)))
->where("policy_transaction.$date_type <=", date('Y-m-d 23:59:59', strtotime($end_date)));
$startDate = change_date_format($start_date, 'd/m/Y', 'Y-m-d 00:00:00');
$endDate = change_date_format($end_date, 'd/m/Y', 'Y-m-d 23:59:59');
if($date_type == "policy_issue_date"){
$builder->where("pt_co_share_details.pt_policy_issue_date >=", $startDate)
->where("pt_co_share_details.pt_policy_issue_date <=", $endDate);
}else{
$builder->where("policy_transaction.$date_type >=", $startDate)
->where("policy_transaction.$date_type <=", $startDate);
}
}
// Apply Filters Only When Necessary
@ -1080,6 +1098,7 @@
// Optimize Query Execution
$builder->orderBy('policy_transaction.id', 'desc');
$data = $builder->get()->getResultArray();
// dd($this->db->getLastQuery());
return $data;
}
@ -1134,11 +1153,17 @@
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));
$startDate = change_date_format($start_date, 'd/m/Y', 'Y-m-d 00:00:00');
$endDate = change_date_format($end_date, 'd/m/Y', 'Y-m-d 23:59:59');
if($date_type == "policy_issue_date"){
$builder->where("pt_co_share_details.pt_policy_issue_date >=", $startDate)
->where("pt_co_share_details.pt_policy_issue_date <=", $endDate);
}else{
$builder->where('policy_transaction.' . $date_type . '>=', $startDate)
->where('policy_transaction.' . $date_type . '<=', $endDate);
}
$builder->where('policy_transaction.' . $date_type . '>=', $startDate)
->where('policy_transaction.' . $date_type . '<=', $endDate);
} else {
// $fromDate = date('Y-m-d', strtotime('-30 days'));
@ -1177,7 +1202,7 @@
}
$builder->orderBy('policy_transaction.id', 'desc');
// dd($this->db->getLastQuery());
return $builder->get()->getResultArray();
}
@ -1315,8 +1340,17 @@
$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);
// $builder->where('policy_transaction.' . $date_type . '>=', $startDate)
// ->where('policy_transaction.' . $date_type . '<=', $endDate);
if($date_type == "policy_issue_date"){
$builder->where("pt_co_share_details.pt_policy_issue_date >=", $startDate)
->where("pt_co_share_details.pt_policy_issue_date <=", $endDate);
}else{
$builder->where('policy_transaction.' . $date_type . '>=', $startDate)
->where('policy_transaction.' . $date_type . '<=', $endDate);
}
} else {
$fromDate = date('Y-m-d', strtotime('-90 days'));
@ -1356,8 +1390,10 @@
$builder->orderBy('policy_transaction.id', 'desc');
$return_data = $builder->get()->getResultArray();
// dd(db_connect()->getLastQuery());
return $builder->get()->getResultArray();
return $return_data;
}
public function getBusinessReportList($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $status = 0)
@ -1418,8 +1454,16 @@
$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);
// $builder->where('policy_transaction.' . $date_type . '>=', $startDate)
// ->where('policy_transaction.' . $date_type . '<=', $endDate);
if($date_type == "policy_issue_date"){
$builder->where("pt_co_share_details.pt_policy_issue_date >=", $startDate)
->where("pt_co_share_details.pt_policy_issue_date <=", $endDate);
}else{
$builder->where('policy_transaction.' . $date_type . '>=', $startDate)
->where('policy_transaction.' . $date_type . '<=', $endDate);
}
} else {
$fromDate = date('Y-m-d', strtotime('-90 days'));
@ -1521,8 +1565,17 @@
$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);
// $builder->where('policy_transaction.' . $date_type . '>=', $startDate)
// ->where('policy_transaction.' . $date_type . '<=', $endDate);
if($date_type == "policy_issue_date"){
$builder->where("pt_co_share_details.pt_policy_issue_date >=", $startDate)
->where("pt_co_share_details.pt_policy_issue_date <=", $endDate);
}else{
$builder->where('policy_transaction.' . $date_type . '>=', $startDate)
->where('policy_transaction.' . $date_type . '<=', $endDate);
}
} else {
$fromDate = date('Y-m-d', strtotime('-90 days'));
@ -1627,8 +1680,16 @@
$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);
// $builder->where('policy_transaction.' . $date_type . '>=', $startDate)
// ->where('policy_transaction.' . $date_type . '<=', $endDate);
if($date_type == "policy_issue_date"){
$builder->where("pt_co_share_details.pt_policy_issue_date >=", $startDate)
->where("pt_co_share_details.pt_policy_issue_date <=", $endDate);
}else{
$builder->where('policy_transaction.' . $date_type . '>=', $startDate)
->where('policy_transaction.' . $date_type . '<=', $endDate);
}
} else {
$fromDate = date('Y-m-d', strtotime('-90 days'));
$toDate = date('Y-m-d 23:59:59');

View File

@ -12,7 +12,7 @@ class TicketClaimStatusModel extends Model
protected $returnType = 'array';
protected $useSoftDeletes = false;
protected $protectFields = true;
protected $allowedFields = ["id", "ticket_type", "claim_status", "created_by", "updated_by", "is_active"];
protected $allowedFields = ["id", "ticket_type", "claim_status", "display_name", "created_by", "updated_by", "is_active"];
// Callbacks
protected $allowCallbacks = true;

View File

@ -793,7 +793,26 @@ class TicketMasterModel extends Model
//api
public function get_ticket_data($emp_id, $returnType,$ticket_type = null, $ticket_id = null)
{
$query = $this->select('ticket_master.*, tms.mail_subject as subject, tms.id as ticket_message_id')
$query = $this->select("
ticket_master.*,
tms.mail_subject as subject,
tms.id as ticket_message_id,
(
SELECT th1.old_value
FROM ticket_history th1
JOIN ticket_claim_status tcs ON th1.old_value = tcs.id
WHERE th1.field_name = 'claim_status_id'
AND th1.ticket_id = ticket_master.id
AND th1.id = (
SELECT MAX(th2.id)
FROM ticket_history th2
WHERE th2.ticket_id = th1.ticket_id
AND th2.field_name = 'claim_status_id'
)
) AS old_status_id
")
->join('ticket_messages tms', 'ticket_master.id = tms.ticket_id', 'left')
->where('ticket_master.is_active', 1);
$query->whereIn('sender', ['staff', 'user']);

View File

@ -339,6 +339,7 @@ table.dataTable tbody td {
border: 1px solid #ddd; /* matches border-width:1px */
padding: 3px;
}
.dataTables_length label {height: 21px !important;}
</style>
@ -440,7 +441,7 @@ table.dataTable tbody td {
<td class="text-left">
<?php if (!empty($row['created_at'])):
$cd = date("j F Y", strtotime($row['created_at']));
$ct = date("h:i a", strtotime($row['created_at']));
$ct = date("h:i A", strtotime($row['created_at']));
echo $cd . "<br><span class='time'> " . $ct . "</span>";
endif;
?>
@ -448,7 +449,7 @@ table.dataTable tbody td {
<td class="text-left">
<?php if (!empty($row['updated_at'])):
$ud = date("j F Y", strtotime($row['updated_at']));
$ut = date("h:i a", strtotime($row['updated_at']));
$ut = date("h:i A", strtotime($row['updated_at']));
echo $ud . "<br><span class='time'> " . $ut . "</span>";
endif;
?>
@ -858,9 +859,13 @@ table.dataTable tbody td {
table = $('#user-table').DataTable({
scrollX: true,
// dom: "<'row'<'col-sm-3'f><'col-sm-9'B>>" +
// "<'row'<'col-sm-12'tr>>" +
// "<'row'<'col-sm-5'i><'col-sm-7'p>>",
dom: "<'row'<'col-sm-3'f><'col-sm-9'B>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
// {
// extend: 'collection',

View File

@ -16,6 +16,9 @@ table.dataTable thead th {
max-width: 98% !important;
}
.dataTables_length label {height: 21px !important;}
</style>
<div class="row" id="client_list">
@ -36,9 +39,9 @@ table.dataTable thead th {
<table data-custom-table-css="table" class="table mb-0 nowrap w-100 table-centered" cellspacing="0" id="tickets-table">
<thead class="bg-light">
<tr>
<th class="font-weight-medium">Advertisement Image Name</th>
<th class="font-weight-medium">Status</th>
<th class="font-weight-medium">Action</th>
<th class="font-weight-medium"><div class="column-header">Advertisement Image Name</div></th>
<th class="font-weight-medium"><div class="column-header">Status</div></th>
<th class="font-weight-medium"><div class="column-header">Action</div></th>
</tr>
</thead>
@ -222,9 +225,13 @@ var table;
$(document).ready(function() {
table = $('#tickets-table').DataTable({
dom: "<'row'<'col-sm-1'f><'col-sm-11 text-right'B>>" + // Filter left, button right
// dom: "<'row'<'col-sm-1'f><'col-sm-11 text-right'B>>" + // Filter left, button right
// "<'row'<'col-sm-12'tr>>" +
// "<'row'<'col-sm-5'i><'col-sm-7'p>>",
dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
text: '<i class="mdi mdi-plus"></i> <span class="btn-custom">Add</span>',

View File

@ -13,6 +13,7 @@
overflow: hidden;
text-overflow: ellipsis;
}
.dataTables_length label {height: 21px !important;}
</style>
<div class="col-12" id="second_page">
@ -224,9 +225,9 @@
$(document).ready(function() {
$('#datatable-buttons').DataTable({
dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
// dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
// "<'row'<'col-sm-12'tr>>" +
// "<'row'<'col-sm-5'i><'col-sm-7'p>>",
// buttons: [{
// extend: 'csv',
// text: 'CSV',
@ -239,6 +240,10 @@
// left: "50px"
// });
// },
dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [{
extend: 'collection',
text: '<span class=" btn-custom"> Export </span><i class="mdi mdi-menu-down"></i>',

View File

@ -19,6 +19,7 @@
.right-align-input {
text-align: right;
}
.dataTables_length label {height: 21px !important;}
</style>
@ -89,9 +90,13 @@
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
// dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" +
// "<'row'<'col-sm-12'tr>>" +
// "<'row'<'col-sm-5'i><'col-sm-7'p>>",
dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
extend: 'collection',

View File

@ -14,6 +14,8 @@ table.dataTable tbody td {
table[data-custom-table-css="table"].dataTable thead th {
padding-right: 20px !important;
}
.dataTables_length label {height: 21px !important;}
</style>
<div class="col-12" id="inception_list">
@ -117,9 +119,13 @@ $(document).ready(function() {
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
// dom: "<'row'<'col-sm-2'f><'col-sm-10 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
dom: "<'row'<'col-sm-2'f><'col-sm-10 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
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
extend: 'collection',

View File

@ -23,6 +23,7 @@ table.dataTable tbody td {
#scroll-horizontal-datatable tfoot .right-align-input {
text-align: right !important;
}
.dataTables_length label {height: 21px !important;}
</style>
<div class="col-12">
@ -74,9 +75,13 @@ table.dataTable tbody td {
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
// 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
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
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
extend: 'collection',

View File

@ -23,6 +23,7 @@ table.dataTable tbody td {
#scroll-horizontal-datatable tfoot .right-align-input {
text-align: right !important;
}
.dataTables_length label {height: 21px !important;}
</style>
@ -76,9 +77,13 @@ table.dataTable tbody td {
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
// 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
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
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
extend: 'collection',

View File

@ -19,6 +19,7 @@
.right-align-input {
text-align: right;
}
.dataTables_length label {height: 21px !important;}
</style>
@ -91,9 +92,9 @@
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
// dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" +
// "<'row'<'col-sm-12'tr>>" +
// "<'row'<'col-sm-5'i><'col-sm-7'p>>",
// buttons: [
// {
// extend: 'csv',
@ -107,6 +108,10 @@
// },
// ],
dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
extend: 'collection',

View File

@ -43,6 +43,7 @@
color: #16181b !important;
cursor: pointer !important;
}
.dataTables_length label {height: 21px !important;}
</style>
@ -338,9 +339,13 @@
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
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
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
extend: 'collection',

View File

@ -17,6 +17,8 @@ table.dataTable thead th {
max-width: 98% !important;
}
.column-header {margin-right: 10px;}
.custom-dropdown-menu {
display: none;
position: absolute;
@ -49,6 +51,8 @@ table.dataTable thead th {
.dataTables_filter {
position: absolute;
}
.dataTables_length label {height: 21px !important;}
</style>
@ -70,15 +74,15 @@ table.dataTable thead th {
<table data-custom-table-css="table" id="scroll-horizontal-datatable" class="table w-100 nowrap text-custom-black text-custom app-datatable">
<thead class="bg-light">
<tr>
<th class="font-weight-medium">S.No&nbsp;</th>
<th class="font-weight-medium">Client Name&nbsp;</th>
<th class="font-weight-medium">Insurer Name&nbsp;</th>
<th class="font-weight-medium">Insurer Branch Name&nbsp;</th>
<th class="font-weight-medium">Opening Date&nbsp;</th>
<th class="font-weight-medium">CD Account No&nbsp;</th>
<th class="font-weight-medium">Opening Amount&nbsp;</th>
<th class="font-weight-medium">Date/User&nbsp;</th>
<th class="font-weight-medium">Action&nbsp;</th>
<th class="font-weight-medium"> <div class="column-header">S.No&nbsp; </div> </th>
<th class="font-weight-medium"> <div class="column-header">Client Name&nbsp; </div> </th>
<th class="font-weight-medium"> <div class="column-header">Insurer Name&nbsp; </div> </th>
<th class="font-weight-medium"> <div class="column-header">Insurer Branch Name&nbsp; </div> </th>
<th class="font-weight-medium"> <div class="column-header">Opening Date&nbsp; </div> </th>
<th class="font-weight-medium"> <div class="column-header">CD Account No&nbsp; </div> </th>
<th class="font-weight-medium"> <div class="column-header">Opening Amount&nbsp; </div> </th>
<th class="font-weight-medium"> <div class="column-header">Date/User&nbsp; </div> </th>
<th class="font-weight-medium"> <div class="column-header">Action&nbsp; </div> </th>
</tr>
</thead>
<tbody class="app-table-body">
@ -215,9 +219,13 @@ table.dataTable thead th {
$('#scroll-horizontal-datatable').DataTable({
scrollX: true,
dom: "<'row'<'col-sm-2'f><'col-sm-10 text-right'B>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
// dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" +
// "<'row'<'col-sm-12'tr>>" +
// "<'row'<'col-sm-5'i><'col-sm-7'p>>",
dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
text: '<i class="mdi mdi-plus" ></i><span class=" btn-custom"> Add </span>',

View File

@ -21,6 +21,7 @@
position: absolute;
}
.dataTables_length label {height: 21px !important;}
</style>
<!-- <div class="row">
@ -90,7 +91,7 @@
<td style="overflow: hidden;" class="reload truncate" data-toggle="tooltip" data-placement="top" title="<?php echo $file['file_name'] ?>">
<?php echo $file['file_name'] ?>
</td>
<td><?php echo change_date_format($file['created_at'], 'Y-m-d H:i:s', 'd M Y h:i a') . ' by <strong>' . $file['user_name'] . '</strong>' ?> </td>
<td><?php echo change_date_format($file['created_at'], 'Y-m-d H:i:s', 'd M Y h:i A') . ' by <strong>' . $file['user_name'] . '</strong>' ?> </td>
<td>
<?php if ($file['status'] == "failed") { ?>
<span style="color : #BD0707 ;"> <?= $file['status'] ?> </span>
@ -284,9 +285,13 @@
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
// dom: "<'row'<'col-sm-7'f><'col-sm-5 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
dom: "<'row'<'col-sm-7'f><'col-sm-5 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
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
text: 'Add',

View File

@ -56,7 +56,7 @@
<table data-custom-table-css="table" id="scroll-horizontal-datatable" class="table w-100 nowrap">
<thead class="bg-light">
<tr>
<th>S.No&nbsp;</th>
<th class="text-center">S.No&nbsp;</th>
<th>Docs Name&nbsp;</th>
<th>File Name&nbsp;</th>
<th>Action&nbsp;</th>
@ -266,7 +266,7 @@ function create_url_list(data) {
let base_url = "<?php echo base_url() ?>";
if (data && data.length > 0) {
if (data && data.length > 0) {
let html = "";
data.forEach((item, index) => {

View File

@ -18,6 +18,9 @@
#scroll-horizontal-datatable tbody tr:hover {
background-color: #e0e0e0;
}
.dataTables_length label {height: 21px !important;}
</style>
<div class="col-12">
@ -84,9 +87,13 @@
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
// dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" +
// "<'row'<'col-sm-12'tr>>" +
// "<'row'<'col-sm-5'i><'col-sm-7'p>>",
dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
extend: 'collection',

View File

@ -15,6 +15,7 @@
.right-align-input {
text-align: right;
}
.dataTables_length label {height: 21px !important;}
</style>
<div class="col-12">
@ -82,9 +83,13 @@
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
// dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" +
// "<'row'<'col-sm-12'tr>>" +
// "<'row'<'col-sm-5'i><'col-sm-7'p>>",
dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
extend: 'collection',

View File

@ -71,6 +71,9 @@ $(document).ready(function() {
$('#tickets-table').DataTable({
// dom: "<'row'<'col-sm-0'f><'col-sm-9 text-right'B>>",
dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>",
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
extend: 'collection',
@ -103,15 +106,16 @@ $(document).ready(function() {
<div class="datatable-search-wrapper" style="position:relative; display:inline-block;">
_INPUT_
<i class="mdi mdi-magnify datatable-search-icon"
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666;"></i>
style="position:absolute; right:11px; top:50%; transform:translateY(-53%); color:#666;"></i>
<i class="mdi mdi-close-circle datatable-clear-icon"
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666; display:none;"></i>
style="position:absolute; right:11px; top:50%; transform:translateY(-53%); color:#666; display:none;"></i>
</div>`,
searchPlaceholder: "Search",
emptyTable: '<div class="text-center text-muted">No Data found</div>'
},
});
$('.dataTables_length label').css('height', '21px');
})
</script>

View File

@ -65,6 +65,8 @@ table.dataTable thead th {
text-decoration: underline ;
}
.dataTables_length label {height: 21px !important;}
@ -298,10 +300,13 @@ var table;
$(document).ready(function()
{
table = $('#tickets-table').DataTable({
// dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
// "<'row'<'col-sm-12'tr>>" +
// "<'row'<'col-sm-5'i><'col-sm-7'p>>",
dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
text: 'Add From Lead',
@ -344,9 +349,9 @@ $(document).ready(function()
<div class="datatable-search-wrapper" style="position:relative; display:inline-block;">
_INPUT_
<i class="mdi mdi-magnify datatable-search-icon"
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666;"></i>
style="position:absolute; right:11px; top:50%; transform:translateY(-53%); color:#666;"></i>
<i class="mdi mdi-close-circle datatable-clear-icon"
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666; display:none;"></i>
style="position:absolute; right:11px; top:50%; transform:translateY(-53%); color:#666; display:none;"></i>
</div>`,
searchPlaceholder: "Search",
emptyTable: '<div class="text-center text-muted">No Data found</div>'

View File

@ -235,7 +235,7 @@ input:checked + .slider_blue::before {
<div class="form-row" id="third" style="display: none; position: relative;top: 22px;">
<div class="form-group col-md-4">
<label for="cd_ac_no">CD Account Number<span id="tpa_danger" class="text-danger">*</span></label>
<label for="cd_ac_no">CD Account Number<span class="text-danger">*</span></label>
<select class="form-control" id="cd_ac_no" name="cd_ac_no" required>
<option value="">Select CD Account Number</option>
<option value="add_cd">+ Add New CD</option>
@ -243,10 +243,28 @@ input:checked + .slider_blue::before {
</div>
<div class="form-group col-md-4">
<label for="gst_no">GST ( % )<span id="tpa_danger" class="text-danger">*</span></label>
<label for="gst_no">GST ( % )<span class="text-danger">*</span></label>
<input type="text" class="form-control" placeholder="GST (%)" id="gst_no" name="gst" required>
</div>
<div class="form-group col-md-4">
<label for="wellness_plan_id">Wellness Plan ID<span class="text-danger"></span></label>
<input type="text" class="form-control" id="wellness_plan_id" name="wellness_plan_id">
</div>
<div class="form-group col-md-4">
<label for="wellness_vendor_id">Wellness Vendor ID<span class="text-danger"></span></label>
<select class="form-control" id="wellness_vendor_id" name="wellness_vendor_id">
<option value="0">Visit</option>
<?php if(isset($tpa_list)) : ?>
<?php foreach ($tpa_list as $value) { ?>
<option value="<?= $value['id'] ?>">
<?= $value['short_name'] ?></option>
<?php } ?>
<?php endif; ?>
</select>
</div>
<!-- <div class="form-group col-md-4 EB">
<label class="switch" style="position: relative;top: 43px;left: 20px;">
<input id="inception_type" type="checkbox" name="inception_type">
@ -377,6 +395,7 @@ input:checked + .slider_blue::before {
$("#tpa").select2();
$("#base_policy").select2();
$("#client_branch").select2();
$("#wellness_vendor_id").select2();
});
$(document).ready(function() {
@ -541,6 +560,20 @@ input:checked + .slider_blue::before {
searching: true,
autoWidth: false,
responsive: true,
language: {
search: `
<div class="datatable-search-wrapper" style="position:relative; display:inline-block; width:100%;">
_INPUT_
<i class="mdi mdi-magnify datatable-search-icon"
style="position:absolute; right:122px !important; top:50%; transform:translateY(-50%); color:#666;"></i>
<i class="mdi mdi-close-circle datatable-clear-icon"
style="position:absolute; right:122px !important; top:50%; transform:translateY(-50%); color:#666; display:none; cursor:pointer;"></i>
</div>
`,
searchPlaceholder: "Search",
emptyTable: '<div class="text-center text-muted">No Data found</div>'
},
});
@ -949,6 +982,8 @@ input:checked + .slider_blue::before {
$('#reminder_date').val(res.data.reminder_date);
$('#disclaimer').val(res.data.disclaimer);
$('#gst_no').val(gst);
$('#wellness_plan_id').val(res.data.wellness_plan_id);
$('#wellness_vendor_id').val(res.data.wellness_vendor_id ?? 0).select2();
$('#policy_status').val(checkDateStatus(res.data.policy_end_date));
$('#policy_status_field').show();
@ -2522,6 +2557,20 @@ $(document).ready(function () {
searching: true,
autoWidth: false,
responsive: true,
// language: {
// search: `
// <div class="datatable-search-wrapper" style="position:relative; display:inline-block; width:100%;">
// _INPUT_
// <i class="mdi mdi-magnify datatable-search-icon"
// style="position:absolute; right:122px !important; top:50%; transform:translateY(-50%); color:#666;"></i>
// <i class="mdi mdi-close-circle datatable-clear-icon"
// style="position:absolute; right:122px !important; top:50%; transform:translateY(-50%); color:#666; display:none; cursor:pointer;"></i>
// </div>
// `,
// searchPlaceholder: "Search",
// emptyTable: '<div class="text-center text-muted">No Data found</div>'
// },
});

View File

@ -0,0 +1,694 @@
<style>
.table td,
.table th {
padding: 3px 8px !important;
vertical-align: middle;
line-height: 1.2;
}
table.dataTable tbody td {
padding: 4px 4px !important;
}
.highlight {
border: 2px solid red;
background-color: #ffe6e6;
}
.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;
}
table[data-custom-table-css="table"] tbody tr td {
padding: 1px 10px !important;
line-height: 12px;
min-height: 40px;
vertical-align: middle;
}
.reload:hover {
cursor: pointer;
}
.swal-append-btn {
background-color: #007bff !important; /* Blue */
color: #fff !important;
border: none !important;
box-shadow: none !important;
}
</style>
<style>
.switch {
position: relative;
display: inline-block;
width: 54px;
height: 34px;
}
.switch input {
opacity: 0;
width: 0;
height: 0;
}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 19px;
width: 19px;
left: 4px;
bottom: 4px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}
input:checked+.slider {
background-color: #2196F3;
}
input:focus+.slider {
box-shadow: 0 0 1px #2196F3;
}
input:checked+.slider:before {
-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);
transform: translateX(26px);
}
/* Rounded sliders */
.slider.round {
border-radius: 34px;
}
.slider.round:before {
border-radius: 50%;
}
.disabled-option {
color: gray;
}
.custom-dropdown-menu {
display: none;
position: absolute;
background-color: #ffffff !important;
border: 1px solid rgba(0, 0, 0, 0.15);
border-radius: 0.25rem;
padding: 0.5rem 0;
min-width: 10rem;
z-index: 9999;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.custom-dropdown-menu .dropdown-item {
display: block !important;
width: 100% !important;
padding: 0.5rem 1rem !important;
color: #212529 !important;
text-decoration: none !important;
background-color: transparent !important;
}
.custom-dropdown-menu .dropdown-item:hover {
background-color: #f8f9fa !important;
color: #16181b !important;
cursor: pointer !important;
}
.dataTables_length label {height: 21px !important;}
</style>
<div class="row" id="inception_list">
<div class="col-12">
<div class="card">
<div class="card-body">
<div>
<div class="table-responsive">
<table data-custom-table-css="table" class="table table-striped mb-0 nowrap" cellspacing="0" id="tickets-table">
<thead class="bg-light">
<tr>
<th><div class="column-header">S.No.</div></th>
<th><div class="column-header">File Name</div></th>
<th><div class="column-header">Insurer</div></th>
<th><div class="column-header">Commission <br> Month</div></th>
<th><div class="column-header">Department</div></th>
<th><div class="column-header">Rules <br> Count</div></th>
<th><div class="column-header">status</div></th>
<th><div class="column-header">User/Time</div></th>
<th><div class="column-header">Action</div></th>
</tr>
</thead>
<tbody>
<?php if (isset($commission_file_list)) : ?>
<?php foreach ($commission_file_list as $index => $row) { ?>
<tr>
<td class="text-center"><?= $index+1 ?></td>
<td style="overflow: hidden;" class="reload truncate" data-toggle="tooltip" data-placement="top" title="<?php echo $row['file_name'] ?>">
<?php echo $row['file_name'] ?>
</td>
<td><?php echo $row['insurer_name'] ?> </td>
<td><?php echo change_date_format($row['commission_month'], 'Y-m-d', 'M-Y'); ?></td>
<td><?php echo ucfirst($row['department']) ?> </td>
<td><?php echo $row['rules_count'] ?></td>
<td><?php echo ucfirst($row['file_status']) ?> </td>
<td><?php echo change_date_format($row['created_at'],'Y-m-d H:i:s', 'd M Y h:i A') . ' by <strong>' . $row['created_user_name'] . '</strong>' ?>
<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">
<?php if($row['file_status'] == "failed") : ?>
<a href="<?= base_url('commission/downloadErrorFile?file_id=') . $row['id'] ?>" class="dropdown-item" target="_blank"><i class="mdi mdi-download mr-2 text-muted font-18 vertical-middle"></i>Download Error File</a>
<?php endif; ?>
<?php if($row['file_status'] == "success") : ?>
<a href="<?= base_url('commission/rules/list/') . $row['id'] ?>" class="dropdown-item" target="_blank"><i class="mdi mdi-eye mr-2 text-muted font-18 vertical-middle"></i>View Rules</a>
<?php endif; ?>
<a class="dropdown-item btnEdit" data-id="<?= $row['id']; ?>" onclick="deleteCommissionData(<?= $row['id']; ?>)">
<i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete
</a>
</div>
</div>
</td>
</tr>
<?php } ?>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal fade" id="file_upload" 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">Commission File Upload</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="commission_upload_form" enctype="multipart/form-data" action="upload">
<div class="form-group">
<div class="row">
<div class="form-group float-right-end offset-8 col-4">
<span><a href="sample_file" id="download_sample_file" style="font-size: small; color:red !important;">Download sample file</a></span>
</div>
</div>
<div class="row">
<div class="form-group col-md-6">
<label for="insurer"> Insurer <spanclass="text-danger">*</spanclass=></label>
<select class="form-control" id="insurer_id" name="insurer_id" onchange="checkSameEntry(this)" required>
<option value="" selected>Select Insurer</option>
<?php
if (isset($insurers) && count($insurers)) {
foreach ($insurers as $key => $value) {
echo "<option value=" . $value['id'] . ">" . $value['short_name'] . "</option>";
}
}
?>
</select>
</div>
<div class="form-group col-md-6">
<label for="statement_month">Commission Month</label>
<input type="text" class="form-control" id="commission_month" name="commission_month" onchange="checkSameEntry(this)" placeholder="" required readonly>
</div>
</div>
<div class="row">
<div class="form-group col-md-6">
<label for="statement_no">Department</label>
<select class="form-control" id="department" name="department" onchange="checkSameEntry(this)" required>
<option value="" selected>Select Department</option>
<?php
if (isset($departments) && count($departments)) {
foreach ($departments as $key => $value) {
echo "<option value=" . $key . ">" . $value . "</option>";
}
}
?>
</select>
</div>
<div class="form-group col-md-6">
<label for="statment">File</label>
<div class="input-icon">
<input type="file" class="form-control" name="rules_file" required accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,
application/vnd.ms-excel,
application/vnd.oasis.opendocument.spreadsheet,
text/csv"
>
<i class="mdi mdi-upload additional-icon"></i>
</div>
</div>
</div>
</div>
<div class="form-group text-right m-b-0">
<button type="button" class="btn app-btn-outline-secondary mr-2" data-dismiss="modal" aria-hidden="true">Cancel</button>
<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>
let isDublicateFound = false;
// document.addEventListener("DOMContentLoaded", function() {
// const table = document.getElementById("tickets-table");
// // Create custom dropdown
// function createCustomDropdown(row) {
// const originalDropdown = row.querySelector('.dropdown-menu');
// console.log('originalDropdown', originalDropdown)
// if (!originalDropdown) return null;
// const customDropdown = document.createElement('div');
// customDropdown.className = 'custom-dropdown-menu';
// customDropdown.innerHTML = originalDropdown.innerHTML;
// // Remove inline onclick handlers and store them in data attributes
// const originalItems = originalDropdown.querySelectorAll('.dropdown-item');
// customDropdown.querySelectorAll('.dropdown-item').forEach((item, index) => {
// const originalOnclick = originalItems[index].getAttribute('onclick');
// item.removeAttribute('onclick'); // Remove the inline handler
// item.setAttribute('data-onclick', originalOnclick); // Store in data attribute
// });
// return customDropdown;
// }
// let activeDropdown = null;
// // Add click event listener to rows
// table.querySelectorAll("tbody tr").forEach(row => {
// const customDropdown = createCustomDropdown(row);
// if (!customDropdown) return;
// document.body.appendChild(customDropdown);
// row.addEventListener("click", function(event) {
// // Ignore clicks on the first column
// if (event.target.closest('td:first-child')) return;
// if (activeDropdown) activeDropdown.style.display = 'none';
// const rect = event.target.getBoundingClientRect();
// customDropdown.style.display = 'block';
// customDropdown.style.position = 'fixed';
// customDropdown.style.left = `${rect.left}px`;
// customDropdown.style.top = `${rect.bottom + 5}px`;
// activeDropdown = customDropdown;
// event.stopPropagation();
// });
// // Handle custom dropdown clicks
// customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
// item.addEventListener('click', function(e) {
// e.preventDefault();
// // Execute the original onclick from data attribute
// const onclickAttr = this.getAttribute('data-onclick');
// if (onclickAttr) eval(onclickAttr);
// // Handle href navigation
// const href = this.getAttribute('href');
// if (href && href !== '#') window.location.href = href;
// if (activeDropdown) {
// activeDropdown.style.display = 'none';
// activeDropdown = null;
// }
// e.stopPropagation();
// });
// });
// });
// // Close dropdown on outside click
// document.addEventListener("click", function() {
// if (activeDropdown) {
// activeDropdown.style.display = 'none';
// activeDropdown = null;
// }
// });
// });
//datatable
$(document).ready(function() {
table = $('#tickets-table').DataTable({
scrollX: true,
// dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
// "<'row'<'col-sm-12'tr>>" +
// "<'row'<'col-sm-5'i><'col-sm-7'p>>",
dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [{
text: 'Upload <i class="mdi mdi-upload"></i>',
className: 'btn app-btn-primary mr-2', // custom class
action: function(e, dt, node, config) {
showFileUploadModal();
}
},
{
extend: 'collection',
text: '<span class=" btn-custom"> Export </span><i class="mdi mdi-menu-down"></i>',
className: 'btn app-btn-secondary ',
buttons: [
{
extend: 'csv',
text: '<i class="mdi mdi-file-delimited " ></i><span class=" btn-custom"> CSV </span>',
title: 'List',
className: 'app-btn-primary ',
exportOptions: {
columns: ':not(:last-child)'
},
},
{
extend: 'excel',
title: 'List',
text: '<i class="mdi mdi-file-excel " ></i><span class=" btn-custom"> EXCEL </span>',
className: 'app-btn-primary ',
exportOptions: {
columns: ':not(:last-child)'
},
}
]
}
],
language: {
search: `
<div class="datatable-search-wrapper" style="position:relative; display:inline-block;">
_INPUT_
<i class="mdi mdi-magnify datatable-search-icon"
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666;"></i>
<i class="mdi mdi-close-circle datatable-clear-icon"
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666; display:none;"></i>
</div>`,
searchPlaceholder: "Search",
emptyTable: '<div class="text-center text-muted">No Data found</div>'
},
paging: true,
// pagingType: 'full_numbers'
});
$(".datatable-buttons").prepend(`
<span id="statusSwitchWrapper" class="dt-switch-wrapper" style="margin-right: 20px !important;">
<span class="custom-switch" style="text-align: left;">
<input type="checkbox" class="custom-control-input" id="statusSwitch">
<label class="custom-control-label" for="statusSwitch" style="vertical-align: middle !important;">Failed Status</label>
</span>
</span>
`);
})
// others
$(document).ready(function() {
$('#insurer_id').select2();
$('#commission_month').datepicker({
format: 'yyyy-M',
viewMode: 'months',
minViewMode: 'months',
autoclose: true
});
// Add custom filter function to DataTables
$.fn.dataTable.ext.search.push(function(settings, data, dataIndex) {
const showFailedStatus = $('#statusSwitch').is(':checked');
const status = data[6].toLowerCase().trim(); // Index 6 is the file_status column
if (showFailedStatus) {
return status.includes('failed');
} else{
return !status.includes('failed');
}
});
// Add event listener for switch changes
$('#statusSwitch').on('change', function() {
table.draw(); // Redraw the table to apply the filter
});
// Trigger initial filter to show only success status
table.draw();
});
// form submit
$('#commission_upload_form').submit(function(event) {
event.preventDefault();
var isValid = $('#commission_upload_form').parsley().validate();
if (!isValid) {
console.log('Form is Empty', 'Warning');
return;
}
// Create FormData object
var formData = new FormData($(this)[0]);
// FUNCTION to actually submit AJAX
function submitAjax(formData) {
$('#btnSubmit').prop('disabled', true).text('Submitting...');
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
$.ajax({
url: $('#commission_upload_form').attr("action"),
type: "POST",
data: formData,
processData: false,
contentType: false,
headers: {
"X-Requested-With": "XMLHttpRequest"
},
success: function(response) {
console.log(response);
$('#commission_upload_form')[0].reset();
if (response.code === 200 && response.status === true) {
toastr.success('File upload success', 'SUCCESS');
} else if (response.code === 404 && response.status === false) {
toastr.error(response.message, 'FAILED');
} else {
toastr.error('Something went wrong! Try later', 'ERROR');
}
$('.close').click();
$('.loader').fadeOut();
$('.loader-mask').delay(10).fadeOut('slow');
$('#btnSubmit').prop('disabled', false).text('Submit');
window.location.reload(true);
},
error: function(xhr, status, error) {
console.error("Request failed:", status, error);
toastr.error('Something went wrong! Try later', 'ERROR');
$('.close').click();
$('.loader').fadeOut();
$('.loader-mask').delay(10).fadeOut('slow');
$('#btnSubmit').prop('disabled', false).text('Submit');
window.location.reload(true);
}
});
}
// Duplicate check
if (isDublicateFound) {
Swal.fire({
icon: "warning",
title: "Existing rules found for this insurer and month. What would you like to do?",
showDenyButton: true, // For Append
showCancelButton: true, // For Cancel
confirmButtonText: "Overwrite",
denyButtonText: "Append",
cancelButtonText: "Cancel",
confirmButtonColor: "#ff3333",
customClass: {
denyButton: 'swal-append-btn' // Apply CSS class
}
}).then((result) => {
if (result.isConfirmed) {
// Overwrite
formData.append('overwrite', 1);
submitAjax(formData);
isDublicateFound = false;
} else if (result.isDenied) {
// Append
formData.append('overwrite', 0);
submitAjax(formData);
isDublicateFound = false;
} else if (result.dismiss === Swal.DismissReason.cancel) {
// Cancel clicked
console.log("Cancelled");
isDublicateFound = true;
}
});
return;
}
// If no duplicate, submit normally
submitAjax(formData);
});
// open the file upload modal
function showFileUploadModal(input) {
var myModal = new bootstrap.Modal(document.getElementById('file_upload'));
myModal.show();
}
// remove the file entry
function deleteCommissionData(id) {
Swal.fire({
icon: "warning",
title: "Do you want to delete commission & it's data if any?",
html: "<small class='text-danger'>This data cannot be retrieved.</small>",
showCancelButton: true,
confirmButtonText: "Delete",
confirmButtonColor: "#ff3333",
}).then((result) => {
console.log(result);
if (result.isConfirmed) {
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
var apiURL = 'deleteCommissionData/' + id;
$.ajax({
url: apiURL,
method: 'GET',
headers: {
"X-Requested-With": "XMLHttpRequest"
},
success: function(response) {
$('.loader').fadeOut();
$('.loader-mask').delay(10).fadeOut('slow');
if (response.code === 200 && response.status === true) {
Swal.fire({
title: "Deleted!",
icon: "success"
});
window.location.reload(true);
} else {
Swal.fire({
title: "Failed!",
text: 'Something went wrong! Try later',
icon: "error"
});
window.location.reload(true);
}
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(10).fadeOut('slow');
console.error('Error fetching data from API:', error);
toastr.error('Something went wrong! Try later', 'Error');
window.location.reload(true);
}
});
}
});
}
// avoid dublicate entry
function checkSameEntry()
{
let insurer_id = $('#insurer_id').val()
let commission_month = $('#commission_month').val()
let department = $('#department').val()
let url = '<?= base_url('commission/checkSameEntry') ?>';
// Data to send in the AJAX request
let requestData = {
insurer_id: insurer_id,
commission_month: commission_month,
department: department,
};
// Send AJAX request
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
console.log('Data fetched successfully:', response);
if (response.status == true) {
isDublicateFound = true;
}else{
isDublicateFound = false;
}
}, function(xhr, status, error) {
isDublicateFound = false;
console.error('Error fetching data:', error);
console.error(xhr.responseText);
console.log('An error occurred while fetching the data.', 'ERROR');
});
}
</script>

File diff suppressed because it is too large Load Diff

View File

@ -22,6 +22,9 @@
.autocomplete-suggestion:hover {
background-color: #e9e9e9;
}
.dataTables_length label {height: 21px !important;}
</style>
<div class="row">
@ -173,9 +176,13 @@
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
dom: "<'row'<'col-sm-2'f><'col-sm-10 text-right'B>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
// dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
// "<'row'<'col-sm-12'tr>>" +
// "<'row'<'col-sm-5'i><'col-sm-7'p>>",
dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [{
extend: 'collection',
text: '<span class=" btn-custom"> Export </span><i class="mdi mdi-menu-down"></i>',
@ -197,6 +204,20 @@
}],
paging: true,
pageLength: 10,
language: {
search: `
<div class="datatable-search-wrapper" style="position:relative; display:inline-block; width:100%;">
_INPUT_
<i class="mdi mdi-magnify datatable-search-icon"
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666;"></i>
<i class="mdi mdi-close-circle datatable-clear-icon"
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666; display:none; cursor:pointer;"></i>
</div>
`,
searchPlaceholder: "Search",
emptyTable: '<div class="text-center text-muted">No Data found</div>'
},
order: [
[0, 'desc']
]

View File

@ -49,7 +49,7 @@
<table data-custom-table-css="second-table" id="scroll-horizontal-datatable" class="table w-100 nowrap">
<thead class="bg-light">
<tr>
<th>S.No&nbsp;</th>
<th class="text-center">S.No&nbsp;</th>
<th>Docs Name&nbsp;</th>
<th>File Name&nbsp;</th>
<th>Action&nbsp;</th>

View File

@ -76,6 +76,9 @@
border-radius: 5px;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
}
.dataTables_length label {height: 21px !important;}
</style>
<?php $pro_rata_total = 0; $gst_total = 0 ?>
@ -341,9 +344,13 @@
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
// 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
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
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
extend: 'collection',

View File

@ -12,6 +12,8 @@
position: relative;
left: 79px;
}
.dataTables_length label {height: 21px !important;}
</style>
<div class="container-fluid-min">
@ -594,9 +596,13 @@
$(document).ready(function() {
$('#tickets-table').DataTable({
// dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
// "<'row'<'col-sm-12'tr>>" +
// "<'row'<'col-sm-5'i><'col-sm-7'p>>",
dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [{
text: '<i class="mdi mdi-plus" ></i><span class=" btn-custom"> Add </span>',
className: 'btn app-btn-primary mr-2',

43
app/Views/fedeploy.php Normal file
View File

@ -0,0 +1,43 @@
<form action="<?= base_url('fedeploy'); ?>" method="post" enctype="multipart/form-data">
<!-- Single zip upload -->
<div>
<label for="zip_file">Zip File</label>
<input type="file" name="zip_file" id="zip_file" required>
</div>
<div>
<label for="zip_folder">Zip Folder (inside zip to deploy)</label>
<select name="zip_folder" id="zip_folder">
<option value="web/">web/</option>
<option value="dist/">dist/</option>
</select>
</div>
<div>
<label for="s3_bucket">S3 Bucket</label>
<select name="s3_bucket" id="s3_bucket">
<option value="benefits-app-bucket">benefits-app-bucket</option>
<option value="other-bucket">other-bucket</option>
</select>
</div>
<div>
<label for="s3_prefix">S3 Prefix</label>
<input type="text" name="s3_prefix" id="s3_prefix" value="hr/">
</div>
<div>
<label for="cf_distribution_id">CloudFront Distribution ID (optional)</label>
<input type="text" name="cf_distribution_id" id="cf_distribution_id" value="E1MKRK4U5MZ3BD">
</div>
<div>
<label for="cf_paths">
CloudFront Invalidation Paths (comma or newline separated, e.g. <code>/hr/*,/hr/special/*</code>)
</label>
<input type="text" name="cf_paths" id="cf_paths" value="/hr/*">
<!-- If you prefer multi-line, use <textarea> instead of <input> -->
</div>
<button type="submit">Deploy</button>
</form>

View File

@ -8,6 +8,9 @@
cursor: pointer;
}
.dataTables_length label {height: 21px !important;}
</style>
<div class="col-12">
@ -461,12 +464,16 @@ $(document).ready(function() {
$('#tickets-table').DataTable({
dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
// dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
// "<'row'<'col-sm-12'tr>>" +
// "<'row'<'col-sm-5'i><'col-sm-7'p>>",
dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [{
extend: 'collection',
text: '<span class=" btn-custom"> Export </span><i class="mdi mdi-menu-down"></i>',

View File

@ -43,6 +43,8 @@
color: #16181b !important;
cursor: pointer !important;
}
.dataTables_length label {height: 21px !important;}
</style>
@ -336,10 +338,14 @@ $(document).ready(function () {
if (ticketsTable.length) {
ticketsTable.DataTable({
dom:
"<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // Filter left, buttons right
// 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
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
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
extend: 'collection',

View File

@ -47,6 +47,8 @@ table.dataTable tbody td {
#hr_activity_history_append_area tbody tr {
background-color: transparent !important;
}
.dataTables_length label {height: 21px !important;}
</style>
@ -98,12 +100,26 @@ $(document).ready(function () {
var table = ticketsTable.DataTable({
scrollX: true,
// dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
// "<'row'<'col-sm-12'tr>>" +
// "<'row'<'col-sm-5'i><'col-sm-7'p>>",
dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
language: {
search: "_INPUT_",
searchPlaceholder: "Search..."
search: `
<div class="datatable-search-wrapper" style="position:relative; display:inline-block; width:100%;">
_INPUT_
<i class="mdi mdi-magnify datatable-search-icon"
style="position:absolute; right:122px !important; top:50%; transform:translateY(-50%); color:#666;"></i>
<i class="mdi mdi-close-circle datatable-clear-icon"
style="position:absolute; right:122px !important; top:50%; transform:translateY(-50%); color:#666; display:none; cursor:pointer;"></i>
</div>
`,
searchPlaceholder: "Search",
emptyTable: '<div class="text-center text-muted">No Data found</div>'
},
paging: true,
pageLength: 10,

View File

@ -3,6 +3,8 @@
padding: 5px 7px 5px 0 !important;
color: #000000;
}
.dataTables_length label {height: 21px !important;}
</style>
<div class="tab-pane fade" id="HR-DOC-tab">
@ -143,7 +145,7 @@
<td><?php echo $file['branch_name'] ?></td>
<td><?php echo $file['policy_no'] ?></td>
<td><?php echo $file['file_action'] ?></td>
<td><?php echo change_date_format($file['created_at'],'Y-m-d H:i:s', 'd M Y h:i a') . ' by <strong>' . $file['first_name'] . '</strong>' ?></td>
<td><?php echo change_date_format($file['created_at'],'Y-m-d H:i:s', 'd M Y h:i A') . ' by <strong>' . $file['first_name'] . '</strong>' ?></td>
<td><?php echo $file['status']; ?> </td>
<td> </td>
</tr>
@ -356,9 +358,13 @@
// for datatable
$(document).ready(function() {
$('#hr_tickets_table').DataTable({
// dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
// "<'row'<'col-sm-12'tr>>" +
// "<'row'<'col-sm-5'i><'col-sm-7'p>>",
dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [{
extend: 'collection',
text: '<span class=" btn-custom"> Export </span><i class="mdi mdi-menu-down"></i>',

View File

@ -37,6 +37,9 @@
color: white;
border: 1px solid rgba(41, 139, 142, 1);
}
.dataTables_length label {height: 21px !important;}
</style>
<div class="container-fluid-min">
@ -182,9 +185,13 @@
$(document).ready(function() {
$('#tickets-table').DataTable({
// dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
// "<'row'<'col-sm-12'tr>>" +
// "<'row'<'col-sm-5'i><'col-sm-7'p>>",
dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
text: '<i class="mdi mdi-plus" ></i><span class=" btn-custom"> Add </span>',

View File

@ -164,6 +164,15 @@
margin-left: 5px;
border-radius: 6px;
}
th.no-sort {
pointer-events: none; /* disable click */
}
th.no-sort:before,
th.no-sort:after {
display: none !important; /* hide DataTables sorting arrows */
}
</style>
<div class="container-fluid-min">
<div class="row" id="inception_list">
@ -205,11 +214,12 @@
</div>
<div class="dataTables_length d-flex align-items-center">
</div>
<div>
<div class="table-responsive">
<table data-custom-table-css="table" class="table table-striped mb-0 nowrap" cellspacing="0" id="tickets-table">
<thead class="bg-light">
<tr>
<th></th>
<th class="no-sort"></th>
<th>
<div class="column-header">Insurer</div>
</th>
@ -269,7 +279,7 @@
</span>
</td>
<td><?php echo change_date_format($row['created_at'], 'Y-m-d H:i:s', 'd M Y h:i a') . ' <br> by ' . $row['first_name'] ?></td>
<td><?php echo change_date_format($row['created_at'], 'Y-m-d H:i:s', 'd M Y h:i A') . ' <br> by ' . $row['first_name'] ?></td>
<td>
<?php if ($row['file_status'] != 'failed') { ?>
<div class="btn-group dropdown">
@ -1734,9 +1744,24 @@
"order": [], // Disable initial sorting if needed
"pageLength": 10,
// "dom": '<"top"lf>rt<"bottom"ip><"clear">', // This places length and filter controls at top
"language": {
"lengthMenu": "Show _MENU_ entries",
"search": "Search:"
// "language": {
// "lengthMenu": "Show _MENU_ entries",
// "search": "Search:"
// }
language: {
lengthMenu: "Show _MENU_ entries",
search: `
<div class="datatable-search-wrapper" style="position:relative; display:inline-block; width:100%;">
_INPUT_
<i class="mdi mdi-magnify datatable-search-icon"
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666;"></i>
<i class="mdi mdi-close-circle datatable-clear-icon"
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666; display:none; cursor:pointer;"></i>
</div>
`,
searchPlaceholder: "Search",
emptyTable: '<div class="text-center text-muted">No Data found</div>'
}
});

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,609 @@
<style>
/* ---- CSS cleaned/optimized ---- */
.table th, .table td { padding: 8px; }
table.dataTable tbody td { padding: 4px 4px !important; }
.col-12 { max-width: 98% !important; }
.dataTables_filter { position: absolute; }
.column-header { margin-right: 10px; }
.filter-inline { display: flex; align-items: center; gap: 10px; }
.filter-inline input[type="date"] { padding: 8px 12px; border:1px solid #ddd; border-radius:4px; font-size:13px; background:white; cursor:pointer; }
.filter-inline input[type="date"]:focus { outline:none; border-color:#00a9a3; }
.icon-btn { width:36px; height:36px; border:1px solid #ddd; background:white; border-radius:4px; cursor:pointer; display:flex; align-items:center; justify-content:center; transition:all 0.2s; }
.icon-btn:hover { background:#f5f5f5; border-color:#00a9a3; }
.icon-btn svg { width:18px; height:18px; fill:#666; }
.icon-btn:hover svg { fill:#00a9a3; }
.policy-list { border:1px solid #e0e0e0; border-radius:4px; overflow:hidden; margin-top:0; }
.policy-header { background:#f8f9fa; padding:12px 15px; font-weight:600; border-bottom:1px solid #e0e0e0; display:flex; align-items:center; font-size:14px; }
.policy-header input[type="checkbox"] { width:18px; height:18px; margin-right:10px; cursor:pointer; }
.policy-item { border-bottom:1px solid #e0e0e0; padding:12px 15px; display:flex; align-items:center; background:white; transition:background 0.2s; }
.policy-item:hover { background:#f9f9f9; }
.policy-item:last-child { border-bottom:none; }
.policy-item.selected { background:#e8f5f4; }
.policy-checkbox { width:18px; height:18px; margin-right:15px; cursor:pointer; }
.policy-info { flex:1; display:flex; justify-content:space-between; align-items:center; }
.policy-details { flex:1; }
.policy-number { font-weight:600; color:#333; margin-bottom:4px; font-size:14px; }
.policy-meta { color:#666; font-size:13px; }
.policy-amount { font-size:16px; font-weight:600; color:#00a9a3; margin-left:20px; }
.badge { display:inline-block; padding:4px 10px; border-radius:12px; font-size:12px; font-weight:600; margin-left:10px; }
.badge-selected { background:#00a9a3; color:white; }
.summary-bar { position:fixed; bottom:0; left:0; right:0; width:100%; background:white; border-top:2px solid #00a9a3; padding:15px 30px; display:none; box-shadow:0 -2px 10px rgba(0,0,0,0.1); z-index:100; }
.summary-bar.show { display:flex; justify-content:flex-start; align-items:center; }
.summary-info { margin-left:auto; margin-right:0; display:flex; gap:40px; align-items:center; }
.summary-item { display:flex; flex-direction:column; }
.summary-label { font-size:12px; color:#666; margin-bottom:2px; }
.summary-value { font-size:18px; font-weight:600; color:#00a9a3; }
.summary-actions { display:flex; gap:10px; margin-left:auto; }
.btn-icon { background:#008b8b; border:none; border-radius:50%; width:32px; height:32px; display:flex; align-items:center; justify-content:center; cursor:pointer; }
.btn-icon i { color:#fff !important; font-size:18px; }
.btn-icon:hover { background:#00a3a3; }
/* Responsive */
@media (max-width:1024px){ .filter-inline{flex-wrap:wrap;} .filter-inline input[type="date"]{font-size:12px;padding:6px 8px;} }
@media (max-width:768px){
.section-header{flex-direction:column;gap:10px;align-items:flex-start;}
.header-right{width:100%;justify-content:space-between;}
.filter-inline{flex:1;}
.summary-bar{left:0;flex-direction:column;gap:15px;padding:15px;}
.summary-info{width:100%;justify-content:space-around;}
.summary-actions{width:100%;}
}
.dataTables_length label {height: 21px !important;}
</style>
<!-- ---- HTML structure remains mostly same ---- -->
<div class="row" id="invoices_details">
<div class="col-12">
<div id="invoices_accordion" class="ml-3">
<div class="card mb-1">
<h4 class="m-1">
<a href="#" onclick="history.back(); return false;">
<i style="font-size: 18px;" class="mdi mdi-chevron-left" title="Back"></i>
</a>
<span>Invoice Details</span>
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseOne"
aria-expanded="true">
<i id="icon" class="mdi mdi-chevron-down mr-1 text-primary" style="font-size: 28px;"></i>
</a>
</h4>
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#invoices_accordion">
<div class="card-body" style="padding-bottom: unset;">
<div class="form-row">
<div class="form-group col-md-3">
<label>Invoice Number </label>
<input class="form-control" type="text" id="invoiceNo" placeholder="Auto-generated" readonly>
</div>
<div class="form-group col-md-3">
<label>Invoice Date <span class="text-danger"></span></label>
<input class="form-control" type="date" id="invoiceDate" required value="" >
</div>
<div class="form-group col-md-3">
<label for="agents"> Agents <span class="text-danger"></span></label>
<select class="form-control" id="agentSelect" name="agents_id" onchange="loadPolicies(); generateInvoiceNumberAjaxCall();" required autocomplete="off">
<option value="">Select Agent</option>
<?php
if(isset($agents) && count($agents)) {
foreach($agents as $agent): ?>
<option value="<?= $agent['id'] ?>">
<?= $agent['name'] ?> - <?= $agent['agent_code'] ?>
</option>
<?php endforeach;
}
?>
</select>
</div>
<div class="form-group col-md-3">
<label>Policy Till Date<span class="text-danger"></span></label>
<input class="form-control" type="date" id="policyTillDate" required onchange="loadPolicies()" max="<?= date('Y-m-d') ?>" >
</div>
<div class="form-group col-md-3">
<input class="form-control" type="hidden" id="invoiceID" required value="<?= isset($invoice['id']) ? $invoice['id'] : '' ?>" >
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row" id="payouts_details">
<div class="col-12">
<div id="policy_accordion" class="ml-3">
<div class="card mb-1">
<div class="row align-items-center m-1" id="policy_filter">
<div class="col d-flex align-items-center">
<h4 class="mb-0">
Policy Selection
<span id="selectedCount" class="badge badge-selected" style="display:none;">0 selected</span>
</h4>
</div>
<div class="col-auto d-flex align-items-center">
<!-- <input type="date" class="form-control mr-2" id="fromDate" placeholder="From Date" title="From Date" style="width:170px;" autocomplete="off">
<input type="date" class="form-control mr-2" id="toDate" placeholder="To Date" title="To Date" style="width:170px;" autocomplete="off">
<button type="button" class="btn-icon mr-1" title="Reset Filters" onclick="resetFilters()"><i class="mdi mdi-refresh"></i></button>
<button type="button" class="btn-icon mr-1" title="Search" onclick="searchPolicies()"><i class="mdi mdi-magnify"></i></button> -->
</div>
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseTwo" aria-expanded="true">
<i id="icon" class="mdi mdi-chevron-down mr-1 text-primary" style="font-size: 28px;"></i>
</a>
</div>
<div id="collapseTwo" class="collapse show" aria-labelledby="headingTwo" data-parent="#policy_accordion">
<div class="card-body" style="padding-top: unset !important; border: white !important; background: unset !important;">
<div>
<div>
<table data-custom-table-css="table" class="table table-striped mb-0 nowrap" cellspacing="0" id="tickets-table">
<thead class="bg-light">
<tr>
<th style="text-align:center;"><input type="checkbox" class="CB" id="selectAll" onchange="toggleSelectAll(this)"></th>
<th><div class="column-header">Policy No</div></th> <!-- 2 -->
<th><div class="column-header">Customer</div></th> <!-- 3 -->
<th><div class="column-header">Premium</div></th> <!-- 4 -->
<th><div class="column-header">Policy Issues Date</div></th> <!-- 5 -->
<th><div class="column-header">Commission Amount</div></th> <!-- 6 -->
</tr>
</thead>
<tbody id="ticketListBody">
</tbody>
</table>
</div>
<div id="summaryBar" class="summary-bar">
<div class="summary-info">
<div class="summary-item">
<span class="summary-label">Selected Policies</span>
<span class="summary-value" id="totalPolicies">0</span>
</div>
<div class="summary-item">
<span class="summary-label">Total Commission</span>
<span class="summary-value" id="totalAmount">₹0.00</span>
</div>
</div>
<div class="summary-actions">
<button type="button" class="btn app-btn-outline-primary C" onclick="clearSelection()">Clear</button>
<button type="button" class="btn app-btn-secondary S" onclick="saveInvoice()">Submit</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div><!-- end col -->
</div>
<script>
let selectedPolicies = new Set();
let filteredPolicies = [];
let allPolicies = <?php echo json_encode($payouts); ?> || [];
// Helper
function getEl(id) { return document.getElementById(id); }
$(document).ready(function(){
// Initialize Select2
if ($('#agentSelect').select2) $('#agentSelect').select2();
// Clear fields without triggering change
$("#invoiceNo").val("");
$("#agentSelect").val(""); // do NOT trigger change
// Set max dates for date fields
const today = new Date().toISOString().split("T")[0];
if (getEl('invoiceDate')) getEl('invoiceDate').max = today;
if (getEl('policyTillDate')) getEl('policyTillDate').max = today;
if (getEl('invoiceDate')) getEl('invoiceDate').valueAsDate = new Date();
if (getEl('policyTillDate')) getEl('policyTillDate').valueAsDate = new Date();
// Initial empty DataTable so buttons/search are available even before loading policies
if ($.fn.DataTable.isDataTable('#tickets-table')) {
$('#tickets-table').DataTable().clear().destroy();
}
$('#tickets-table').DataTable({
dom:
"<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
extend: 'collection',
text: '<span class=" btn-custom"> Export </span><i class="mdi mdi-menu-down"></i>',
className: 'btn app-btn-secondary ',
buttons: [
{
extend: 'csv',
text: '<i class="mdi mdi-file-delimited"></i><span class="btn-custom"> CSV </span>',
className: 'app-btn-primary',
title: getExportFileName(),
exportOptions: {columns: ':not(:first-child)'}
},
{
extend: 'excel',
text: '<i class="mdi mdi-file-excel"></i><span class="btn-custom"> EXCEL </span>',
className: 'app-btn-primary',
title: getExportFileName(),
filename: getExportFileName(),
exportOptions: {columns: ':not(:first-child)'}
}
]
}
],
language: {
search: `
<div class="datatable-search-wrapper" style="position:relative; display:inline-block;">
_INPUT_
<i class="mdi mdi-magnify datatable-search-icon"
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666;"></i>
<i class="mdi mdi-close-circle datatable-clear-icon"
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666; display:none;"></i>
</div>`,
searchPlaceholder: "Search",
emptyTable: '<div class="text-center text-muted">No Data found</div>'
},
paging: false,
ordering: false,
});
});
// MAIN: load and render policies for selected agent / date
function loadPolicies() {
let agentEl = getEl('agentSelect');
let policyTillDateEl = getEl('policyTillDate');
let list = getEl('ticketListBody');
if (!list) return;
let agentId = agentEl ? agentEl.value : '';
let policyTillDate = policyTillDateEl ? policyTillDateEl.value : '';
console.log('policyTillDate', policyTillDate);
selectedPolicies.clear();
if (!agentId || agentId === '' || agentId === '0') {
// Destroy DataTable so table returns to normal
if ($.fn.DataTable.isDataTable('#tickets-table')) {
$('#tickets-table').DataTable().clear().destroy();
}
list.innerHTML = `<tr><td colspan="6" class="text-center text-danger">Please select an agent</td></tr>`;
reinitDataTable();
updateSummary();
return;
}
filteredPolicies = allPolicies.filter(p => String(p.agentId) === String(agentId));
// policy Till Date filter
filteredPolicies = allPolicies.filter(p => {
if (String(p.agentId) !== String(agentId)) return false;
if (policyTillDate && p.date_db > policyTillDate) return false;
return true;
});
let rows = '';
filteredPolicies.forEach(p => {
const idStr = String(p.id);
const checked = selectedPolicies.has(idStr) ? 'checked' : '';
rows += `
<tr>
<td style="text-align:center;">
<input type="checkbox" class="policy-checkbox CB"
value="${idStr}" ${checked}
onchange="togglePolicy(this.value, this.checked)">
</td>
<td>${p.policyNo || ''}</td>
<td>${p.customer || ''}</td>
<td>${Number(p.premium || 0).toFixed(2)}</td>
<td>${p.date || ''}</td>
<td>${Number(p.commission || 0).toFixed(2)}</td>
</tr>
`;
});
// Destroy DataTable BEFORE inserting rows
if ($.fn.DataTable.isDataTable('#tickets-table')) {
$('#tickets-table').DataTable().clear().destroy();
}
// Insert rows
list.innerHTML = rows;
// Reinitialize AFTER writing rows
reinitDataTable();
updateSelectAllCheckbox();
updateSummary();
}
// DataTable re-init helper (destroy + create)
function reinitDataTable() {
if ($.fn.DataTable.isDataTable('#tickets-table')) {
try {
$('#tickets-table').DataTable().clear().destroy();
} catch (e) {
// ignore destroy errors
}
}
$('#tickets-table').DataTable({
dom:
"<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
extend: 'collection',
text: '<span class=" btn-custom"> Export </span><i class="mdi mdi-menu-down"></i>',
className: 'btn app-btn-secondary ',
buttons: [
{
extend: 'csv',
text: '<i class="mdi mdi-file-delimited"></i><span class="btn-custom"> CSV </span>',
className: 'app-btn-primary',
title: getExportFileName(),
exportOptions: {columns: ':not(:first-child)'}
},
{
extend: 'excel',
text: '<i class="mdi mdi-file-excel"></i><span class="btn-custom"> EXCEL </span>',
className: 'app-btn-primary',
title: getExportFileName(),
filename: getExportFileName(),
exportOptions: {columns: ':not(:first-child)'}
}
]
}
],
language: {
search: `
<div class="datatable-search-wrapper" style="position:relative; display:inline-block;">
_INPUT_
<i class="mdi mdi-magnify datatable-search-icon"
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666;"></i>
<i class="mdi mdi-close-circle datatable-clear-icon"
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666; display:none;"></i>
</div>`,
searchPlaceholder: "Search",
emptyTable: '<div class="text-center text-muted">No Data found</div>'
},
paging: false,
ordering: false,
// After init, align first column
initComplete: function() {
$('#tickets-table tbody tr td:first-child').css('text-align', 'center');
}
});
}
// Toggle single policy selection (called from checkbox onchange)
function togglePolicy(policyId, checked) {
policyId = String(policyId);
if (checked === undefined) {
// if called without the checked param, toggle based on presence
if (selectedPolicies.has(policyId)) selectedPolicies.delete(policyId);
else selectedPolicies.add(policyId);
} else {
if (checked) selectedPolicies.add(policyId);
else selectedPolicies.delete(policyId);
}
// update UI elements that reflect selection
updateSelectAllCheckbox();
updateSummary();
}
// Select / deselect all currently filtered policies
function toggleSelectAll(sourceCheckbox) {
if (!filteredPolicies || filteredPolicies.length === 0) return;
if (sourceCheckbox.checked) {
filteredPolicies.forEach(p => selectedPolicies.add(String(p.id)));
} else {
filteredPolicies.forEach(p => selectedPolicies.delete(String(p.id)));
}
// update all visible checkboxes to match selection
document.querySelectorAll('#ticketListBody .policy-checkbox').forEach(cb => {
cb.checked = selectedPolicies.has(cb.value);
});
updateSummary();
}
// Update header select-all checkbox state
function updateSelectAllCheckbox() {
const selectAllCheckbox = getEl('selectAll');
if (!selectAllCheckbox) return;
const allSelected = filteredPolicies.length > 0 && filteredPolicies.every(p => selectedPolicies.has(String(p.id)));
selectAllCheckbox.checked = !!allSelected;
}
// Update summary UI (footer/summaryBar)
function updateSummary() {
const summaryBar = getEl('summaryBar');
const selectedCountBadge = getEl('selectedCount');
const totalPoliciesEl = getEl('totalPolicies');
const totalAmountEl = getEl('totalAmount');
if (!totalPoliciesEl || !totalAmountEl) {
return;
}
if (selectedPolicies.size === 0) {
if (summaryBar) summaryBar.classList && summaryBar.classList.remove('show');
if (selectedCountBadge) selectedCountBadge.style.display = 'none';
totalPoliciesEl.textContent = '0';
totalAmountEl.textContent = '₹0.00';
return;
}
if (selectedCountBadge) {
selectedCountBadge.style.display = 'inline-block';
selectedCountBadge.textContent = `${selectedPolicies.size} selected`;
}
if (summaryBar) summaryBar.classList && summaryBar.classList.add('show');
const totalAmount = filteredPolicies
.filter(p => selectedPolicies.has(String(p.id)))
.reduce((sum, p) => sum + Number(p.commission || 0), 0);
totalPoliciesEl.textContent = String(selectedPolicies.size);
totalAmountEl.textContent = `₹${totalAmount.toFixed(2)}`;
}
// Clear selection
function clearSelection() {
if (!confirm('Are you sure you want to clear the selection?')) return;
selectedPolicies.clear();
// uncheck all checkboxes in view
document.querySelectorAll('#ticketListBody .policy-checkbox').forEach(cb => cb.checked = false);
updateSelectAllCheckbox();
updateSummary();
}
// Reset filters (keeps agent selection; clear others)
function resetFilters() {
// Keep agent selected
['fromDate','toDate','from_date','to_date'].forEach(id => {
if (getEl(id)) getEl(id).value = '';
});
}
// Save invoice (AJAX)
function saveInvoice() {
const agentId = getEl('agentSelect')?.value || '';
const invoiceNo = getEl('invoiceNo')?.value || '';
const invoiceDate = getEl('invoiceDate')?.value || '';
const policyTillDate = getEl('policyTillDate')?.value || '';
const invoiceID = '';
if (!agentId || agentId === '0') return toastr.warning('Please select an agent', 'Required');
if (!invoiceDate) return toastr.warning('Please select invoice date', 'Required');
if (selectedPolicies.size === 0) return toastr.warning('Please select at least one policy', 'Required');
const selectedPolicyData = filteredPolicies.filter(p => selectedPolicies.has(String(p.id)));
console.log('selectedPolicyData');
console.log(selectedPolicyData);
let totalAmount = 0;
const policies = selectedPolicyData.map(p => {
let finalAmount = Number(p.commission || 0);
totalAmount += finalAmount;
return {
policy_id: p.id,
policy_no: p.policyNo,
commission_amount: finalAmount,
partner_policy_id : p.partner_policy_id
};
});
const invoiceData = {
invoice_id: invoiceID,
invoice_no: invoiceNo,
agent_id: agentId,
invoice_date: invoiceDate,
invoice_amount: totalAmount,
policies: policies
};
$.ajax({
url: '<?= base_url('payout/invoices/save') ?>',
type: 'POST',
data: JSON.stringify(invoiceData),
contentType: 'application/json',
success: function(response) {
// toastr.success(`Invoice created successfully!<br>Invoice No: ${invoiceNo}`, 'Success');
toastr.success(response.message, 'Success');
window.location.href = '<?= base_url('payout/list') ?>';
},
error: function() {
toastr.error(response.message, 'Invoice Error');
// toastr.error('An error occurred while creating the invoice. Please try again.','Invoice Error');
}
});
}
function getExportFileName() {
let d = new Date();
let day = String(d.getDate()).padStart(2, '0');
let month = String(d.getMonth() + 1).padStart(2, '0');
let year = d.getFullYear();
return `Payouts (${day}-${month}-${year})`;
}
function generateInvoiceNumberAjaxCall() {
let agentId = $("#agentSelect").val();
if (!agentId) {
$("#invoiceNo").val("");
toastr.error("Please Select The Agent");
return;
}
$.ajax({
url: "<?= base_url('payout/invoice/generate-number') ?>/" + agentId,
method: "GET",
dataType: "json",
success: function (res) {
if (res.status === "success") {
$("#invoiceNo").val(res.invoice_no);
} else {
toastr.error(res.message);
}
},
error: function () {
toastr.error("Error generating invoice number");
}
});
}
// function searchPolicies() {
// filterPolicies();
// }
// function filterPolicies() {
// const fromDate = document.getElementById('fromDate').value;
// const toDate = document.getElementById('toDate').value;
// const agentId = document.getElementById('agentSelect').value;
// const policyTillDate = document.getElementById('policyTillDate').value;
// if (!agentId) {
// alert('Please select an agent first');
// return;
// }
// filteredPolicies = allPolicies.filter(p => {
// if (p.agentId != agentId) return false;
// if (policyTillDate && p.date_db > policyTillDate) return false;
// if (fromDate && p.date_db < fromDate) return false;
// if (toDate && p.date_db > toDate) return false;
// return true;
// });
// loadPolicies();
// }
</script>

View File

@ -0,0 +1,430 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Agent Commission Invoice</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
font-size: 12px;
color: #333;
background: #fff;
}
/* Page Setup for DOMPDF */
@page {
size: A4;
margin: 10mm;
}
/* .invoice-container {
width: 100%;
max-width: 210mm;
margin: 0 auto;
padding: 10mm;
background: #fff;
} */
.invoice-container {
width: 180mm; /* reduced from 210mm */
max-width: 180mm;
margin: 0 auto;
padding: 8mm; /* reduced padding */
background: #fff;
}
/* Header */
.invoice-header {
border-bottom: 3px solid #2c3e50;
padding-bottom: 15px;
margin-bottom: 20px;
}
.header-top {
width: 100%;
display: table;
}
.header-top > div {
display: table-cell;
vertical-align: top;
width: 50%;
}
.company-info h1 {
color: #2c3e50;
font-size: 24px;
margin-bottom: 5px;
}
.company-info p {
color: #666;
font-size: 11px;
line-height: 1.4;
}
.invoice-title {
text-align: right;
}
.invoice-title h2 {
font-size: 32px;
color: #e74c3c;
margin-bottom: 5px;
}
.invoice-title p {
font-size: 11px;
color: #666;
}
/* Invoice Info (converted grid to table layout) */
.invoice-info {
width: 100%;
display: table;
margin-bottom: 25px;
background: #f8f9fa;
border-radius: 5px;
}
.invoice-info > div {
display: table-cell;
width: 50%;
vertical-align: top;
padding: 15px;
}
.info-section h3 {
font-size: 13px;
color: #2c3e50;
margin-bottom: 10px;
padding-bottom: 5px;
border-bottom: 2px solid #3498db;
}
.info-row {
width: 100%;
display: table;
padding: 5px 0;
font-size: 11px;
}
.info-row span {
display: table-cell;
}
.info-label {
font-weight: 600;
color: #555;
}
.info-value {
color: #333;
font-weight: 500;
text-align: right;
}
/* Table */
.invoice-table {
width: 100%;
border-collapse: collapse;
margin-bottom: 10px;
margin-top: -16px;
}
.invoice-table thead {
display: table-header-group;
background: #2c3e50;
color: #fff;
}
.invoice-table thead th {
padding: 12px 8px;
font-size: 11px;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.5px;
text-align: left;
}
.invoice-table td {
padding: 10px 8px;
font-size: 11px;
border-bottom: 1px solid #e0e0e0;
}
.invoice-table tbody tr:nth-child(even) {
background: #f8f9fa;
}
/* Text alignment */
.text-right {
text-align: right;
}
.text-center {
text-align: center;
}
/* Summary Section */
.invoice-summary {
width: 100%;
text-align: right;
margin-top: 20px;
}
.summary-box {
width: 300px;
border: 2px solid #2c3e50;
border-radius: 5px;
display: inline-block;
}
.summary-row {
width: 100%;
display: table;
padding: 10px 15px;
border-bottom: 1px solid #e0e0e0;
}
.summary-row span {
display: table-cell;
}
.summary-row:last-child {
background: #2c3e50;
color: #fff;
font-weight: bold;
font-size: 14px;
}
.summary-label {
font-weight: 600;
}
/* Footer */
.invoice-footer {
border-top: 2px solid #2c3e50;
padding-top: 15px;
margin-top: 30px;
}
.footer-content {
width: 100%;
display: table;
}
.footer-section {
display: table-cell;
width: 50%;
vertical-align: top;
font-size: 10px;
color: #666;
}
.footer-section h4 {
font-size: 12px;
color: #2c3e50;
margin-bottom: 8px;
}
.footer-section p {
line-height: 1.6;
margin-bottom: 5px;
}
/* Signature */
.signature-section {
margin-top: 40px;
text-align: right;
}
.signature-line {
border-top: 2px solid #333;
width: 200px;
margin-left: auto;
padding-top: 10px;
font-size: 11px;
font-weight: 600;
}
/* Page break support */
.page-break {
page-break-after: always;
}
/* Row breaking prevention */
.invoice-table tr {
page-break-inside: avoid;
}
/* Optional hide */
.hide-header .invoice-header {
display: none;
}
.hide-footer .invoice-footer {
display: none;
}
</style>
</head>
<body>
<div class="invoice-container" id="invoiceContent">
<!-- Invoice Header (Can be toggled) -->
<div class="invoice-header">
<div class="header-top">
<div class="company-info">
<h1><?= $broker_company_name ?? 'Broker Company Name' ?></h1>
<p><?= $broker_address ?? 'Company Address Line 1' ?><br>
<?= $broker_city ?? 'City' ?>, <?= $broker_state ?? 'State' ?> - <?= $broker_pincode ?? 'PIN' ?><br>
Email: <?= $broker_email ?? 'email@company.com' ?> | Phone: <?= $broker_phone ?? '+91-XXXXXXXXXX' ?></p>
</div>
<div class="invoice-title">
<p>Commission Statement</p>
</div>
</div>
</div>
<!-- Invoice Information -->
<div class="invoice-info">
<div class="info-section">
<h3>Invoice Details</h3>
<div class="info-row">
<span class="info-label">Invoice Number:</span>
<span class="info-value"><?= $invoice_number ?? 'INV-2024-0001' ?></span>
</div>
<div class="info-row">
<span class="info-label">Invoice Date:</span>
<span class="info-value"><?= $invoice_date ?? date('d-M-Y') ?></span>
</div>
<div class="info-row">
<span class="info-label">Period:</span>
<span class="info-value"><?= $period ?? 'January 2024' ?></span>
</div>
</div>
<div class="info-section">
<h3>Agent Information</h3>
<div class="info-row">
<span class="info-label">Agent Name:</span>
<span class="info-value"><?= $agent_name ?? 'Agent Name' ?></span>
</div>
<div class="info-row">
<span class="info-label">Agent Code:</span>
<span class="info-value"><?= $agent_code ?? 'AGT-0001' ?></span>
</div>
<div class="info-row">
<span class="info-label">No. of Policies:</span>
<span class="info-value"><?= $total_policies ?? '0' ?></span>
</div>
<div class="info-row">
<span class="info-label">Policies Till Date:</span>
<span class="info-value"><?= $policies_till_date ?? '0' ?></span>
</div>
</div>
</div>
<!-- Policy Details Table -->
<table class="invoice-table">
<thead>
<tr>
<th style="width: 5%;">Sr.</th>
<th style="width: 15%;">Policy No.</th>
<th style="width: 25%;">Customer Name</th>
<th style="width: 15%;" class="text-right">Premium ()</th>
<th style="width: 15%;" class="text-center">Issue Date</th>
<th style="width: 15%;" class="text-right">Commission ()</th>
</tr>
</thead>
<tbody>
<?php
$serial = 1;
$total_premium = 0;
$total_commission = 0;
$records_per_page = 25; // Adjust based on page size
foreach($policies as $index => $policy):
$total_premium += $policy['premium'];
$total_commission += $policy['commission'];
// Add page break after certain records
$page_break_class = (($serial % $records_per_page) == 0 && $serial != count($policies)) ? 'page-break' : '';
?>
<tr class="<?= $page_break_class ?>">
<td class="text-center"><?= $serial ?></td>
<td><?= $policy['policy_no'] ?></td>
<td><?= $policy['customer_name'] ?></td>
<td class="text-right"><?= number_format($policy['premium'], 2) ?></td>
<td class="text-center"><?= date('d-M-Y', strtotime($policy['issue_date'])) ?></td>
<td class="text-right"><?= number_format($policy['commission'], 2) ?></td>
</tr>
<?php
// Insert page header for continuation pages
if($page_break_class && $serial != count($policies)):
?>
<tr class="page-header">
<td colspan="6">
<h3>Invoice #<?= $invoice_number ?? 'INV-2024-0001' ?> - Continued</h3>
</td>
</tr>
<?php
endif;
$serial++;
endforeach;
?>
</tbody>
</table>
<!-- Summary Section -->
<div class="invoice-summary">
<div class="summary-box">
<div class="summary-row">
<span class="summary-label">Total Premium:</span>
<span> <?= number_format($total_premium, 2) ?></span>
</div>
<div class="summary-row">
<span class="summary-label">Total Policies:</span>
<span><?= count($policies) ?></span>
</div>
<div class="summary-row">
<span class="summary-label">Total Commission:</span>
<span> <?= number_format($total_commission, 2) ?></span>
</div>
</div>
</div>
<!-- Invoice Footer (Can be toggled) -->
<div class="invoice-footer">
<div class="footer-content">
<div class="footer-section">
<h4>Payment Terms</h4>
<p>Payment due within 15 days of invoice date.</p>
<p>Bank Transfer Details:</p>
<p><strong>Bank:</strong> <?= $bank_name ?? 'Bank Name' ?></p>
<p><strong>Account No:</strong> <?= $account_number ?? 'XXXXXXXXXXXX' ?></p>
<p><strong>IFSC:</strong> <?= $ifsc_code ?? 'XXXXXX' ?></p>
</div>
<div class="footer-section">
<h4>Notes</h4>
<p>Commission calculated as per agreed terms.</p>
<p>This is a computer-generated invoice.</p>
<p>For queries, contact: <?= $contact_email ?? 'accounts@company.com' ?></p>
</div>
</div>
<div class="signature-section">
<div class="signature-line">
Authorized Signatory
</div>
</div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,158 @@
<head>
<style>
/* Page Setup for DOMPDF */
@page {
size: A4;
margin: 10mm;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
font-size: 12px;
color: #333;
background: #fff;
}
.invoice-container {
width: 180mm; /* reduced from 210mm */
max-width: 180mm;
margin: 0 auto;
padding: 8mm; /* reduced padding */
background: #fff;
}
.invoice-container table {
width: 100%;
/* border-collapse: collapse; */
margin-bottom: 15pt;
}
.invoice-container table th,
.invoice-container table td {
border: 1pt solid #000;
padding: 8pt;
text-align: left;
vertical-align: top;
}
.invoice-container th {
background-color: #f0f0f0;
font-weight: bold;
}
.header {
text-align: center;
font-weight: bold;
background-color: #fff;
}
.nhance-address {
text-align: center;
font-weight: bold;
background-color: #fff;
}
.section-header {
font-weight: bold;
background-color: #f8f8f8;
}
.amount {
text-align: right;
}
.bank-details {
margin-top: 15pt;
margin-bottom: 15pt;
line-height: 1.6;
}
.signature {
text-align: right;
margin-top: 40pt;
padding-top: 20pt;
}
.amount-words {
margin-top: 10pt;
margin-bottom: 10pt;
font-weight: bold;
}
strong {
font-weight: bold;
}
</style>
</head>
<body>
<div class="invoice-container">
<table>
<?php if(isset($agent_name)) : ?>
<tr>
<td colspan="3" class="header"><?= $agent_name ?></td>
</tr>
<?php endif; ?>
<?php if(isset($agent_address) && !empty($agent_address)) : ?>
<tr>
<td colspan="3" class="header"><?= $agent_address ?></td>
</tr>
<?php endif; ?>
<tr>
<td class="section-header">Bill To:</td>
<td class="section-header">Invoice No</td>
<td class="section-header">Date</td>
</tr>
<tr>
<td>
<strong>NHANCE INDIA INSURANCE BROKING PVT LTD</strong><br>
'Old No.76, New No.82, 'Sreshtha', First floor , <br>
4th Avenue, Ashok Nagar, Chennai - 600083
</td>
<td><?= isset($invoice_no) && !empty($invoice_no) ? $invoice_no : "-" ?></td>
<td><?= isset($invoice_date) && !empty($invoice_date) ? change_date_format($invoice_date, 'Y-m-d', 'd/m/Y') : "-" ?></td>
</tr>
</table>
<table>
<tr>
<th>Sl No</th>
<th>Description</th>
<th>Amount-INR</th>
</tr>
<tr>
<td>1</td>
<td>INSURANCE BROKING SERVICE (POINT OF SALE)</td>
<td class="amount"><?= isset($invoice_no) && !empty($invoice_amount) ? format_indian_number($invoice_amount) : "-" ?></td>
</tr>
<tr>
<td colspan="2"><strong>Total</strong></td>
<td class="amount"><strong><?= isset($invoice_no) && !empty($invoice_amount) ? format_indian_number($invoice_amount) : "-" ?></strong></td>
</tr>
</table>
<div class="amount-words">
<strong>Amount Payable in words : <?= isset($invoice_no) && !empty($invoice_amount) ? numberToWords((int)$invoice_amount) . ' Only' : "-" ?> </strong>
</div>
<div class="bank-details">
<strong>BANK ACCOUNT DETAILS</strong><br>
ACCOUNT NUMBER : <?= isset($agent_account_no) && !empty($agent_account_no) ? $agent_account_no : "-" ?><br>
IFSC CODE : <?= isset($agent_ifsc_code) && !empty($agent_ifsc_code) ? $agent_ifsc_code : "-" ?><br>
Bank NAME : <?= isset($agent_bank_name) && !empty($agent_bank_name) ? $agent_bank_name : "-" ?>
</div>
<div class="signature">
Authorised Signatory
</div>
</div>
</body>

View File

@ -34,6 +34,7 @@ table.dataTable tbody td {
#scroll-horizontal-datatable tfoot .right-align-input {
text-align: right !important;
}
.dataTables_length label {height: 21px !important;}
</style>
@ -206,9 +207,13 @@ $(document).ready(function() {
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
// 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
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
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
extend: 'collection',

View File

@ -24,6 +24,7 @@ table.dataTable tbody td {
#scroll-horizontal-datatable tfoot .right-align-input {
text-align: right !important;
}
.dataTables_length label {height: 21px !important;}
</style>
<div class="col-12" id="second_page">
@ -239,9 +240,9 @@ $(document).ready(function() {
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
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
// 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',
@ -295,6 +296,10 @@ $(document).ready(function() {
// }
// ],
dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // Filter left, buttons right
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
extend: 'collection',

View File

@ -20,6 +20,7 @@ table.dataTable tbody td {
.right-align-input {
text-align: right;
}
.dataTables_length label {height: 21px !important;}
</style>
<div class="col-12" id="second_page">
@ -75,9 +76,9 @@ $(document).ready(function() {
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
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
// 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',
@ -131,6 +132,10 @@ $(document).ready(function() {
// }
// ],
dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // Filter left, buttons right
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
extend: 'collection',

View File

@ -38,7 +38,7 @@
color: white;
border:1px solid rgba(41, 139, 142, 1);
}
.dataTables_length label {height: 21px !important;}
</style>
<div class="row" id="kyc_list">
<div class="col-12">
@ -176,11 +176,13 @@
$('#tickets-table').DataTable({
// dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
// "<'row'<'col-sm-12'tr>>" +
// "<'row'<'col-sm-5'i><'col-sm-7'p>>" ,
dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>" ,
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
text: '<i class="mdi mdi-plus" ></i><span class=" btn-custom"> Add </span>',

View File

@ -1256,14 +1256,14 @@
/* Cancel Bootstrap's .form-control for file inputs */
/* input[type="file"].form-control { */
/* height: auto !important;*/
/* remove forced height */
/* padding: initial !important;*/
/* reset padding */
/* font-size: inherit !important;*/
/* reset font size */
/* line-height: normal !important;*/
/* reset line height */
/* height: auto !important;*/
/* remove forced height */
/* padding: initial !important;*/
/* reset padding */
/* font-size: inherit !important;*/
/* reset font size */
/* line-height: normal !important;*/
/* reset line height */
/* } */
@ -1327,7 +1327,7 @@
<!-- accordian -->
<style>
.card #collapseOne .card-body,
#collapseOne .card-body,
#collapseOne .card-body,
.card #collapseTwo .card-body,
.card #collapseThree .card-body,
.card #collapseFour .card-body {
@ -1758,62 +1758,62 @@
</li>
<?php } ?>
<!-- Masters -->
<?php if (get_role_id() == 1 || get_role_id() == 5 || ( get_role_id() == 4 && (in_array(BUSINESS_SUPPORT_TEAM_ID, user_team()) || in_array(SALES_TEAM_ID, user_team())))) { ?>
<!-- Masters -->
<?php if (get_role_id() == 1 || get_role_id() == 5 || (get_role_id() == 4 && (in_array(BUSINESS_SUPPORT_TEAM_ID, user_team()) || in_array(SALES_TEAM_ID, user_team())))) { ?>
<li class="li-seperate" id="masters-li">
<a href="#sidebarPolicies" data-toggle="collapse" class=" img-inactive">
<img
src="<?= base_url() . "public"; ?>/assets/images/masters_sb.png" alt="Logo" height="20">
<span> Masters </span>
</a>
<div class="collapse" id="sidebarDashboards">
<ul class="nav-second-level">
<span> Masters </span>
</a>
<div class="collapse" id="sidebarDashboards">
<ul class="nav-second-level">
<?php if (get_role_id() == 1 || get_role_id() == 5 || ( get_role_id() == 4 && (in_array(BUSINESS_SUPPORT_TEAM_ID, user_team()) || in_array(SALES_TEAM_ID, user_team())))) { ?>
<?php if (get_role_id() == 1 || get_role_id() == 5 || (get_role_id() == 4 && (in_array(BUSINESS_SUPPORT_TEAM_ID, user_team()) || in_array(SALES_TEAM_ID, user_team())))) { ?>
<li>
<a href="<?= base_url('/master/insurer/list') ?>">Insurer</a>
</li>
<li>
<a href="<?= base_url('/master/insurer/list') ?>">Insurer</a>
</li>
<?php } ?>
<?php } ?>
<?php if (get_role_id() == 1 || get_role_id() == 5) { ?>
<?php if (get_role_id() == 1 || get_role_id() == 5) { ?>
<li>
<a href="<?= base_url('/master/tpa/list') ?>">TPA</a>
</li>
<li>
<a href="<?= base_url('/master/kyc/list') ?>">KYC</a>
</li>
<li>
<a href="<?= base_url('/master/policy/list') ?>">Policy</a>
</li>
<li>
<a href="<?= base_url('/master/cash_deposite/list') ?>">CD Master</a>
</li>
<li>
<a href="<?= base_url('/master/vehicle/list') ?>">Vehicle Master</a>
</li>
<li>
<a href="<?= base_url('/user/list') ?>"> Users </a>
</li>
<li>
<a href="<?= base_url('/util/nhanceBranchMaster') ?>"> Nhance Branch </a>
</li>
<li>
<a href="<?= base_url('/util/vehicleTypeMaster') ?>"> Vehicle Type </a>
</li>
<li>
<a href="<?= base_url('/util/rtoMaster') ?>"> RTO </a>
</li>
<li>
<a href="<?= base_url('/master/tpa/list') ?>">TPA</a>
</li>
<li>
<a href="<?= base_url('/master/kyc/list') ?>">KYC</a>
</li>
<li>
<a href="<?= base_url('/master/policy/list') ?>">Policy</a>
</li>
<li>
<a href="<?= base_url('/master/cash_deposite/list') ?>">CD Master</a>
</li>
<li>
<a href="<?= base_url('/master/vehicle/list') ?>">Vehicle Master</a>
</li>
<li>
<a href="<?= base_url('/user/list') ?>"> Users </a>
</li>
<li>
<a href="<?= base_url('/util/nhanceBranchMaster') ?>"> Nhance Branch </a>
</li>
<li>
<a href="<?= base_url('/util/vehicleTypeMaster') ?>"> Vehicle Type </a>
</li>
<li>
<a href="<?= base_url('/util/rtoMaster') ?>"> RTO </a>
</li>
<?php } ?>
<?php } ?>
</ul>
</div>
</li>
</ul>
</div>
</li>
<?php } ?>
@ -1904,9 +1904,9 @@
</div>
</li>
<?php if ((get_role_id() == 1 || get_role_id() == 5) ||(get_role_id() == 4 && in_array(FINANCE_TEAM_ID, user_team())) || (in_array(MANAGEMENT_TEAM_ID, user_team()) || in_array(FINANCE_TEAM_ID, user_team()) || in_array(BUSINESS_TEAM_ID, user_team()) || in_array(POS_TEAM_ID, user_team()))) { ?>
<?php if ((get_role_id() == 1 || get_role_id() == 5) || (get_role_id() == 4 && in_array(FINANCE_TEAM_ID, user_team())) || (in_array(MANAGEMENT_TEAM_ID, user_team()) || in_array(FINANCE_TEAM_ID, user_team()) || in_array(BUSINESS_TEAM_ID, user_team()) || in_array(POS_TEAM_ID, user_team()))) { ?>
<?php if (in_array(get_role_id(), [1, 5]) ||(get_role_id() == 4 && in_array(FINANCE_TEAM_ID, user_team())) || in_array(MANAGEMENT_TEAM_ID, user_team()) || in_array(POS_TEAM_ID, user_team())) { ?>
<?php if (in_array(get_role_id(), [1, 5]) || (get_role_id() == 4 && in_array(FINANCE_TEAM_ID, user_team())) || in_array(MANAGEMENT_TEAM_ID, user_team()) || in_array(POS_TEAM_ID, user_team())) { ?>
<li>
<a href="#policyReports" data-toggle="collapse" class="waves-effect">
<i class="ri-file-chart-fill"></i>
@ -2017,6 +2017,18 @@
</a>
</li>
<?php } ?>
<li>
<a href="<?= base_url('/payout/list') ?>">
<i class="ri-money-rupee-circle-line"></i>
<span> Payouts</span>
</a>
</li>
<li>
<a href="<?= base_url('/commission/list') ?>">
<i class="ri-percent-line"></i>
<span> Commission</span>
</a>
</li>
<?php } ?>
</ul>

View File

@ -139,7 +139,7 @@ table.dataTable tbody td {
font-size: 0.9rem;
padding: 0.5rem 1rem;
}
.dataTables_length label {height: 21px !important;}
/* Modeal class */
</style>
@ -458,9 +458,13 @@ table.dataTable tbody td {
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
// dom: "<'row'<'col-sm-7'f><'col-sm-5 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
dom: "<'row'<'col-sm-7'f><'col-sm-5 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
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
text: 'Add',

View File

@ -95,6 +95,7 @@ p{
background-image:url('<?= $client_logo ?>');
background-size:contain;
background-repeat:no-repeat;
background-position: center;
">
</div>

View File

@ -8,7 +8,7 @@
</div>
<div class="form-group">
<label for="subject">Subject:</label>
<input type="text" class="form-control" id="subject" name="subject" value="Gmail API Test - . <?php echo date('Y-m-d h:i:s');?>" required>
<input type="text" class="form-control" id="subject" name="subject" value="Gmail API Test - . <?php echo date('Y-m-d h:i:s A');?>" required>
</div>
<div class="form-group">
<label for="content">Content:</label>

View File

@ -2,6 +2,7 @@
.dataTables_filter {
position: absolute;
}
.dataTables_length label {height: 21px !important;}
</style>
<!-- End ADD and EDIT Page HTML -->
@ -94,9 +95,13 @@
var ticketsTable = $('#user-table');
ticketsTable.DataTable({
scrollX: true,
// dom: "<'row'<'col-sm-7'f><'col-sm-5 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
dom: "<'row'<'col-sm-7'f><'col-sm-5 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
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
text: 'Add',

View File

@ -194,7 +194,7 @@
<div class="form-row">
<!-- Example: Member welcome mail -->
<!-- <div class="form-group col-md-6 mail-row">
<div class="form-group col-md-6 mail-row">
<div class="mail-section">
<div class="left">
<label class="switch">
@ -209,9 +209,9 @@
</a>
</div>
</div>
</div> -->
</div>
<!-- Example: Member reminder mail -->
<!-- <div class="form-group col-md-6 mail-row">
<div class="form-group col-md-6 mail-row">
<div class="mail-section">
<div class="left">
<label class="switch">
@ -226,7 +226,7 @@
</a>
</div>
</div>
</div> -->
</div>
</div>
@ -266,7 +266,7 @@
</div>
</div>
<!-- member review and summary mail -->
<!-- <div class="form-group col-md-6 mail-row">
<div class="form-group col-md-6 mail-row">
<div class="mail-section">
<div class="left">
<label class="switch">
@ -283,13 +283,13 @@
</div>
</div> -->
</div>
</div>
<div class="form-row">
<!-- Account Manager Summary Mail row-->
<!-- <div class="form-group col-md-6 mail-row">
<div class="form-group col-md-6 mail-row">
<div class="mail-section">
<div class="left">
<label class="switch">
@ -304,9 +304,9 @@
</a>
</div>
</div>
</div> -->
</div>
<!-- client hr summary mail -->
<!-- <div class="form-group col-md-6 mail-row">
<div class="form-group col-md-6 mail-row">
<div class="mail-section">
<div class="left">
<label class="switch">
@ -321,7 +321,7 @@
</a>
</div>
</div>
</div> -->
</div>
</div>
<div class="form-row">
@ -342,7 +342,7 @@
<!-- end -->
<!-- Modal content for the Large example -->
<!-- Modal content for the Large example => Common mail -->
<div class="modal fade" id="member_common_mail_modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"
aria-hidden="true" aria-modal="true" data-backdrop="static">
<div class="modal-dialog modal-full-width scrollb">
@ -429,6 +429,7 @@
</tr>
</thead>
<tbody id="attachment_tbody">
</tbody>
</table>
@ -446,8 +447,7 @@
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- Modal content for the Large example -->
<!-- Modal content for the Large example => Welcome mail-->
<div class="modal fade" id="member_welcome_mail_modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"
aria-hidden="true" aria-modal="true" data-backdrop="static">
<div class="modal-dialog modal-full-width scrollb">
@ -527,7 +527,7 @@
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- Modal content for the Large example -->
<!-- Modal content for the Large example => Remainder mail -->
<div class="modal fade" id="member_reminder_mail_modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="false" aria-modal="true">
<div class="modal-dialog modal-full-width">
<div class="modal-content">
@ -618,7 +618,7 @@
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- Modal content for the Large example -->
<!-- Modal content for the Large example => Ecard mail -->
<div class="modal fade" id="member_ecard_mail_modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"
aria-hidden="true" aria-modal="true" data-backdrop="static">
<div class="modal-dialog modal-full-width">
@ -708,7 +708,7 @@
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- Modal content for the Large example -->
<!-- Modal content for the Large example => Review And Summary mail -->
<div class="modal fade" id="member_review_and_summary_mail_modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"
aria-hidden="true" aria-modal="true" data-backdrop="static">
<div class="modal-dialog modal-full-width">
@ -799,6 +799,8 @@
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- Modal content for the Large example => Acc Manager Summary mail -->
<div class="modal fade" id="account_maneger_summary_mail_modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"
aria-hidden="true" aria-modal="true" data-backdrop="static">
<div class="modal-dialog modal-full-width">
@ -1368,7 +1370,7 @@
let test_mail_list = $('#common_mail').val();
let test_mail = test_mail_list.split(',')[0] ?? '';
let test_mail = test_mail_list.split(',')[0] ?? ''; //REF:SVM
if (test_mail !== null || test_mail !== "") {
@ -1400,30 +1402,19 @@
type: "POST",
data:{
template_id,
test_mail,
test_mail_list
test_mail_list,
},
dataType: 'json',
success: function(res) {
console.log('Test mail send function response', res)
console.log('Test mail send function response', res);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
if (res.status == true) {
let respond = res.respond;
console.log('Parsed respond', respond)
if (respond.status == 'success') {
toastr.success(respond.message, 'SUCCESS')
} else {
toastr.warning(respond.message, 'WARNING')
}
if (res.status === true) {
toastr.success(res.message, 'SUCCESS');
} else {
toastr.warning('Failed to sent mail', 'WARNING')
toastr.warning('Failed to send mail', 'WARNING');
}
},
error: function(xhr, status, error) {

View File

@ -33,6 +33,7 @@
padding-right: 15px !important;
padding-left: 15px !important;
}
.dataTables_length label {height: 21px !important;}
</style>
<div class="container-fluid-min">
@ -178,9 +179,13 @@
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
// 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
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
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [{
extend: 'collection',
text: '<span class=" btn-custom"> Export </span><i class="mdi mdi-menu-down"></i>',

499
app/Views/payout_list.php Normal file
View File

@ -0,0 +1,499 @@
<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;
}
.right-align-input {
text-align: right;
}
.badge-container {
background: #F0F0F0;
padding: 6px 12px;
border-radius: 6px;
font-size: 14px;
display: inline-block;
}
.summary-box {
background: #e3f2fd;
padding: 15px;
border-radius: 6px;
margin-bottom: 20px;
border-left: 4px solid #2196F3;
}
</style>
<style>
.summary-box {
padding: 10px;
margin-bottom: 15px;
}
.summary-row {
display: flex;
justify-content: space-between;
margin-bottom: 8px;
font-size: 13px;
}
.summary-row:last-child {
margin-bottom: 0;
font-size: 12px;
font-weight: bold;
padding-top: 4px;
border-top: 1px solid #2196F3;
}
.summary-row {
padding: 0px 0;
font-size: 13px;
}
.summary-row span:last-child {
font-weight: bold;
font-size: 12px !important;
}
.utr-section {
margin-top: 15px;
padding-top: 15px;
border-top: 1px solid #eee;
}
.utr-heading {
margin-bottom: 10px;
font-size: 15px;
}
.utr-form-group {
margin-bottom: 10px;
}
.utr-label {
font-size: 13px;
margin-bottom: 5px;
}
.utr-small-text {
color: #666;
display: block;
margin-top: 3px;
font-size: 11px;
}
.utr-submit-wrapper {
margin-bottom: 10px;
margin-top: 24px;
}
.utr-list {
margin-top: 15px;
border-top: 1px solid #eee;
}
.utr-table {
font-size: 13px;
}
.utr-table thead tr {
font-size: 13px;
}
.utr-table tbody {
font-size: 13px;
}
.utr-dropdown-item {
font-size: 13px;
padding: 5px 15px;
}
.utr-icon {
font-size: 16px;
}
#payout_modal .modal-body {
max-height: 550px; /* adjust as needed */
overflow-y: auto;
}
</style>
<style>
.utr-table td,
.utr-table th {
padding: 3px 8px !important;
vertical-align: middle;
line-height: 1.2;
}
.utr-table tbody tr {
height: 30px;
}
.utr-table thead th {
padding: 5px 8px !important;
}
.utr-table .btn-sm {
padding: 1px 6px;
font-size: 11px;
}
.utr-table .mdi {
font-size: 14px;
}
.utr-table .dropdown-menu {
min-width: 110px;
}
.utr-dropdown-item {
padding: 7px 10px !important;
}
table[data-custom-table-css="table"] tbody tr td {
padding: 1px 10px !important;
line-height: 12px;
min-height: 40px;
vertical-align: middle;
}
.dataTables_length label {height: 21px !important;}
</style>
<style>
.invoice-actions {
display: flex;
justify-content: flex-end;
gap: 10px;
}
#invoiceModal .modal-body {
max-height: 520px; /* adjust as needed */
overflow-y: auto;
}
</style>
<div class="col-12">
<div class="card">
<div class="card-body">
<div class="table-responsive">
<table data-custom-table-css="table" id="scroll-horizontal-datatable" class="table w-100 nowrap">
<thead class="bg-light">
<tr>
<th class="font-weight-medium">S.No.</th>
<th class="font-weight-medium">Inovice No</th>
<th class="font-weight-medium">Invoice Date</th>
<th class="font-weight-medium">Invoice Amount</th>
<th class="font-weight-medium">UTR Total Amount</th>
<th class="font-weight-medium">Balance</th>
<th class="font-weight-medium">Status</th>
<th class="font-weight-medium">Agent</th>
<th class="font-weight-medium">Action</th>
</tr>
</thead>
<tbody>
<?php if (isset($payout_list_data) && !empty($payout_list_data)) { ?>
<?php foreach($payout_list_data as $index => $row){ ?>
<tr>
<td> <?= $index + 1 ?> </td>
<td> <?= $row['invoice_no'] ?> </td>
<td> <?= change_date_format($row['invoice_date'], null, 'd-M-Y') ?? "" ?> </td>
<td> <?= format_indian_number($row['invoice_amount']) ?> </td>
<td> <?= format_indian_number($row['total_utr_amount']) ?> </td>
<td> <?= format_indian_number($row['balance_amount']) ?> </td>
<td> <?= $row['status_text'] ?> </td>
<td> <?= $row['agent_name'] ?? " - " ?> </td>
<td>
<div class="btn-group dropdown">
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" onclick="fetchUtrDetails(<?= $row['id'] ?>, '<?= $row['invoice_no'] ?>')"><i class="mdi mdi-bank-transfer mr-2 text-muted font-18 vertical-middle"></i>UTR</a>
<a href="<?= base_url('payout/invoices?type=edit&id=' . $row['id']) ?>" class="dropdown-item"><i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
<a href="<?= base_url('payout/invoices?type=adjustment&id=' . $row['id']) ?>" class="dropdown-item"><i class="mdi mdi-tune mr-2 text-muted font-18 vertical-middle"></i>Adjustment</a>
<a onclick="fetchPreviewInvoiceDetails(<?= $row['id'] ?>, '<?= $row['invoice_no'] ?>')" class="dropdown-item"><i class="mdi mdi-eye mr-2 text-muted font-18 vertical-middle"></i>Preview Invoice</a>
</div>
</div>
</td>
</tr>
<?php } ?>
<?php } ?>
</tbody>
</table>
</div>
</div><!-- end col -->
</div>
</div>
<div class="modal fade" id="payout_modal" tabindex="-1" role="dialog" aria-hidden="true" aria-modal="true" data-bs-backdrop="static">
<div class="modal-dialog modal-lg" style="max-width: 800px;">
<div class="modal-content">
<div class="modal-header" style="background-color: gainsboro;">
<h5 class="modal-title" id="myCenterModalLabel">UTR <span id="heading"></span></h5>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body" id="modal_body">
</div>
</div>
</div>
</div>
<!-- Invoice Preview Modal -->
<div class="modal fade" id="invoiceModal" tabindex="-1" role="dialog" aria-hidden="true" aria-modal="true" data-bs-backdrop="static">
<div class="modal-dialog modal-full-width">
<div class="modal-content">
<div class="modal-header" style="background-color: gainsboro;">
<h5 class="modal-title" id="invoiceModalLabel">
Invoice Preview <span id="invoice_heading"></span>
</h5>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body" id="invoice_modal_body">
<input type="hidden" id="row_invoice_id">
<!-- Action Buttons -->
<div class="invoice-actions">
<button class="btn btn-success btn-sm" onclick="downloadInvoicePdf()"><i class="mdi mdi-download"></i> Download PDF</button>
<!-- <button class="btn btn-info btn-sm" onclick="printInvoice()"><i class="mdi mdi-printer"></i> Print </button> -->
</div>
<hr>
<!-- Invoice Preview Container -->
<div id="invoicePreview"></div>
</div>
</div>
</div>
</div>
<!-------------------------------------------------------------------------------------------------->
<script>
// Datatable document ready
$(document).ready(function() {
var tableEl = $('#scroll-horizontal-datatable');
if (tableEl.length) {
var ticketsTable = tableEl.DataTable({
scrollX: true,
// 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
dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // Filter left, buttons right
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
text: 'Add',
className: 'btn app-btn-primary mr-2',
action: function (e, dt, node, config) {
window.location.href = "<?= base_url('payout/invoices?type=add') ?>";
}
},
{
extend: 'collection',
text: '<span class=" btn-custom"> Export </span><i class="mdi mdi-menu-down"></i>',
className: 'btn app-btn-secondary ',
buttons: [
{
extend: 'csv',
title: getExportFileName(),
text: '<i class="mdi mdi-file-delimited " ></i><span class=" btn-custom"> CSV </span>',
exportOptions: {
columns: ':not(:last-child)'
},
},
{
extend: 'excel',
title: getExportFileName(),
sheetName: getExportFileName(),
text: '<i class="mdi mdi-file-excel " ></i><span class=" btn-custom"> EXCEL </span>',
className: 'app-btn-primary ',
exportOptions: {
columns: ':not(:last-child)'
},
}
]
}
],
language: {
search: `
<div class="datatable-search-wrapper" style="position:relative; display:inline-block;">
_INPUT_
<i class="mdi mdi-magnify datatable-search-icon"
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666;"></i>
<i class="mdi mdi-close-circle datatable-clear-icon"
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666; display:none;"></i>
</div>`,
searchPlaceholder: "Search",
emptyTable: '<div class="text-center text-muted">No Data found</div>'
},
paging: true, // Enable pagination
pageLength: 10, // Set default number of rows per page (optional)
ordering: false
});
// IMPORTANT — DataTables draw event REF: TTS
ticketsTable.on('draw.dt', function () {
let rowCount = $('#scroll-horizontal-datatable').DataTable().rows({ filter: 'applied' }).count();
if (rowCount <= 2) {
$('.dataTables_scrollBody').css('overflow', 'inherit');
} else {
$('.dataTables_scrollBody').css('overflow', 'auto');
}
});
} else {
console.error("Table atet found.");
}
});
function fetchUtrDetails(invoice_id, invoice_no){
if (!invoice_id) {
toastr.warning("Invoice Id not found!", "WARNING");
return false;
}
let heading_text = ' - ( Invoice No : ' + invoice_no + ' )';
$('#modal_body').empty();
$('#heading').text(heading_text);
$('#modal_body').append('<div class="text-center p-5"><div class="spinner-border text-primary" role="status"><span class="sr-only">Loading...</span></div></div>');
var myModal = new bootstrap.Modal(document.getElementById('payout_modal'));
myModal.show();
let url = '<?= base_url('payout/fetchUtrDetails') ?>';
// Data to send in the AJAX request
let requestData = {
invoice_id: invoice_id,
};
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
// Send AJAX request
sendAjaxRequestForGlobal(url, 'POST', requestData, function(response) {
console.log('Data fetched successfully:', response);
$('#modal_body').empty();
$('#heading').text(heading_text);
$('#modal_body').append(response.data);
if (response.status == false) {
toastr.warning(response.message || 'Unable to fetch data', 'WARNING');
}
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, function(xhr, status, error) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.error('Error fetching data:', error);
console.error(xhr.responseText);
toastr.error('An error occurred while fetching the data.', 'ERROR');
});
}
function fetchPreviewInvoiceDetails(invoice_id, invoice_no){
if (!invoice_id) {
toastr.warning("Invoice Id not found!", "WARNING");
return false;
}
let heading_text = ' - ( ' + invoice_no + ' )';
$('#invoicePreview').empty();
$('#invoice_heading').text(heading_text);
$('#invoicePreview').append('<div class="text-center p-5"><div class="spinner-border text-primary" role="status"><span class="sr-only">Loading...</span></div></div>');
var myModal = new bootstrap.Modal(document.getElementById('invoiceModal'));
myModal.show();
let url = '<?= base_url('payout/invoices/preview') ?>';
// Data to send in the AJAX request
let requestData = {
invoice_id: invoice_id,
};
// Send AJAX request
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
console.log('Data fetched successfully:', response);
$('#invoicePreview').empty();
$('#invoice_heading').text(heading_text);
if (response.status == true) {
$('#invoicePreview').append(response.data);
$('#row_invoice_id').val(invoice_id);
}else{
$('#invoicePreview').append('<div class="text-center p-5 text-muted">No data found</div>');
}
}, function(xhr, status, error) {
console.error('Error fetching data:', error);
console.error(xhr.responseText);
// toastr.error('An error occurred while fetching the data.', 'ERROR');
$('#invoicePreview').empty();
$('#invoicePreview').append('<div class="text-center p-5 text-muted">No data found</div>');
});
}
function addInvoiceButton(){
window.location.href='<?= base_url('payout/invoices?type=add') ?>'
}
function getExportFileName() {
let d = new Date();
let day = String(d.getDate()).padStart(2, '0');
let month = String(d.getMonth() + 1).padStart(2, '0');
let year = d.getFullYear();
return `Invoices (${day}-${month}-${year})`;
}
function downloadInvoicePdf(){
let invoice_id = $('#row_invoice_id').val();
window.location.href = '<?= base_url('payout/invoices/downloadPdf/') ?>' + invoice_id
}
$('#invoiceModal').on('hidden.bs.modal', function () {
$('#row_invoice_id').val("");
console.log('value reseted...')
});
</script>

View File

@ -0,0 +1,199 @@
<div class="container-fluid-min">
<div class="col-12" id="bds_filter">
<div class="card-body">
<div id="accordion" class="mb-3">
<div class="card mb-1">
<h4 class="m-1">
<span>Filter</span>
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseOne"
aria-expanded="true">
<i id="icon" class="mdi mdi-chevron-down mr-1 text-primary" style="font-size: 28px;"></i>
</a>
</h4>
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
<div class="card-body">
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-3">
<label for="client_branch">Agents<span class="text-danger"></span></label>
<select class="form-control" id="agent_id" name="agent_id">
<option value="">Select Agent</option>
<?php if (isset($agent_list) && !empty($agent_list)) : ?>
<?php foreach ($agent_list as $agent) : ?>
<option value="<?= $agent['id']; ?>"><?= $agent['name']; ?></option>
<?php endforeach; ?>
<?php endif; ?>
</select>
</div>
<div class="form-group col-md-3">
<label for="client_branch_id">Status<span class="text-danger"></span></label>
<select class="form-control" id="status_id" name="status_id">
<option value="">Select status</option>
<?php if (isset($payout_status) && !empty($payout_status)) : ?>
<?php foreach ($payout_status as $id => $status) : ?>
<option value="<?= $id; ?>"><?= $status; ?></option>
<?php endforeach; ?>
<?php endif; ?>
</select>
</div>
<div class="form-group col-md-3" style="display: true;" id="date_div">
<label>Date<span class="text-danger"></span></label>
<div class="input-icon">
<input type="text" id="reportrange" class="form-control" readonly style="caret-color: transparent;">
<i class="mdi mdi-calendar-blank-outline additional-icon"></i>
</div>
<input type="hidden" id="startDate">
<input type="hidden" id="endDate">
</div>
<div class="form-group col-md-3 text-right" style="margin-top: 29px;">
<a class="btn btn-secondary" id="clear-filters">Clear</a>
<a class="btn btn-primary" id="get-emp-list" onclick="fetchPayoutList(this);">Submit</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- end page title -->
<div id="payout_list">
<?php if(isset($payout_list) && !empty($payout_list)) { echo $payout_list; }else{ } ?>
</div>
</div>
<script>
let utrHasBeenChanged = false;
$(document).ready(function(){
$('#agent_id').select2();
$('#startDate').val('');
$('#endDate').val('');
$('#reportrange').val('');
})
$(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(60, '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');
function cb(start, end) {
$('#reportrange').val(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,
locale: {
format: 'DD-MM-YYYY'
},
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')]
},
autoUpdateInput: false
}, cb);
// Only update inputs when user selects a date range
$('#reportrange').on('apply.daterangepicker', function(ev, picker) {
cb(picker.startDate, picker.endDate);
});
$('#clear-filters').on('click', function() {
// Reset all select dropdowns to the first option
$('#agent_id').val('').change();
$('#status_id').val('').change();
// Clear the date range inputs
$('#reportrange').val('');
$('#startDate').val('');
$('#endDate').val('');
window.location.reload(true);
});
});
function fetchPayoutList(internalCall = false)
{
let agent_id = $('#agent_id').val();
let status_id = $('#status_id').val();
let start_date = $('#startDate').val();
let end_date = $('#endDate').val();
console.log({agent_id, status_id, start_date, end_date, internalCall, utrHasBeenChanged});
if(!internalCall){
if (!agent_id && !status_id && !start_date && !end_date) {
toastr.warning("Please select any one filter!", "WARNING");
return false;
}
}
let url = '<?= base_url('payout/list') ?>';
// Data to send in the AJAX request
let requestData = {
agent_id: agent_id,
status_id: status_id,
start_date: start_date,
end_date: end_date,
};
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
// Send AJAX request
sendAjaxRequestForGlobal(url, 'POST', requestData, function(response) {
console.log('Data fetched successfully:', response);
$('#payout_list').empty();
$('#payout_list').append(response.data);
if (response.status == false) {
toastr.warning(response.message || 'Unable to fetch data', 'WARNING');
}
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, function(xhr, status, error) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
$('#payout_list').empty();
$('#payout_list').append(response.data);
console.error('Error fetching data:', error);
console.error(xhr.responseText);
toastr.error('An error occurred while fetching the data.', 'ERROR');
});
}
$(document).ready(function(){
$('#payout_modal').on('hidden.bs.modal', function () {
console.log("Payout Modal closed");
console.log('utrHasBeenChanged', utrHasBeenChanged);
if(utrHasBeenChanged == true){
fetchPayoutList(true);
}
});
});
</script>

View File

@ -0,0 +1,283 @@
<div>
<div class="summary-box">
<div class="summary-row">
<span>Invoice Amount:</span>
<span id="utrInvoiceAmount" data-id="<?php echo isset($summary['invoice_amount']) && !empty($summary['invoice_amount']) ? $summary['invoice_amount'] : ""?>">
<?php echo isset($summary['invoice_amount']) && !empty($summary['invoice_amount']) ? format_indian_number($summary['invoice_amount']) : "0.00"?>
</span>
</div>
<div class="summary-row">
<span>Total Paid:</span>
<span id="utrTotalPaid" data-id="<?php echo isset($summary['total_utr_amount']) && !empty($summary['total_utr_amount']) ? $summary['total_utr_amount'] : ""?>">
<?php echo isset($summary['total_utr_amount']) && !empty($summary['total_utr_amount']) ? format_indian_number($summary['total_utr_amount']) : "0.00"?>
</span>
</div>
<div class="summary-row">
<span>Remaining Balance:</span>
<span id="utrRemaining" data-id="<?php echo isset($summary['balance_amount']) && !empty($summary['balance_amount']) ? $summary['balance_amount'] : ""?>">
<?php echo isset($summary['balance_amount']) && !empty($summary['balance_amount']) ? format_indian_number($summary['balance_amount']) : "0.00"?>
</span>
</div>
</div>
<div id="utrContent">
<div class="utr-section">
<!-- <h5 class="utr-heading">Add New UTR</h5> -->
<form id="utrForm" role="form" class="parsley-examples">
<input type="hidden" name="utr_pk" id="utr_pk">
<input type="hidden" name="invoice_id" value="<?php echo isset($summary['id']) && !empty($summary['id']) ? $summary['id'] : ""?>">
<div class="row">
<div class="col-md-3">
<div class="form-group utr-form-group">
<label class="utr-label">UTR Number <span class="text-danger">*</span></label>
<input type="text" name="utr_no" id="utrNumber" class="form-control form-control-sm" placeholder="Enter UTR number" required>
</div>
</div>
<div class="col-md-3">
<div class="form-group utr-form-group">
<label class="utr-label">Amount () <span class="text-danger">*</span></label>
<input type="number" name="amount" id="utrAmount" oninput="checkSum(this)" class="form-control form-control-sm" step="0.01" placeholder="Enter amount" required>
<!-- <small class="utr-small-text">
Max: <span id="maxUtrAmount">₹0.00</span>
</small> -->
</div>
</div>
<div class="col-md-3">
<div class="form-group utr-form-group">
<label class="utr-label">Date <span class="text-danger">*</span></label>
<input type="text" name="utr_date" id="utrDate" class="form-control form-control-sm" placeholder="DD/MM/YYYY" required>
</div>
</div>
<div class="col-md-3" style="<?= !isset($invoice_completed) ? 'display: block;' : 'display: none;' ?>">
<div class="form-group utr-submit-wrapper">
<a onclick="resetvalues()" class="btn btn-secondary btn-sm">Clear</a>
<button id="utr_submit_btn" onclick="saveUtrDetails(event)" class="btn btn-primary btn-sm">Add UTR</button>
</div>
</div>
</div>
</form>
</div>
</div>
<div class="utr-list" id="utrList">
<h5 class="utr-heading">Existing UTRs</h5>
<div class="table-responsive">
<table data-custom-table-css="table" id="ticket-table" class="table table-sm w-100 nowrap utr-table">
<thead class="bg-light">
<tr>
<th class="font-weight-medium">S.No.</th>
<th class="font-weight-medium">UTR No</th>
<th class="font-weight-medium">Amount</th>
<th class="font-weight-medium">Date</th>
<!-- <th class="font-weight-medium">User</th> -->
<th class="font-weight-medium">Action</th>
</tr>
</thead>
<tbody>
<?php if (isset($utr_list_data) && !empty($utr_list_data)) { ?>
<?php foreach($utr_list_data as $index => $row){
$row['utr_date'] = change_date_format($row['utr_date'], null, 'd/m/Y') ?? " - "
?>
<tr>
<td> <?= $index + 1 ?> </td>
<td> <?= $row['utr_no'] ?> </td>
<td> <?= format_indian_number($row['amount']) ?> </td>
<td> <?= $row['utr_date'] ?> </td>
<!-- <td> <?php // format_indian_number($row['created_user']) ?> </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 style="<?= !isset($invoice_completed) ? 'display: block;' : 'display: none;' ?>" class="dropdown-item utr-dropdown-item" onclick='updateUtr(<?= htmlspecialchars(json_encode($row ?? []), ENT_QUOTES, "UTF-8") ?>)'><i class="mdi mdi-pencil mr-2 text-muted utr-icon vertical-middle"></i>Edit</a>
<a class="dropdown-item utr-dropdown-item" onclick="removeUtrApi(<?php echo isset($summary['id']) && !empty($summary['id']) ? $summary['id'] : ''?>, <?= $row['id'] ?>)"><i class="mdi mdi-delete mr-2 text-muted utr-icon vertical-middle"></i>Delete</a>
</div>
</div>
</td>
</tr>
<?php } ?>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
<script>
var dob = flatpickr("#utrDate", {
dateFormat: "d/m/Y",
allowInput: false,
maxDate: "today"
});
function saveUtrDetails(e) {
e.preventDefault();
console.log('saveUtrDetails function called');
var isValid = $('#utrForm').parsley().validate();
if (!isValid) {
$('#utrForm').find('input, select, textarea').each(function() {
if ($(this).parsley().isValid() === false && !$(this).val()) {
console.log(' :) Empty field ID:', this.id);
}
});
console.log('Form is Empty', 'Warning');
return;
}
var formData = new FormData($('#utrForm')[0]);
// Show loading state
$('#utr_submit_btn').prop('disabled', true).text('Saving...');
let url = '<?= base_url('payout/saveUtrDetails') ?>';
$.ajax({
url: url,
type: 'POST',
data: formData,
processData: false,
contentType: false,
dataType: 'json',
success: function(response) {
console.log('Data fetched successfully:', response);
if (response.status == true) {
toastr.success(response.message, 'SUCCESS');
$('#modal_body').empty();
$('#modal_body').append(response.data);
window.location.href = '<?= base_url("payout/list") ?>';
}else{
toastr.warning(response.message || 'Unable to fetch data', 'WARNING');
}
// Re-enable button
$('#utr_submit_btn').prop('disabled', false).text('Add UTR');
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
},
error: function(xhr, status, error) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.error('Error fetching data:', error);
console.error(xhr.responseText);
toastr.error('An error occurred while fetching the data.', 'ERROR');
},
complete: function() {
$('#utr_submit_btn').prop('disabled', false).text('Add UTR');
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
utrHasBeenChanged = true;
resetvalues();
}
});
}
function updateUtr(data){
console.log("data", data)
if(data){
$('#utr_pk').val(data.id);
$('#utrNumber').val(data.utr_no);
$('#utrAmount').val(data.amount);
$('#utrDate').val(data.utr_date);
$('#utr_submit_btn').text('Update UTR');
$('#utrNumber').trigger('focus');
}
}
function resetvalues(){
$('#utr_pk').val("");
$('#utrNumber').val("");
$('#utrAmount').val("");
$('#utrDate').val("");
$('#utr_submit_btn').text('Add UTR');
}
function removeUtrApi(invoice_id, utr_id) {
Swal.fire({
title: "Are you sure?",
text: "Do you want to remove this UTR?",
icon: "warning",
showCancelButton: true,
confirmButtonText: "Yes, Proceed!",
cancelButtonText: "Cancel"
}).then((result) => {
if (result.isConfirmed) {
removeUtr(invoice_id, utr_id);
}
});
}
function removeUtr(invoice_id, utr_id){
let url = '<?= base_url('payout/removeUtrDetails') ?>';
// Data to send in the AJAX request
let requestData = {
invoice_id: invoice_id,
utr_id: utr_id,
};
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
// Send AJAX request
sendAjaxRequestForGlobal(url, 'POST', requestData, function(response) {
console.log('Data fetched successfully:', response);
$('#modal_body').empty();
$('#modal_body').append(response.data);
if (response.status == true) {
toastr.success(response.message, 'SUCCESS');
}else{
toastr.warning(response.message || 'Unable to fetch data', 'WARNING');
}
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, function(xhr, status, error) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.error('Error fetching data:', error);
console.error(xhr.responseText);
toastr.error('An error occurred while fetching the data.', 'ERROR');
});
utrHasBeenChanged = true;
}
function checkSum(input) {
let invoice_amt = parseFloat($('#utrInvoiceAmount').data('id')) || 0;
let utr_amt = parseFloat($('#utrTotalPaid').data('id')) || 0;
let balance_amt = parseFloat($('#utrRemaining').data('id')) || 0;
let input_amt = parseFloat($(input).val()) || 0;
console.log({ invoice_amt, utr_amt, balance_amt, input_amt });
let total_amt = utr_amt + input_amt;
if (total_amt > invoice_amt) {
toastr.warning('UTR amount exceeds the invoice amount');
$(input).val('');
$('#utr_submit_btn').prop('disabled', true);
}else{
$('#utr_submit_btn').prop('disabled', false);
}
}
</script>

View File

@ -32,11 +32,13 @@
box-shadow: none;
outline: none;
width: 100%;
padding: 5px 30px !important;
}
#insurerTable th,
#insurerTable td {
padding: 5px;
height: 30px;
padding: 2px 4px !important;
/* height: 30px; */
vertical-align: middle;
}
@ -50,16 +52,65 @@
height: 20px;
width: 20px;
}
#insurerTable th,
#insurerTable th {
min-width: 230px;
}
/** newly implemented */
#insurerTable thead th:first-child {
border-top: 0px solid #fff !important;
border-bottom: 0px solid #fff !important;
background-color: transparent !important;
}
#insurerTable tbody td {
border-top: 0px solid #fff !important;
border-bottom: 0px solid #fff !important;
background-color: transparent !important;
}
#insurerTable th{
color: black !important;
background-color: transparent !important;
}
#insurerTable input[type="text"],
#insurerTable select {
width: 100%;
font-size: 14px;
line-height: 1.5;
color: #000;
background-color: #fff;
background-clip: padding-box;
border: 1px solid #ced4da;
border-radius: 4px;
transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
box-sizing: border-box;
}
/* Focus effect like form-control */
#insurerTable input[type="text"]:focus,
#insurerTable select:focus {
border-color: #80bdff;
outline: 0;
box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}
/* Disabled & readonly styling */
#insurerTable input[readonly],
#insurerTable input:disabled,
#insurerTable select:disabled {
background-color: #e0e0e0; /* Darker background */
color: #666; /* Darker text color */
cursor: not-allowed;
}
</style>
<style>
.readonly-color {
background-color: #e0e0e0; /* Darker background */
color: #666; /* Darker text color */
}
.readonly-select {
pointer-events: none;
/* background-color: #f0f0f0; */
@ -91,28 +142,13 @@
.input-with-percentage::after {
content: '%';
position: absolute;
right: 5px;
right: 10px;
top: 50%;
transform: translateY(-50%);
font-weight: bold;
color: #000;
}
/** newly implemented */
#insurerTable thead th:first-child {
border-top: 0px solid #fff !important;
border-bottom: 0px solid #fff !important;
background-color: transparent !important;
}
#insurerTable tbody td {
border-top: 0px solid #fff !important;
border-bottom: 0px solid #fff !important;
background-color: transparent !important;
}
#insurerTable th{
color: black !important;
background-color: transparent !important;
}
</style>
<div class="row" id="endorsement_form" style="display: none;">
@ -241,11 +277,6 @@
<input id="policy_end_date" type="text" class="form-control" placeholder="DD/MM/YYYY" readonly>
</div>
<div class="form-group col-md-3">
<label for="addon_policy">Policy Issue Month<span id="base_danger" class="text-danger">*</span></label>
<input type="text" class="form-control" id="month" name="month" placeholder="MM/YYYY" required>
</div>
<div class="form-group col-md-3">
<label for="addon_policy"> Endorsement Type <span id="base_danger" class="text-danger">*</span></label>
<select class="form-control" id="action_type" name="action_type" required>
@ -271,10 +302,15 @@
</div>
<div class="form-group col-md-3">
<label for="policy_issue_date">Date of Issue<span id="base_danger" class="text-danger">*</span></label>
<label for="policy_issue_date">Endorsement Issue Date<span id="base_danger" class="text-danger">*</span></label>
<input type="text" class="form-control" id="policy_issue_date" name="policy_issue_date" placeholder="DD/MM/YYYY" required>
</div>
<div class="form-group col-md-3">
<label for="month">Endorsement Issue Month<span id="base_danger" class="text-danger">*</span></label>
<input type="text" class="form-control readonly-select" id="month" name="month" placeholder="MM/YYYY" required>
</div>
<div class="form-group col-md-3">
<label for="endorse_eff_date">Endorsement Effective Date<span id="base_danger" class="text-danger"></span></label>
<input type="text" class="form-control" id="endorse_eff_date" name="endorse_eff_date" placeholder="DD/MM/YYYY" >
@ -399,15 +435,19 @@
<td>CD Amount</td>
</tr>
<tr id="table_tr_35">
<tr id="table_tr_35" style="display: none;">
<td>Follower Policy No</td>
</tr>
<tr id="table_tr_40" >
<td>Endorsement Issue Date</td>
</tr>
<tr id="table_tr_3" style="display: none;">
<td>Co-Share %</td>
</tr>
<tr id="table_tr_36">
<td>Non Commitional <br> Premium Amount</td>
<td>Non Commissional <br> Premium Amount</td>
</tr>
<tr id="table_tr_4">
<td>Base Premium</td>
@ -2120,100 +2160,103 @@
break;
case 4: // follower policy no
newCell = `<td class=""><input type="text" class="readonly-color" id="follower_policy_no_${insurerCount}" name="follower_policy_no[]" readonly></td>`;
break;
case 5: // calc_policy_issue_date
newCell = `<td class=""><input type="text" class="" id="calc_policy_issue_date_${insurerCount}" name="calc_policy_issue_date[]"></td>`;
break;
case 5: // Co-Share %
case 6: // Co-Share %
newCell = `<td class="input-with-percentage"><input type="text" id="co_share_per_${insurerCount}" class="right-align-input" name="co_share_per[]" oninput="validateRange(this)" onchange="co_share_percentage_calculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 6: // Non commissionable Premium amount %
case 7: // Non commissionable Premium amount %
newCell = `<td><input type="text" class="right-align-input" id="non_comm_per_amt_${insurerCount}" name="non_comm_per_amt[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 7: // Base Premium
case 8: // Base Premium
newCell = `<td><input type="text" class="right-align-input" id="base_premium_${insurerCount}" name="base_premium[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 8: // TP Premium
case 9: // TP Premium
newCell = `<td><input type="text" class="right-align-input" id="tp_premium_${insurerCount}" name="tp_premium[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 9: // Ter Premium
case 10: // Ter Premium
newCell = `<td><input type="text" class="right-align-input" id="ter_premium_${insurerCount}" name="ter_premium[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 10: // co Premium
case 11: // co Premium
newCell = `<td><input type="text" class="right-align-input" id="co_premium_${insurerCount}" name="co_premium[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 11: // Co TP Premium
case 12: // Co TP Premium
newCell = `<td><input type="text" class="right-align-input" id="co_tp_premium_${insurerCount}" name="co_tp_premium[]" oninput="" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 12: // Co Ter Premium
case 13: // Co Ter Premium
newCell = `<td><input type="text" class="right-align-input" id="co_ter_premium_${insurerCount}" name="co_ter_premium[]" oninput="" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 13: // CGST
case 14: // CGST
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="cgst_${insurerCount}" name="cgst[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 14: // SGST
case 15: // SGST
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="sgst_${insurerCount}" name="sgst[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 15: // IGST
case 16: // IGST
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="igst_${insurerCount}" name="igst[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 16: // GST Amount
case 17: // GST Amount
newCell = `<td><input type="text" class="right-align-input" id="gst_amount_${insurerCount}" name="gst_amount[]" onchange="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 17: // Stamp Duty
case 18: // Stamp Duty
newCell = `<td><input type="text" class="right-align-input" id="stamp_duty_${insurerCount}" name="stamp_duty[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 18: // Total
case 19: // Total
newCell = `<td><input type="text" class="readonly-color right-align-input" id="total_amt_${insurerCount}" name="total[]" readonly onkeypress="return onlyNumbers(event)"></td>`;
break;
case 19: // Agreed BP %
case 20: // Agreed BP %
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="agreed_bp_${insurerCount}" name="agreed_bp[]" oninput="amountCalculation('${insurerCount}'); validateRange(this)" onkeypress="return onlyNumbers(event)" ></td>`;
break;
case 20: // Agreed TP %
case 21: // Agreed TP %
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="agreed_tp_${insurerCount}" name="agreed_tp[]" oninput="amountCalculation('${insurerCount}'); validateRange(this)" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 21: // Agreed Ter %
case 22: // Agreed Ter %
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="agreed_tep_${insurerCount}" name="agreed_ter[]" oninput="amountCalculation('${insurerCount}'); validateRange(this)" onkeypress="return onlyNumbers(event)" ></td>`;
break;
case 22: // Agreed Amount
case 23: // Agreed Amount
newCell = `<td><input type="text" class="right-align-input" id="agreed_amount_${insurerCount}" name="agreed_amount[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 23: // Standard BP %
case 24: // Standard BP %
newCell = `<td class="input-with-percentage"><input type="text" class="readonly-color right-align-input" id="standard_bp_${insurerCount}" name="standard_bp[]" onkeypress="return onlyNumbers(event)" readonly></td>`;
break;
case 24: // Standard TP %
case 25: // Standard TP %
newCell = `<td class="input-with-percentage"><input type="text" class="readonly-color right-align-input" name="standard_tp[]" onkeypress="return onlyNumbers(event)" readonly ></td>`;
break;
case 25: // Standard Ter %
case 26: // Standard Ter %
newCell = `<td class="input-with-percentage"><input type="text" class="readonly-color right-align-input" name="standard_ter[]" onkeypress="return onlyNumbers(event)" readonly></td>`;
break;
case 26: // Actual BP Amount
case 27: // Actual BP Amount
newCell = `<td><input type="text" class="readonly-select right-align-input" id="actual_bp_amt_${insurerCount}" name="actual_bp_amt[]" onchange="actualAmountCalculation('${insurerCount}', 'bp_amt_for_calc')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 27: // Actual TP Amount
case 28: // Actual TP Amount
newCell = `<td><input type="text" class="readonly-select right-align-input" id="actual_tp_amt_${insurerCount}" name="actual_tp_amt[]" onchange="actualAmountCalculation('${insurerCount}', 'tp_amt_for_calc')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 28: // Actual TEP Amount
case 29: // Actual TEP Amount
newCell = `<td><input type="text" class="readonly-select right-align-input" id="actual_tep_amt_${insurerCount}" name="actual_tep_amt[]" onchange="actualAmountCalculation('${insurerCount}', 'tep_amt_for_calc')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 29: // Actual BP %
case 30: // Actual BP %
newCell = `<td class="input-with-percentage"><input type="text" class="readonly-select right-align-input" id="actual_bp_per_${insurerCount}" name="actual_bp_per[]" onchange="actualAmountCalculation('${insurerCount}', 'bp_per')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 30: // Actual TP %
case 31: // Actual TP %
newCell = `<td class="input-with-percentage"><input type="text" class="readonly-select right-align-input" id="actual_tp_per_${insurerCount}" name="actual_tp_per[]" onchange="actualAmountCalculation('${insurerCount}', 'tp_per')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 31: // Actual TEP %
case 32: // Actual TEP %
newCell = `<td class="input-with-percentage"><input type="text" class="readonly-select right-align-input" id="actual_tep_per_${insurerCount}" name="actual_tep_per[]" onchange="actualAmountCalculation('${insurerCount}', 'tep_per')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 32: // Actual BP Brokerage Amount
case 33: // Actual BP Brokerage Amount
newCell = `<td><input type="text" class="readonly-select right-align-input" id="actual_bp_brokerage_amt_${insurerCount}" name="actual_bp_brokerage_amt[]" onchange="actualAmountCalculation('${insurerCount}', 'bp_broker_amt')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 33: // Actual TP Brokerage Amount
case 34: // Actual TP Brokerage Amount
newCell = `<td><input type="text" class="readonly-select right-align-input" id="actual_tp_brokerage_amt_${insurerCount}" name="actual_tp_brokerage_amt[]" onchange="actualAmountCalculation('${insurerCount}', 'tp_broker_amt' )" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 34: // Actual TEP Brokerage Amount
case 35: // Actual TEP Brokerage Amount
newCell = `<td><input type="text" class="readonly-select right-align-input" id="actual_tep_brokerage_amt_${insurerCount}" name="actual_tep_brokerage_amt[]" onchange="actualAmountCalculation('${insurerCount}', 'tep_broker_amt')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 35: // Expected Amount
case 36: // Expected Amount
newCell = `<td><input type="text" class="readonly-select right-align-input" id="exp_amt_${insurerCount}" name="exp_amt[]" onchange="actualAmountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
break;
// case 30: // Variance
@ -2222,7 +2265,7 @@
// case 31: // Reward
// newCell = `<td><input type="text" class="right-align-input" id="reward_${insurerCount}" name="reward[]" onkeypress="return onlyNumbers(event)"></td>`;
// break;
case 36: // ID For Update
case 37: // ID For Update
newCell = `<td><input type="hidden" name="co_share_id[]" id="co_share_id[]" onkeypress="return onlyNumbers(event)"></td>`;
break;
}
@ -2254,69 +2297,72 @@
case 4: // follower policy no
newCell = `<td class=""><input type="text" class="readonly-color" id="follower_policy_no_${insurerCount}" name="follower_policy_no[]" readonly></td>`;
break;
case 5: // Co-Share %
case 5: // calc_policy_issue_date
newCell = `<td class=""><input type="text" class="" id="calc_policy_issue_date_${insurerCount}" name="calc_policy_issue_date[]"></td>`;
break;
case 6: // Co-Share %
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" name="co_share_per[]" oninput="validateRange(this)" onchange="co_share_percentage_calculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 6: // Non commissionable Premium amount %
case 7: // Non commissionable Premium amount %
newCell = `<td><input type="text" class="right-align-input" id="non_comm_per_amt_${insurerCount}" name="non_comm_per_amt[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 7: // Base Premium
case 8: // Base Premium
newCell = `<td><input type="text" class="right-align-input" id="base_premium_${insurerCount}" name="base_premium[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 8: // TP Premium
case 9: // TP Premium
newCell = `<td><input type="text" class="right-align-input" id="tp_premium_${insurerCount}" name="tp_premium[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 9: // Ter Premium
case 10: // Ter Premium
newCell = `<td><input type="text" class="right-align-input" id="ter_premium_${insurerCount}" name="ter_premium[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 10: // co Premium
case 11: // co Premium
newCell = `<td><input type="text" class="right-align-input" id="co_premium_${insurerCount}" name="co_premium[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 11: // Co TP Premium
case 12: // Co TP Premium
newCell = `<td><input type="text" class="right-align-input" id="co_tp_premium_${insurerCount}" name="co_tp_premium[]" oninput="" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 12: // Co Ter Premium
case 13: // Co Ter Premium
newCell = `<td><input type="text" class="right-align-input" id="co_ter_premium_${insurerCount}" name="co_ter_premium[]" oninput="" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 13: // CGST
case 14: // CGST
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="cgst_${insurerCount}" name="cgst[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 14: // SGST
case 15: // SGST
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="sgst_${insurerCount}" name="sgst[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 15: // IGST
case 16: // IGST
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="igst_${insurerCount}" name="igst[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 16: // GST Amount
case 17: // GST Amount
newCell = `<td><input type="text" class="readonly-color right-align-input" id="gst_amount_${insurerCount}" name="gst_amount[]" oninput="amountCalculation('${insurerCount}')" readonly onkeypress="return onlyNumbers(event)"></td>`;
break;
case 17: // Stamp Duty
case 18: // Stamp Duty
newCell = `<td><input type="text" class="right-align-input" id="stamp_duty_${insurerCount}" name="stamp_duty[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 18: // Total
case 19: // Total
newCell = `<td><input type="text" class="readonly-color right-align-input" id="total_amt_${insurerCount}" name="total[]" readonly onkeypress="return onlyNumbers(event)"></td>`;
break;
case 19: // Agreed BP %
case 20: // Agreed BP %
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="agreed_bp_${insurerCount}" name="agreed_bp[]" oninput="amountCalculation('${insurerCount}'); validateRange(this)" onkeypress="return onlyNumbers(event)" ></td>`;
break;
case 20: // Agreed TP %
case 21: // Agreed TP %
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="agreed_tp_${insurerCount}" name="agreed_tp[]" oninput="amountCalculation('${insurerCount}'); validateRange(this)" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 21: // Agreed Ter %
case 22: // Agreed Ter %
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="agreed_tep_${insurerCount}" name="agreed_ter[]" oninput="amountCalculation('${insurerCount}'); validateRange(this)" onkeypress="return onlyNumbers(event)" ></td>`;
break;
case 22: // Standard BP %
case 23: // Standard BP %
newCell = `<td class="input-with-percentage"><input type="text" class="readonly-color right-align-input" id="standard_bp_${insurerCount}" name="standard_bp[]" onkeypress="return onlyNumbers(event)" readonly></td>`;
break;
case 23: // Standard TP %
case 24: // Standard TP %
newCell = `<td class="input-with-percentage"><input type="text" class="readonly-color right-align-input" name="standard_tp[]" onkeypress="return onlyNumbers(event)" readonly ></td>`;
break;
case 24: // Standard Ter %
case 25: // Standard Ter %
newCell = `<td class="input-with-percentage"><input type="text" class="readonly-color right-align-input" name="standard_ter[]" onkeypress="return onlyNumbers(event)" readonly></td>`;
break;
case 25: // ID For Update
case 26: // ID For Update
newCell = `<td><input type="hidden" name="co_share_id[]" id="co_share_id[]" onkeypress="return onlyNumbers(event)"></td>`;
break;
}
@ -2404,10 +2450,12 @@
if(is_co_pay_yes == 1){
$('.hidecotp').show();
$('#table_tr_7').show();
$('#table_tr_35').show();
$('#table_tr_3').show();
}else{
$('.hidecotp').hide();
$('#table_tr_7').hide();
$('#table_tr_35').hide();
$('#table_tr_3').hide();
}
@ -2452,6 +2500,11 @@
$('.follow_insurer').prop('required', false);
}
var calc_policy_issue_date = flatpickr("#calc_policy_issue_date_" + insurerCount, {
dateFormat: "d/m/Y",
allowInput: false
});
});
// Add click event for delete button
@ -2547,97 +2600,100 @@
case 4: // follower_policy_no
cell.find('input').val(data.follower_policy_no);
break;
case 5: // Co-Share %
case 5: // follower_policy_no
cell.find('input').val(data.pt_policy_issue_date);
break;
case 6: // Co-Share %
cell.find('input').val(data.co_share_per).toggleClass('readonly-select', !!disable_td);
break;
case 6: // non_comm_per_amt
case 7: // non_comm_per_amt
cell.find('input').val(data.non_comm_per_amt);
break;
case 7: // Base Premium
case 8: // Base Premium
cell.find('input').val(status ? data.bp_amt : '').toggleClass('readonly-select', !!disable_td);
break;
case 8: // TP Premium
case 9: // TP Premium
cell.find('input').val(status ? data.tp_amt : '').toggleClass('readonly-select', !!disable_td);
break;
case 9: // Ter Premium
case 10: // Ter Premium
cell.find('input').val(status ? data.tep_amt : '').toggleClass('readonly-select', !!disable_td);
break;
case 10: // Co Premium
case 11: // Co Premium
cell.find('input').val(status ? data.cop_amt : '').toggleClass('readonly-select', !!disable_td);
break;
case 11: // Co TP Premium
case 12: // Co TP Premium
cell.find('input').val(status ? data.cotp_amt : '').toggleClass('readonly-select', !!disable_td);
break;
case 12: // Co Ter Premium
case 13: // Co Ter Premium
cell.find('input').val(status ? data.cotep_amt : '').toggleClass('readonly-select', !!disable_td);
break;
case 13: // CGST
case 14: // CGST
cell.find('input').val(data.bp_cgst).toggleClass('readonly-select', !!disable_td);
break;
case 14: // SGST
case 15: // SGST
cell.find('input').val(data.bp_sgst).toggleClass('readonly-select', !!disable_td);
break;
case 15: // IGST
case 16: // IGST
cell.find('input').val(data.bp_igst).toggleClass('readonly-select', !!disable_td);
break;
case 16: // GST Amount
case 17: // GST Amount
cell.find('input').val(status ? data.bp_gst_amt : '').toggleClass('readonly-select', !!disable_td);
break;
case 17: // Stamp Duty
case 18: // Stamp Duty
cell.find('input').val(status ? data.stamp_duty : '').toggleClass('readonly-select', !!disable_td);
break;
case 18: // Total
case 19: // Total
cell.find('input').val(status ? data.amount : '');
break;
case 19: // Agreed BP %
case 20: // Agreed BP %
cell.find('input').val(data.agreed_bp_per).toggleClass('readonly-select', !!disable_td);
break;
case 20: // Agreed TP %
case 21: // Agreed TP %
cell.find('input').val(data.agreed_tp_per).toggleClass('readonly-select', !!disable_td);
break;
case 21: // Agreed Ter %
case 22: // Agreed Ter %
cell.find('input').val(data.agreed_tep_per).toggleClass('readonly-select', !!disable_td);
break;
case 22: // Agreed Amount
case 23: // Agreed Amount
cell.find('input').val(data.agreed_amt).toggleClass('readonly-select', !!disable_td);
break;
case 23: // Standard BP %
case 24: // Standard BP %
cell.find('input').val(data.standerd_bp_per);
break;
case 24: // Standard TP %
case 25: // Standard TP %
cell.find('input').val(data.standerd_tp_per);
break;
case 25: // Standard Ter %
case 26: // Standard Ter %
cell.find('input').val(data.standerd_tep_per);
break;
case 26: // Actual BP Amount
case 27: // Actual BP Amount
cell.find('input').val(status ? data.actual_bp_amt : '');
break;
case 27: // Actual TP Amount
case 28: // Actual TP Amount
cell.find('input').val(status ? data.actual_tp_amt : '');
break;
case 28: // Actual Ter Amount
case 29: // Actual Ter Amount
cell.find('input').val(status ? data.actual_tep_amt : '');
break;
case 29: // Actual BP %
case 30: // Actual BP %
cell.find('input').val(status ? data.actual_bp_per : '');
break;
case 30: // Actual TP %
case 31: // Actual TP %
cell.find('input').val(status ? data.actual_tp_per : '');
break;
case 31: // Actual Ter %
case 32: // Actual Ter %
cell.find('input').val(status ? data.actual_tep_per : '');
break;
case 32: // Actual BP Brokerage Amount
case 33: // Actual BP Brokerage Amount
cell.find('input').val(status ? data.actual_bp_brokerage_amt : '');
break;
case 33: // Actual TP Brokerage Amount
case 34: // Actual TP Brokerage Amount
cell.find('input').val(status ? data.actual_tp_brokerage_amt : '');
break;
case 34: // Actual Ter Brokerage Amount
case 35: // Actual Ter Brokerage Amount
cell.find('input').val(status ? data.actual_tep_brokerage_amt : '');
break;
case 35: // Expected Amount
case 36: // Expected Amount
cell.find('input').val(status ? data.exp_amt : '');
break;
// case 30: // Variance
@ -2646,7 +2702,7 @@
// case 31: // Reward
// cell.find('input').val(status ? data.reward : '');
// break;
case 36: // Co-share ID (hidden field)
case 37: // Co-share ID (hidden field)
cell.find('input[type="hidden"]').val(status ? data.id : '');
break;
}
@ -2668,67 +2724,70 @@
case 4: // follower_policy_no
cell.find('input').val(data.follower_policy_no);
break;
case 5: // Co-Share %
case 5: // follower_policy_no
cell.find('input').val(data.pt_policy_issue_date);
break;
case 6: // Co-Share %
cell.find('input').val(data.co_share_per).toggleClass('readonly-select', !!disable_td);
break;
case 6: // non_comm_per_amt
case 7: // non_comm_per_amt
cell.find('input').val(data.non_comm_per_amt);
break;
case 7: // Base Premium
case 8: // Base Premium
cell.find('input').val(status ? data.bp_amt : '').toggleClass('readonly-select', !!disable_td);
break;
case 8: // TP Premium
case 9: // TP Premium
cell.find('input').val(status ? data.tp_amt : '').toggleClass('readonly-select', !!disable_td);
break;
case 9: // Ter Premium
case 10: // Ter Premium
cell.find('input').val(status ? data.tep_amt : '').toggleClass('readonly-select', !!disable_td);
break;
case 10: // Co Premium
case 11: // Co Premium
cell.find('input').val(status ? data.cop_amt : '').toggleClass('readonly-select', !!disable_td);
break;
case 11: // Co TP Premium
case 12: // Co TP Premium
cell.find('input').val(status ? data.cotp_amt : '').toggleClass('readonly-select', !!disable_td);
break;
case 12: // Co Ter Premium
case 13: // Co Ter Premium
cell.find('input').val(status ? data.cotep_amt : '').toggleClass('readonly-select', !!disable_td);
break;
case 13: // CGST
case 14: // CGST
cell.find('input').val(data.bp_cgst).toggleClass('readonly-select', !!disable_td);
break;
case 14: // SGST
case 15: // SGST
cell.find('input').val(data.bp_sgst).toggleClass('readonly-select', !!disable_td);
break;
case 15: // IGST
case 16: // IGST
cell.find('input').val(data.bp_igst).toggleClass('readonly-select', !!disable_td);
break;
case 16: // GST Amount
case 17: // GST Amount
cell.find('input').val(status ? data.bp_gst_amt : '').toggleClass('readonly-select', !!disable_td);
break;
case 17: // Stamp Duty
case 18: // Stamp Duty
cell.find('input').val(status ? data.stamp_duty : '').toggleClass('readonly-select', !!disable_td);
break;
case 18: // Total
case 19: // Total
cell.find('input').val(status ? data.amount : '');
break;
case 19: // Agreed BP %
case 20: // Agreed BP %
cell.find('input').val(data.agreed_bp_per).toggleClass('readonly-select', !!disable_td);
break;
case 20: // Agreed TP %
case 21: // Agreed TP %
cell.find('input').val(data.agreed_tp_per).toggleClass('readonly-select', !!disable_td);
break;
case 21: // Agreed Ter %
case 22: // Agreed Ter %
cell.find('input').val(data.agreed_tep_per).toggleClass('readonly-select', !!disable_td);
break;
case 22: // Standard BP %
case 23: // Standard BP %
cell.find('input').val(data.standerd_bp_per);
break;
case 23: // Standard TP %
case 24: // Standard TP %
cell.find('input').val(data.standerd_tp_per);
break;
case 24: // Standard Ter %
case 25: // Standard Ter %
cell.find('input').val(data.standerd_tep_per);
break;
case 25: // Co-share ID (hidden field)
case 26: // Co-share ID (hidden field)
cell.find('input[type="hidden"]').val(status ? data.id : '');
break;
}
@ -2884,6 +2943,25 @@
})
$('#policy_issue_date').on('change', function(){
let date = $(this).val();
let date_set = false
$('[name="co_share_type[]"]').each(function () {
console.log('co_share_type[] value', $(this).val());
if($(this).val() == 1){
let uniqueid = $(this).data('id');
$('#calc_policy_issue_date_' + uniqueid).val(date).addClass('readonly-select');
date_set = true;
}
});
if(!date_set){
$('#calc_policy_issue_date_1').val(date).addClass('readonly-select');
}
});
//-----------------------------------------------------------------------------------------------------------
$(document).on('change', '#insurerTable input, #insurerTable select, #insurerTable textarea', function() {

View File

@ -164,6 +164,7 @@ table.dataTable thead th {
.slider.round:before {
border-radius: 50%;
}
.dataTables_length label {height: 21px !important;}
</style>
<div class="container-fluid-min">
@ -287,7 +288,6 @@ table.dataTable thead th {
</div>
</div>
</div>
</div>
</div>
@ -490,9 +490,14 @@ table.dataTable thead th {
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
dom: "<'row'<'col-sm-1'f><'col-sm-11 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
// dom: "<'row'<'col-sm-1'f><'col-sm-11 text-right'B>>" + // Filter left, buttons right
// dom: "<'row'<'col-12 d-flex justify-content-between'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
// "<'row'<'col-sm-12'tr>>" +
// "<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
dom: "<'row'<'col-12 d-flex justify-content-between'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
text: '<i class="mdi mdi-plus" ></i><span class=" btn-custom"> Add </span>',
@ -568,10 +573,24 @@ table.dataTable thead th {
maxDate: today // Disallow future dates
});
var month = flatpickr("#month", {
dateFormat: "M/Y", // Format as month and year
allowInput: false, // Disable manual input
});
var closure_date = flatpickr("#policy_issue_date", {
dateFormat: "d/m/Y",
allowInput: false
var policy_issue_date = flatpickr("#policy_issue_date", {
dateFormat: "d/m/Y", // Format as day-month-year
allowInput: false, // Disable manual input
onChange: function(selectedDates, dateStr, instance) {
// Get the selected date
var selectedDate = new Date(selectedDates[0]);
// Format the selected date to "M-Y"
var formattedMonth = flatpickr.formatDate(selectedDate, "M/Y");
// Set the value of the #month input
month.setDate(formattedMonth);
}
});
var install_due_date = flatpickr("#install_due_date", {
@ -579,26 +598,11 @@ table.dataTable thead th {
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
});
var month = flatpickr("#month", {
dateFormat: "M/Y",
allowInput: false,
});
});
function hide_list_show_add() {

View File

@ -32,11 +32,13 @@
box-shadow: none;
outline: none;
width: 100%;
padding: 5px 30px !important;
}
#insurerTable th,
#insurerTable td {
padding: 5px;
height: 30px;
padding: 2px 4px !important;
/* height: 30px; */
vertical-align: middle;
}
@ -50,6 +52,7 @@
height: 20px;
width: 20px;
}
#insurerTable th,
#insurerTable th {
min-width: 230px;
@ -96,11 +99,11 @@
.input-with-percentage::after {
content: '%';
position: absolute;
right: 5px;
right: 10px;
top: 50%;
transform: translateY(-50%);
font-weight: bold;
color: #000;
color: #495057;
}
/* .select2-container .select2-selection__rendered {
@ -142,21 +145,55 @@
}
/** newly implemented */
#insurerTable thead th:first-child {
border-top: 0px solid #fff !important;
border-bottom: 0px solid #fff !important;
background-color: transparent !important;
}
#insurerTable tbody td {
border-top: 0px solid #fff !important;
border-bottom: 0px solid #fff !important;
background-color: transparent !important;
}
#insurerTable th{
color: black !important;
background-color: transparent !important;
}
#insurerTable input[type="text"],
#insurerTable select {
width: 100%;
font-size: 14px;
line-height: 1.5;
color: #000;
background-color: #fff;
background-clip: padding-box;
border: 1px solid #ced4da;
border-radius: 4px;
transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
box-sizing: border-box;
}
/* Focus effect like form-control */
#insurerTable input[type="text"]:focus,
#insurerTable select:focus {
border-color: #80bdff;
outline: 0;
box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}
/* Disabled & readonly styling */
#insurerTable input[readonly],
#insurerTable input:disabled,
#insurerTable select:disabled {
background-color: #e0e0e0; /* Darker background */
color: #666; /* Darker text color */
cursor: not-allowed;
}
</style>
<style>
@ -654,7 +691,7 @@
<div class="form-group col-md-3">
<label for="addon_policy">Policy Issue Month<span id="base_danger" class="text-danger">*</span></label>
<input type="text" class="form-control" id="month" name="month" placeholder="MM/YYYY" >
<input type="text" class="form-control readonly-select" id="month" name="month" placeholder="MM/YYYY" >
</div>
<div class="form-group col-md-3">
@ -825,14 +862,17 @@
<tr id="table_tr_37">
<td>CD Amount</td>
</tr>
<tr id="table_tr_35">
<tr id="table_tr_35" style="display: none;">
<td>Follower Policy No</td>
</tr>
<tr id="table_tr_40">
<td>Policy Issue Date</td>
</tr>
<tr id="table_tr_3" style="display: none;">
<td>Co-Share %</td>
</tr>
<tr id="table_tr_36">
<td>Non Commitional <br> Premium Amount</td>
<td>Non Commissional <br> Premium Amount</td>
</tr>
<tr id="table_tr_4">
<td>Base Premium</td>
@ -1691,7 +1731,7 @@
var bap = selectedOption.data('bap');
var allocg = selectedOption.data('allocg');
console.log('allocg:', allocg);
// console.log('allocg:', allocg);
// console.log('EBP:', ebp);
// console.log('ETP:', etp);
@ -1870,10 +1910,8 @@
if (isAnyChecked) {
toastr.warning('Only one leader can be selected.', 'WARNING!');
$(this).prop('checked', false);
return;
}
});
$(document).on('click', '[name="co_share_type[]"]', function() {
let val = $(this).val();
let uniqueid = $(this).data('id');
@ -1889,10 +1927,24 @@
if(insurer == ""){
toastr.warning('Please select the insurer.', 'WARNING!');
$(this).prop('checked', false);
return;
}else{
$('#insurer_id').val(insurer)
}
$('[name="calc_policy_issue_date[]"]').each(function () {
$(this).val('').removeClass('readonly-select');
});
let policy_issue_date = $('#policy_issue_date').val();
if ($('#cop_yes').is(':checked') && $(this).is(':checked')) {
$('#follower_policy_no_' + uniqueid).prop('readonly', true);
$('#calc_policy_issue_date_' + uniqueid).val(policy_issue_date).addClass('readonly-select');;
} else {
$('#follower_policy_no_' + uniqueid).prop('readonly', false);
$('#calc_policy_issue_date_1').val(policy_issue_date).addClass('readonly-select');
}
});
$(document).on('change', 'select[name="relationship[]"]', function() {
@ -2417,7 +2469,7 @@
let selectedOption = $('#policy_type_id').find('option:selected');
let bap = selectedOption.data('bap');
let allocg = selectedOption.data('allocg');
console.log('allocg:', allocg);
// console.log('allocg:', allocg);
const event = window.event;
console.log("Event id:", event.target.id);
@ -3675,11 +3727,10 @@
let co_share_type = []; // Initialize an object to mimic the array structure
$('[name="cd_ac_no_for_child[]"]').each(function(index) {
let value = $(this).val();
$('[name="co_share_type[]"]').each(function(index) {
let value = $(this).is(':checked');
if(value){
co_share_type.push(1); // Assign value with index as key
}else{
co_share_type.push(2); // Assign value with index as key
}
@ -3967,7 +4018,7 @@
var selectedOption = $('#policy_type_id').find('option:selected');
var bap = selectedOption.data('bap');
var allocg = selectedOption.data('allocg');
console.log('allocg:', allocg);
// console.log('allocg:', allocg);
// do not remove this commented items
@ -4405,6 +4456,23 @@
$('#CDMasterForm')[0].reset();
});
$('#policy_issue_date').on('change', function(){
let date = $(this).val();
let date_set = false
$('[name="co_share_type[]"]').each(function () {
if($(this).is(':checked')){
let uniqueid = $(this).data('id');
$('#calc_policy_issue_date_' + uniqueid).val(date).addClass('readonly-select');
date_set = true;
}
});
if(!date_set){
$('#calc_policy_issue_date_1').val(date).addClass('readonly-select');
}
});
//------------------------------------------------------------------------------------------------------------
var insurerCount = 0;
@ -4469,108 +4537,111 @@
case 3: // CD Amount
newCell = `<td class=""><input type="text" class="right-align-input" id="cd_current_balance_${insurerCount}" readonly></td>`;
break;
case 4: // follower policy no %
case 4: // follower policy no
newCell = `<td class=""><input type="text" class="" id="follower_policy_no_${insurerCount}" name="follower_policy_no[]" onchange="validateInput(this, 'client_policy', 'policy_no')"></td>`;
break;
case 5: // policy issue date
newCell = `<td class=""><input type="text" class="" id="calc_policy_issue_date_${insurerCount}" name="calc_policy_issue_date[]"></td>`;
break;
case 5: // Co-Share %
case 6: // Co-Share %
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="co_share_per_${insurerCount}" name="co_share_per[]" oninput="validateRange(this); " onchange="co_share_percentage_calculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 6: // Non commissionable Premium amount %
case 7: // Non commissionable Premium amount %
newCell = `<td><input type="text" class="right-align-input" id="non_comm_per_amt_${insurerCount}" name="non_comm_per_amt[]" oninput="" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 7: // Base Premium
case 8: // Base Premium
newCell = `<td><input type="text" class="right-align-input" id="base_premium_${insurerCount}" name="base_premium[]" oninput="" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 8: // TP Premium
case 9: // TP Premium
newCell = `<td><input type="text" class="right-align-input" id="tp_premium_${insurerCount}" name="tp_premium[]" oninput="" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 9: // Ter Premium
case 10: // Ter Premium
newCell = `<td><input type="text" class="right-align-input" id="ter_premium_${insurerCount}" name="ter_premium[]" oninput="" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 10: // co Premium
case 11: // co Premium
newCell = `<td><input type="text" class="right-align-input" id="co_premium_${insurerCount}" name="co_premium[]" oninput="" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 11: // Co TP Premium
case 12: // Co TP Premium
newCell = `<td><input type="text" class="right-align-input" id="co_tp_premium_${insurerCount}" name="co_tp_premium[]" oninput="" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 12: // Co Ter Premium
case 13: // Co Ter Premium
newCell = `<td><input type="text" class="right-align-input" id="co_ter_premium_${insurerCount}" name="co_ter_premium[]" oninput="" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 13: // CGST
case 14: // CGST
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="cgst_${insurerCount}" name="cgst[]" oninput="" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 14: // SGST
case 15: // SGST
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="sgst_${insurerCount}" name="sgst[]" oninput="" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 15: // IGST
case 16: // IGST
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="igst_${insurerCount}" name="igst[]" oninput="" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 16: // GST Amount
case 17: // GST Amount
newCell = `<td><input type="text" class="right-align-input" id="gst_amount_${insurerCount}" name="gst_amount[]" onchange="" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 17: // Stamp Duty
case 18: // Stamp Duty
newCell = `<td><input type="text" class="right-align-input" id="stamp_duty_${insurerCount}" name="stamp_duty[]" oninput="" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 18: // Total
case 19: // Total
newCell = `<td><input type="text" class="readonly-color right-align-input" id="total_amt_${insurerCount}" name="total[]" readonly onkeypress="return onlyNumbers(event)"></td>`;
break;
case 19: // Agreed BP %
case 20: // Agreed BP %
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="agreed_bp_${insurerCount}" name="agreed_bp[]" oninput="validateRange(this); " onkeypress="return onlyNumbers(event)" ></td>`;
break;
case 20: // Agreed TP %
case 21: // Agreed TP %
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="agreed_tp_${insurerCount}" name="agreed_tp[]" oninput="validateRange(this); " onkeypress="return onlyNumbers(event)"></td>`;
break;
case 21: // Agreed Ter %
case 22: // Agreed Ter %
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="agreed_ter_${insurerCount}" name="agreed_ter[]" oninput="validateRange(this); " onkeypress="return onlyNumbers(event)" ></td>`;
break;
case 22: // Agreed Amount
case 23: // Agreed Amount
newCell = `<td><input type="text" class="right-align-input" id="agreed_amount_${insurerCount}" name="agreed_amount[]" oninput="" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 23: // Standard BP %
case 24: // Standard BP %
newCell = `<td class="input-with-percentage"><input type="text" class="readonly-color right-align-input" id="standard_bp_${insurerCount}" name="standard_bp[]" onkeypress="return onlyNumbers(event)" readonly></td>`;
break;
case 24: // Standard TP %
case 25: // Standard TP %
newCell = `<td class="input-with-percentage"><input type="text" class="readonly-color right-align-input" id="standard_tp_${insurerCount}" name="standard_tp[]" onkeypress="return onlyNumbers(event)" readonly ></td>`;
break;
case 25: // Standard Ter %
case 26: // Standard Ter %
newCell = `<td class="input-with-percentage"><input type="text" class="readonly-color right-align-input" id="standard_tep_${insurerCount}" name="standard_ter[]" onkeypress="return onlyNumbers(event)" readonly></td>`;
break;
case 26: // Actual BP Amount
case 27: // Actual BP Amount
newCell = `<td><input type="text" class="readonly-select right-align-input" id="actual_bp_amt_${insurerCount}" name="actual_bp_amt[]" onchange="actualAmountCalculation('${insurerCount}', 'bp_amt_for_calc')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 27: // Actual TP Amount
case 28: // Actual TP Amount
newCell = `<td><input type="text" class="readonly-select right-align-input" id="actual_tp_amt_${insurerCount}" name="actual_tp_amt[]" onchange="actualAmountCalculation('${insurerCount}', 'tp_amt_for_calc')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 28: // Actual TEP Amount
case 29: // Actual TEP Amount
newCell = `<td><input type="text" class="readonly-select right-align-input" id="actual_tep_amt_${insurerCount}" name="actual_tep_amt[]" onchange="actualAmountCalculation('${insurerCount}', 'tep_amt_for_calc')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 29: // Actual BP %
case 30: // Actual BP %
newCell = `<td class="input-with-percentage"><input type="text" class="readonly-select right-align-input" id="actual_bp_per_${insurerCount}" name="actual_bp_per[]" onchange="actualAmountCalculation('${insurerCount}', 'bp_per')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 30: // Actual TP %
case 31: // Actual TP %
newCell = `<td class="input-with-percentage"><input type="text" class="readonly-select right-align-input" id="actual_tp_per_${insurerCount}" name="actual_tp_per[]" onchange="actualAmountCalculation('${insurerCount}', 'tp_per')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 31: // Actual TEP %
case 32: // Actual TEP %
newCell = `<td class="input-with-percentage"><input type="text" class="readonly-select right-align-input" id="actual_tep_per_${insurerCount}" name="actual_tp_per[]" onchange="actualAmountCalculation('${insurerCount}', 'tep_per')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 32: // Actual BP Brokerage Amount
case 33: // Actual BP Brokerage Amount
newCell = `<td><input type="text" class="readonly-select right-align-input" id="actual_bp_brokerage_amt_${insurerCount}" name="actual_bp_brokerage_amt[]" onchange="actualAmountCalculation('${insurerCount}', 'bp_broker_amt')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 33: // Actual TP Brokerage Amount
case 34: // Actual TP Brokerage Amount
newCell = `<td><input type="text" class="readonly-select right-align-input" id="actual_tp_brokerage_amt_${insurerCount}" name="actual_tp_brokerage_amt[]" onchange="actualAmountCalculation('${insurerCount}', 'tp_broker_amt')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 34: // Actual TEP Brokerage Amount
case 35: // Actual TEP Brokerage Amount
newCell = `<td><input type="text" class="readonly-select right-align-input" id="actual_tep_brokerage_amt_${insurerCount}" name="actual_tep_brokerage_amt[]" onchange="actualAmountCalculation('${insurerCount}', 'tep_broker_amt')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 35: // Expected Amount
case 36: // Expected Amount
newCell = `<td><input type="text" class="readonly-select right-align-input" id="exp_amt_${insurerCount}" name="exp_amt[]" onchange="actual" onkeypress="return onlyNumbers(event)"></td>`;
break;
// case 34: // Variance
// newCell = `<td><input type="text" class="readonly-select right-align-input" id="variance_${insurerCount}" name="variance[]" onchange="actual" onkeypress="return onlyNumbers(event)"></td>`;
// break;
case 36: // ID For Update
case 37: // ID For Update
newCell = `<td><input type="hidden" name="co_share_id[]" id="co_share_id[]" onkeypress="return onlyNumbers(event)"></td>`;
break;
@ -4614,68 +4685,70 @@
case 4: // follower policy no %
newCell = `<td class=""><input type="text" class="" id="follower_policy_no_${insurerCount}" name="follower_policy_no[]" oninput="" onchange=""></td>`;
break;
case 5: // Co-Share %
case 5: // calc_policy_issue_date %
newCell = `<td class=""><input type="text" class="" id="calc_policy_issue_date_${insurerCount}" name="calc_policy_issue_date[]" oninput="" onchange=""></td>`;
break;
case 6: // Co-Share %
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="co_share_per_${insurerCount}" name="co_share_per[]" oninput="validateRange(this); " onchange="co_share_percentage_calculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 6: // Non commissionable Premium amount %
case 7: // Non commissionable Premium amount %
newCell = `<td><input type="text" class="right-align-input" id="non_comm_per_amt_${insurerCount}" name="non_comm_per_amt[]" oninput="" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 7: // Base Premium
case 8: // Base Premium
newCell = `<td><input type="text" class="right-align-input" id="base_premium_${insurerCount}" name="base_premium[]" oninput="" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 8: // TP Premium
case 9: // TP Premium
newCell = `<td><input type="text" class="right-align-input" id="tp_premium_${insurerCount}" name="tp_premium[]" oninput="" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 9: // Ter Premium
case 10: // Ter Premium
newCell = `<td><input type="text" class="right-align-input" id="ter_premium_${insurerCount}" name="ter_premium[]" oninput="" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 10: // co Premium
case 11: // co Premium
newCell = `<td><input type="text" class="right-align-input" id="co_premium_${insurerCount}" name="co_premium[]" oninput="" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 11: // Co TP Premium
case 12: // Co TP Premium
newCell = `<td><input type="text" class="right-align-input" id="co_tp_premium_${insurerCount}" name="co_tp_premium[]" oninput="" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 12: // Co Ter Premium
case 13: // Co Ter Premium
newCell = `<td><input type="text" class="right-align-input" id="co_ter_premium_${insurerCount}" name="co_ter_premium[]" oninput="" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 13: // CGST
case 14: // CGST
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="cgst_${insurerCount}" name="cgst[]" oninput="" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 14: // SGST
case 15: // SGST
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="sgst_${insurerCount}" name="sgst[]" oninput="" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 15: // IGST
case 16: // IGST
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="igst_${insurerCount}" name="igst[]" oninput="" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 16: // GST Amount
case 17: // GST Amount
newCell = `<td><input type="text" class="right-align-input" id="gst_amount_${insurerCount}" name="gst_amount[]" onchange="" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 17: // Stamp Duty
case 18: // Stamp Duty
newCell = `<td><input type="text" class="right-align-input" id="stamp_duty_${insurerCount}" name="stamp_duty[]" oninput="" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 18: // Total
case 19: // Total
newCell = `<td><input type="text" class="readonly-color right-align-input" id="total_amt_${insurerCount}" name="total[]" readonly onkeypress="return onlyNumbers(event)"></td>`;
break;
case 19: // Agreed BP %
case 20: // Agreed BP %
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="agreed_bp_${insurerCount}" name="agreed_bp[]" oninput="validateRange(this); " onkeypress="return onlyNumbers(event)" ></td>`;
break;
case 20: // Agreed TP %
case 21: // Agreed TP %
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="agreed_tp_${insurerCount}" name="agreed_tp[]" oninput="validateRange(this); " onkeypress="return onlyNumbers(event)"></td>`;
break;
case 21: // Agreed Ter %
case 22: // Agreed Ter %
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="agreed_ter_${insurerCount}" name="agreed_ter[]" oninput="validateRange(this); " onkeypress="return onlyNumbers(event)" ></td>`;
break;
case 22: // Standard BP %
case 23: // Standard BP %
newCell = `<td class="input-with-percentage"><input type="text" class="readonly-color right-align-input" id="standard_bp_${insurerCount}" name="standard_bp[]" onkeypress="return onlyNumbers(event)" readonly></td>`;
break;
case 23: // Standard TP %
case 24: // Standard TP %
newCell = `<td class="input-with-percentage"><input type="text" class="readonly-color right-align-input" id="standard_tp_${insurerCount}" name="standard_tp[]" onkeypress="return onlyNumbers(event)" readonly ></td>`;
break;
case 24: // Standard Ter %
case 25: // Standard Ter %
newCell = `<td class="input-with-percentage"><input type="text" class="readonly-color right-align-input" id="standard_tep_${insurerCount}" name="standard_ter[]" onkeypress="return onlyNumbers(event)" readonly></td>`;
break;
case 25: // ID For Update
case 26: // ID For Update
newCell = `<td><input type="hidden" name="co_share_id[]" id="co_share_id[]" onkeypress="return onlyNumbers(event)"></td>`;
break;
}
@ -4705,7 +4778,7 @@
var bap = selectedOption.data('bap');
var allocg = selectedOption.data('allocg');
console.log('allocg:', allocg);
// console.log('allocg:', allocg);
var client_type_id = $('#client_type').val() ?? 1;
@ -4784,11 +4857,6 @@
std_tp = itp;
std_tep = itep;
}
// console.log('client_type_id', client_type_id);
// console.log('std_bp', std_bp);
// console.log('std_tp', std_tp);
// console.log('std_tep', std_tep);
$('[name="standard_bp[]"]').val(std_bp);
$('[name="standard_tp[]"]').val(std_tp);
@ -4802,7 +4870,7 @@
});
insurer_count_array.push(insurerCount)
insurer_count_array.push(insurerCount);
// Add click event for delete button
// $('.delete-insurer').off('click').on('click', function() {
@ -4821,6 +4889,11 @@
} else {
$('.follow_insurer').prop('required', true);
}
var calc_policy_issue_date = flatpickr("#calc_policy_issue_date_" + insurerCount, {
dateFormat: "d/m/Y",
allowInput: false
});
}
function removeInsurerColumn(index, count_index) {
@ -4920,103 +4993,106 @@
case 4: // follower_policy_no
cell.find('input').val(data.follower_policy_no).toggleClass('readonly-select', !!disable_td);
break;
case 5: // Co-Share %
case 5: // pt_policy_issue_date
cell.find('input').val(data.pt_policy_issue_date).toggleClass('readonly-select', !!disable_td);
break;
case 6: // Co-Share %
cell.find('input').val(data.co_share_per).toggleClass('readonly-select', !!disable_td);
break;
case 6: // non_comm_per_amt
case 7: // non_comm_per_amt
cell.find('input').val(data.non_comm_per_amt);
break;
case 7: // Base Premium
case 8: // Base Premium
cell.find('input').val(data.bp_amt).toggleClass('readonly-select', !!disable_td);
break;
case 8: // TP Premium
case 9: // TP Premium
cell.find('input').val(data.tp_amt).toggleClass('readonly-select', !!disable_td);
break;
case 9: // Ter Premium
case 10: // Ter Premium
cell.find('input').val(data.tep_amt).toggleClass('readonly-select', !!disable_td);
break;
case 10: // Co Premium
case 11: // Co Premium
cell.find('input').val(data.cop_amt).toggleClass('readonly-select', !!disable_td);
break;
case 11: // Co TP Premium
case 12: // Co TP Premium
cell.find('input').val(data.cotp_amt).toggleClass('readonly-select', !!disable_td);
break;
case 12: // Co Ter Premium
case 13: // Co Ter Premium
cell.find('input').val(data.cotep_amt).toggleClass('readonly-select', !!disable_td);
break;
case 13: // CGST
case 14: // CGST
cell.find('input').val(data.bp_cgst).toggleClass('readonly-select', !!disable_td);
break;
case 14: // SGST
case 15: // SGST
cell.find('input').val(data.bp_sgst).toggleClass('readonly-select', !!disable_td);
break;
case 15: // IGST
case 16: // IGST
cell.find('input').val(data.bp_igst).toggleClass('readonly-select', !!disable_td);
break;
case 16: // GST Amount
case 17: // GST Amount
cell.find('input').val(data.bp_gst_amt).toggleClass('readonly-select', !!disable_td);
break;
case 17: // Stamp Duty
case 18: // Stamp Duty
cell.find('input').val(data.stamp_duty).toggleClass('readonly-select', !!disable_td);
break;
case 18: // Total
case 19: // Total
cell.find('input').val(data.amount).toggleClass('readonly-select', !!disable_td);
break;
case 19: // Agreed BP %
case 20: // Agreed BP %
cell.find('input').val(data.agreed_bp_per).toggleClass('readonly-select', !!disable_td);
break;
case 20: // Agreed TP %
case 21: // Agreed TP %
cell.find('input').val(data.agreed_tp_per).toggleClass('readonly-select', !!disable_td);
break;
case 21: // Agreed Ter %
case 22: // Agreed Ter %
cell.find('input').val(data.agreed_tep_per).toggleClass('readonly-select', !!disable_td);
break;
case 22: // Agreed Amount
case 23: // Agreed Amount
cell.find('input').val(data.agreed_amt).toggleClass('readonly-select', !!disable_td);
break;
case 23: // Standard BP %
case 24: // Standard BP %
cell.find('input').val(data.standerd_bp_per).toggleClass('readonly-select', !!disable_td);
break;
case 24: // Standard TP %
case 25: // Standard TP %
cell.find('input').val(data.standerd_tp_per).toggleClass('readonly-select', !!disable_td);
break;
case 25: // Standard Ter %
case 26: // Standard Ter %
cell.find('input').val(data.standerd_tep_per).toggleClass('readonly-select', !!disable_td);
break;
case 26: // Actual BP Amount
case 27: // Actual BP Amount
cell.find('input').val(data.actual_bp_amount);
break;
case 27: // Actual TP Amount
case 28: // Actual TP Amount
cell.find('input').val(data.actual_tp_amount);
break;
case 28: // Actual Ter Amount
case 29: // Actual Ter Amount
cell.find('input').val(data.actual_tep_amount);
break;
case 29: // Actual BP %
case 30: // Actual BP %
cell.find('input').val(data.actual_bp_percentage);
break;
case 30: // Actual TP %
case 31: // Actual TP %
cell.find('input').val(data.actual_tp_percentage);
break;
case 31: // Actual Ter %
case 32: // Actual Ter %
cell.find('input').val(data.actual_tep_percentage);
break;
case 32: // Actual BP Brokerage Amount
case 33: // Actual BP Brokerage Amount
cell.find('input').val(data.actual_bp_brokerage_amount);
break;
case 33: // Actual TP Brokerage Amount
case 34: // Actual TP Brokerage Amount
cell.find('input').val(data.actual_tp_brokerage_amount);
break;
case 34: // Actual Ter Brokerage Amount
case 35: // Actual Ter Brokerage Amount
cell.find('input').val(data.actual_tep_brokerage_amount);
break;
case 35: // Expected Amount
case 36: // Expected Amount
cell.find('input').val(data.exp_amt);
break;
// case 34: // Variance
// cell.find('input').val(data.variance);
// break;
case 36: // Co-share ID (hidden field)
case 37: // Co-share ID (hidden field)
cell.find('input[type="hidden"]').val(data.id);
break;
}
@ -5047,67 +5123,70 @@
case 4: // follower_policy_no
cell.find('input').val(data.follower_policy_no).toggleClass('readonly-select', !!disable_td);
break;
case 5: // co_share_per
case 5: // pt_policy_issue_date
cell.find('input').val(data.pt_policy_issue_date).toggleClass('readonly-select', !!disable_td);
break;
case 6: // co_share_per
cell.find('input').val(data.co_share_per).toggleClass('readonly-select', !!disable_td);
break;
case 6: // non_comm_per_amt
case 7: // non_comm_per_amt
cell.find('input').val(data.non_comm_per_amt);
break;
case 7: // Base Premium
case 8: // Base Premium
cell.find('input').val(data.bp_amt).toggleClass('readonly-select', !!disable_td);
break;
case 8: // TP Premium
case 9: // TP Premium
cell.find('input').val(data.tp_amt).toggleClass('readonly-select', !!disable_td);
break;
case 9: // Ter Premium
case 10: // Ter Premium
cell.find('input').val(data.tep_amt).toggleClass('readonly-select', !!disable_td);
break;
case 10: // Co Premium
case 11: // Co Premium
cell.find('input').val(data.cop_amt).toggleClass('readonly-select', !!disable_td);
break;
case 11: // Co TP Premium
case 12: // Co TP Premium
cell.find('input').val(data.cotp_amt).toggleClass('readonly-select', !!disable_td);
break;
case 12: // Co Ter Premium
case 13: // Co Ter Premium
cell.find('input').val(data.cotep_amt).toggleClass('readonly-select', !!disable_td);
break;
case 13: // CGST
case 14: // CGST
cell.find('input').val(data.bp_cgst).toggleClass('readonly-select', !!disable_td);
break;
case 14: // SGST
case 15: // SGST
cell.find('input').val(data.bp_sgst).toggleClass('readonly-select', !!disable_td);
break;
case 15: // IGST
case 16: // IGST
cell.find('input').val(data.bp_igst).toggleClass('readonly-select', !!disable_td);
break;
case 16: // GST Amount
case 17: // GST Amount
cell.find('input').val(data.bp_gst_amt).toggleClass('readonly-select', !!disable_td);
break;
case 17: // Stamp Duty
case 18: // Stamp Duty
cell.find('input').val(data.stamp_duty).toggleClass('readonly-select', !!disable_td);
break;
case 18: // Total
case 19: // Total
cell.find('input').val(data.amount).toggleClass('readonly-select', !!disable_td);
break;
case 19: // Agreed BP %
case 20: // Agreed BP %
cell.find('input').val(data.agreed_bp_per).toggleClass('readonly-select', !!disable_td);
break;
case 20: // Agreed TP %
case 21: // Agreed TP %
cell.find('input').val(data.agreed_tp_per).toggleClass('readonly-select', !!disable_td);
break;
case 21: // Agreed Ter %
case 22: // Agreed Ter %
cell.find('input').val(data.agreed_tep_per).toggleClass('readonly-select', !!disable_td);
break;
case 22: // Standard BP %
case 23: // Standard BP %
cell.find('input').val(data.standerd_bp_per).toggleClass('readonly-select', !!disable_td);
break;
case 23: // Standard TP %
case 24: // Standard TP %
cell.find('input').val(data.standerd_tp_per).toggleClass('readonly-select', !!disable_td);
break;
case 24: // Standard Ter %
case 25: // Standard Ter %
cell.find('input').val(data.standerd_tep_per).toggleClass('readonly-select', !!disable_td);
break;
case 25: // Co-share ID (hidden field)
case 26: // Co-share ID (hidden field)
cell.find('input[type="hidden"]').val(data.id);
break;
}
@ -6353,7 +6432,6 @@
}
}
function makeUniqueShortName(baseName) {
let input = $("#short_name")[0]; // input element
checkDuplicateTableFieldValue("clients", "short_name", baseName, function(isDuplicate) {

View File

@ -142,6 +142,7 @@ table.dataTable tbody td {
#inception_list{
margin-left:20px !important;
}
.dataTables_length label {height: 21px !important;}
</style>
@ -561,9 +562,14 @@ $(document).ready(function() {
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
dom: "<'row'<'col-sm-1'f><'col-sm-11 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
// dom: "<'row'<'col-12'f><'col-sm-11 text-right'B>>" + // Filter left, buttons right
// dom: "<'row'<'col-12 d-flex justify-content-between'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
// "<'row'<'col-sm-12'tr>>" +
// "<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
dom: "<'row'<'col-12 d-flex justify-content-between'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
text: '<i class="mdi mdi-plus" ></i><span class=" btn-custom"> Add </span>',

View File

View File

@ -65,6 +65,7 @@
z-index: -2;
pointer-events: none;
}
.dataTables_length label {height: 21px !important;}
</style>
<div class="container-fluid-min">
@ -217,9 +218,9 @@
$(document).ready(function(){
$('#tickets-table').DataTable({
dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
// dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
// "<'row'<'col-sm-12'tr>>" +
// "<'row'<'col-sm-5'i><'col-sm-7'p>>",
// buttons: [
// {
// extend: 'csv',
@ -230,6 +231,10 @@
// }
// }
// ],
dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
extend: 'collection',

View File

@ -33,7 +33,7 @@ table.dataTable tbody td {
flex-wrap: wrap;
gap: 8px;
}
.dataTables_length label {height: 21px !important;}
</style>
@ -84,7 +84,7 @@ table.dataTable tbody td {
<th style="display: none;">Business Type</th>
<th style="display: none;">Client Type</th>
<th>Insured Name</th>
<th>Policy/<br>Endorsement</th>
<th style="text-align:center;">Policy /<br>Endorsement</th>
<th>Policy Type</th>
<th style="display: none;">BAP Group</th>
<th style="display: none;">Vehicle Number</th>
@ -100,9 +100,9 @@ table.dataTable tbody td {
<th style="display: none;">Remarks</th>
<th>BP Premium</th>
<th>TP/Ter Premium</th>
<th style="display: none;">Premium <br> (without GST)</th>
<th style="text-align:center;">Premium <br>(without GST)</th>
<!-- <th style="display: none;">GST @ 18%</th> -->
<th>Total Premium</th>
<th style="display: none;">Total Premium</th>
<th>BP%</th>
<th>TP/Ter%</th>
<th style="display: none;">Rewards</th>
@ -144,9 +144,9 @@ table.dataTable tbody td {
<td style="display: none;"><?php echo $row['remarks'] ?: 'N/A'; ?></td>
<td class="right-align-input"><?php echo $row['bp_amt'] ?: '0.00'; ?></td>
<td class="right-align-input"><?php echo $row['tp_or_ter'] ?: '0.00'; ?></td>
<td class="right-align-input" style="display: none;"><?php echo $row['premium_wo_gst']; ?></td>
<td class="right-align-input"><?php echo $row['premium_wo_gst']; ?></td>
<!-- <td class="right-align-input" style="display: none;"><?php echo $row['gst_amount']; ?></td> -->
<td class="right-align-input"><?php echo $row['total_premium'] ?: '0.00'; ?></td>
<td class="right-align-input" style="display: none;"><?php echo $row['total_premium'] ?: '0.00'; ?></td>
<td class="right-align-input"><?php echo $row['agreed_bp_per'] ?: '0.00'; ?>%</td>
<td class="right-align-input"><?php echo $row['agreed_tp_or_ter_per'] ?: '0.00';?>%</td>
<td class="right-align-input" style="display: none;"><?php echo isset($row['reward']) ? $row['reward'] : '0.00'; ?></td>
@ -232,9 +232,9 @@ $(document).ready(function() {
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
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
// 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',
@ -286,6 +286,10 @@ $(document).ready(function() {
// }
// }
// ],
dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // Filter left, buttons right
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
extend: 'collection',

View File

@ -33,6 +33,7 @@
flex-wrap: wrap;
gap: 8px;
}
.dataTables_length label {height: 21px !important;}
</style>
@ -301,9 +302,9 @@
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
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
// 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',
@ -355,6 +356,10 @@
// }
// }
// ],
dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // Filter left, buttons right
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
extend: 'collection',

View File

@ -20,6 +20,7 @@ table.dataTable tbody td {
.right-align-input {
text-align: right;
}
.dataTables_length label {height: 21px !important;}
</style>
<div class="col-12" id="second_page">
@ -149,9 +150,13 @@ $(document).ready(function() {
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
// 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
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
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
extend: 'csv',

View File

@ -28,6 +28,7 @@
color: #00999E !important;
transform: scale(1.5);
}
.dataTables_length label {height: 21px !important;}
</style>
<div class="container-fluid-min">
@ -140,7 +141,7 @@
<td class="text-center"><?php echo $employee['manager_name'] ?? 'N/A' ?></td>
<td class="text-center"><?php if (!empty($employee['created_at'])):
$cd = date("j F Y", strtotime($employee['created_at']));
$ct = date("h:i a", strtotime($employee['created_at']));
$ct = date("h:i A", strtotime($employee['created_at']));
echo $cd . "<br><span class='time'> " . $ct . "</span>";
endif; ?></td>
<td class="text-center"><?php if ($employee['status'] == 'open') {
@ -340,9 +341,9 @@
$(document).ready(function() {
$('#tickets-table').DataTable({
dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
// dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
// "<'row'<'col-sm-12'tr>>" +
// "<'row'<'col-sm-5'i><'col-sm-7'p>>",
// buttons: [{
// extend: 'csv',
// text: 'CSV',
@ -361,6 +362,10 @@
// }
// }
// }],
dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [{
extend: 'collection',
text: '<span class=" btn-custom"> Export </span><i class="mdi mdi-menu-down"></i>',

View File

@ -1,7 +1,6 @@
<style>
.dataTables_filter {
position: absolute;
}
.dataTables_filter {position: absolute;}
.dataTables_length label {height: 21px !important;}
</style>
<!-- End ADD and EDIT Page HTML -->
@ -117,9 +116,13 @@
var ticketsTable = $('#user-table');
ticketsTable.DataTable({
scrollX: true,
// dom: "<'row'<'col-sm-7'f><'col-sm-5 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
dom: "<'row'<'col-sm-7'f><'col-sm-5 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
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
text: 'Add',

View File

@ -17,6 +17,7 @@
.right-align-input {
text-align: right;
}
.dataTables_length label {height: 21px !important;}
</style>
<div class="col-12" id="second_page">
@ -97,9 +98,9 @@
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
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
// 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',
@ -111,6 +112,10 @@
// title: 'TAT BAND WISE DATA',
// }
// ],
dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // Filter left, buttons right
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
extend: 'collection',

View File

@ -120,7 +120,7 @@ th:first-child, td:first-child {
background-color:#00999E ;
margin-right:10px;
}
.dataTables_length label {height: 21px !important;}
</style>
@ -539,9 +539,13 @@ document.addEventListener("DOMContentLoaded", function () {
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
// 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
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
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [{
text:'Map Employees',
action: function(e, dt, node, config) {

View File

@ -35,6 +35,20 @@ table.dataTable tbody td {
color: #6c757d !important;
}
/* don't erase it. keep it safe
beccause = dataTables_length and dataTables_paginate need in same line thats why i tried in css ...
.dataTables_info,
.dataTables_length,
.dataTables_paginate {
display: flex;
align-items: center;
} */
.dataTables_length label {
height: 21px !important;
}
</style>
<div class="row" id="ticket_list">
@ -43,7 +57,7 @@ table.dataTable tbody td {
<div class="card-body">
<div>
<div class="table-responsive">
<table data-custom-table-css="table" class="table mb-0 nowrap w-100 table-centered" cellspacing="0" id="tickets-table">
<table data-custom-table-css="table" class="table mb-0 nowrap w-100 table-centered" cellspacing="0" id="thz-table">
<thead class="bg-light">
<tr>
@ -86,7 +100,7 @@ table.dataTable tbody td {
<td class="text-left">
<?php if (!empty($row['created_at'])):
$cd = date("j M Y", strtotime($row['created_at']));
$ct = date("h:i a", strtotime($row['created_at']));
$ct = date("h:i A", strtotime($row['created_at']));
echo $cd . "<br><span class='time'> " . $ct . "</span>";
endif;
?>
@ -94,7 +108,7 @@ table.dataTable tbody td {
<td class="text-left">
<?php if (!empty($row['updated_at'])):
$ud = date("j M Y", strtotime($row['updated_at']));
$ut = date("h:i a", strtotime($row['updated_at']));
$ut = date("h:i A", strtotime($row['updated_at']));
echo $ud . "<br><span class='time'> " . $ut . "</span>";
endif;
?>
@ -315,14 +329,18 @@ table.dataTable tbody td {
// Datatable document ready
$(document).ready(function() {
var ticketsTable = $('#tickets-table');
var ticketsTable = $('#thz-table');
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
// dom: "<'row'<'col-sm-7'f><'col-sm-5 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
dom: "<'row'<'col-sm-7'f><'col-sm-5 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
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
text: '<i class="mdi mdi-plus" ></i><span class=" btn-custom"> Add </span>',
@ -349,7 +367,7 @@ table.dataTable tbody td {
orthogonal: 'sort'
},
className: 'app-btn-primary ',
title: 'Tickets'
title: 'Tickets',
sheetName: 'Tickets',
}
]
@ -374,6 +392,12 @@ table.dataTable tbody td {
} else {
console.error("Table not found.");
}
$(document).on('click', '.datatable-clear-icon', function () {
const input = $(this).closest('.datatable-search-wrapper').find('input');
input.val('').trigger('input');
$('#thz-table').DataTable().search('').draw();
});
});

View File

@ -274,7 +274,7 @@ hr{
<!-- Bottom Row: Name + Date -->
<div class="d-flex justify-content-between small text-muted" style="padding-top: 5px;">
<span class="" style="font-weight: 400 !important;"><i class="mdi mdi-account"></i> <?= $conv['name'] ?></span>
<span style="font-size:9px; font-weight: 400 !important;" class=""><?= date("j F Y h:i a", strtotime($conv['created_at'])) ?></span>
<span style="font-size:9px; font-weight: 400 !important;" class=""><?= date("j F Y h:i A", strtotime($conv['created_at'])) ?></span>
</div>
<!-- <?php echo $i < count($notes)-1 ? '<hr/>' : ''; ?> -->
@ -410,7 +410,7 @@ data-backdrop="static"
<small classs="" style="font-size:7px;">
<?php if (!empty($rt['created_at'])):
$cd = date("j F Y", strtotime($rt['created_at']));
$ct = date("h:i a", strtotime($rt['created_at']));
$ct = date("h:i A", strtotime($rt['created_at']));
echo $cd . " " . $ct;
endif;
?>

View File

@ -23,7 +23,7 @@
</div>
<div class="col">
<div class="mb-3">
<div class="text-muted"><i class="mdi mdi-calendar-blank"></i> <?php echo (new DateTime($message['created_at']))->format('j F Y h:i a');?></div>
<div class="text-muted"><i class="mdi mdi-calendar-blank"></i> <?php echo (new DateTime($message['created_at']))->format('j F Y h:i A');?></div>
</div>
<div id="msg_388" class="form-group">
<p><?= $message['mail_content'] ?></p>
@ -69,7 +69,7 @@
</div>
<div class="col">
<div class="mb-3">
<div class="text-muted"><i class="mdi mdi-calendar-blank"></i> <?php echo (new DateTime($message['created_at']))->format('j F Y h:i a');?></div>
<div class="text-muted"><i class="mdi mdi-calendar-blank"></i> <?php echo (new DateTime($message['created_at']))->format('j F Y h:i A');?></div>
</div>
<div id="msg_394" class="form-group">
<p><?= $message['mail_content'] ?></p>

View File

@ -34,7 +34,7 @@ table.dataTable tbody td {
text-overflow: ellipsis !important;
white-space: nowrap !important;
}
.dataTables_length label {height: 21px !important;}
</style>
@ -95,9 +95,9 @@ $(document).ready(function() {
ticketsTable.DataTable({
scrollX: true,
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
// 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',
@ -112,6 +112,10 @@ $(document).ready(function() {
// },
// },
// ],
dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // Filter left, buttons right
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
extend: 'collection',

View File

@ -333,7 +333,7 @@
<div class="form-row">
<div class="form-group col-md-3 up_cnu" style="display: none;">
<label class="label-font-size" for="claim_number">Claim Number <span class="text-danger"></span></label>
<label class="label-font-size" for="claim_number">Claim Number</label>
<input type="text" class="form-control" id="claim_number" placeholder="Enter Claim NO"
value="<?= isset($ticket_data['claim_number']) ? $ticket_data['claim_number'] : '' ?>"
name="claim_number">
@ -370,9 +370,10 @@
</div>
<div class="form-group col-md-3 approved" style="display: none;">
<label class="label-font-size" for="approved_amount">Approved Amount</label> #
<label class="label-font-size" for="approved_amount">Approved Amount</label> <span style="display:none"># REF : SVR</span>
<input type="text" class="form-control" id="approved_amount" placeholder="Enter Approved Amount"
value="<?= isset($ticket_data['approved_amount']) ? $ticket_data['approved_amount'] : '' ?>" name="approved_amount">
value="<?= isset($ticket_data['approved_amount']) ? $ticket_data['approved_amount'] : '' ?>" name="approved_amount"
oninput="this.value = this.value.replace(/[^0-9]/g, '');">
</div>
<div class="form-group col-md-3 approved" style="display: none;">
@ -565,11 +566,11 @@
allowInput: false
});
// updateClaimStatusDisplay("<?= isset($ticket_data['claim_status_id']) ? $ticket_data['claim_status_id'] : 0 ?>")
var extraFields = <?= json_encode(isset($extra_fields) ? $extra_fields : []); ?>;
GlobelExtraFields = extraFields;
console.log("extraFields", extraFields);
claimStatusFieldChanges(extraFields);
updateClaimStatusDisplay("<?= isset($ticket_data['claim_status_id']) ? $ticket_data['claim_status_id'] : 0 ?>")
})
@ -948,16 +949,21 @@
})
function getClientPolicy() {
console.log("get policy function called");
hiddenData = $("#empIDHidden").val();
hiddenData = JSON.parse(hiddenData);
console.log('employee id ', hiddenData['emp_id']);
let ticket_type_id = $('#ticket_type_id').val();
console.log("ticket_type_id", ticket_type_id);
let client_id = $('#mobile_emp_client_data_list').val();
console.log({ticket_type_id, client_id});
data = {
emp_id: hiddenData['emp_id'],
ticket_type_id: ticket_type_id,
client_id: client_id,
}
$.ajax({
url: '<?= base_url("/ticket/getPoliciesbyEmpID") ?>',
type: "POST",

Some files were not shown because too many files have changed in this diff Show More