Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
velz 2025-10-14 16:41:47 +05:30
commit fb2bf1fb56
24 changed files with 5094 additions and 818 deletions

View File

@ -172,6 +172,7 @@ $routes->group("/client", ["filter" => "authMVC"], function ($routes) {
$routes->group("others", ["filter" => "authMVC"], function ($routes) {
$routes->post("create", "ClientController::createOtherTabContent");
$routes->post('check-duplicate', 'ClientController::validateDuplicateByClientBranch');
});
});
@ -394,6 +395,11 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
$routes->get('getMemberDataExcelFileErrors', 'LeadsController::getMemberDataExcelFileErrors');
$routes->post('savePlacementDataAndValidateMemberDataFile', 'LeadsController::savePlacementDataAndValidateMemberDataFile');
$routes->get('checkMemberDataFileValidationStatus', 'LeadsController::checkMemberDataFileValidationStatus');
$routes->match(['get', 'post', 'delete'], 'nhanceBranchMaster', 'MasterController::nhanceBranchMaster');
$routes->match(['get', 'post', 'delete'], 'vehicleTypeMaster', 'MasterController::vehicleTypeMaster');
$routes->match(['get', 'post', 'delete'], 'rtoMaster', 'MasterController::rtoMaster');
});
$routes->post("policy_tranction/sendInstallmentRemainderMail","PolicyTransactionController::sendInstallmentRemainderMail");
@ -526,6 +532,7 @@ $routes->post("employeeRest/updateMpin", "RestAuthenticationController::updateMp
$routes->post("employeeRest/getPostEmployeeDataForAuth", "RestAuthenticationController::getPostEmployeeDataForAuth");
// $routes->post("logHrActivity", "RestAuthenticationController::logHrActivity");
$routes->get("employeeRest/getClientDetails", "EmployeeRestController::getClientDetails");
$routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
@ -550,7 +557,7 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
$routes->get("deleteDependence", "EmployeeRestController::deleteDependence");
$routes->get("getEmployeeAndDependenceByClientId", "EmployeeRestController::getEmployeeAndDependenceByClientId");
$routes->get("getClientPolicy", "EmployeeRestController::getClientPolicy");
$routes->get("getClientDetails", "EmployeeRestController::getClientDetails");
$routes->get("getAddOnPolicy", "EmployeeRestController::getAddOnPolicy");
$routes->post("iAgreeForAddOn", "EmployeeRestController::iAgreeForAddOn");
@ -706,8 +713,10 @@ $routes->group('test', function($routes) {
$routes->get('viewrfq', 'TestingController::viewRFQNonEb');
$routes->get('exportexcel', 'TestingController::exportExcel');
$routes->post('saverfq', 'TestingController::saverfq');
$routes->get('mapping_client_id_and_branch_id','TestingController::mapping_client_id_and_branch_id');
$routes->get('membervalidation', 'TestingController::membervalidation');
$routes->get('generateExcel', 'TestingController::generateExcel');
$routes->get('logo_renaming','TestingController::logo_renaming');
});
$routes->cli('cli/testcli', 'TestingController::testcli');

View File

@ -132,6 +132,15 @@ class ClientController extends AdminController
//--------------------------------------------------------------------------------------------------------
public function validateDuplicateByClientBranch()
{
$value = $this->request->getPost('value');
$clientId = $this->request->getPost('client_id');
$branchId = $this->request->getPost('branch_id');
$field = $this->request->getPost('field');
$isDuplicate = $this->clientModel->isDuplicateByClientBranch($value, $field, $clientId, $branchId);
return $this->response->setJSON(['isDuplicate' => $isDuplicate]);
}
public function checkDuplicateTableFieldValue()
{
$table = $this->request->getPost('table');
@ -1121,14 +1130,47 @@ class ClientController extends AdminController
}
$data['created_by'] = get_session_userid();
// before updating check if pre_branch_id is already existing in the current db
if(isset($data['pre_branch_id']) && !empty($data['pre_branch_id']))
{
$existing_pre_branch = $this->clientBranchModel
->where('pre_branch_id',$data['pre_branch_id'])
//->where('id !=',$post_branch_id)
->first();
if($existing_pre_branch)
{
return $this->respond([
'status' => false,
'code' => 409,
'message' => 'The branch is already mapped with another branch. Please check.',
], 409);
}
}
$insert = $this->clientBranchModel->insert($data);
$post_branch_id = $insert;
if ($insert) {
$level_contact_data = $this->request->getPost('level_contect_data');
$level_contact_data = !empty($level_contact_data) ? json_decode($level_contact_data, true) : null;
$this->saveLevelContacts($level_contact_data, $insert);
}
if($post_branch_id && isset($data['pre_branch_id']) && !empty($data['pre_branch_id']))
{
// need to update the client_branch in the pre
$result = $this->updatePreClientBranch($data['pre_branch_id'],$post_branch_id , "create");
log_message('error','Pre client_branch update result for pre_branch_id '.$data['pre_branch_id'].' and post_branch_id '.$post_branch_id.' is '.json_encode($result));
}
if ($insert) {
$branchData = $this->clientBranchModel->where('client_id', $this->request->getPost('client_id'))->findAll();
$branchData['role'] = get_role_id();
@ -1153,7 +1195,11 @@ class ClientController extends AdminController
$this->myLogger->logme('error', 'Client branch EDIT function called');
$id = $this->request->getPost('branch_id_primarykey');
$client_id = $this->request->getPost('client_id');
$pre_branch_id = $this->request->getPost('pre_branch_id') ?? '';
$data = $this->request->getPost();
$data['pre_branch_id'] = $pre_branch_id;
$units = $this->request->getPost('units');
$emp_unit_count = 0;
@ -1212,7 +1258,41 @@ class ClientController extends AdminController
}
$data['updated_by'] = get_session_userid();
$post_branch_id = $id;
// before updating check if pre_branch_id is already existing in the current db
if(isset($data['pre_branch_id']) && !empty($data['pre_branch_id']))
{
$existing_pre_branch = $this->clientBranchModel
->where('pre_branch_id',$data['pre_branch_id'])
->where('id !=',$post_branch_id)
->first();
if($existing_pre_branch)
{
return $this->respond([
'status' => false,
'code' => 409,
'message' => 'The branch is already mapped with another branch. Please check.',
], 409);
}
}
$insert = $this->clientBranchModel->update($id, $data);
if($post_branch_id && isset($data['pre_branch_id']) && !empty($data['pre_branch_id']))
{
// need to update the client_branch in the pre
$result = $this->updatePreClientBranch($data['pre_branch_id'],$post_branch_id , "update");
log_message('error','Pre client_branch update result for pre_branch_id '.$data['pre_branch_id'].' and post_branch_id '.$post_branch_id.' is '.json_encode($result));
}
$this->myLogger->logme('error', 'Client branch EDITED by {data}', ['data' => get_session_userid()]);
@ -4589,7 +4669,7 @@ class ClientController extends AdminController
// Additional logic for non-individual clients (client_type != 2)
$branch_insert = null;
if ($client_type != 2) {
$unit[] = $postData['short_name'] . '-' . $postData['branch_code'] ?? 001;
$unit[] = $postData['short_name'] . '-' . ($postData['branch_code'] ?? 001);
$branch_data = [
'client_id' => $client_insert,
'branch_name' => $postData['branch_name'],
@ -6939,7 +7019,9 @@ class ClientController extends AdminController
foreach ($postHrs as $post) {
$found = false;
foreach ($preHrs as $index => $pre) {
if ($post['hr_mobile'] === $pre['hr_mobile'] && $post['hr_mail'] === $pre['hr_mail']) {
if ( trim($post['hr_mobile']) == trim($pre['hr_mobile']) && trim($post['hr_mail']) == trim($pre['hr_mail']) ) {
$merged[] = [
'pre_hr_id' => $pre['pre_hr_id'],
'post_hr_id' => $post['post_hr_id'],
@ -6972,6 +7054,13 @@ class ClientController extends AdminController
// Remaining preHrs (not matched)
foreach ($preHrs as $pre) {
foreach ($merged as $value) {
if ( trim($pre['hr_mobile']) == trim($value['hr_mobile']) && trim($pre['hr_mail']) == trim($value['hr_mail']) ) {
continue 2; // Skip adding this pre_hr as it's already matched
}
}
$merged[] = [
'pre_hr_id' => $pre['pre_hr_id'],
'post_hr_id' => null,
@ -7130,9 +7219,15 @@ class ClientController extends AdminController
$post_branch_id = $value['post_branch_id'];
$post_hr_id = $value['post_hr_id'];
$value['pre_client_id'] = $this->getPreClientId($post_branch_id);
$value['pre_branch_id'] = $this->getPreBranchId($post_branch_id);
$value["pre_hr_id"] = $this->getPreHrId($post_branch_id);
$preBranchId = $this->getPreBranchIdByPostBranchId($post_branch_id);
if (!empty($preBranchId)) {
$value['pre_branch_id'] = $preBranchId;
$value['pre_client_id'] = $this->getPreClientIdByPreBranchId($preBranchId);
$value["pre_hr_id"] = $this->getPreHrIdByPreBranchId($preBranchId);
}
// INSERT or UPDATE
if (empty($value['pk']) || (int)$value['pk'] === 0) {
@ -7199,26 +7294,30 @@ class ClientController extends AdminController
}
}
private function getPreClientId($post_branch_id){
private function getPreClientIdByPreBranchId($pre_branch_id){
$db2 = \Config\Database::connect('preDB');
$pre_client_id = $db2->table('client_branch')->where('post_branch_id',$post_branch_id)->where('is_Active',1)->get()->getResultArray()[0]['client_id']??[];
$pre_client_id = $db2->table('client_branch')->where('id',$pre_branch_id)->where('is_Active',1)->get()->getResultArray()[0]['client_id']??"";
return $pre_client_id;
}
private function getPreBranchId($post_branch_id){
$db2 = \Config\Database::connect('preDB');
$pre_branch_id = $db2->table('client_branch')->where('post_branch_id',$post_branch_id)->where('is_Active',1)->get()->getResultArray()[0]['id']??[];
return $pre_branch_id;
}
private function getPreHrId($post_branch_id){
private function getPreHrIdByPreBranchId($pre_branch_id){
$db2 = \Config\Database::connect('preDB');
$pre_hr_id = $db2->table('client_branch cb')
->select('lc.id')
->join('level_contacts lc','lc.ref_id = cb.id')
->where('post_branch_id',$post_branch_id)->where('is_Active',1)->get()->getResultArray()[0]['id']??[];
->where('lc.contact_type', 'client')
->where('cb.id',$pre_branch_id)->where('cb.is_Active',1)
->where('lc.is_Active',1)->get()->getResultArray()[0]['id']??"";
return $pre_hr_id;
}
private function getPreBranchIdByPostBranchId($post_branch_id){
$db = \Config\Database::connect();
$pre_branch_id = $db->table('client_branch')->where('id',$post_branch_id)->where('is_Active',1)->get()->getResultArray()[0]['pre_branch_id']??"";
return $pre_branch_id;
}
// ------------------- DEMO CLIENT FUNCTION --------------------------------------------------------------------------------
public function wipeDemoClient()
@ -7607,6 +7706,26 @@ class ClientController extends AdminController
}
private function updatePreClientBranch($pre_branch_id,$post_branch_id ,$operation)
{
$preDB = \Config\Database::connect('preDB');
if($operation != 'create'){
$builder = $preDB->table('client_branch');
$builder->where('post_branch_id', $post_branch_id);
$builder->update(['post_branch_id' => null]);
}
$builder = $preDB->table('client_branch');
$builder->where('id', $pre_branch_id);
$builder->update(['post_branch_id' => $post_branch_id]);
return true;
}

View File

@ -2868,14 +2868,14 @@ class EmployeeRestController extends AdminController
}else if($ClientPolicyValue['policy_type_id'] == 6)
{
$policyGroup = 'gpa';
$policyGroup = 'other';
$data['ticket_type_id'] = 3;
$data['claim_subject'] = "Claim EDLI";
$data['sum_insured_label'] = "Sum Assured";
}else if($ClientPolicyValue['policy_type_id'] == 7)
{
$policyGroup = 'gpa';
$policyGroup = 'other';
$data['ticket_type_id'] = 4;
$data['claim_subject'] = "Claim GTLI";
$data['sum_insured_label'] = "Sum Assured";
@ -2969,9 +2969,6 @@ class EmployeeRestController extends AdminController
function policyTermsFiter($terms , $type)
{
$gpa = [
"sumInsured2" => "Sum Insured",
"totalSumInsured" => "Total Sum Assured",
@ -3021,8 +3018,6 @@ class EmployeeRestController extends AdminController
"moderntreatmentsasperirdai" => "Modern Treatment "
];
$finalarray = [];
if($type == 'gpa'){
foreach ($gpa as $key => $value) {
@ -3046,6 +3041,18 @@ class EmployeeRestController extends AdminController
$finalarray[$terms->gpa_special_condition_label[$i]] = $terms->gpa_special_condition_input[$i];
}
}
}else if($type == 'other'){
foreach ($terms as $key => $value) {
if($key != "multiple_sum_insured" && $value != ""){
$result = ucwords(str_replace('_', ' ', $key));
$finalarray[$result] = $value;
}
}
if(isset(($terms->gpa_special_condition_label)) && is_array($terms->gpa_special_condition_label) && is_array($terms->gpa_special_condition_input)){
for ($i=0; $i < count($terms->gpa_special_condition_label); $i++) {
$finalarray[$terms->gpa_special_condition_label[$i]] = $terms->gpa_special_condition_input[$i];
}
}
}else{
foreach ($gmc as $key => $value) {
if(isset($terms->$key))
@ -3070,9 +3077,7 @@ class EmployeeRestController extends AdminController
}
}
return $finalarray;
}

View File

@ -138,7 +138,10 @@ class LeadsController extends BaseController
$this->cause_of_death = [
'natural_death' => 'Natural Death',
'suicide' => 'Suicide',
'accident' => 'Accident'
'accident' => 'Accident',
'cardiac_arrest' => 'Cardiac Arrest',
'septic_shock' => 'Septic shock',
'heart_attack' => 'Heart Attack',
];
$this->member_data_excel_columns = [
@ -2408,8 +2411,11 @@ class LeadsController extends BaseController
$row = 2;
foreach ($claim_details['finyear'] as $record) {
$col = 'A';
foreach ($record as $value) {
foreach ($record as $array_key => $value) {
$label = ucwords(str_replace('_', ' ', ($value ?? "")));
if(in_array($array_key, ['sum_insured', 'claim_amount', 'settled'])){
$label = formatIndianCurrency(intval($label));
}
$sheet->setCellValue($col . $row, $label);
$col++;
}
@ -2427,19 +2433,27 @@ class LeadsController extends BaseController
}
// Enable wrap text for all cells
$maxColLetter = chr(64 + count($headers)); // Last column letter
$sheet->getStyle("A2:{$maxColLetter}{$row}")->getAlignment()->setWrapText(true);
// $maxColLetter = chr(64 + count($headers)); // Last column letter
// $sheet->getStyle("A2:{$maxColLetter}{$row}")->getAlignment()->setWrapText(true);
// Optional: center vertically for neatness
$sheet->getStyle("A2:{$maxColLetter}{$row}")->getAlignment()->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER);
// // Optional: center vertically for neatness
// $sheet->getStyle("A2:{$maxColLetter}{$row}")->getAlignment()->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER);
// Optional: Make row height auto (helps when wrap text is on)
for ($i = 2; $i < $row; $i++) {
$sheet->getRowDimension($i)->setRowHeight(-1);
}
$maxColLetter = chr(64 + count($headers));
$dataRange = "A1:{$maxColLetter}" . ($row - 1);
}
}
$sheet->getStyle($dataRange)->getAlignment()
->setWrapText(true)
->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER)
->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER);
// Optional: Make row height auto (helps when wrap text is on)
for ($i = 2; $i < $row; $i++) {
$sheet->getRowDimension($i)->setRowHeight(-1);
}
}
}
// Save to temporary location
$uploadFilePath = WRITEPATH . 'tmp/' . $filename;

View File

@ -33,8 +33,11 @@ use App\Models\ClientDepositModel;
use App\Models\EmployeePolicyModel;
use App\Models\FileModel;
use App\Models\InsurerExcelExportTemplateModel;
use App\Models\NhanceBranchModel;
use App\Models\SettingsModel;
use App\Models\VehicleModel;
use App\Models\VehicleTypeModel;
use App\Models\RTOModel;
use CodeIgniter\CLI\CLI;
@ -1618,7 +1621,8 @@ class MasterController extends AdminController
//Vehicle Master data Function
public function VehicleMasterList()
{ $data['tab_name'] = 'Vehicle Master';
{
$data['tab_name'] = 'Vehicle Master';
$data['page_name'] = 'Vehicles';
$data['vehicle_type'] = [
'two_wheeler' => 'Two Wheeler',
@ -2020,4 +2024,255 @@ class MasterController extends AdminController
dd($result);
}
//----------------------------------------------------------------------------------------------------------
public function nhanceBranchMaster()
{
$nhanceBranchModel = new NhanceBranchModel();
$method = $this->request->getMethod();
$data['tab_name'] = 'Nhance Branch';
$data['page_name'] = 'Nhance Branchs';
if ($method === 'post') {
$id = $this->request->getPost('pk') ?? null;
$data = $this->request->getPost();
if (empty($id)) {
$update_status = $nhanceBranchModel->insert($data);
} else {
$update_status = $nhanceBranchModel->where('id', $id)->set($data)->update();
}
if ($update_status) {
return $this->respond([
'status' => true,
'code' => 200,
'message' => 'Nhance Branch Master updated successfully',
'data' => $data
], 200);
} else {
return $this->respond([
'status' => false,
'code' => 400,
'message' => 'Failed to update',
'data' => $data
], 200);
}
} elseif ($method === 'get') {
$id = $this->request->getGet('pk') ?? null;
if (!empty($id)) {
$data = $nhanceBranchModel->where('is_active', 1)->where('id', $id)->findAll();
if (!empty($data)) {
return $this->respond(['status' => true, 'code' => 200, 'data' => $data], 200);
} else {
return $this->respond(['status' => false, 'code' => 400, 'message' => 'No data found'], 200);
}
}
$data = $nhanceBranchModel->where('is_active', 1)->findAll();
return $this->loadLayout('nhance_branch_list', ['data' => $data]);
} elseif ($method === 'delete') {
$input = $this->request->getRawInput();
$id = $input['pk'] ?? null;
if (empty($id)) {
return $this->respond([
'status' => false,
'code' => 404,
'message' => 'No ID provided for deletion'
], 200);
}
$update_status = $nhanceBranchModel->where('id', $id)->set(['is_active' => 0])->update();
if ($update_status) {
return $this->respond([
'status' => true,
'code' => 200,
'message' => 'Data removed successfully',
'pk' => $id
], 200);
} else {
return $this->respond([
'status' => false,
'code' => 400,
'message' => 'Failed to remove data',
'pk' => $id
], 200);
}
}
}
public function vehicleTypeMaster()
{
$vehicleTypeModel = new VehicleTypeModel();
$method = $this->request->getMethod();
$data['tab_name'] = 'Vehicle Type';
$data['page_name'] = 'Vehicle Types';
if ($method === 'post') {
$id = $this->request->getPost('pk') ?? null;
$data = $this->request->getPost();
if (empty($id)) {
$update_status = $vehicleTypeModel->insert($data);
} else {
$update_status = $vehicleTypeModel->where('id', $id)->set($data)->update();
}
if ($update_status) {
return $this->respond([
'status' => true,
'code' => 200,
'message' => 'Vehicle Type Master updated successfully',
'data' => $data
], 200);
} else {
return $this->respond([
'status' => false,
'code' => 400,
'message' => 'Failed to update',
'data' => $data
], 200);
}
} elseif ($method === 'get') {
$id = $this->request->getGet('pk') ?? null;
if (!empty($id)) {
$data = $vehicleTypeModel->where('is_active', 1)->where('id', $id)->findAll();
if (!empty($data)) {
return $this->respond(['status' => true, 'code' => 200, 'data' => $data], 200);
} else {
return $this->respond(['status' => false, 'code' => 400, 'message' => 'No data found'], 200);
}
}
$data = $vehicleTypeModel->where('is_active', 1)->findAll();
return $this->loadLayout('vehicle_type_master_list', ['data' => $data]);
} elseif ($method === 'delete') {
$input = $this->request->getRawInput();
$id = $input['pk'] ?? null;
if (empty($id)) {
return $this->respond([
'status' => false,
'code' => 404,
'message' => 'No ID provided for deletion'
], 200);
}
$update_status = $vehicleTypeModel->where('id', $id)->set(['is_active' => 0])->update();
if ($update_status) {
return $this->respond([
'status' => true,
'code' => 200,
'message' => 'Data removed successfully',
'pk' => $id
], 200);
} else {
return $this->respond([
'status' => false,
'code' => 400,
'message' => 'Failed to remove data',
'pk' => $id
], 200);
}
}
}
public function rtoMaster()
{
$rtoModel = new RTOModel();
$method = $this->request->getMethod();
$data['tab_name'] = 'RTO';
$data['page_name'] = 'RTO';
if ($method === 'post') {
$id = $this->request->getPost('pk') ?? null;
$data = $this->request->getPost();
if (empty($id)) {
$update_status = $rtoModel->insert($data);
} else {
$update_status = $rtoModel->where('id', $id)->set($data)->update();
}
if ($update_status) {
return $this->respond([
'status' => true,
'code' => 200,
'message' => 'RTO Master updated successfully',
'data' => $data
], 200);
} else {
return $this->respond([
'status' => false,
'code' => 400,
'message' => 'Failed to update',
'data' => $data
], 200);
}
} elseif ($method === 'get') {
$id = $this->request->getGet('pk') ?? null;
if (!empty($id)) {
$data = $rtoModel->where('is_active', 1)->where('id', $id)->findAll();
if (!empty($data)) {
return $this->respond(['status' => true, 'code' => 200, 'data' => $data], 200);
} else {
return $this->respond(['status' => false, 'code' => 400, 'message' => 'No data found'], 200);
}
}
$data = $rtoModel->where('is_active', 1)->findAll();
return $this->loadLayout('rto_master_list', ['data' => $data]);
} elseif ($method === 'delete') {
$input = $this->request->getRawInput();
$id = $input['pk'] ?? null;
if (empty($id)) {
return $this->respond([
'status' => false,
'code' => 404,
'message' => 'No ID provided for deletion'
], 200);
}
$update_status = $rtoModel->where('id', $id)->set(['is_active' => 0])->update();
if ($update_status) {
return $this->respond([
'status' => true,
'code' => 200,
'message' => 'Data removed successfully',
'pk' => $id
], 200);
} else {
return $this->respond([
'status' => false,
'code' => 400,
'message' => 'Failed to remove data',
'pk' => $id
], 200);
}
}
}
}

View File

@ -594,6 +594,7 @@ class PolicyTransactionController extends BaseController
'client_branch_id' => $data['client_branch_id'] ?? 0,
'cd_ac_pk' => $data['cd_ac_no'] ?? null,
'gst' => 18,
'policy_entry_from' => 2,
];
}
@ -1397,6 +1398,12 @@ class PolicyTransactionController extends BaseController
->orderBy('id', 'asc')
->first();
$pt_id = null;
if(!empty($data)){
$inception_data = $this->policyTransactionModel->where('policy_no', $data['policy_no'])->where('client_id', $data['client_id'])->first();
$pt_id = $inception_data['id'];
}
if (!empty($data['policy_start_date'])) {
$data['policy_start_date'] = change_date_format($data['policy_start_date'], 'Y-m-d', 'd/m/Y');
@ -1559,7 +1566,7 @@ class PolicyTransactionController extends BaseController
// print_r($data['endorse_eff_date']); die;
if ($data) {
return $this->respond(['status' => true, 'data' => $data], 200);
return $this->respond(['status' => true, 'data' => $data, 'pt_id' => $pt_id], 200);
} else {
return $this->respond(['status' => false], 200);
}
@ -1709,14 +1716,16 @@ class PolicyTransactionController extends BaseController
")
->join('policy_transaction', 'policy_transaction.id = pt_co_share_details.pt_id')
->where('policy_transaction.client_id', $client_id)
->where('policy_transaction.client_policy_id', $client_policy_id)
// ->where('policy_transaction.client_policy_id', $client_policy_id)
->where('policy_transaction.id', $client_policy_id)
->where('policy_transaction.action_type', 'inception')
->where('policy_transaction.is_active', 1)
->findAll();
$is_copay_yes = $this->policyTransactionModel
->where('client_id', $client_id)
->where('client_policy_id', $client_policy_id)
// ->where('client_policy_id', $client_policy_id)
->where('id', $client_policy_id)
->where('action_type', 'inception')
->where('is_active', 1)
->first();

View File

@ -26,7 +26,7 @@ class TestingController extends BaseController
{
$this->myLogger = \Config\Services::mylogger();
}
public function saveForm()
{
// Get JSON input
@ -41,7 +41,7 @@ class TestingController extends BaseController
}
public function testcli()
{
{
echo "hi";
$this->myLogger->logme('error', "test log");
echo "hi 2";
@ -85,19 +85,19 @@ class TestingController extends BaseController
$options->set('debugLayoutBlocks', false);
$options->set('debugLayoutInline', false);
$options->set('debugLayoutPaddingBox', false);
// Initialize DomPDF
$dompdf = new Dompdf($options);
// Load HTML content
$dompdf->loadHtml($html);
// Set paper size and orientation
$dompdf->setPaper('A4', 'landscape'); // or 'portrait'
// Render PDF
$dompdf->render();
// Output PDF to browser
$filename = 'ecard_' . date('Y-m-d_H-i-s') . '.pdf';
$dompdf->stream($filename, ['Attachment' => true]); // Set to false for inline view
@ -117,7 +117,7 @@ class TestingController extends BaseController
'POLICY_DATE' => '31/12/2024',
'INSURER_NAME' => 'ZURICH KOTAK GTNERAL INSURANCE COIIPANY lNDlA LIMITED',
'TPA_NAME' => 'HealthIndia Insurance TPA Services Pvt. Ltd.',
'FRONT_CARD' => base_url() .('public/uploads/template_bg/Nhance_Ecard_working_1_front_3.png'),
'FRONT_CARD' => base_url() . ('public/uploads/template_bg/Nhance_Ecard_working_1_front_3.png'),
'BACK_CARD' => base_url() . ('public/uploads/template_bg/Nhance_Ecard_working_1_Back_3.png'),
'LEVELS' => 'Level 1: 1800-XXX-XXXX<br>Level 2: support@company.com'
];
@ -133,7 +133,7 @@ class TestingController extends BaseController
'POLICY_DATE' => '31/12/2024',
'INSURER_NAME' => 'ABC Insurance Co.',
'TPA_NAME' => 'XYZ TPA Ltd.',
'FRONT_CARD' => base_url() .('public/uploads/template_bg/Nhance_Ecard_working_1_front_3.png'),
'FRONT_CARD' => base_url() . ('public/uploads/template_bg/Nhance_Ecard_working_1_front_3.png'),
'BACK_CARD' => base_url() . ('public/uploads/template_bg/Nhance_Ecard_working_1_Back_3.png'),
'LEVELS' => 'Level 1: 1800-XXX-XXXX<br>Level 2: support@company.com'
];
@ -163,12 +163,12 @@ class TestingController extends BaseController
{
// Load your HTML template
$template = file_get_contents(WRITEPATH . 'e_card_template/common.html');
// Replace placeholders with actual data
foreach ($data as $key => $value) {
$template = str_replace('{' . $key . '}', $value, $template);
}
return $template;
}
@ -231,21 +231,21 @@ class TestingController extends BaseController
$employeePolicy = new EmployeePolicyModel();
$data = $employeePolicy
->select('client_policy.policy_type_id')
->join('employees', 'employee_polices.employee_id = employees.id')
->join('client_policy', 'employee_polices.client_policy_id = client_policy.id')
->where('employees.is_active', 1)
->where('employees.emp_status', ['active', 'expired'])
->where('employee_polices.is_active', 1)
->where('employee_polices.status', ['active', 'expired'])
->where('employees.client_id', $client_id)
->where('employees.emp_code', $emp_code)
->groupBy('employee_polices.client_policy_id')
->findAll();
->select('client_policy.policy_type_id')
->join('employees', 'employee_polices.employee_id = employees.id')
->join('client_policy', 'employee_polices.client_policy_id = client_policy.id')
->where('employees.is_active', 1)
->where('employees.emp_status', ['active', 'expired'])
->where('employee_polices.is_active', 1)
->where('employee_polices.status', ['active', 'expired'])
->where('employees.client_id', $client_id)
->where('employees.emp_code', $emp_code)
->groupBy('employee_polices.client_policy_id')
->findAll();
}
public function ptedfitdata($id){
public function ptedfitdata($id)
{
$policy_transaction = new PolicyTransactionController();
$data = $policy_transaction->getInceptionDataForEdit($id);
// dd($data);
@ -255,7 +255,7 @@ class TestingController extends BaseController
$dataArray = $data['pt_co_share_details']; // Example
$cd_ac_pk = 'CD12345';
$role_id = 1;
$team_id = ['6'];
$team_id = ['6'];
$insurer_branch = $insurer_branch;
return view('pt_calc_table', [
@ -321,7 +321,7 @@ class TestingController extends BaseController
}
public function viewRFQNonEb()
{
{
$insurerBranchModel = new InsurerBranchModel();
$data['page_name'] = "RFQ NON EB";
$data['insurer'] = $insurerBranchModel->getInsurerBranchesWithInsurerNames();
@ -329,7 +329,8 @@ class TestingController extends BaseController
return $this->loadLayout('view_rfq_non_eb_new', $data);
}
public function saverfq(){
public function saverfq()
{
$json = $this->request->getPost('json');
$json = json_encode($json);
print_r($json);
@ -348,10 +349,191 @@ class TestingController extends BaseController
// print_rr($policy_data['json']); die;
$policy_data = json_decode($policy_data['json'], true);
$policy_data = array_slice($policy_data, 0, -2);
print_rr($policy_data); die;
dd($policy_data);
print_rr($policy_data);
die;
dd($policy_data);
}
public function mapping_client_id_and_branch_id()
{
$post_clients_list = $this->getNonDuplicatePostClients();
$pre_clients_list = $this->getNonDuplicatePreClients();
$log_post_clients_list = $post_clients_list ;
$log_pre_clients_list = $pre_clients_list ;
log_message('error', 'Post Clients to be processed: ' . count($log_post_clients_list));
log_message('error', 'Pre Clients to be processed: ' . count($log_pre_clients_list));
$matched_Count = 0 ;
$expected_match_count = min(count($post_clients_list), count($pre_clients_list));
if (
!empty($pre_clients_list) &&
!empty($post_clients_list)
) {
$postDB = \Config\Database::connect();
$preDB = \Config\Database::connect('preDB');
foreach ($post_clients_list as $index => $post_client) {
foreach ($pre_clients_list as $index => $pre_client) {
if (trim($post_client['short_name']) == trim($pre_client['short_name'])) {
unset($log_post_clients_list[$index]);
unset($log_pre_clients_list[$index]);
$matched_Count++;
$postDB->table('clients')->where('id', $post_client['id'])->update(['pre_client_id' => $pre_client['id']]);
$preDB->table('clients')->where('id', $pre_client['id'])->update(['post_client_id' => $post_client['id']]);
// upto here we updated client_id in both dbs.
$post_branches = $postDB->table('client_branch')
->where('client_id', $post_client['id'])
->get()
->getResultArray() ?? [];
$pre_branches = $preDB->table('client_branch')
->where('client_id', $pre_client['id'])
->get()
->getResultArray() ?? [];
if (!empty($post_branches) && !empty($pre_branches)) {
foreach ($post_branches as $post_branch) {
$pre_branch = $preDB->table('client_branch')
->where('client_id', $pre_client['id'])
->where('branch_code', $post_branch['branch_code'])
->get()
->getRowArray() ?? [];
if (!empty($pre_branch)) {
$postDB->table('client_branch')->where('id', $post_branch['id'])->update(['pre_branch_id' => $pre_branch['id']]);
}
}
foreach ($pre_branches as $pre_branch) {
$post_branch = $postDB->table('client_branch')
->where('client_id', $post_client['id'])
->where('branch_code', $pre_branch['branch_code'])
->get()
->getRowArray() ?? [];
if (!empty($post_branch)) {
$preDB->table('client_branch')->where('id', $pre_branch['id'])->update(['post_branch_id' => $post_branch['id']]);
}
}
}
}
}
}
log_message('error', 'Expected Match Count : ' . $expected_match_count);
log_message('error', 'Total Matched Count: ' . $matched_Count);
log_message('error', 'Total UnMatched Count: ' . $expected_match_count - $matched_Count);
log_message('error','unmatched_reocrds');
$log_post_clients_list = array_values($log_post_clients_list);
$log_pre_clients_list = array_values($log_pre_clients_list);
if( (count($log_pre_clients_list) < count($log_post_clients_list))){
log_message('error',"unmatched records count from pre- ". count($log_pre_clients_list));
log_message('error',print_r($log_pre_clients_list,true));
} else {
log_message('error',"unmatched records count from post - ".count($log_post_clients_list));
log_message('error',print_r($log_post_clients_list,true));
}
}
return $this->response->setJSON(['status' => 'success', 'message' => 'Client and Branch mapping completed.'])->setStatusCode(200);
}
private function getNonDuplicatePostClients()
{
$postDB = \Config\Database::connect();
$sql = "SELECT *
FROM clients AS post_clients
WHERE post_clients.client_type = 1
AND post_clients.is_active = 1
AND (post_clients.short_name NOT IN
(
SELECT ir_post_clients.short_name
FROM clients as ir_post_clients
WHERE ir_post_clients.client_type = 1
AND ir_post_clients.short_name IS NOT NULL
AND TRIM(ir_post_clients.short_name) <> ''
AND ir_post_clients.is_active = 1
GROUP BY ir_post_clients.short_name
HAVING COUNT(*) > 1)
)
ORDER BY post_clients.short_name";
$binds = [];
$query = $postDB->query($sql, $binds);
$results = $query->getResultArray() ?? [];
return $results;
}
private function getNonDuplicatePreClients()
{
$preDB = \Config\Database::connect('preDB');
$sql = "SELECT *
FROM clients AS pre_clients
WHERE pre_clients.client_type = 1
AND pre_clients.is_active = 1
AND (pre_clients.short_name NOT IN
(
SELECT ir_pre_clients.short_name
FROM clients as ir_pre_clients
WHERE ir_pre_clients.client_type = 1
AND ir_pre_clients.short_name IS NOT NULL
AND TRIM(ir_pre_clients.short_name) <> ''
AND ir_pre_clients.is_active = 1
GROUP BY ir_pre_clients.short_name
HAVING COUNT(*) > 1)
)
ORDER BY pre_clients.short_name";
$binds = [];
$query = $preDB->query($sql, $binds);
$results = $query->getResultArray() ?? [];
return $results;
}
public function membervalidation($lead_id = 329)
{
$lead_controll = new LeadsController();
@ -533,4 +715,97 @@ class TestingController extends BaseController
];
}
public function logo_renaming(){
$directory = ROOTPATH . 'public/uploads/logo/';
if (!is_dir($directory)) {
die("Directory not found: $directory");
}
$files = scandir($directory);
$client_logo_files = $this->get_client_logo_files();
$rename_files = "";
$failed_rename_files = "";
foreach ($files as $file) {
// Skip system entries
if ($file === '.' || $file === '..' ) {
continue;
}
$oldPath = $directory . $file;
if (is_file($oldPath) && in_array(trim($file) , $client_logo_files)) {
// Remove all spaces from filename
$newFileName = preg_replace('/\s+|\x{00A0}|\x{200B}|\x{200C}|\x{200D}|\x{FEFF}/u', '', $file);
$newPath = $directory . $newFileName;
// Only rename if the name changed
if ($oldPath !== $newPath) {
if (rename($oldPath, $newPath)) {
$rename_files .= "\n Renamed: $file$newFileName \n";
} else {
$failed_rename_files .= "\n Failed file: $file \n";
}
}
}
}
$dbUpdated = $this->update_client_logo_files();
log_message('error', 'Renamed Files: ' . $rename_files);
log_message('error', 'Failed Renames: ' . $failed_rename_files);
log_message('error', 'Database Update Status: ' . ($dbUpdated ? 'Success' : 'No changes made'));
return $this->response->setJSON(['status' => 'success',
'message' => 'Logo renaming completed. kindly check backend logs for details',
'data' => [
'renamed_files' => $rename_files,
'failed_renames' => $failed_rename_files
]
])->setStatusCode(200);
}
public function get_client_logo_files(){
$db = \Config\Database::connect();
$sql = "SELECT client_logo FROM clients WHERE client_logo IS NOT NULL AND TRIM(client_logo) <> '' ";
$query = $db->query($sql);
$results = $query->getResultArray() ?? [];
$files = array_map(function($item) {
return trim($item['client_logo']);
}, $results);
return $files;
}
public function update_client_logo_files(){
$db = \Config\Database::connect();
$sql = "UPDATE clients
SET client_logo = REPLACE(REPLACE(REPLACE(client_logo, CHAR(160), ''), ' ', ''), '\t', '')
WHERE client_logo IS NOT NULL
AND TRIM(client_logo) <> ''
";
$query = $db->query($sql);
return $db->affectedRows() > 0;
}
}

View File

@ -57,6 +57,7 @@ if (!function_exists('file_Upload')) {
if ($fileToUpload !== null && $fileToUpload->isValid() && !$fileToUpload->hasMoved()) {
$fileToUpload->move($filepath);
$fileName = $fileToUpload->getName();
$fileName = preg_replace('/[\s\x{00A0}\x{200B}-\x{200D}\x{FEFF}]/u', '', $fileName);
return $fileName;
} else {
return "";

View File

@ -226,5 +226,18 @@ class ClientModel extends Model
return $result;
}
public function isDuplicateByClientBranch($value, $field, $clientId, $branchId)
{
$builder = $this->db->table('level_contacts lc')
->select('lc.id')
->join('client_branch cb', 'lc.ref_id = cb.id', 'left')
->where('lc.'.$field, $value)
->where('lc.contact_type', 'client')
->where('cb.client_id', $clientId)
->where('lc.ref_id', $branchId)
->get();
return $builder->getNumRows() > 0 ? true : false;
}
}

View File

@ -55,6 +55,7 @@ class ClientPolicyModel extends Model
"cd_ac_pk",
"is_lgbtq",
"placement_json",
"policy_entry_from",
];
// Callbacks

View File

@ -1492,6 +1492,7 @@ class EmployeePolicyModel extends Model
tpa.tpa_logo AS tpa_logo,
tpa.front_card,
tpa.back_card,
tpa.network_hospitals,
tpa.short_name AS tpa_short_name'
)
@ -1557,6 +1558,7 @@ class EmployeePolicyModel extends Model
tpa.tpa_logo AS tpa_logo,
tpa.front_card,
tpa.back_card,
tpa.network_hospitals,
tpa.short_name AS tpa_short_name'
)

57
app/Models/RTOModel.php Normal file
View File

@ -0,0 +1,57 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class RTOModel extends Model
{
protected $table = 'rto_master';
protected $primaryKey = 'id';
protected $allowedFields = [
'id',
'rto_state',
'rto_code',
'rto_name',
'created_at',
'created_by',
'updated_at',
'updated_by',
'is_active',
];
// Callbacks
protected $allowCallbacks = true;
protected $beforeInsert = ["checkAndADDCreatedByValue"];
protected $afterInsert = [];
protected $beforeUpdate = ["checkAndUpdateUpdatedByValue"];
protected $afterUpdate = [];
protected $beforeFind = [];
protected $afterFind = [];
protected $beforeDelete = [];
protected $afterDelete = [];
protected function checkAndADDCreatedByValue(array $data)
{
// Check if 'updated_by' value is null or empty
if (empty($data['data']['created_by'])) {
// Set 'updated_by' value to the current session user ID
$data['data']['created_by'] = get_session_userid();
}
return $data;
}
protected function checkAndUpdateUpdatedByValue(array $data)
{
// Check if 'updated_by' value is null or empty
if (empty($data['data']['updated_by'])) {
// Set 'updated_by' value to the current session user ID
$data['data']['updated_by'] = get_session_userid();
}
return $data;
}}

View File

@ -0,0 +1,54 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class VehicleTypeModel extends Model
{
protected $table = 'vehicle_type';
protected $primaryKey = 'id';
protected $allowedFields = [
'id',
'vehicle_type',
'created_at',
'created_by',
'updated_at',
'updated_by',
'is_active',
];
// Callbacks
protected $allowCallbacks = true;
protected $beforeInsert = ["checkAndADDCreatedByValue"];
protected $afterInsert = [];
protected $beforeUpdate = ["checkAndUpdateUpdatedByValue"];
protected $afterUpdate = [];
protected $beforeFind = [];
protected $afterFind = [];
protected $beforeDelete = [];
protected $afterDelete = [];
protected function checkAndADDCreatedByValue(array $data)
{
// Check if 'updated_by' value is null or empty
if (empty($data['data']['created_by'])) {
// Set 'updated_by' value to the current session user ID
$data['data']['created_by'] = get_session_userid();
}
return $data;
}
protected function checkAndUpdateUpdatedByValue(array $data)
{
// Check if 'updated_by' value is null or empty
if (empty($data['data']['updated_by'])) {
// Set 'updated_by' value to the current session user ID
$data['data']['updated_by'] = get_session_userid();
}
return $data;
}}

View File

@ -74,7 +74,7 @@
<div class="row float-left" style="position: relative; bottom: 20px; left: 13px;">
<button type="button" id="btnAutoBranchFetch"
class="btn btn-primary waves-effect waves-light btn-sm "> Auto Fetch branch Details</button>
class="btn btn-primary waves-effect waves-light btn-sm ">Fetch Client Branch (Pre-Enrolment)</button>
</div>
<div class="row float-right" style="position: relative; bottom: 20px; right: 13px;">
@ -86,13 +86,18 @@
<hr>
<form role="form" class="parsley-examples" method="post" id="branch_form" enctype="multipart/form-data">
<input type="hidden" class="form-control" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
<!-- post_client_id as client_id -->
<input type="hidden" name="client_id" id="client_id_branch"
value="<?= isset($client['id']) ? $client['id'] : '' ?>" />
<!-- pre_branch_id -->
<input type="hidden" name="pre_branch_id" id="pre_branch_id"
value="<?= isset($pre_branch_id) ? $pre_branch_id : '' ?>" />
<!-- post_branch_id as branch_id_primarykey -->
<input type="hidden" name="branch_id_primarykey" id="branch_id_primarykey" />
<div class="form-group">
@ -193,12 +198,13 @@
<div class="form-group col-md-6">
<label for="last_name">Email<span class="text-danger">*</span></label>
<input value="" type="text" class="form-control" placeholder="Enter Contact Email"
name="email[]" id="email" data-parsley-trigger="change" data-parsley-type="email" onkeyup="validateInput(this, 'level_contacts', 'email', 'branchBtnSubmit')" required>
name="email[]" id="email" data-parsley-trigger="change" data-parsley-type="email" onchange="validateDuplicateByClientBranch(this, 'email','branchBtnSubmit')" required>
</div>
<div class="form-group col-md-6">
<label for="mobile">Mobile<span class="text-danger">*</span></label>
<input value="" type="text" class="form-control" placeholder="Enter Contact Mobile"
name="mobile[]" id="mobile" onkeyup="validateInput(this, 'level_contacts', 'mobile', 'branchBtnSubmit')"
name="mobile[]" id="mobile"
onchange="validateDuplicateByClientBranch(this, 'mobile','branchBtnSubmit')"
onkeypress="return onlyNumbers(event)" maxlength="10" minlength="10"
data-parsley-type-message="Please enter a valid 10-digit mobile number."
data-parsley-required-message="Please enter a valid 10-digit mobile number."
@ -297,6 +303,10 @@ $('#btnBranchAdd').click(function() {
$('#district').val('');
$('#branch_city').val('');
$('#branch_form')[0].reset();
$('#branch_form').parsley().reset();
$('#pre_branch_id').val('');
$('#branch_id_primarykey').val('');
$('.ac').css('display', 'block');
contactCount = 1
@ -363,13 +373,14 @@ $("#branch_form").submit(function(event) {
var selectedValues = $("#selected").val();
console.log(selectedValues, selectedValues);
console.log("branch_id_primarykey", $('#branch_id_primarykey').val());
let level_contect_data = getContactsData();
console.log('level_contect_data', level_contect_data);
event.preventDefault();
branch_PrimaryKey = $('#client_id_branch').val();
console.log('branch_PrimaryKey', branch_PrimaryKey)
if (branch_PrimaryKey === '') {
@ -389,6 +400,7 @@ $("#branch_form").submit(function(event) {
var formData = new FormData($('#branch_form')[0]);
const jsonString = JSON.stringify(selectedValues);
const level_contect_data_json_string = JSON.stringify(level_contect_data);
console.log('jsonString', jsonString);
@ -479,6 +491,9 @@ $("#branch_form").submit(function(event) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.log('Something Wrong!', 'warning');
if(xhr.status === 409){
alert('The Current Branch is Already Existing..!!');
}
}, 300);
},
complete: function() {
@ -546,7 +561,7 @@ $('body').on('click', '.btnBranchEdit', function() {
$('#district').val(res.data.district);
$('#branch_city').val(res.data.city);
$('#branch_PrimaryKey').val(res.data.id);
$('#pre_branch_id').val(res.data.pre_branch_id)
$('#pre_branch_id').val(res.data.pre_branch_id??'')
if(res.data.sez == 1){
$('#sez').prop('checked', true);
@ -638,11 +653,11 @@ function appendContactHtml(contact = false, reset = false) {
<div class="form-row">
<div class="form-group col-md-6">
<label for="${uniqueId}_last_name">Email<span class="text-danger">*</span></label>
<input value="${contact !== undefined && contact !== false ? contact.email : ''}" type="text" class="form-control" placeholder="Enter Contact Email" name="email[]" id="${uniqueId}_email" data-parsley-trigger="change" data-parsley-type="email" onkeyup="validateInput(this, 'level_contacts', 'email', 'branchBtnSubmit')" required>
<input value="${contact !== undefined && contact !== false ? contact.email : ''}" type="text" class="form-control" placeholder="Enter Contact Email" name="email[]" id="${uniqueId}_email" data-parsley-trigger="change" data-parsley-type="email" onchange="validateDuplicateByClientBranch(this, 'email', 'branchBtnSubmit')" required>
</div>
<div class="form-group col-md-6">
<label for="${uniqueId}_mobile">Mobile<span class="text-danger">*</span></label>
<input value="${contact !== undefined && contact !== false ? contact.mobile : ''}" type="text" class="form-control" placeholder="Enter Contact Mobile" name="mobile[]" id="${uniqueId}_mobile" onkeyup="validateInput(this, 'level_contacts', 'mobile', 'branchBtnSubmit')" onkeypress = "return onlyNumbers(event)" maxlength="10" min="10" data-parsley-type-message="Please enter a valid 10-digit mobile number." data-parsley-required-message="Please enter a valid 10-digit mobile number." required>
<input value="${contact !== undefined && contact !== false ? contact.mobile : ''}" type="text" class="form-control" placeholder="Enter Contact Mobile" name="mobile[]" id="${uniqueId}_mobile" onchange="validateDuplicateByClientBranch(this, 'mobile', 'branchBtnSubmit')" onkeypress = "return onlyNumbers(event)" maxlength="10" min="10" data-parsley-type-message="Please enter a valid 10-digit mobile number." data-parsley-required-message="Please enter a valid 10-digit mobile number." required>
</div>
</div>
<div class="form-group" style="display: flex;">
@ -961,6 +976,121 @@ function validateInput(input, table, field, submitButId){
}
function validateDuplicateByClientBranch(input, field, submitButId) {
let value = $(input).val().trim();
let clientId = $('#client_id_branch').val();
let branchId = $('#branch_id_primarykey').val();
let label = $(input).closest('.form-group').find('label').text().replace('*', '').trim();
let message = label ? label + " is duplicate!" : "Value is duplicate!";
console.log(`cId: ${clientId} | bId: ${branchId}`);
// Don't forgot be careful
// 1 Local duplication check (User entered)
let isLocalDuplicate = false;
$('input[name="' + field + '[]"]').each(function(index) {
let compareVal = $(this).val().trim();
console.log(`Entered value: ${value} | Contact ${index+1} value: ${$(this).val()}`);
if (this !== input && compareVal !== '' && compareVal === value) {
isLocalDuplicate = true;
return false;
}
});
if (isLocalDuplicate) {
console.log(`r u n Local`);
console.log(`duplicate found for ${field}`);
toastr.warning(message, 'WARNING');
$('#' + submitButId).prop('disabled', true);
return;
}
// important Skip empty values
if (value === '') {
checkAllFieldsValid(submitButId);
return;
}
// Don't forgot be careful
// 2 Server-side duplicate check (DB)
$.ajax({
url: '<?= base_url("client/others/check-duplicate") ?>',
type: 'POST',
data: {
client_id: clientId,
branch_id: branchId,
value: value,
field: field
},
dataType: 'json',
success: function(response) {
if (response.isDuplicate) {
console.log(`r u n Server`);
console.log(`duplicate found for ${field}`);
toastr.warning(message, 'WARNING');
$('#' + submitButId).prop('disabled', true);
} else {
console.log(`No duplicate for ${field}`);
checkAllFieldsValid(submitButId);
}
},
error: function(xhr, status, error) {
console.error('AJAX Error:', error);
}
});
}
// recheck all contacts before enabling submit
function checkAllFieldsValid(submitButId) {
let emailDuplicates = false;
let mobileDuplicates = false;
// cross check all EMAIL duplicates
let emailSeen = [];
$('input[name="email[]"]').each(function() {
let val = $(this).val().trim();
if (val && emailSeen.includes(val)) {
emailDuplicates = true;
} else if (val) {
emailSeen.push(val);
}
});
// cross check all MOBILE duplicates
let mobileSeen = [];
$('input[name="mobile[]"]').each(function() {
let val = $(this).val().trim();
if (val && mobileSeen.includes(val)) {
mobileDuplicates = true;
} else if (val) {
mobileSeen.push(val);
}
});
if (emailDuplicates || mobileDuplicates) {
$('#' + submitButId).prop('disabled', true);
// show correct message based on whats duplicated
if (emailDuplicates && mobileDuplicates) {
toastr.warning("Email and Mobile values are duplicate!", "WARNING");
console.log('Both Email and Mobile duplicates');
} else if (emailDuplicates) {
toastr.warning("Email duplicate!", "WARNING");
console.log('Cross Check Email duplicates');
} else if (mobileDuplicates) {
toastr.warning("Mobile duplicate!", "WARNING");
console.log('Cross Check Mobile duplicates');
}
console.log(`btn Dis - true`);
} else {
console.log('unique — enable');
console.log(`btn Dis - false`);
$('#' + submitButId).prop('disabled', false);
}
}
function getContactsData() {
const contacts = [];

View File

@ -407,7 +407,7 @@
<div class="modal-dialog modal-dialog-centered" style="margin-left: 400px !important;">
<div class="modal-content modal-lg">
<div class="modal-header">
<h5 class="modal-title" id="autoFetchBranchModalLabel">Auto Fetch Branch Details</h5>
<h5 class="modal-title" id="autoFetchBranchModalLabel">Fetch Client Branch (Pre-Enrolment)</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
@ -418,7 +418,7 @@
<div class="col-md-6">
<div class="form-group col-md-12">
<label for="auto_fetch_client">Client List<span class="text-danger">*</span></label>
<select class="form-control" id="auto_fetch_client" name="auto_fetch_client" required>
<select class="form-control select2" id="auto_fetch_client" name="auto_fetch_client" required>
<option value="">Select Client</option>
<?php if (!empty($auto_fetch_client_list)): ?>
<?php foreach ($auto_fetch_client_list as $client_list): ?>
@ -434,7 +434,7 @@
<div class="col-md-6">
<div class="form-group col-md-12">
<label for="auto_fetch_branch">Branch List<span class="text-danger">*</span></label>
<select class="form-control" id="auto_fetch_branch" name="auto_fetch_branch" required>
<select class="form-control select2" id="auto_fetch_branch" name="auto_fetch_branch" required>
<option value="">Select Branch</option>
</select>
@ -1043,38 +1043,52 @@
</script>
<script>
$('#auto_fetch_client').change(function() {
$(document).ready(function() {
$('#auto_fetch_branch').html(`<option value="">Select Branch</option>`);
$('#auto_fetch_client').select2();
$('#auto_fetch_branch').select2();
$('#auto_fetch_client').change(function() {
$.ajax({
url: "<?php echo base_url('client/branch/auto_fetch_branch'); ?>",
type: "POST",
data: {
client_id: $('#auto_fetch_client').val()
},
dataType: "json",
success: function(response, textStatus, xhr) {
if (xhr.status === 200) {
let options = `<option value="">Select Branch</option>`;
$('#auto_fetch_branch').html(`<option value="">Select Branch</option>`);
response.data.forEach((data) => {
options += `<option value="${data.id}">${data.branch_name}</option>`;
});
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
$('#auto_fetch_branch').html(options);
} else {
$('#auto_fetch_branch').html('<option value="">No Branch Found</option>');
$.ajax({
url: "<?php echo base_url('client/branch/auto_fetch_branch'); ?>",
type: "POST",
data: {
client_id: $('#auto_fetch_client').val()
},
dataType: "json",
success: function(response, textStatus, xhr) {
if (xhr.status === 200) {
let options = `<option value="">Select Branch</option>`;
response.data.forEach((data) => {
options += `<option value="${data.id}">${data.branch_name}</option>`;
});
$('#auto_fetch_branch').html(options);
} else {
$('#auto_fetch_branch').html('<option value="">No Branch Found</option>');
}
},
error: function(xhr, status, error) {
console.error("Error occurred:", status, error);
},
complete: function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.log("auto_fetch_client call is completed..!!");
}
},
error: function(xhr, status, error) {
console.error("Error occurred:", status, error);
},
complete: function() {
console.log("auto_fetch_client call is completed..!!");
}
});
});
});
</script>
<script>
@ -1156,4 +1170,7 @@
})
</script>

View File

@ -1792,6 +1792,15 @@
<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 } ?>

View File

@ -1862,6 +1862,7 @@
let claimData = [];
$(".claim-row").each(function() {
let year = $(this).find("[name='first_year[]']").val();
let claimAmount = $(this).find("[name='first_claim_amount[]']").val();
let claimStatus = $(this).find("[name='first_claim_status[]']").val();
@ -1869,13 +1870,22 @@
let causeOfDeath = $(this).find("[name='first_cause_of_death[]']").val();
let deathDate = $(this).find("[name='first_death_date[]']").val();
let emp_id = $(this).find("[name='emp_id[]']").val();
let emp_name = $(this).find("[name='emp_name[]']").val();
let gender = $(this).find("[name='gender[]']").val();
let designation = $(this).find("[name='designation[]']").val();
let sum_insured = $(this).find("[name='sum_insured[]']").val();
claimData.push({
"year": year,
"claim_amount": claimAmount,
"status": claimStatus,
"claim_type": claimType,
"emp_id": emp_id,
"emp_name": emp_name,
"gender": gender,
"designation": designation,
"sum_insured": sum_insured,
"death_date": deathDate,
"cause_of_death": causeOfDeath,
"death_date": deathDate
"settled": claimAmount,
});
});
@ -1893,6 +1903,93 @@
//-----------------------------------------------------------------------------------------------------------
// do not remove this
// function appendThreeYearsClaims(count) {
// // let count = $('#appendAreaForClaim').data('count');
// console.log("count", count);
// let policy_type_id = $('#policy_type_id_' + count).val()
// console.log('policy_type_id', policy_type_id);
// console.log('claimIndex from parent', claimIndex);
// let increment = claimIndex;
// let claimsFields = `
// <div class="row claim-row">
// <div class="form-group col-md-2">
// <label for="first_year_${increment}">Year<span class="text-danger">*</span></label>
// <select class="form-control first_year_" id="first_year_${increment}" name="first_year[]">
// <option value="">Select Year</option>
// <?php foreach ($lastFiveYears as $year) {echo "<option value='$year'>$year</option>";} ?>
// </select>
// </div>
// <div class="form-group col-md-2">
// <label for="first_claim_amount_${increment}">Claim/Settled Amount<span class="text-danger">*</span></label>
// <input type="text" class="form-control" id="first_claim_amount_${increment}" name="first_claim_amount[]">
// </div>
// <div class="form-group col-md-2">
// <label for="first_claim_status_${increment}">Claim Status<span class="text-danger">*</span></label>
// <input type="text" class="form-control" id="first_claim_status_${increment}" name="first_claim_status[]">
// </div>
// <div class="form-group col-md-2 lifeClaimFields" style="display:none;">
// <label for="first_cause_of_death_${increment}">Nature/Cause Of Death <span class="text-danger">*</span></label>
// <select class="form-control" id="first_cause_of_death_${increment}" name="first_cause_of_death[]">
// <option value="">Select Cause of Death</option>
// <?php foreach ($causeOfDeath as $cause => $death_value) {echo "<option value='$cause'>$death_value</option>";} ?>
// </select>
// </div>
// <div class="form-group col-md-2 lifeClaimFields" style="display:none;">
// <label for="first_death_date_${increment}">Date of Death<span class="text-danger">*</span></label>
// <input type="text" class="form-control" id="first_death_date_${increment}" name="first_death_date[]">
// </div>
// <div class="form-group col-md-2 gpaClaimFileds" style="display:none;">
// <label for="claim_type_${increment}">Claim Type<span class="text-danger">*</span></label>
// <select class="form-control" id="claim_type_${increment}" name="claim_type[]">
// <option value="">Select Claim Type</option>
// <?php foreach ($gpaClaimType as $claimType => $claim_value) {echo "<option value='$claimType'>$claim_value</option>";} ?>
// </select>
// </div>
// <div class="form-group col-md-2">
// <div class="" style="position: relative; top: 28px; float: right; text-align: end;">
// <a class="btn btn-danger waves-effect waves-light" onclick="removeClaim(this, ${count})">x</a>
// <a class="btn btn-primary waves-effect waves-light mr-1" onclick="appendThreeYearsClaims(${count})">+</a>
// </div>
// </div>
// </div>
// `;
// // Append new claim fields
// let referenceDiv = document.getElementById('appendAreaForClaim_' + count);
// if (referenceDiv) {
// referenceDiv.insertAdjacentHTML('beforeend', claimsFields);
// } else {
// console.error('Element not found: appendAreaForClaim_' + count);
// }
// // Increment claim index
// console.log("claim index " + claimIndex);
// claimIndex++;
// console.log("after claim index " + claimIndex);
// if (policy_type_id == 1) {
// $('.gpaClaimFileds').show();
// $('.lifeClaimFields').hide();
// } else if (policy_type_id == 6 || policy_type_id == 7) {
// $('.gpaClaimFileds').hide();
// $('.lifeClaimFields').show();
// }
// // Initialize Select2 for the newly added fields
// $("#first_year_" + increment).select2();
// $("#claim_type_" + increment).select2();
// $("#first_cause_of_death_" + increment).select2();
// toggleRequiredFields();
// }
function appendThreeYearsClaims(count) {
// let count = $('#appendAreaForClaim').data('count');
@ -1916,15 +2013,46 @@
} ?>
</select>
</div>
<div class="form-group col-md-2">
<label for="first_claim_amount_${increment}">Claim/Settled Amount<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_claim_amount_${increment}" name="first_claim_amount[]">
<label for="emp_id_${increment}">Emp ID<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="emp_id_${increment}" name="emp_id[]">
</div>
<div class="form-group col-md-2">
<label for="first_claim_status_${increment}">Claim Status<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_claim_status_${increment}" name="first_claim_status[]">
<label for="emp_name_${increment}">Employee Name<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="emp_name_${increment}" name="emp_name[]">
</div>
<div class="form-group col-md-2 lifeClaimFields" style="display:none;">
<div class="form-group col-md-2">
<label for="gender_${increment}">Gender<span class="text-danger">*</span></label>
<select class="form-control" id="gender_${increment}" name="gender[]">
<option value="">Select Gender</option>
<option value="Female">Female</option>
<option value="Male">Male</option>
</select>
</div>
<div class="form-group col-md-2">
<label for="designation_${increment}">Designation <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="designation_${increment}" name="designation[]">
</div>
<div class="form-group col-md-2">
<label for="sum_insured_${increment}">Sum Insured <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="sum_insured_${increment}" name="sum_insured[]">
</div>
<div class="form-group col-md-2">
<label for="first_death_date_${increment}">Date of Death<span class="text-danger">*</span></label>
<div class="input-icon">
<input type="text" class="form-control death_date flatpickr-date" id="first_death_date_${increment}" name="first_death_date[]" autocomplete="off">
<i class="mdi mdi-calendar-blank-outline additional-icon"></i>
</div>
</div>
<div class="form-group col-md-2">
<label for="first_cause_of_death_${increment}">Nature/Cause Of Death <span class="text-danger">*</span></label>
<select class="form-control" id="first_cause_of_death_${increment}" name="first_cause_of_death[]">
<option value="">Select Cause of Death</option>
@ -1933,11 +2061,18 @@
} ?>
</select>
</div>
<div class="form-group col-md-2 lifeClaimFields" style="display:none;">
<label for="first_death_date_${increment}">Date of Death<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_death_date_${increment}" name="first_death_date[]">
<div class="form-group col-md-2">
<label for="first_claim_amount_${increment}">Claim/Settled Amount<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_claim_amount_${increment}" name="first_claim_amount[]">
</div>
<div class="form-group col-md-2 gpaClaimFileds" style="display:none;">
<!-- <div class="form-group col-md-2">
<label for="first_claim_status_${increment}">Claim Status<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_claim_status_${increment}" name="first_claim_status[]">
</div> -->
<!-- <div class="form-group col-md-2 gpaClaimFileds" style="display:none;">
<label for="claim_type_${increment}">Claim Type<span class="text-danger">*</span></label>
<select class="form-control" id="claim_type_${increment}" name="claim_type[]">
<option value="">Select Claim Type</option>
@ -1945,7 +2080,8 @@
echo "<option value='$claimType'>$claim_value</option>";
} ?>
</select>
</div>
</div> -->
<div class="form-group col-md-2">
<div class="" style="position: relative; top: 28px; float: right; text-align: end;">
<a class="btn btn-danger waves-effect waves-light" onclick="removeClaim(this, ${count})">x</a>
@ -1981,10 +2117,18 @@
$("#first_year_" + increment).select2();
$("#claim_type_" + increment).select2();
$("#first_cause_of_death_" + increment).select2();
$("#gender_" + increment).select2();
flatpickr('.flatpickr-date', {
dateFormat: 'd-m-Y', // Example format: 11-10-2025
allowInput: true, // Allow manual typing
maxDate: 'today', // Optional: disable future dates
});
toggleRequiredFields();
}
function removeClaim(btn, count) {
const container = document.getElementById('appendAreaForClaim_' + count);
const rows = container.querySelectorAll('.claim-row');
@ -2108,6 +2252,10 @@
$(this).find('.form-group').each(function() {
var input = $(this).find('input, select');
if (input.attr('name') === "gender[]") {
return;
}
if (input.length === 0) {
console.warn('No input/select fields found in:', this);
return;

View File

@ -393,7 +393,6 @@ if (isset($selected_lead_type)) {
}
});
$('#client_branch_id').change(function() {
let client_branch_id = $(this).val();

View File

@ -0,0 +1,290 @@
<style>
.dataTables_filter {
position: absolute;
}
</style>
<!-- End ADD and EDIT Page HTML -->
<div class="row" id="List-page">
<div class="col-12">
<div class="card">
<div class="card-body maincard">
<table data-custom-table-css="table" class="table table-sm m-0 table-centered dt-responsive nowrap w-100" cellspacing="a" id="user-table">
<thead class="bg-light">
<tr>
<th class="font-weight-medium">S.No.</th>
<th class="font-weight-medium">Branch Name</th>
<!-- <th class="font-weight-medium">Status</th> -->
<th class="font-weight-medium">Action</th>
</tr>
</thead>
<tbody>
<?php if(isset($data)) { ?>
<?php foreach($data as $index => $row) { ?>
<tr>
<td class="text-dark">&nbsp;&nbsp;<?= esc($index + 1); ?></td>
<td><?= $row['branch_name']; ?></td>
<!-- <td>
<span class="<?php if($row['is_active'] == 1){ echo 'badge badge-primary'; }else{ echo 'badge badge-danger'; } ?>">
<?php if($row['is_active'] == 1){ echo 'Active'; }else{ echo 'In-Active'; } ?>
</span>
</td> -->
<td>
<div class="btn-group dropdown" style="position: relative !important;left:0px !important;top:0px !important;">
<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" style="cursor: pointer;">
<a class="dropdown-item" data-id="<?= $row['id']; ?>" onclick="handleSaveEditAndDelete('edit', this)">
<i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit
</a>
<?php if ($row['is_active'] == 1): ?>
<a class="dropdown-item" data-id="<?= $row['id']; ?>" onclick="handleSaveEditAndDelete('remove', this)">
<i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete
</a>
<?php endif; ?>
</div>
</div>
</td>
</tr>
<?php } ?>
<?php } else { ?>
<tr>
<td colspan="3" class="text-center">No data available</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- modal content -->
<div id="con-close-modal" class="modal fade app-font-family" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;" data-backdrop="static">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="modalLabel">Add Branch</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body p-4">
<!-- <form class="parsley-examples" id="nhanceBranchForm" enctype="multipart/form-data"> -->
<form id="nhanceBranchForm" enctype="multipart/form-data">
<input type="hidden" name="pk" id="nhance_branch_id"/>
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-12">
<label for="branch_name">Branch Name<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="branch_name" name="branch_name" placeholder="Enter Branch Name" required>
</div>
</div>
</div>
<div class="form-group text-right m-b-0">
<button type="button" class="btn app-btn-secondary waves-effect waves-light" id="btnSubmit" onclick="handleSaveEditAndDelete('submit')">Submit</button>
</div>
</form>
</div>
</div>
</div>
</div>
<script>
var table;
$(document).ready(function () {
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
buttons: [
{
text: 'Add',
className: 'btn app-btn-primary mr-2',
action: function(e, dt, node, config) {
openModal()
}
},
{
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: 'Policy-Tranction-Inception-List',
className: 'app-btn-primary ',
exportOptions: {
columns: ':not(:last-child)'
},
}
]
}
],
language: {
search: `
<div class="datatable-search-wrapper">
_INPUT_
<i class="mdi mdi-magnify datatable-search-icon"></i>
</div>`,
searchPlaceholder: "Search"
},
paging: true, // Enable pagination
pageLength: 10, // Set default number of rows per page (optional)
// ordering: false,
});
});
$('.close').click(function(){
resetValues()
})
function openModal(){
var myModal = new bootstrap.Modal(document.getElementById('con-close-modal'));
myModal.show();
}
// old Version
// function handleSaveEditAndDelete(type = 'submit', pk = null){
// let url = '<?= base_url('util/nhanceBranchMaster') ?>';
// let method = "POST";
// let requestData = {};
// $('#modalLabel').text('Add Branch');
// requestData.pk = pk;
// if(type == 'submit'){
// $("#nhanceBranchForm").find("input, select, textarea").each(function () {
// let name = $(this).attr("name");
// let value = $.trim($(this).val());
// if (name) requestData[name] = value;
// });
// }
// if(type == 'remove'){
// method = "DELETE";
// }else if (type == 'edit'){
// method = "GET"
// }
// console.log("type", type)
// console.log("url", url)
// console.log("method", method)
// console.log("requestData", requestData)
// $('.loader').fadeIn();
// $('.loader-mask').fadeIn();
// // Send AJAX request
// sendAjaxRequestForGlobal(url, method, requestData, function(response) {
// console.log('Data fetched successfully:', response);
// if (response.status) {
// if(type == 'edit'){
// $('#modalLabel').text('Edit Branch');
// appendEditData(response.data);
// }else{
// toastr.success(response.message, 'SUCCESS');
// }
// } else {
// toastr.warning(response.message, 'WARNING');
// }
// $('.loader').fadeOut();
// $('.loader-mask').delay(350).fadeOut('slow');
// }, function(xhr, status, error) {
// console.error('Error fetching data:', error);
// console.error(xhr.responseText);
// $('.loader').fadeOut();
// $('.loader-mask').delay(350).fadeOut('slow');
// });
// }
function handleSaveEditAndDelete(type = 'submit', el = null) {
let url = '<?= base_url('util/nhanceBranchMaster') ?>';
let method = "POST";
let requestData = {};
let pk = null;
// If element is passed (from edit/remove button), get its data-id
if (el) { pk = $(el).data('id'); }
requestData.pk = pk;
if(type == 'submit'){
$("#nhanceBranchForm").find("input, select, textarea").each(function () {
let name = $(this).attr("name");
let value = $.trim($(this).val());
if (name) requestData[name] = value;
});
}
if(type == 'remove'){
method = "DELETE";
} else if (type == 'edit'){
method = "GET";
$('#modalLabel').text('Edit Branch');
$('#nhanceBranchForm')[0].reset();
}
console.log("type", type)
console.log("url", url)
console.log("method", method)
console.log("requestData", requestData)
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
// Send AJAX request
sendAjaxRequestForGlobal(url, method, requestData, function(response) {
console.log('Data fetched successfully:', response);
if (response.status) {
if(type == 'edit'){
appendEditData(response.data);
} else if(type == 'remove'){
toastr.success(response.message, 'Success');
if(el) $(el).closest('tr').remove();
} else if(type == 'submit'){
toastr.success(response.message, 'Success');
var myModal = new bootstrap.Modal(document.getElementById('con-close-modal'));
myModal.hide();
$('#nhanceBranchForm')[0].reset();
window.location.reload();
}
} else {
toastr.warning(response.message, 'Warning');
}
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, function(xhr, status, error) {
console.error('Error fetching data:', error);
console.error(xhr.responseText);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
});
}
function resetValues(){
$('#modalLabel').text('Add Branch');
$('#nhanceBranchForm')[0].reset();
}
function appendEditData(data){
$('#nhance_branch_id').val(data[0]['id']);
$('#branch_name').val(data[0]['branch_name']);
openModal()
}
</script>

File diff suppressed because it is too large Load Diff

View File

@ -37,14 +37,15 @@
<hr>
<?php if(isset($lead_edit_data)) { ?>
<div class="form-row" id="appendAreaForClaim_1">
<?php
$claims = !empty($lead_edit_data['fin_years_claims_array']) ? $lead_edit_data['fin_years_claims_array'] : [ ['year' => '', 'claim_amount' => '', 'status' => '', 'claim_type' => '', 'cause_of_death' => '', 'death_date' => ''] ];
foreach ($claims as $key => $value) { ?>
<div class="row claim-row">
<div class="form-group col-md-2">
<label for="first_year">Year<span class="text-danger">*</span></label>
<select class="form-control first_year_" id="first_year" name="first_year[]">
@ -55,15 +56,43 @@
} ?>
</select>
</div>
<div class="form-group col-md-2">
<label for="first_claim_amount">Claim/Settled Amount<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_claim_amount" name="first_claim_amount[]" value="<?= htmlspecialchars($value['claim_amount']) ?>">
<label for="emp_id">Emp ID<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="emp_id" name="emp_id[]" value="<?= htmlspecialchars(isset($value['emp_id']) ? $value['emp_id'] : '-' ) ?>">
</div>
<div class="form-group col-md-2">
<label for="first_claim_status">Claim Status<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_claim_status" name="first_claim_status[]" value="<?= htmlspecialchars($value['status']) ?>">
<label for="emp_name">Employee Name<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="emp_name" name="emp_name[]" value="<?= htmlspecialchars(isset($value['emp_name']) ? $value['emp_name'] : '-' ) ?>">
</div>
<div class="form-group col-md-2 lifeClaimFields" style="display:none;">
<div class="form-group col-md-2">
<label for="gender">Gender<span class="text-danger">*</span></label>
<select class="form-control" id="gender" name="gender[]">
<option value="">Select Gender</option>
<option value="Female" <?= (isset($value['gender']) && $value['gender'] == 'Female') ? 'selected' : '' ?>>Female</option>
<option value="Male" <?= (isset($value['gender']) && $value['gender'] == 'Male') ? 'selected' : '' ?>>Male</option>
</select>
</div>
<div class="form-group col-md-2">
<label for="designation">Designation <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="designation" name="designation[]" value="<?= htmlspecialchars(isset($value['designation']) ? $value['designation'] : '-' ) ?>">
</div>
<div class="form-group col-md-2">
<label for="sum_insured">Sum Insured <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="sum_insured" name="sum_insured[]" value="<?= htmlspecialchars(isset($value['sum_insured']) ? $value['sum_insured'] : '-' ) ?>">
</div>
<div class="form-group col-md-2">
<label for="first_death_date">Date of Death<span class="text-danger">*</span></label>
<input type="text" class="form-control flatpickr-date" id="first_death_date" name="first_death_date[]" value="<?= htmlspecialchars($value['death_date']) ?>" autocomplete="off">
</div>
<div class="form-group col-md-2">
<label for="first_cause_of_death">Nature/Cause Of Death <span class="text-danger">*</span></label>
<select class="form-control" id="first_cause_of_death" name="first_cause_of_death[]">
<option value="">Select Cause of Death</option>
@ -73,26 +102,37 @@
} ?>
</select>
</div>
<div class="form-group col-md-2 lifeClaimFields" style="display:none;">
<label for="first_death_date">Date of Death<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_death_date" name="first_death_date[]" value="<?= htmlspecialchars($value['death_date']) ?>">
<div class="form-group col-md-2">
<label for="first_claim_amount">Claim/Settled Amount<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_claim_amount" name="first_claim_amount[]" value="<?= htmlspecialchars(isset($value['claim_amount']) ? $value['claim_amount'] : ( isset($value['settled']) ? $value['settled'] : '-' )) ?>">
</div>
<div class="form-group col-md-2 gpaClaimFileds" style="display:none;">
<!-- <div class="form-group col-md-2">
<label for="first_claim_status">Claim Status<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_claim_status" name="first_claim_status[]" value="<?php //htmlspecialchars($value['status']) ?>">
</div> -->
<!-- <div class="form-group col-md-2 gpaClaimFileds" style="display:none;">
<label for="claim_type">Claim Type<span class="text-danger">*</span></label>
<select class="form-control" id="claim_type" name="claim_type[]">
<option value="">Select Claim Type</option>
<?php foreach ($gpaClaimType as $claimType => $claim_value) {
$selected = ($claimType == $value['claim_type']) ? 'selected' : '';
echo "<option value='$claimType' $selected>$claim_value</option>";
} ?>
<?php
// foreach ($gpaClaimType as $claimType => $claim_value) {
// $selected = ($claimType == $value['claim_type']) ? 'selected' : '';
// echo "<option value='$claimType' $selected>$claim_value</option>";
// }
?>
</select>
</div>
</div> -->
<div class="form-group col-md-2">
<div class="" style="position: relative; top: 28px; float: right; text-align: end;">
<a class="btn btn-danger waves-effect waves-light" onclick="removeClaim(this, 1)">x</a>
<a class="btn btn-primary waves-effect waves-light mr-1" onclick="appendThreeYearsClaims(1)">+</a>
</div>
</div>
</div>
<?php } ?>
</div>
@ -100,3 +140,13 @@
<div class="form-row" id="appendAreaForClaim"></div>
<?php } ?>
<script>
flatpickr('.flatpickr-date', {
dateFormat: 'd-M-Y', // Example format: 11-10-2025
allowInput: true, // Allow manual typing
maxDate: 'today', // Optional: disable future dates
});
</script>

View File

@ -0,0 +1,254 @@
<style>
.dataTables_filter {
position: absolute;
}
</style>
<!-- End ADD and EDIT Page HTML -->
<div class="row" id="List-page">
<div class="col-12">
<div class="card">
<div class="card-body maincard">
<table data-custom-table-css="table" class="table table-sm m-0 table-centered dt-responsive nowrap w-100" cellspacing="a" id="user-table">
<thead class="bg-light">
<tr>
<th class="font-weight-medium">S.No.</th>
<th class="font-weight-medium">RTO Office at</th>
<th class="font-weight-medium">RTO Code</th>
<th class="font-weight-medium">RTO State</th>
<!-- <th class="font-weight-medium">Status</th> -->
<th class="font-weight-medium">Action</th>
</tr>
</thead>
<tbody>
<?php if(isset($data)) { ?>
<?php foreach($data as $index => $row) { ?>
<tr>
<td class="text-dark">&nbsp;&nbsp;<?= esc($index + 1); ?></td>
<td><?= $row['rto_name']; ?></td>
<td><?= $row['rto_code']; ?></td>
<td><?= $row['rto_state']; ?></td>
<!-- <td>
<span class="<?php if($row['is_active'] == 1){ echo 'badge badge-primary'; }else{ echo 'badge badge-danger'; } ?>">
<?php if($row['is_active'] == 1){ echo 'Active'; }else{ echo 'In-Active'; } ?>
</span>
</td> -->
<td>
<div class="btn-group dropdown" style="position: relative !important;left:0px !important;top:0px !important;">
<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" style="cursor: pointer;">
<a class="dropdown-item" data-id="<?= $row['id']; ?>" onclick="handleSaveEditAndDelete('edit', this)">
<i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit
</a>
<?php if ($row['is_active'] == 1): ?>
<a class="dropdown-item" data-id="<?= $row['id']; ?>" onclick="handleSaveEditAndDelete('remove', this)">
<i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete
</a>
<?php endif; ?>
</div>
</div>
</td>
</tr>
<?php } ?>
<?php } else { ?>
<tr>
<td colspan="3" class="text-center">No data available</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- modal content -->
<div id="con-close-modal" class="modal fade app-font-family" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;" data-backdrop="static">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="modalLabel">Add RTO Details</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body p-4">
<!-- <form class="parsley-examples" id="RTOForm" enctype="multipart/form-data"> -->
<form id="RTOForm" enctype="multipart/form-data">
<input type="hidden" name="pk" id="rto_id"/>
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-12">
<label for="rto_name">RTO Office Name<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="rto_name" name="rto_name" placeholder="Enter RTO Office Name" required>
</div>
<div class="form-group col-md-12">
<label for="rto_code">RTO Code<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="rto_code" name="rto_code"
placeholder="Enter RTO Code" required
maxlength="2"
inputmode="numeric"
pattern="[0-9]{2}"
oninput="this.value = this.value.replace(/[^0-9]/g, '').slice(0,2);">
</div>
<div class="form-group col-md-12">
<label for="rto_state">RTO State<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="rto_state" name="rto_state"
placeholder="Enter RTO State" required
maxlength="2"
pattern="[A-Z]{2}"
oninput="this.value = this.value.replace(/[^A-Za-z]/g, '').toUpperCase().slice(0,2);">
</div>
</div>
</div>
<div class="form-group text-right m-b-0">
<button type="button" class="btn app-btn-secondary waves-effect waves-light" id="btnSubmit" onclick="handleSaveEditAndDelete('submit')">Submit</button>
</div>
</form>
</div>
</div>
</div>
</div>
<script>
var table;
$(document).ready(function () {
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
buttons: [
{
text: 'Add',
className: 'btn app-btn-primary mr-2',
action: function(e, dt, node, config) {
openModal()
}
},
{
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: 'RTO',
className: 'app-btn-primary ',
exportOptions: {
columns: ':not(:last-child)'
},
}
]
}
],
language: {
search: `
<div class="datatable-search-wrapper">
_INPUT_
<i class="mdi mdi-magnify datatable-search-icon"></i>
</div>`,
searchPlaceholder: "Search"
},
paging: true, // Enable pagination
pageLength: 10, // Set default number of rows per page (optional)
// ordering: false,
});
});
$('.close').click(function(){
resetValues()
})
function openModal(){
var myModal = new bootstrap.Modal(document.getElementById('con-close-modal'));
myModal.show();
}
function handleSaveEditAndDelete(type = 'submit', el = null) {
let url = '<?= base_url('util/rtoMaster') ?>';
let method = "POST";
let requestData = {};
let pk = null;
// If element is passed (from edit/remove button), get its data-id
if (el) { pk = $(el).data('id'); }
requestData.pk = pk;
if(type == 'submit'){
$("#RTOForm").find("input, select, textarea").each(function () {
let name = $(this).attr("name");
let value = $.trim($(this).val());
if (name) requestData[name] = value;
});
}
if(type == 'remove'){
method = "DELETE";
} else if (type == 'edit'){
method = "GET";
$('#modalLabel').text('Edit RTO details');
$('#vehicleTypeForm')[0].reset();
}
console.log("type", type)
console.log("url", url)
console.log("method", method)
console.log("requestData", requestData)
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
// Send AJAX request
sendAjaxRequestForGlobal(url, method, requestData, function(response) {
console.log('Data fetched successfully:', response);
if (response.status) {
if(type == 'edit'){
appendEditData(response.data);
} else if(type == 'remove'){
toastr.success(response.message, 'Success');
if(el) $(el).closest('tr').remove();
} else if(type == 'submit'){
toastr.success(response.message, 'Success');
var myModal = new bootstrap.Modal(document.getElementById('con-close-modal'));
myModal.hide();
resetValues();
window.location.reload();
}
} else {
toastr.warning(response.message, 'Warning');
}
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, function(xhr, status, error) {
console.error('Error fetching data:', error);
console.error(xhr.responseText);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
});
}
function resetValues(){
$('#modalLabel').text('Add RTO Details');
$('#RTOForm')[0].reset();
}
function appendEditData(data){
$('#rto_id').val(data[0]['id']);
$('#rto_name').val(data[0]['rto_name']);
$('#rto_code').val(data[0]['rto_code']);
$('#rto_state').val(data[0]['rto_state']);
openModal()
}
</script>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,230 @@
<style>
.dataTables_filter {
position: absolute;
}
</style>
<!-- End ADD and EDIT Page HTML -->
<div class="row" id="List-page">
<div class="col-12">
<div class="card">
<div class="card-body maincard">
<table data-custom-table-css="table" class="table table-sm m-0 table-centered dt-responsive nowrap w-100" cellspacing="a" id="user-table">
<thead class="bg-light">
<tr>
<th class="font-weight-medium">S.No.</th>
<th class="font-weight-medium">Vehicle Type</th>
<!-- <th class="font-weight-medium">Status</th> -->
<th class="font-weight-medium">Action</th>
</tr>
</thead>
<tbody>
<?php if(isset($data)) { ?>
<?php foreach($data as $index => $row) { ?>
<tr>
<td class="text-dark">&nbsp;&nbsp;<?= esc($index + 1); ?></td>
<td><?= $row['vehicle_type']; ?></td>
<!-- <td>
<span class="<?php if($row['is_active'] == 1){ echo 'badge badge-primary'; }else{ echo 'badge badge-danger'; } ?>">
<?php if($row['is_active'] == 1){ echo 'Active'; }else{ echo 'In-Active'; } ?>
</span>
</td> -->
<td>
<div class="btn-group dropdown" style="position: relative !important;left:0px !important;top:0px !important;">
<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" style="cursor: pointer;">
<a class="dropdown-item" data-id="<?= $row['id']; ?>" onclick="handleSaveEditAndDelete('edit', this)">
<i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit
</a>
<?php if ($row['is_active'] == 1): ?>
<a class="dropdown-item" data-id="<?= $row['id']; ?>" onclick="handleSaveEditAndDelete('remove', this)">
<i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete
</a>
<?php endif; ?>
</div>
</div>
</td>
</tr>
<?php } ?>
<?php } else { ?>
<tr>
<td colspan="3" class="text-center">No data available</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- modal content -->
<div id="con-close-modal" class="modal fade app-font-family" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;" data-backdrop="static">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="modalLabel">Add Vehicle Type</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body p-4">
<!-- <form class="parsley-examples" id="vehicleTypeForm" enctype="multipart/form-data"> -->
<form id="vehicleTypeForm" enctype="multipart/form-data">
<input type="hidden" name="pk" id="vehicle_type_id"/>
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-12">
<label for="vehicle_type">Vehicle Type<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="vehicle_type" name="vehicle_type" placeholder="Enter Vehicle Type" required>
</div>
</div>
</div>
<div class="form-group text-right m-b-0">
<button type="button" class="btn app-btn-secondary waves-effect waves-light" id="btnSubmit" onclick="handleSaveEditAndDelete('submit')">Submit</button>
</div>
</form>
</div>
</div>
</div>
</div>
<script>
var table;
$(document).ready(function () {
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
buttons: [
{
text: 'Add',
className: 'btn app-btn-primary mr-2',
action: function(e, dt, node, config) {
openModal()
}
},
{
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: 'Policy-Tranction-Inception-List',
className: 'app-btn-primary ',
exportOptions: {
columns: ':not(:last-child)'
},
}
]
}
],
language: {
search: `
<div class="datatable-search-wrapper">
_INPUT_
<i class="mdi mdi-magnify datatable-search-icon"></i>
</div>`,
searchPlaceholder: "Search"
},
paging: true, // Enable pagination
pageLength: 10, // Set default number of rows per page (optional)
// ordering: false,
});
});
$('.close').click(function(){
resetValues()
})
function openModal(){
var myModal = new bootstrap.Modal(document.getElementById('con-close-modal'));
myModal.show();
}
function handleSaveEditAndDelete(type = 'submit', el = null) {
let url = '<?= base_url('util/vehicleTypeMaster') ?>';
let method = "POST";
let requestData = {};
let pk = null;
// If element is passed (from edit/remove button), get its data-id
if (el) { pk = $(el).data('id'); }
requestData.pk = pk;
if(type == 'submit'){
$("#vehicleTypeForm").find("input, select, textarea").each(function () {
let name = $(this).attr("name");
let value = $.trim($(this).val());
if (name) requestData[name] = value;
});
}
if(type == 'remove'){
method = "DELETE";
} else if (type == 'edit'){
method = "GET";
$('#modalLabel').text('Edit Vehicle Type');
$('#vehicleTypeForm')[0].reset();
}
console.log("type", type)
console.log("url", url)
console.log("method", method)
console.log("requestData", requestData)
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
// Send AJAX request
sendAjaxRequestForGlobal(url, method, requestData, function(response) {
console.log('Data fetched successfully:', response);
if (response.status) {
if(type == 'edit'){
appendEditData(response.data);
} else if(type == 'remove'){
toastr.success(response.message, 'Success');
if(el) $(el).closest('tr').remove();
} else if(type == 'submit'){
toastr.success(response.message, 'Success');
var myModal = new bootstrap.Modal(document.getElementById('con-close-modal'));
myModal.hide();
resetValues();
window.location.reload();
}
} else {
toastr.warning(response.message, 'Warning');
}
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, function(xhr, status, error) {
console.error('Error fetching data:', error);
console.error(xhr.responseText);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
});
}
function resetValues(){
$('#modalLabel').text('Add Vehicle Type');
$('#vehicleTypeForm')[0].reset();
}
function appendEditData(data){
$('#vehicle_type_id').val(data[0]['id']);
$('#vehicle_type').val(data[0]['vehicle_type']);
openModal()
}
</script>