Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
29baa4661d
@ -776,3 +776,13 @@ $routes->group('payout', function($routes) {
|
||||
$routes->post('removeUtrDetails',"PayoutController::removeUtrDetails");
|
||||
});
|
||||
|
||||
//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");
|
||||
});
|
||||
|
||||
|
||||
@ -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";
|
||||
|
||||
@ -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');
|
||||
|
||||
@ -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'],
|
||||
|
||||
@ -754,7 +754,7 @@ class EmployeeRestController extends AdminController
|
||||
$result = $empServiceController->excelFileFormatValidation(['file_id' => $file_id]);
|
||||
if (isset($result['error_summary']) && count($result['error_summary'])) {
|
||||
$result = $empServiceController->getExcelErrorData($file_id);
|
||||
return $this->respond(['status' => 'failed', 'code' => 404, 'message' => "file upload failed with errors", 'data' => $result], 200);
|
||||
return $this->respond(['status' => 'failed', 'code' => 404, 'message' => "The data format is invalid. Click 'Next' to view details.", 'data' => $result], 200);
|
||||
}
|
||||
|
||||
|
||||
@ -2573,95 +2573,117 @@ class EmployeeRestController extends AdminController
|
||||
|
||||
public function claimView()
|
||||
{
|
||||
$ticket_id = $this->request->getGet('ticket_id');
|
||||
$ticketController = new TicketController;
|
||||
$data['ticket_history'] = $ticketController->ticketHistory($ticket_id);
|
||||
$data['claims_data'] = $this->ticketMaster->getTicketDataByTicketID($ticket_id);
|
||||
$data['ticket_data'] = $ticketController->getMoreInfo($requestFrom = 'rest', $ticket_id);
|
||||
try {
|
||||
|
||||
// $ticketData = $data['ticket_data'];
|
||||
// $ticketHistory = $data['ticket_history'];
|
||||
$ticket_id = $this->request->getGet('ticket_id');
|
||||
$ticketController = new TicketController;
|
||||
$data['ticket_history'] = $ticketController->ticketHistory($ticket_id);
|
||||
$data['claims_data'] = $this->ticketMaster->getTicketDataByTicketID($ticket_id);
|
||||
$data['ticket_data'] = $ticketController->getMoreInfo($requestFrom = 'rest', $ticket_id);
|
||||
|
||||
$ticketClaimStatus = $this->claimStatusModel->select('claim_status, display_name')->where('display_name is not null')->where('is_active', 1)->findAll();
|
||||
$status_list = array_column($ticketClaimStatus, 'display_name', 'claim_status');
|
||||
|
||||
$data['ticket_data'] = array_fill_keys(array_keys($data['ticket_data']), []);
|
||||
// $ticketData = $data['ticket_data'];
|
||||
// $ticketHistory = $data['ticket_history'];
|
||||
// print_r($ticketHistory); die;
|
||||
|
||||
$currentClaimStatus = $this->claimStatusModel->select("claim_status")->where('id', $data['claims_data']['claim_status_id'])->where('is_active', 1)->first();
|
||||
$ticketClaimStatus = $this->claimStatusModel->select('claim_status, display_name')->where('display_name is not null')->where('is_active', 1)->findAll();
|
||||
$status_list = array_column($ticketClaimStatus, 'display_name', 'claim_status');
|
||||
// print_r($currentClaimStatus); die;
|
||||
|
||||
// Loop through ticket_data
|
||||
foreach ($data['ticket_data'] as $status => &$fields) {
|
||||
// Search ticket_history for matching old_status_value
|
||||
foreach ($data['ticket_history'] as $history) {
|
||||
$data['ticket_data'] = array_fill_keys(array_keys($data['ticket_data']), []);
|
||||
|
||||
if ($history['old_status_value'] === $status) {
|
||||
// Attach modified_by and created_at
|
||||
// $fields['modified_by'] = $history['modified_by'];
|
||||
$fields['modified_by'] = "";
|
||||
$fields['modified_at'] = date('d-m-Y h:i A', strtotime($history['created_at']));
|
||||
// Break after first match (assuming latest entry is enough)
|
||||
break;
|
||||
// Loop through ticket_data
|
||||
foreach ($data['ticket_data'] as $status => &$fields) {
|
||||
// Search ticket_history for matching old_status_value
|
||||
foreach ($data['ticket_history'] as $history) {
|
||||
|
||||
if ($history['old_status_value'] === $status) {
|
||||
// Attach modified_by and created_at
|
||||
// $fields['modified_by'] = $history['modified_by'];
|
||||
$fields['modified_by'] = "";
|
||||
$fields['modified_at'] = date('d-m-Y h:i A', strtotime($history['created_at']));
|
||||
// Break after first match (assuming latest entry is enough)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$new_ticket_data = [];
|
||||
$data['ticket_data'][$currentClaimStatus['claim_status']]['modified_by'] = "";
|
||||
$data['ticket_data'][$currentClaimStatus['claim_status']]['modified_at'] = $formatted = date('d-m-Y h:i A', strtotime($data['claims_data']['updated_at']));
|
||||
|
||||
foreach ($data['ticket_data'] as $oldKey => $value) {
|
||||
$new_ticket_data = [];
|
||||
|
||||
// Only process if key exists in status_list
|
||||
if (!isset($status_list[$oldKey])) {
|
||||
continue; // skip and do NOT add to new array
|
||||
foreach ($data['ticket_data'] as $oldKey => $value) {
|
||||
|
||||
// Only process if key exists in status_list
|
||||
if (!isset($status_list[$oldKey])) {
|
||||
continue; // skip and do NOT add to new array
|
||||
}
|
||||
|
||||
// Get new key based on mapping
|
||||
$newKey = $status_list[$oldKey];
|
||||
|
||||
// Avoid duplicates
|
||||
if (!isset($new_ticket_data[$newKey])) {
|
||||
$new_ticket_data[$newKey] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
// Get new key based on mapping
|
||||
$newKey = $status_list[$oldKey];
|
||||
uasort($new_ticket_data, function ($a, $b) {
|
||||
$timeA = \DateTime::createFromFormat('d-m-Y h:i A', $a['modified_at']);
|
||||
$timeB = \DateTime::createFromFormat('d-m-Y h:i A', $b['modified_at']);
|
||||
return $timeA <=> $timeB; // Ascending
|
||||
});
|
||||
|
||||
// Avoid duplicates
|
||||
if (!isset($new_ticket_data[$newKey])) {
|
||||
$new_ticket_data[$newKey] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
uasort($new_ticket_data, function ($a, $b) {
|
||||
$timeA = \DateTime::createFromFormat('d-m-Y h:i A', $a['modified_at']);
|
||||
$timeB = \DateTime::createFromFormat('d-m-Y h:i A', $b['modified_at']);
|
||||
return $timeA <=> $timeB; // Ascending
|
||||
});
|
||||
|
||||
$data['ticket_data'] = $new_ticket_data;
|
||||
$data['ticket_data'] = $new_ticket_data;
|
||||
|
||||
|
||||
$ticketMesssageModel = new TicketMessageModel();
|
||||
$ticket_message = $ticketMesssageModel
|
||||
->where('is_active', 1)
|
||||
->where('sender', "user")
|
||||
->where('ticket_id', $ticket_id)
|
||||
->orderBy('id', "desc")
|
||||
->first();
|
||||
|
||||
$claim_file_urls = [];
|
||||
|
||||
if (isset($ticket_message['id'])) {
|
||||
|
||||
$claimFiles = new ClaimFilesModel();
|
||||
$claim_files_data = $claimFiles
|
||||
->select('id as claim_file_id, doc_name as claim_file_name')
|
||||
$ticketMesssageModel = new TicketMessageModel();
|
||||
$ticket_message = $ticketMesssageModel
|
||||
->where('is_active', 1)
|
||||
->where('file_type', 2)
|
||||
->where('sender', "user")
|
||||
->where('ticket_id', $ticket_id)
|
||||
->where('ticket_message_id', $ticket_message['id'])
|
||||
->findAll();
|
||||
->orderBy('id', "desc")
|
||||
->first();
|
||||
|
||||
foreach ($claim_files_data as &$value) {
|
||||
$value['url'] = base_url('downloadClaimFile/') . $value['claim_file_id'];
|
||||
$claim_file_urls[] = $value;
|
||||
$claim_file_urls = [];
|
||||
|
||||
if (isset($ticket_message['id'])) {
|
||||
|
||||
$claimFiles = new ClaimFilesModel();
|
||||
$claim_files_data = $claimFiles
|
||||
->select('id as claim_file_id, doc_name as claim_file_name')
|
||||
->where('is_active', 1)
|
||||
->where('file_type', 2)
|
||||
->where('ticket_id', $ticket_id)
|
||||
->where('ticket_message_id', $ticket_message['id'])
|
||||
->findAll();
|
||||
|
||||
foreach ($claim_files_data as &$value) {
|
||||
$value['url'] = base_url('downloadClaimFile/') . $value['claim_file_id'];
|
||||
$claim_file_urls[] = $value;
|
||||
}
|
||||
unset($value);
|
||||
}
|
||||
unset($value);
|
||||
|
||||
$data['claim_files'] = $claim_file_urls;
|
||||
|
||||
return $this->respond(['status' => (count($data) ? 'success' : 'failed'), 'code' => (count($data) ? 200 : 404), 'data' => $data,], 200);
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
$this->myLogger->logme("error", 'claim_view' .($th->getMessage() . ' --- ' . $th->getLine() . '----' . $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,
|
||||
];
|
||||
return $this->respond(['status' => 'failed', 'code' => 500, 'data' => "", 'error_data' => $errorData], 500);
|
||||
}
|
||||
|
||||
$data['claim_files'] = $claim_file_urls;
|
||||
|
||||
return $this->respond(['status' => (count($data) ? 'success' : 'failed'), 'code' => (count($data) ? 200 : 404), 'data' => $data,], 200);
|
||||
}
|
||||
|
||||
|
||||
@ -3810,15 +3832,17 @@ class EmployeeRestController extends AdminController
|
||||
// 'Under Process' => [5, 6, 7, 10, 19, 23, 45, 50, 29, 33, 51, 39, 43, 56],
|
||||
// ];
|
||||
|
||||
$client_claim_status = [
|
||||
'Claim Received' => [1, 2, 3, 15, 16, 17, 18, 25, 26, 27, 28, 35, 36, 37, 38],
|
||||
'Under Process' => [5, 6, 7, 10, 19, 23, 45, 50, 29, 33, 51, 39, 43, 56],
|
||||
'Information Required' => [4],
|
||||
'Approved' => [9, 20, 30, 40],
|
||||
'Settled' => [11, 24, 34],
|
||||
'Denial Review Awaited' => [66],
|
||||
'Rejected' => [8, 49, 55, 60],
|
||||
];
|
||||
// $client_claim_status = [
|
||||
// 'Claim Received' => [1, 2, 3, 15, 16, 17, 18, 25, 26, 27, 28, 35, 36, 37, 38],
|
||||
// 'Under Process' => [5, 6, 7, 10, 19, 23, 45, 50, 29, 33, 51, 39, 43, 56],
|
||||
// 'Information Required' => [4],
|
||||
// 'Approved' => [9, 20, 30, 40],
|
||||
// 'Settled' => [11, 24, 34],
|
||||
// 'Denial Review Awaited' => [66],
|
||||
// 'Rejected' => [8, 49, 55, 60],
|
||||
// ];
|
||||
|
||||
$client_claim_status = $this->getClaimStatusGrouped();
|
||||
|
||||
foreach ($ticket_data as $key => $value) {
|
||||
|
||||
@ -3866,6 +3890,32 @@ class EmployeeRestController extends AdminController
|
||||
return $this->response->setJSON(['ticket_data' => $ticket_data])->setStatusCode(200);
|
||||
}
|
||||
|
||||
public function getClaimStatusGrouped()
|
||||
{
|
||||
// Fetch active claim statuses
|
||||
$ticketClaimStatus = $this->claimStatusModel
|
||||
->select('id, display_name')
|
||||
->where('display_name IS NOT NULL')
|
||||
->where('is_active', 1)
|
||||
->findAll();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($ticketClaimStatus as $row) {
|
||||
$name = $row['display_name'];
|
||||
$id = $row['id'];
|
||||
|
||||
if (!isset($result[$name])) {
|
||||
$result[$name] = [];
|
||||
}
|
||||
|
||||
$result[$name][] = $id;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
// not in use did for testing
|
||||
function encrypt_for_sso(): string
|
||||
{
|
||||
|
||||
@ -118,26 +118,28 @@ class InsuranceCommissionController extends AdminController
|
||||
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) {
|
||||
$this->rules[strtolower($dept)] = $rules;
|
||||
}
|
||||
|
||||
// print_r($this->rules);die();
|
||||
}
|
||||
|
||||
public function calculateCommission(array $policyData)
|
||||
{
|
||||
$department = $policyData['department'] ?? '';
|
||||
$deptKey = strtolower($department);
|
||||
|
||||
if (!isset($this->rules[$deptKey])) {
|
||||
throw new \Exception("No rules found for department: {$department}");
|
||||
}
|
||||
// print_r($this->rules);die();
|
||||
// if (!isset($this->rules[$deptKey])) {
|
||||
// throw new \Exception("No rules found for department: {$department}");
|
||||
// }
|
||||
|
||||
$matchingRules = [];
|
||||
|
||||
foreach ($this->rules[$deptKey] as $rule) {
|
||||
foreach ($this->rules as $rule) {
|
||||
if ($this->evaluateConditions($rule['conditions'] ?? [], $policyData)) {
|
||||
$matchingRules[] = $rule;
|
||||
}
|
||||
@ -146,7 +148,7 @@ class InsuranceCommissionController extends AdminController
|
||||
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];
|
||||
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -81,6 +81,7 @@ class PayoutController extends BaseController
|
||||
// for list
|
||||
$data['payout_status'] = $this->payout_status;
|
||||
$data['agent_list'] = $this->invoiceModel->agentList();
|
||||
$data['page_name'] = "Payout";
|
||||
$payout_data['payout_list_data'] = $this->invoiceModel->invoiceList();
|
||||
$data['payout_list'] = view('payout_list', $payout_data);
|
||||
|
||||
|
||||
@ -1,13 +1,48 @@
|
||||
<?php
|
||||
namespace App\Controllers;
|
||||
|
||||
use CodeIgniter\API\ResponseTrait;
|
||||
use App\Models\CommissionFilesModel;
|
||||
use App\Models\InsurerModel;
|
||||
|
||||
class RuleImportController extends AdminController
|
||||
{
|
||||
{
|
||||
use ResponseTrait;
|
||||
protected $myLogger;
|
||||
protected $ruleImportService;
|
||||
protected $commissionFilesModel;
|
||||
protected $departments;
|
||||
protected $insurerModel;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
{
|
||||
set_session_context('RuleImportController');
|
||||
|
||||
$this->myLogger = \Config\Services::mylogger();
|
||||
$this->ruleImportService = \Config\Services::ruleImportService();
|
||||
|
||||
$this->commissionFilesModel = new CommissionFilesModel();
|
||||
$this->insurerModel = new InsurerModel();
|
||||
$this->departments = [
|
||||
'motor' => 'Motor',
|
||||
'health' => 'Health',
|
||||
];
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -21,7 +56,7 @@ class RuleImportController extends AdminController
|
||||
try {
|
||||
$file = $this->request->getFile('rules_file');
|
||||
if (!$file || !$file->isValid()) {
|
||||
return $this->response->setJSON(['status'=>'error','message'=>'No file uploaded or upload error']);
|
||||
return $this->response->setJSON(['status'=>false,'message'=>'No file uploaded or upload error']);
|
||||
}
|
||||
|
||||
// Move uploaded file to writable temp location
|
||||
@ -42,53 +77,42 @@ class RuleImportController extends AdminController
|
||||
return $this->response->setJSON($result);
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
log_message('critical', 'RuleImportController::upload ' . $e->getMessage());
|
||||
return $this->response->setJSON(['status'=>'exception','message'=>$e->getMessage()]);
|
||||
$this->myLogger->logme('error', 'RuleImportController::upload ' . $e->getMessage());
|
||||
return $this->response->setJSON(['status'=>false,'message'=>$e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
public function upload()
|
||||
{
|
||||
// Make sure filesystem helpers available if you need them
|
||||
helper(['filesystem']);
|
||||
|
||||
// CommissionFilesModel – adjust namespace if different
|
||||
$commissionFilesModel = new \App\Models\CommissionFilesModel();
|
||||
|
||||
try {
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// 1. Get uploaded file
|
||||
// ---------------------------------------------------------
|
||||
$file = $this->request->getFile('rules_file');
|
||||
if (!$file || !$file->isValid()) {
|
||||
log_message('warning', 'RuleImportController::upload - No file or invalid upload.');
|
||||
return $this->respond([
|
||||
'status' => 'error',
|
||||
'message' => 'No file uploaded or upload error.'
|
||||
], 400);
|
||||
$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');
|
||||
$createdBy = $this->request->getPost('created_by');
|
||||
$overwrite = $this->request->getPost('overwrite') ?? 1;
|
||||
$createdBy = get_session_userid();
|
||||
|
||||
if (empty($insurerId) || empty($department) || empty($commissionMonth) || empty($createdBy)) {
|
||||
log_message('warning', 'RuleImportController::upload - Missing required POST data.', [
|
||||
'insurer_id' => $insurerId,
|
||||
'department' => $department,
|
||||
'commission_month' => $commissionMonth,
|
||||
'created_by' => $createdBy,
|
||||
]);
|
||||
return $this->respond([
|
||||
'status' => 'error',
|
||||
'message' => 'Missing required fields: insurer_id, department, commission_month, created_by.'
|
||||
], 400);
|
||||
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';
|
||||
@ -111,19 +135,18 @@ class RuleImportController extends AdminController
|
||||
|
||||
// sanitize user file name but keep it deterministic (no random, no timestamp)
|
||||
$safeName = preg_replace('/[^a-zA-Z0-9_\-\.]/', '_', $postedFileName);
|
||||
$targetFileName = $safeName;
|
||||
$movedFullPath = $uploadDir . $targetFileName;
|
||||
|
||||
// $movedFullPath = $uploadDir . $safeName;
|
||||
|
||||
$file->move($uploadDir, $targetFileName);
|
||||
$file->move($uploadDir, $safeName);
|
||||
$targetFileName = $file->getName();
|
||||
$movedFullPath = $uploadDir . $targetFileName;
|
||||
if (!file_exists($movedFullPath)) {
|
||||
log_message('error', "RuleImportController::upload - Failed to move uploaded file to {$movedFullPath}");
|
||||
return $this->respond([
|
||||
'status' => 'error',
|
||||
'message' => 'Failed to store uploaded file.'
|
||||
], 500);
|
||||
$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);
|
||||
}
|
||||
|
||||
log_message('info', "RuleImportController::upload - File moved to {$movedFullPath}");
|
||||
$this->myLogger->logme('info', "RuleImportController::upload - File moved to {$movedFullPath}");
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// 4. Insert commission_files row with status pending
|
||||
@ -132,7 +155,7 @@ class RuleImportController extends AdminController
|
||||
'file_name' => $targetFileName,
|
||||
'insurer_id' => (int)$insurerId,
|
||||
'department' => $department,
|
||||
'commission_month'=> $commissionMonth,
|
||||
'commission_month' => $commissionMonth,
|
||||
'rules_count' => 0, // will update on success
|
||||
'file_status' => $fileStatus, // 'pending' by default
|
||||
'is_active' => $isActive,
|
||||
@ -140,18 +163,19 @@ class RuleImportController extends AdminController
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
];
|
||||
|
||||
$commissionFilesModel->insert($insertData);
|
||||
$insertId = $commissionFilesModel->getInsertID();
|
||||
$this->commissionFilesModel->insert($insertData);
|
||||
$insertId = $this->commissionFilesModel->getInsertID();
|
||||
|
||||
if (empty($insertId)) {
|
||||
log_message('error', 'RuleImportController::upload - Failed to insert commission_files record', ['data' => $insertData]);
|
||||
$this->myLogger->logme('error', 'RuleImportController::upload - Failed to insert commission_files record', ['data' => $insertData]);
|
||||
return $this->respond([
|
||||
'status' => 'error',
|
||||
'status' => false,
|
||||
'code' => 404,
|
||||
'message' => 'Failed to record upload in database.'
|
||||
], 500);
|
||||
], 200);
|
||||
}
|
||||
|
||||
log_message('info', "RuleImportController::upload - commission_files inserted id={$insertId}", $insertData);
|
||||
$this->myLogger->logme('info', "RuleImportController::upload - commission_files inserted id={$insertId}", $insertData);
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// 5. Call ruleImportService->processUpload with inserted file info
|
||||
@ -172,22 +196,23 @@ class RuleImportController extends AdminController
|
||||
'commission_month' => $commissionMonth,
|
||||
];
|
||||
|
||||
log_message('info', 'RuleImportController::upload - Calling ruleImportService->processUpload', ['payload' => $payload]);
|
||||
$this->myLogger->logme('info', 'RuleImportController::upload - Calling ruleImportService->processUpload', ['payload' => $payload]);
|
||||
|
||||
$result = $this->ruleImportService->processUpload($payload);
|
||||
|
||||
if (!is_array($result) || !isset($result['status'])) {
|
||||
log_message('error', 'RuleImportController::upload - Invalid service response', ['response' => $result]);
|
||||
$this->myLogger->logme('error', 'RuleImportController::upload - Invalid service response', ['response' => $result]);
|
||||
// update file status as failed
|
||||
$commissionFilesModel->update($insertId, [
|
||||
$this->commissionFilesModel->update($insertId, [
|
||||
'file_status' => 'failed',
|
||||
'updated_by' => (int)$createdBy,
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
return $this->respond([
|
||||
'status' => 'error',
|
||||
'status' => false,
|
||||
'code' => 404,
|
||||
'message' => 'Invalid response from import service.'
|
||||
], 500);
|
||||
], 200);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
@ -202,56 +227,123 @@ class RuleImportController extends AdminController
|
||||
$rulesCount = count($rulesArray);
|
||||
|
||||
// Save JSON to WRITEPATH . 'uploads/commission/json/{insurer_id}_{department}.json'
|
||||
$jsonDir = WRITEPATH . 'uploads/commission/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) {
|
||||
log_message('error', 'RuleImportController::upload - json_encode failed for rules', [
|
||||
$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
|
||||
$commissionFilesModel->update($insertId, [
|
||||
$this->commissionFilesModel->update($insertId, [
|
||||
'file_status' => 'failed',
|
||||
'updated_by' => (int)$createdBy,
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
return $this->respond([
|
||||
'status' => 'error',
|
||||
'status' => false,
|
||||
'code' => 404,
|
||||
'message' => 'Failed to encode rules as JSON.'
|
||||
], 500);
|
||||
], 200);
|
||||
}
|
||||
|
||||
if (file_put_contents($jsonPath, $jsonData) === false) {
|
||||
log_message('error', 'RuleImportController::upload - Failed to write rules JSON file', ['json_path' => $jsonPath]);
|
||||
$commissionFilesModel->update($insertId, [
|
||||
// handle existing JSON file based on $override (bool)
|
||||
if (file_exists($jsonPath)) {
|
||||
if ($overwrite) {
|
||||
// delete existing file before writing (deterministic overwrite)
|
||||
if (!@unlink($jsonPath)) {
|
||||
$this->myLogger->logme('warning', 'RuleImportController::upload - Failed to delete existing JSON before overwrite', ['json_path' => $jsonPath]);
|
||||
// proceed to overwrite anyway by writing to the same path
|
||||
}
|
||||
$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' => 'error',
|
||||
'status' => false,
|
||||
'code' => 404,
|
||||
'message' => 'Failed to store rules JSON file.'
|
||||
], 500);
|
||||
}
|
||||
|
||||
log_message('info', 'RuleImportController::upload - Rules JSON written', [
|
||||
// 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
|
||||
$commissionFilesModel->update($insertId, [
|
||||
'file_status' => 'processed',
|
||||
$this->commissionFilesModel->update($insertId, [
|
||||
'file_status' => 'success',
|
||||
'rules_count' => $rulesCount,
|
||||
'updated_by' => (int)$createdBy,
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
@ -260,7 +352,8 @@ class RuleImportController extends AdminController
|
||||
]);
|
||||
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
'status' => true,
|
||||
'code' => 200,
|
||||
'message' => 'File processed successfully.',
|
||||
'file_id' => $insertId,
|
||||
'rules_count' => $rulesCount,
|
||||
@ -280,7 +373,7 @@ class RuleImportController extends AdminController
|
||||
$errors = $result['errors'] ?? [];
|
||||
|
||||
$updateData = [
|
||||
'file_status' => 'validation_failed',
|
||||
'file_status' => 'failed',
|
||||
'rules_count' => 0, // do not save rules
|
||||
'updated_by' => (int)$createdBy,
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
@ -291,15 +384,16 @@ class RuleImportController extends AdminController
|
||||
$updateData['annotated_file_path'] = $annotatedPath;
|
||||
}
|
||||
|
||||
$commissionFilesModel->update($insertId, $updateData);
|
||||
$this->commissionFilesModel->update($insertId, $updateData);
|
||||
|
||||
log_message('warning', "RuleImportController::upload - Validation failed for file_id={$insertId}", [
|
||||
$this->myLogger->logme('error', "RuleImportController::upload - Validation failed for file_id={$insertId}", [
|
||||
'errors' => $errors,
|
||||
'annotated_file' => $annotatedPath
|
||||
]);
|
||||
|
||||
return $this->respond([
|
||||
'status' => 'error',
|
||||
'status' => false,
|
||||
'code' => 404,
|
||||
'message' => 'Validation failed. No rules saved.',
|
||||
'file_id' => $insertId,
|
||||
'errors' => $errors,
|
||||
@ -310,41 +404,242 @@ class RuleImportController extends AdminController
|
||||
// ---------------------------------------------------------
|
||||
// 8. Unexpected status
|
||||
// ---------------------------------------------------------
|
||||
log_message('error', 'RuleImportController::upload - Unexpected result status from service', ['result' => $result]);
|
||||
$commissionFilesModel->update($insertId, [
|
||||
$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' => 'error',
|
||||
'message' => 'Unexpected import service result.'
|
||||
], 500);
|
||||
|
||||
'status' => false,
|
||||
'code' => 404,
|
||||
'message' => $result['message']
|
||||
], 200);
|
||||
} catch (\Throwable $ex) {
|
||||
log_message('critical', 'RuleImportController::upload exception: ' . $ex->getMessage(), [
|
||||
$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 {
|
||||
$commissionFilesModel->update($insertId, [
|
||||
$this->commissionFilesModel->update($insertId, [
|
||||
'file_status' => 'failed',
|
||||
'updated_by' => isset($createdBy) ? (int)$createdBy : null,
|
||||
'updated_by' => get_session_userid(),
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
'notes' => 'Upload exception: ' . $ex->getMessage(),
|
||||
]);
|
||||
} catch (\Throwable $e2) {
|
||||
log_message('error', 'RuleImportController::upload - failed to update commission_files after exception: ' . $e2->getMessage());
|
||||
$this->myLogger->logme('error', 'RuleImportController::upload - failed to update commission_files after exception: ' . $e2->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return $this->respond([
|
||||
'status' => 'exception',
|
||||
'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->removeCommissionRules($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 deActiveCommissionRules($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);
|
||||
|
||||
// 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);
|
||||
// dd($rules);
|
||||
|
||||
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;
|
||||
foreach ($rules as &$rule) {
|
||||
if (!isset($rule['is_deleted']) && isset($rule['file_id']) && $rule['file_id'] == $id) {
|
||||
$rule['is_deleted'] = true; // <-- NEW FEATURE
|
||||
$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", "Rule marked deleted and file updated: $filePath");
|
||||
|
||||
return [
|
||||
'status' => true,
|
||||
'message' => 'Rule marked as deleted and file updated successfully'
|
||||
];
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -57,6 +57,8 @@ class ClientPolicyModel extends Model
|
||||
"placement_json",
|
||||
"policy_entry_from",
|
||||
"is_from_lead",
|
||||
"wellness_plan_id",
|
||||
"wellness_vendor_id",
|
||||
];
|
||||
|
||||
// Callbacks
|
||||
|
||||
@ -21,6 +21,7 @@ class CommissionFilesModel extends Model
|
||||
'is_active',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'rules_count',
|
||||
];
|
||||
|
||||
// Auto timestamps by CI4
|
||||
@ -28,6 +29,39 @@ class CommissionFilesModel extends Model
|
||||
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]',
|
||||
|
||||
@ -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() {
|
||||
@ -949,6 +968,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();
|
||||
|
||||
|
||||
685
app/Views/commission_file_upload.php
Normal file
685
app/Views/commission_file_upload.php
Normal file
@ -0,0 +1,685 @@
|
||||
<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;
|
||||
}
|
||||
</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; ?>
|
||||
<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>>",
|
||||
|
||||
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>
|
||||
@ -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>
|
||||
@ -2018,11 +2018,17 @@
|
||||
</li>
|
||||
<?php } ?>
|
||||
<li>
|
||||
<a href="<?= base_url('/payouts') ?>">
|
||||
<i class="ri-book-open-line"></i>
|
||||
<span> Payouts</span>
|
||||
</a>
|
||||
</li>
|
||||
<a href="<?= base_url('/payout/list') ?>">
|
||||
<i class="ri-book-open-line"></i>
|
||||
<span> Payouts</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/commission/list') ?>">
|
||||
<i class="ri-book-open-line"></i>
|
||||
<span> Commission</span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<?php } ?>
|
||||
</ul>
|
||||
|
||||
@ -182,11 +182,11 @@
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="row" style="padding-bottom: 10px;">
|
||||
<!-- <div class="row" style="padding-bottom: 10px;">
|
||||
<div class="col-6" style="align-self: center;">
|
||||
<h4 style="position: relative;">Payout List <span id="payout_title"></span></h4>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
<div class="table-responsive">
|
||||
<table data-custom-table-css="table" id="scroll-horizontal-datatable" class="table w-100 nowrap">
|
||||
<thead class="bg-light">
|
||||
|
||||
@ -48,7 +48,7 @@
|
||||
<input type="hidden" id="endDate">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-12 text-right m-b-0" style="margin-top: 29px;">
|
||||
<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>
|
||||
@ -69,6 +69,7 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
let utrHasBeenChanged = false;
|
||||
|
||||
$(document).ready(function(){
|
||||
$('#agent_id').select2();
|
||||
@ -131,16 +132,19 @@
|
||||
|
||||
});
|
||||
|
||||
function fetchPayoutList()
|
||||
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 (!agent_id && !status_id && !start_date && !end_date) {
|
||||
toastr.warning("Please select any one filter!", "WARNING");
|
||||
return false;
|
||||
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') ?>';
|
||||
@ -180,5 +184,15 @@
|
||||
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>
|
||||
@ -107,7 +107,7 @@
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script>
|
||||
|
||||
var dob = flatpickr("#utrDate", {
|
||||
dateFormat: "d/m/Y",
|
||||
@ -176,6 +176,7 @@
|
||||
$('#utr_submit_btn').prop('disabled', false).text('Add UTR');
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
utrHasBeenChanged = true;
|
||||
resetvalues();
|
||||
}
|
||||
});
|
||||
@ -253,6 +254,8 @@
|
||||
console.error(xhr.responseText);
|
||||
toastr.error('An error occurred while fetching the data.', 'ERROR');
|
||||
});
|
||||
|
||||
utrHasBeenChanged = true;
|
||||
}
|
||||
|
||||
function checkSum(input) {
|
||||
|
||||
@ -241,11 +241,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>
|
||||
@ -275,6 +270,11 @@
|
||||
<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">Policy 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" >
|
||||
|
||||
@ -287,7 +287,6 @@ table.dataTable thead th {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -568,10 +567,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 +592,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() {
|
||||
|
||||
@ -654,7 +654,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">
|
||||
|
||||
5
public/sample_excel/sample_commission.csv
Normal file
5
public/sample_excel/sample_commission.csv
Normal file
@ -0,0 +1,5 @@
|
||||
Rule Name,Policy Business Type,Policy Name,Premium Type,Vehicle Type,Vehicle Sub Type,Make,Model,CC Min,CC Max,Fuel Type,Vehicle Age Min,Vehicle Age Max,Vehicle Weight Min,Vehicle Weight Max,RTO State,RTO City,Renewal Type,Renewal Sub Type,Commission Type,Commission Value,Commission Params(TP:OD:PA),Notes
|
||||
Motor sample 1,Retail,,,Two Wheeler,,,,100,100,,,,,,,,,,composite,,10:25:0,"id: rule_68bc096e6d7df; conditions: vehicle_type == Two Wheeler; cubic_capcity == 100; calculation: composite 10% on tp_premium, 25% on od_premium"
|
||||
Motor sample 2,Retail,,,Four Wheeler,,,,1000,1000,,5,5,,,,,,,percentage,10,,id: rule_68fb5ad42f3c4; conditions: vehicle_type == Four Wheeler; cubic_capcity >= 1000; vehicle_age <= 5; calculation: 10% on premium
|
||||
Sample 2,Retail,,TP,Four Wheeler,,,,1000,1000,,,,,,,,,,composite,,10:0:0,id: rule_691438a7cb08b; conditions: vehicle_type == Four Wheeler; policy_type == TP; is_new_vehicle == true; cubic_capcity > 1000; calculation: composite 10% on tp_premium
|
||||
Sample 2 test,Retail,,,"Two Wheeler,Four Wheeler",,,,2500,2500,,,,,,,,,,flat,500,,"id: rule_6916ad2837807; conditions: vehicle_type in [Two Wheeler, Four Wheeler]; cubic_capcity == 2500; calculation: fixed 500 on premium"
|
||||
|
Loading…
Reference in New Issue
Block a user