MERGE_UAT_BDS_TPA_TPA_VARIATION
This commit is contained in:
commit
46bf0a6b78
@ -55,7 +55,6 @@ $routes->post("add_advertise_image", "AppContentManagementController::add_advert
|
||||
$routes->post('remove_advertise_image', 'AppContentManagementController::remove_advertise_image');
|
||||
$routes->get("add_image_index", "AppContentManagementController::add_image_index");
|
||||
$routes->get("getAdvertiseImage/(:any)", "AppContentManagementController::getAdvertiseImage/$1");
|
||||
$routes->get("frontend_content", "AppContentManagementController::frontend_content");
|
||||
$routes->get('showAdvertiseImage/(:any)', 'AppContentManagementController::showAdvertiseImage/$1');
|
||||
|
||||
|
||||
@ -169,6 +168,7 @@ $routes->group("/client", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->post("create_2", "ClientController::createClientKYCInfo_2");
|
||||
$routes->post("edit_2", "ClientController::editClientKYCInfo_2");
|
||||
$routes->post("delete_2", "ClientController::deleteClientKycDocs_2/$1");
|
||||
$routes->get("download_2/(:any)", "ClientController::downloadClientKycDocs_2/$1");
|
||||
|
||||
});
|
||||
|
||||
@ -421,6 +421,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
|
||||
$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->match(['get', 'post', 'delete'], 'partnerPOS', 'MasterController::partnerPOS');
|
||||
$routes->get('checkDuplicateCdAccount', 'MasterController::checkDuplicateCdAccount');
|
||||
$routes->get('proceedExcelFileDataValidation', 'EmployeeController::proceedExcelFileDataValidation');
|
||||
$routes->get('checkTpaApiEnable', 'EmployeeRestController::checkTpaApiEnable');
|
||||
@ -647,7 +648,13 @@ $routes->group("employeeRest", ["filter" => ['appSignature' , 'authJWT']], funct
|
||||
$routes->get("ticketHistoryList", "ThzController::ticketHistoryList");
|
||||
$routes->match(['get','post','put'], 'ticketType', 'ThzController::ticketType');
|
||||
|
||||
|
||||
//this route for nhance website contact form (sales/service)
|
||||
$routes->group("employeeRest", ['filter' => ['appSignature'] ], function ($routes) {
|
||||
$routes->post("ticketSave", "ThzController::ticketSave");
|
||||
});
|
||||
|
||||
//API FAQ
|
||||
$routes->match(['get','post','delete'], 'FAQ', 'AppContentManagementController::FAQ');
|
||||
|
||||
//claims
|
||||
$routes->post('initiateClaim',"EmployeeRestController::initiateClaim");
|
||||
@ -766,6 +773,7 @@ $routes->get('IRSubmission','MediAssistApiController::IRSubmission');
|
||||
// API service
|
||||
$routes->post("ecardRequest", "ApiServiceController::ecardRequest");
|
||||
$routes->post("getTPAID", "ApiServiceController::getTPAID");
|
||||
// $routes->get("getTPAID", "ApiServiceController::getTPAID");
|
||||
$routes->get('fileDownload','MediAssistApiController::fileDownload');
|
||||
|
||||
|
||||
@ -776,7 +784,7 @@ $routes->get('testTracelog','TestBusinessController::a');
|
||||
$routes->get("claimView", "EmployeeRestController::claimView");
|
||||
|
||||
// General Tickets
|
||||
$routes->post("ticketSave", "ThzController::ticketSave");
|
||||
$routes->post("ticketSave", "ThzController::ticketSave"); //
|
||||
$routes->get("ticketList", "ThzController::ticketList");
|
||||
$routes->post("ticketConversationSave", "ThzController::ticketConversationSave");
|
||||
$routes->get("ticketConversationList", "ThzController::ticketConversationList");
|
||||
@ -784,6 +792,10 @@ $routes->post('ticketAutoFetchDetails',"ThzController::ticketAutoFetchDetails");
|
||||
$routes->match(['get','post','put'], 'ticketType', 'ThzController::ticketType');
|
||||
$routes->get("ticketHistoryList", "ThzController::ticketHistoryList");
|
||||
|
||||
// General FAQ
|
||||
$routes->match(['get','post','delete'], 'FAQ', 'AppContentManagementController::FAQ');
|
||||
$routes->match(['get','post','delete'], 'frontend_content', 'AppContentManagementController::frontend_content');
|
||||
$routes->get("getFEContent", "EmployeeRestController::getFEContent");
|
||||
|
||||
//for testing
|
||||
$routes->group('test', function($routes) {
|
||||
@ -852,3 +864,89 @@ $routes->group('logs', function($routes) {
|
||||
$routes->get('delete/(:segment)', 'LogController::delete/$1');
|
||||
$routes->get('clearAll', 'LogController::clearAll');
|
||||
});
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
$routes->group('sales', function($routes) {
|
||||
|
||||
// ==================== LEAD ROUTES ====================
|
||||
|
||||
// Get all leads with filters
|
||||
$routes->get('leads', 'SalesController::getLeads');
|
||||
|
||||
// Get lead statistics
|
||||
$routes->get('leads/stats', 'SalesController::getLeadStats');
|
||||
|
||||
// Get single lead with complete details
|
||||
$routes->get('leads/(:num)', 'SalesController::getLead/$1');
|
||||
|
||||
// Create new lead
|
||||
$routes->post('leads', 'SalesController::createLead');
|
||||
|
||||
// Update lead
|
||||
$routes->put('leads/(:num)', 'SalesController::updateLead/$1');
|
||||
|
||||
// Delete lead
|
||||
$routes->delete('leads/(:num)', 'SalesController::deleteLead/$1');
|
||||
|
||||
// Get contacts for a lead
|
||||
$routes->get('leads/(:num)/contacts', 'SalesController::getContacts/$1');
|
||||
|
||||
// Get activities for a lead
|
||||
$routes->get('leads/(:num)/activities', 'SalesController::getLeadActivities/$1');
|
||||
|
||||
// Get activity timeline for a lead
|
||||
$routes->get('leads/(:num)/timeline', 'SalesController::getActivityTimeline/$1');
|
||||
|
||||
// Get notes for a lead
|
||||
$routes->get('leads/(:num)/notes', 'SalesController::getLeadNotes/$1');
|
||||
|
||||
// ==================== CONTACT PERSON ROUTES ====================
|
||||
|
||||
// Create contact person
|
||||
$routes->post('contacts', 'SalesController::createContact');
|
||||
|
||||
// Update contact person
|
||||
$routes->put('contacts/(:num)', 'SalesController::updateContact/$1');
|
||||
|
||||
// Delete contact person
|
||||
$routes->delete('contacts/(:num)', 'SalesController::deleteContact/$1');
|
||||
|
||||
// Set primary contact
|
||||
$routes->put('contacts/(:num)/set-primary', 'SalesController::setPrimaryContact/$1');
|
||||
|
||||
// ==================== ACTIVITY ROUTES ====================
|
||||
|
||||
// Get all activities with filters
|
||||
$routes->get('activities', 'SalesController::getActivities');
|
||||
|
||||
// Get upcoming activities
|
||||
$routes->get('activities/upcoming', 'SalesController::getUpcomingActivities');
|
||||
|
||||
// Get pending activities count
|
||||
$routes->get('activities/pending-count', 'SalesController::getPendingCount');
|
||||
|
||||
// Create activity
|
||||
$routes->post('activities', 'SalesController::createActivity');
|
||||
|
||||
// Update activity
|
||||
$routes->put('activities/(:num)', 'SalesController::updateActivity/$1');
|
||||
|
||||
// Complete activity
|
||||
$routes->post('activities/(:num)/complete', 'SalesController::completeActivity/$1');
|
||||
|
||||
// Delete activity
|
||||
$routes->delete('activities/(:num)', 'SalesController::deleteActivity/$1');
|
||||
|
||||
// ==================== NOTE ROUTES ====================
|
||||
|
||||
// Create note
|
||||
$routes->post('notes', 'SalesController::createNote');
|
||||
|
||||
// Update note
|
||||
$routes->put('notes/(:num)', 'SalesController::updateNote/$1');
|
||||
|
||||
// Delete note
|
||||
$routes->delete('notes/(:num)', 'SalesController::deleteNote/$1');
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -14,6 +14,8 @@ use App\Controllers\ICICILombardController;
|
||||
use App\Controllers\MediAssistApiController;
|
||||
use App\Models\BatchFileModel;
|
||||
use App\Models\FileModel;
|
||||
use App\Helpers\TPADataCompareHelper;
|
||||
use App\Helpers\TPADataCompareHelper2;
|
||||
|
||||
class ApiServiceController extends BaseController
|
||||
{
|
||||
@ -154,6 +156,19 @@ class ApiServiceController extends BaseController
|
||||
public function getTPAID()
|
||||
{
|
||||
|
||||
// helper('TPADataCompareHelper');
|
||||
// print_rr(json_decode(file_get_contents(WRITEPATH.'/tmp/medi.json'),true));die();
|
||||
// $report = TPADataCompareHelper::compareDbVsMediassist(
|
||||
// $report = TPADataCompareHelper2::compareDbVsMediassistGrouped(
|
||||
// json_decode(file_get_contents(WRITEPATH.'/tmp/db.json'),true),
|
||||
// json_decode(file_get_contents(WRITEPATH.'/tmp/medi.json'),true)
|
||||
// );
|
||||
// print_rr($report);
|
||||
// die();
|
||||
|
||||
|
||||
|
||||
//START OF THE PROGRAM
|
||||
log_message('error', "getTPAID payloads :" . json_encode($this->request->getPost() ?? []));
|
||||
$tpa_id = $this->request->getPost('tpa_id') ?? null;
|
||||
$policy_no = $this->request->getPost('policy_no') ?? null;
|
||||
|
||||
@ -11,6 +11,7 @@ use CodeIgniter\API\ResponseTrait;
|
||||
use App\Models\AddImgModel;
|
||||
use App\Models\FEContentModel;
|
||||
use App\Models\ClientModel;
|
||||
use App\Models\FAQModel;
|
||||
|
||||
class AppContentManagementController extends AdminController
|
||||
{
|
||||
@ -19,6 +20,7 @@ class AppContentManagementController extends AdminController
|
||||
protected $addImgModel;
|
||||
protected $feContentModel;
|
||||
protected $clientModel;
|
||||
protected $faqModel;
|
||||
|
||||
|
||||
public function __construct()
|
||||
@ -27,6 +29,7 @@ class AppContentManagementController extends AdminController
|
||||
$this->addImgModel = new AddImgModel();
|
||||
$this->feContentModel = new FEContentModel();
|
||||
$this->clientModel = new ClientModel();
|
||||
$this->faqModel = new FAQModel();
|
||||
}
|
||||
//listing
|
||||
public function add_image_index()
|
||||
@ -133,27 +136,236 @@ class AppContentManagementController extends AdminController
|
||||
|
||||
|
||||
|
||||
// public function getAdvertiseImage($image_id){
|
||||
// $image_data = $this->addImgModel->select('name')->where(['id' => $image_id])->first();
|
||||
// if($image_data){
|
||||
// return $image_data['name'];
|
||||
// }else{
|
||||
// return ;
|
||||
// }
|
||||
// }
|
||||
public function frontend_content()
|
||||
{
|
||||
|
||||
$method = $this->request->getMethod();
|
||||
|
||||
if ($this->request->getMethod() === 'post') {
|
||||
|
||||
$id = $this->request->getPost('fe_id');
|
||||
$data = $this->request->getPost();
|
||||
|
||||
unset($data['fe_id']);
|
||||
|
||||
// Front End Content Area
|
||||
public function frontend_content(){
|
||||
foreach ($data as $k => $v) {
|
||||
if ($v === '' || $v === null) {unset($data[$k]);}
|
||||
}
|
||||
|
||||
// INSERT / UPDATE
|
||||
if (empty($id)) {
|
||||
$status = $this->feContentModel->insert($data);
|
||||
$text = "Created";
|
||||
} else {
|
||||
$status = $this->feContentModel->update($id, $data);
|
||||
$text = "Updated";
|
||||
}
|
||||
|
||||
$data['test'] = $this->feContentModel->findAll();
|
||||
$headerData['tab_name'] = 'Front-End Content';
|
||||
$headerData['page_name'] = 'Front-End Content';
|
||||
return $this->respond([
|
||||
'status' => $status ? true : false,
|
||||
'message' => "Frontend Content $text " . ($status ? 'successfully' : 'failed'),
|
||||
'code' => $status ? 200 : 400,
|
||||
'data' => $data,
|
||||
] , $status ? 200 : 400 );
|
||||
}
|
||||
elseif ($method === 'get') {
|
||||
|
||||
echo view('layout/header', $headerData);
|
||||
echo view('frontend_content_list', $data);
|
||||
echo view('layout/footer');
|
||||
$id = $this->request->getGet('fe_id') ?? null;
|
||||
|
||||
if (!empty($id)) {
|
||||
|
||||
$data['fe_list'] = $this->feContentModel->where('id', $id)->orderBy('id', 'DESC')->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['fe_list'] = $this->feContentModel->orderBy('id', 'DESC')->findAll();
|
||||
|
||||
return $this->loadLayout('frontend_content_list', ['data' => $data,'tab_name' => 'Front-End Content','page_name' => 'Front-End Content']);
|
||||
|
||||
} elseif ($method === 'delete') {
|
||||
|
||||
// $input = $this->request->getRawInput();
|
||||
$id = $this->request->getGet('fe_id'); // ✅ THIS
|
||||
$id = $id ?? null;
|
||||
|
||||
if (empty($id)) {
|
||||
return $this->respond([
|
||||
'status' => false,
|
||||
'code' => 404,
|
||||
'message' => 'No ID provided for deletion'
|
||||
], 200);
|
||||
}
|
||||
|
||||
$update_status = $this->feContentModel->where('id', $id)->set(['is_active' => 0])->update();
|
||||
|
||||
if ($update_status) {
|
||||
return $this->respond([
|
||||
'status' => true,
|
||||
'code' => 200,
|
||||
'message' => 'Data removed successfully',
|
||||
'fe_id' => $id
|
||||
], 200);
|
||||
} else {
|
||||
return $this->respond([
|
||||
'status' => false,
|
||||
'code' => 400,
|
||||
'message' => 'Failed to remove data',
|
||||
'fe_id' => $id
|
||||
], 200);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function FAQ()
|
||||
{
|
||||
$method = strtolower($this->request->getMethod());
|
||||
$returnType = strtolower($this->request->getGet('return_type') ?? 'api');
|
||||
$ref = ['timestamp' => date('Y-m-d H:i:s')];
|
||||
|
||||
try {
|
||||
// --- 1. POST: CREATE OR UPDATE ---
|
||||
if ($method === 'post') {
|
||||
$id = $this->request->getPost('faq_id');
|
||||
$data = array_filter($this->request->getPost(), fn($v) => $v !== '' && $v !== null);
|
||||
|
||||
if (empty($id)) {
|
||||
$status = $this->faqModel->insert($data);
|
||||
$msg = "Created";
|
||||
} else {
|
||||
$status = $this->faqModel->update($id, $data);
|
||||
$msg = "Updated";
|
||||
}
|
||||
|
||||
// if ($returnType === 'web') {
|
||||
// return redirect()->back()->with($status ? 'success' : 'error', "FAQ $msg " . ($status ? 'successfully' : 'failed'));
|
||||
// }
|
||||
|
||||
// return $this->response->setJSON([
|
||||
// ])->setStatusCode($result ? 200 : 400);
|
||||
return $this->response->setJSON([
|
||||
'status' => $status ? 'success' : 'error',
|
||||
'message' => "FAQ $msg " . ($status ? 'successfully' : 'failed'),
|
||||
'code' => $status ? 200 : 400,
|
||||
'data' => $data,
|
||||
'ref' => $ref
|
||||
])->setStatusCode($status ? 200 : 400);
|
||||
}
|
||||
|
||||
// --- 2. GET: FETCH LIST OR SINGLE ---
|
||||
elseif ($method === 'get') {
|
||||
|
||||
$id = $this->request->getGet('faq_id');
|
||||
|
||||
if (!empty($id)) {
|
||||
if($returnType === 'web'){
|
||||
$row = $this->faqModel->find($id);
|
||||
}else{
|
||||
$row = $this->faqModel->where('is_active', 1)->find($id);
|
||||
}
|
||||
|
||||
$data['faq_list'] = $row ? [$row] : [];
|
||||
} else {
|
||||
if($returnType === 'web'){
|
||||
$data['faq_list'] = $this->faqModel->orderBy('id', 'desc')->findAll();
|
||||
}else{
|
||||
$data['faq_list'] = $this->faqModel->where('is_active', 1)->orderBy('id', 'desc')->findAll();
|
||||
}
|
||||
}
|
||||
|
||||
if ($returnType === 'web') {
|
||||
$data['tab_name'] = "FAQ";
|
||||
$data['page_name'] = "FAQ";
|
||||
// print_r($data);die;
|
||||
return $this->loadLayout('faq_list', $data);
|
||||
}
|
||||
|
||||
// API Response Logic
|
||||
if (empty($data['faq_list'])) {
|
||||
return $this->response->setJSON([
|
||||
'status' => $returnType === 'web' ? false : 'error',
|
||||
'message' => 'No data found',
|
||||
'code' => 404,
|
||||
'data' => [],
|
||||
'ref' => $ref
|
||||
])->setStatusCode(200); // Using 200 with error status is common for mobile apps to prevent crashes
|
||||
}
|
||||
|
||||
return $this->response->setJSON([
|
||||
'status' => $returnType === 'web' ? true : 'success',
|
||||
'message' => 'Data retrieved',
|
||||
'code' => 200,
|
||||
'data' => $data,
|
||||
'ref' => $ref
|
||||
])->setStatusCode(200);
|
||||
}
|
||||
|
||||
// --- 3. DELETE: SOFT DELETE ---
|
||||
elseif ($method === 'delete') {
|
||||
$id = $this->request->getGet('faq_id');
|
||||
$status = (!empty($id)) ? $this->faqModel->update($id, ['is_active' => 0]) : false;
|
||||
|
||||
return $this->response->setJSON([
|
||||
'status' => $status ? ($returnType === 'web' ? true : 'success') : ($returnType === 'web' ? false : 'error'),
|
||||
'message' => $status ? 'Data removed successfully' : 'Failed to remove or ID missing',
|
||||
'code' => $status ? 200 : 400,
|
||||
'data' => [],
|
||||
'ref' => $ref
|
||||
])->setStatusCode( 200 );
|
||||
}
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
$msg = $e->getMessage();
|
||||
return $this->response->setJSON([
|
||||
'status' => $returnType === 'web' ? false : 'error',
|
||||
'code' => 500,
|
||||
'message' => $msg,
|
||||
'ref' => ['file' => $e->getFile(), 'line' => $e->getLine()]
|
||||
])->setStatusCode(500);
|
||||
}
|
||||
}
|
||||
|
||||
// public function frontend_content_files()
|
||||
// {
|
||||
|
||||
// // 1. Define your physical system path
|
||||
// define('UPLOAD_PATH', ROOTPATH . 'public/uploads/add_image_upload/');
|
||||
|
||||
// // 2. Define the public URL so the editor can display the image later
|
||||
// // This is what the browser uses to see the image (e.g., https://site.com/uploads/...)
|
||||
// // $publicUrl = "https://yourdomain.com/public/uploads/add_image_upload/";
|
||||
// $publicUrl = ROOTPATH . 'public/uploads/add_image_upload/';
|
||||
// // if (!is_dir($uploadPath)) mkdir($uploadPath, 0755, true);
|
||||
|
||||
// header('Content-Type: application/json');
|
||||
|
||||
// if ($_FILES['files']) {
|
||||
// // Ensure directory exists
|
||||
// if (!is_dir(UPLOAD_PATH)) {
|
||||
// mkdir(UPLOAD_PATH, 0775, true);
|
||||
// }
|
||||
|
||||
// $fileName = time() . '_' . basename($_FILES['files']['name'][0]);
|
||||
// $fullPath = UPLOAD_PATH . $fileName;
|
||||
|
||||
// if (move_uploaded_file($_FILES['files']['tmp_name'][0], $fullPath)) {
|
||||
// echo json_encode([
|
||||
// "success" => true,
|
||||
// "data" => [
|
||||
// "baseurl" => $publicUrl,
|
||||
// "files" => [$fileName]
|
||||
// ]
|
||||
// ]);
|
||||
// } else {
|
||||
// echo json_encode(["success" => false, "error" => "Failed to move file to " . UPLOAD_PATH]);
|
||||
// }
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
}
|
||||
@ -726,7 +726,7 @@ class ClientController extends AdminController
|
||||
if ($requestFrom == 'rest') {
|
||||
return $data;
|
||||
}
|
||||
|
||||
// print_rr($data);die();
|
||||
// Load the view for the new list page;
|
||||
echo view('layout/header', $headerData);
|
||||
echo view('view_deposit', $data);
|
||||
@ -741,12 +741,14 @@ class ClientController extends AdminController
|
||||
$client_id = $this->request->getPost('client_id');
|
||||
$insurer_id = $this->request->getPost('insurer_id');
|
||||
$record_date = $this->request->getPost('record_date');
|
||||
$cd_ac_pk = $this->request->getPost('cd_ac_pk');
|
||||
$cd_ac_no = $this->request->getPost('cd_ac_no');
|
||||
|
||||
$CD_Account_Number = $this->CDMasterModel
|
||||
->where('client_id', $client_id)
|
||||
->where('insurer_id', $insurer_id)
|
||||
->where('is_active', 1)
|
||||
->first();
|
||||
// $CD_Account_Number = $this->CDMasterModel
|
||||
// ->where('client_id', $client_id)
|
||||
// ->where('insurer_id', $insurer_id)
|
||||
// ->where('is_active', 1)
|
||||
// ->first();
|
||||
|
||||
|
||||
if (!empty($record_date)) {
|
||||
@ -762,8 +764,8 @@ class ClientController extends AdminController
|
||||
'sub_type_id' => $this->request->getPost('sub_type_id'),
|
||||
'client_id' => $this->request->getPost('client_id'),
|
||||
'client_policy_id' => null,
|
||||
'cd_ac_no' => $CD_Account_Number['cd_ac_no'] ?? null,
|
||||
'cd_ac_pk' => $CD_Account_Number['id'] ?? null,
|
||||
'cd_ac_no' => $cd_ac_no ?? null,
|
||||
'cd_ac_pk' => $cd_ac_pk ?? null,
|
||||
'endorsement_no' => null,
|
||||
'insurer_id' => $this->request->getPost('insurer_id'),
|
||||
'description' => $this->request->getPost('description'),
|
||||
@ -1099,6 +1101,8 @@ class ClientController extends AdminController
|
||||
|
||||
$kyc_id = $this->request->getPost('id');
|
||||
$client_id = $this->request->getPost('client_id');
|
||||
// echo "KID".$kyc_id;
|
||||
// echo "CID".$client_id;
|
||||
|
||||
if (empty($kyc_id)) {
|
||||
return $this->respond(['status' => false, 'code' => 400, 'message' => 'Missing document ID.'], 200);
|
||||
@ -1107,7 +1111,7 @@ class ClientController extends AdminController
|
||||
$updateData['is_active'] = $this->request->getPost('is_active');
|
||||
|
||||
$delete = $this->clientKYCDocsModel->update($kyc_id, $updateData);
|
||||
|
||||
// $delete = 1;
|
||||
if ($delete) {
|
||||
$html = $this->generateKycSingleTable($client_id);
|
||||
$dropdown = $this->fetch_dropdown($client_id);
|
||||
@ -1117,37 +1121,43 @@ class ClientController extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
public function fetch_dropdown($client_id){
|
||||
|
||||
$db = db_connect();
|
||||
public function fetch_dropdown($client_id)
|
||||
{
|
||||
$db = db_connect();
|
||||
|
||||
|
||||
$submitted_ids_subquery = $db->table('client_kyc_documents ckd')
|
||||
->select('ckd.kyc_doc_type_id')
|
||||
->where('ckd.client_id', $client_id)
|
||||
->where('ckd.is_active', 1)
|
||||
->getCompiledSelect();
|
||||
|
||||
|
||||
$result = $db->table('kyc_docs kd')
|
||||
->select('kd.*')
|
||||
->join('clients c', 'kd.kyc_type_id = c.entity_type_id')
|
||||
->where('c.id', $client_id)
|
||||
->where("kd.kyc_type_id NOT IN ({$submitted_ids_subquery})")
|
||||
->groupBy('kd.id')
|
||||
->get()
|
||||
->getResultArray();
|
||||
// Already uploaded docs
|
||||
$uploadedData = $db->table('client_kyc_documents')
|
||||
->select('kyc_doc_type_id')
|
||||
->where('client_id', $client_id)
|
||||
->where('is_active', 1)
|
||||
->get()
|
||||
->getResultArray();
|
||||
|
||||
|
||||
$dropdown = '<option value="">Select Document</option>';
|
||||
$dropdown .= '<option value="other">Additional Document</option>';
|
||||
$excludedIds = array_column($uploadedData, 'kyc_doc_type_id');
|
||||
|
||||
// Available docs
|
||||
$builder = $db->table('kyc_docs kd');
|
||||
$builder->select('kd.id, kd.file_name');
|
||||
$builder->join('clients c', 'kd.kyc_type_id = c.entity_type_id');
|
||||
$builder->where('c.id', $client_id);
|
||||
$builder->where('kd.is_active', 1);
|
||||
|
||||
if (!empty($excludedIds)) {
|
||||
$builder->whereNotIn('kd.id', $excludedIds);
|
||||
}
|
||||
|
||||
$result = $builder->get()->getResultArray(); // ✅ ARRAY
|
||||
|
||||
// Build dropdown
|
||||
$dropdown = '<option value="">Select Document</option>';
|
||||
$dropdown .= '<option value="other">Additional Document</option>';
|
||||
|
||||
foreach ($result as $row) {
|
||||
$dropdown .= '<option value="' . esc($row['id']) . '">'
|
||||
. esc($row['file_name']) .
|
||||
'</option>';
|
||||
}
|
||||
|
||||
foreach ($result as $row) {
|
||||
$dropdown .= '<option value="' . esc($row['kyc_type_id']) . '">'
|
||||
. esc($row['file_name']) .
|
||||
'</option>';
|
||||
}
|
||||
|
||||
return $dropdown;
|
||||
}
|
||||
|
||||
@ -2388,13 +2398,27 @@ class ClientController extends AdminController
|
||||
|
||||
|
||||
|
||||
public function uploadVehicleFile()
|
||||
public function uploadVehicleFile($params = null)
|
||||
{
|
||||
$this->myLogger->logme('error', 'uploadVehicleFile function called');
|
||||
$data = $this->request->getPost();
|
||||
$files = $this->request->getFiles();
|
||||
// $data['client_id'] = 12;
|
||||
// $data['vehicle_id'] = 1;
|
||||
|
||||
$client_id = null;
|
||||
$vehicle_id = null;
|
||||
$files = null;
|
||||
$docs_name = null;
|
||||
|
||||
if(empty($params) && $this->request){
|
||||
$data = $this->request->getPost();
|
||||
$files = $this->request->getFiles();
|
||||
$client_id = $data['client_id'] ?? null;
|
||||
$vehicle_id = $data['vehicle_id'] ?? null;
|
||||
$docs_name = $data['other_docs_name'] ?? null;
|
||||
}else {
|
||||
$client_id = $params['client_id'] ?? null;
|
||||
$vehicle_id = $params['vehicle_id'] ?? null;
|
||||
$docs_name = $params['other_docs_name'] ?? null;
|
||||
$files = $params['file_data'] ?? null;
|
||||
}
|
||||
|
||||
// upload path
|
||||
$uploadFilePath = WRITEPATH . 'uploads/client_kyc_documents';
|
||||
@ -2402,20 +2426,21 @@ class ClientController extends AdminController
|
||||
$insertedDocs = [];
|
||||
|
||||
// Check document names and files
|
||||
if (isset($data['other_docs_name']) && isset($files['file_name'])) {
|
||||
foreach ($data['other_docs_name'] as $key => $docName) {
|
||||
if (!empty($docs_name) && !empty($files) && !empty($client_id) && !empty($vehicle_id)) {
|
||||
|
||||
foreach ($docs_name as $key => $docName) {
|
||||
// Get the corresponding file for this document name
|
||||
$file = $files['file_name'][$key];
|
||||
|
||||
if (!empty($docName) && $file->isValid() && !$file->hasMoved()) {
|
||||
// Upload the file
|
||||
$uploadedFileName = file_Upload($file, $uploadFilePath);
|
||||
$uploadedFileName = file_Upload_for_lead($file, $uploadFilePath);
|
||||
|
||||
if ($uploadedFileName) {
|
||||
// Prepare data for each document upload
|
||||
$docData = [
|
||||
'client_id' => $data['client_id'],
|
||||
'vehicle_id' => $data['vehicle_id'],
|
||||
'client_id' => $client_id,
|
||||
'vehicle_id' => $vehicle_id,
|
||||
'other_docs_name' => $docName,
|
||||
'file_name' => $uploadedFileName,
|
||||
'created_by' => get_session_userid(),
|
||||
@ -2431,16 +2456,21 @@ class ClientController extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($params) && !$this->request){
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!empty($insertedDocs)) {
|
||||
// Fetch all documents for the client
|
||||
$vehicleDocs = $this->clientKYCDocsModel
|
||||
->where('client_id', $data['client_id'])
|
||||
->where('vehicle_id', $data['vehicle_id'])
|
||||
->findAll();
|
||||
return $this->respond(['status' => true, 'code' => 200, 'vehicle_docs' => $vehicleDocs, 'inserted_docs' => $insertedDocs], 200);
|
||||
return $this->respond(['status' => true, 'code' => 200, 'vehicle_docs' => $vehicleDocs, 'inserted_docs' => $insertedDocs, 'message' => 'File uploaded successfully'], 200);
|
||||
} else {
|
||||
return $this->respond(['status' => false, 'code' => 400, 'message' => 'No documents uploaded or inserted'], 200);
|
||||
}
|
||||
|
||||
} else {
|
||||
return $this->respond(['status' => false, 'code' => 400, 'message' => 'Invalid data submission'], 200);
|
||||
}
|
||||
@ -2513,22 +2543,57 @@ class ClientController extends AdminController
|
||||
{
|
||||
|
||||
|
||||
$result['ckdlist'] = db_connect()->table('client_kyc_documents ckd')
|
||||
->select("ckd.id,ckd.client_id,ckd.kyc_doc_type_id,ckd.file_name,kd.file_name AS kd_docs_name,ckd.other_docs_name,ckd.vehicle_id,ckd.is_active,
|
||||
CASE
|
||||
WHEN ckd.kyc_doc_type_id IS NULL
|
||||
OR ckd.kyc_doc_type_id = 0
|
||||
OR ckd.kyc_doc_type_id = ''
|
||||
THEN ckd.other_docs_name
|
||||
ELSE kd.file_name
|
||||
END AS ui_docs_name")
|
||||
->join('kyc_docs kd','ckd.kyc_doc_type_id = kd.kyc_type_id','left')
|
||||
->where('ckd.client_id',$client_id)
|
||||
->where('ckd.is_active',1)
|
||||
->groupBy('ckd.id')
|
||||
->get()
|
||||
->getResultArray();
|
||||
// $result['ckdlist'] = db_connect()->table('client_kyc_documents ckd')
|
||||
// ->select("ckd.id,ckd.client_id,ckd.kyc_doc_type_id,ckd.file_name,kd.file_name AS kd_docs_name,ckd.other_docs_name,ckd.vehicle_id,ckd.is_active,
|
||||
// CASE
|
||||
// WHEN ckd.kyc_doc_type_id IS NULL
|
||||
// OR ckd.kyc_doc_type_id = 0
|
||||
// OR ckd.kyc_doc_type_id = ''
|
||||
// THEN ckd.other_docs_name
|
||||
// ELSE kd.file_name
|
||||
// END AS ui_docs_name")
|
||||
// ->join('kyc_docs kd','ckd.kyc_doc_type_id = kd.id','left')
|
||||
// ->where('ckd.client_id',$client_id)
|
||||
// ->where('ckd.is_active',1)
|
||||
// ->groupBy('ckd.id')
|
||||
// ->get()
|
||||
// ->getResultArray();
|
||||
|
||||
|
||||
$builder = db_connect()->table('client_kyc_documents AS ckd');
|
||||
|
||||
// Select the standard fields
|
||||
$builder->select('
|
||||
ckd.id,
|
||||
ckd.client_id,
|
||||
ckd.kyc_doc_type_id,
|
||||
ckd.file_name,
|
||||
ckd.other_docs_name,
|
||||
ckd.vehicle_id,
|
||||
ckd.is_active
|
||||
');
|
||||
|
||||
// Add the CASE statement for ui_docs_name
|
||||
// Using false as the second parameter tells CI4 not to escape the string
|
||||
$builder->select("
|
||||
CASE
|
||||
WHEN ckd.kyc_doc_type_id IS NULL OR ckd.kyc_doc_type_id = 0 OR ckd.kyc_doc_type_id = ''
|
||||
THEN ckd.other_docs_name
|
||||
ELSE kd.file_name
|
||||
END AS ui_docs_name
|
||||
", false);
|
||||
|
||||
// Join with kyc_docs
|
||||
$builder->join('kyc_docs AS kd', 'ckd.kyc_doc_type_id = kd.id', 'left');
|
||||
|
||||
// Where clauses
|
||||
$builder->where('ckd.client_id', $client_id);
|
||||
$builder->where('ckd.is_active', 1);
|
||||
|
||||
// Group By
|
||||
$builder->groupBy('ckd.id');
|
||||
|
||||
$result['ckdlist'] = $builder->get()->getResultArray();
|
||||
|
||||
$result['client_id'] = $client_id;
|
||||
$table = view('client_kyc_single_table', $result);
|
||||
@ -8334,6 +8399,32 @@ class ClientController extends AdminController
|
||||
return $default_templates_inserted ? true : false;
|
||||
}
|
||||
|
||||
// public function downloadClientKycDocs_2()
|
||||
// {
|
||||
|
||||
// $file = WRITEPATH . 'uploads/client_kyc_documents/' . $file_name; // Example file path
|
||||
|
||||
// if (file_exists($file)) {
|
||||
// return $this->response->download($file, null)->setFileName($file_name);
|
||||
// } else {
|
||||
// return "File not found.";
|
||||
// }
|
||||
// }
|
||||
public function downloadClientKycDocs_2($file_name = null)
|
||||
{
|
||||
if (!$file_name) {
|
||||
return "No file specified.";
|
||||
}
|
||||
|
||||
// Use absolute path to your upload folder
|
||||
$file = WRITEPATH . 'uploads/client_kyc_documents/' . $file_name;
|
||||
|
||||
if (file_exists($file)) {
|
||||
// download() takes the path as first param and null (or data) as second
|
||||
return $this->response->download($file, null);
|
||||
} else {
|
||||
return "File not found at: " . $file;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2844,7 +2844,7 @@ class EmployeeRestController extends AdminController
|
||||
|
||||
$emp_reatail_policy_data = $this->getEmpRetailPolicy($retailUserData);
|
||||
$wellness_data = ['status' => 'failed','message' => 'Coming soon........!'];
|
||||
return $this->respond(['status' => 'success', 'code' => 200, 'data' => [], 'emp_name' => $emp_reatail_policy_data[0]['insurerd_name'] ?? "", 'pre_policy_count' => 0, 'retail_policy_data' => $emp_reatail_policy_data, 'wellness_data' => $wellness_data], 200);
|
||||
return $this->respond(['status' => 'success', 'code' => 200, 'data' => [], 'emp_name' => $emp_reatail_policy_data[0]['insurerd_name'] ?? "", 'pre_policy_count' => 0, 'emp_not_enrolled_count' => 0, 'retail_policy_data' => $emp_reatail_policy_data, 'wellness_data' => $wellness_data], 200);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3164,7 +3164,7 @@ class EmployeeRestController extends AdminController
|
||||
{
|
||||
try {
|
||||
|
||||
$feContentData = $this->feContentModel->findAll();
|
||||
$feContentData = $this->feContentModel->where('is_active',1)->findAll();
|
||||
if (count($feContentData) > 0) {
|
||||
|
||||
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $feContentData], 200);
|
||||
@ -3828,14 +3828,19 @@ class EmployeeRestController extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
if ($pdf_exist_in_the_file && $tpa_claim_push == true) {
|
||||
$count = $this->ticketMaster->where('id', $ticket_id)->where('is_active', 1)->where('tpa_claim_push_reference_no IS NULL')->countAllResults();
|
||||
log_message('error', 'Ticket validation | Ticket ID: ' . $ticket_id . ' | Matching active tickets with NULL TPA reference: ' . $count);
|
||||
|
||||
if ($count > 0 && $pdf_exist_in_the_file && $tpa_claim_push == true) {
|
||||
// this call for TPA integration
|
||||
$apiServiceController = new ApiServiceController();
|
||||
$apiServiceController->pushClaims($ticket_id);
|
||||
log_message('error', "pushClaims function called with Ticket ID: {$ticket_id}, In Employee Rest Controller");
|
||||
} else {
|
||||
if($tpa_claim_push == false){
|
||||
log_message('error', 'Skip the TPA claim push');
|
||||
log_message('error', 'Skip the TPA claim push for IR DOCUMENTS');
|
||||
} else if($count == 0){
|
||||
log_message('error', 'TPA claim push skipped as the claim reference number is already generated.');
|
||||
}else{
|
||||
log_message('error', "Failed to call the pushClaims function in EmployeeRestController for Ticket ID: {$ticket_id}, because the .pdf file does not exist.");
|
||||
}
|
||||
@ -4408,7 +4413,8 @@ class EmployeeRestController extends AdminController
|
||||
{
|
||||
$client = \Config\Services::curlrequest();
|
||||
$url = env('PRE_ENROLLMENT_BASEURL') . $endPoint;
|
||||
$response = $client->post($url, ['json' => $postData, 'http_errors' => false]);
|
||||
$headers = [ 'App-Signature' => getenv('APP_SIGNATURE') ];
|
||||
$response = $client->post($url, ['json' => $postData,'headers' => $headers,'http_errors' => false]);
|
||||
// return json_decode($response->getBody(), true);
|
||||
return $response->getBody();
|
||||
}
|
||||
|
||||
@ -190,6 +190,9 @@ class JobWorker extends AdminController
|
||||
'initiateWellnessOnboardJob' => [
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\EmployeeController',
|
||||
], 'saveMediAssitAPIData' => [
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\MediAssistApiController',
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
@ -38,6 +38,7 @@ use App\Models\SettingsModel;
|
||||
use App\Models\VehicleModel;
|
||||
use App\Models\VehicleTypeModel;
|
||||
use App\Models\RTOModel;
|
||||
use App\Models\PartnerPosModel;
|
||||
|
||||
use CodeIgniter\CLI\CLI;
|
||||
|
||||
@ -2320,4 +2321,148 @@ class MasterController extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public function partnerPOS()
|
||||
{
|
||||
$posModel = new PartnerPosModel();
|
||||
$method = $this->request->getMethod();
|
||||
|
||||
if ($this->request->getMethod() === 'post') {
|
||||
|
||||
$id = $this->request->getPost('pk');
|
||||
$data = $this->request->getPost();
|
||||
|
||||
unset($data['pk']);
|
||||
|
||||
try {
|
||||
// Certificate
|
||||
$certificate = $this->uploadPOSFile('certificate_file_name', 'pos_certificate_files');
|
||||
if ($certificate !== null) { $data['certificate_file_name'] = $certificate; } else { unset($data['certificate_file_name']); }
|
||||
|
||||
// PAN file
|
||||
$panFile = $this->uploadPOSFile('pan_file_name', 'pos_certificate_files');
|
||||
if ($panFile !== null) { $data['pan_file_name'] = $panFile; } else { unset($data['pan_file_name']);}
|
||||
|
||||
// Aadhaar file
|
||||
$aadharFile = $this->uploadPOSFile('aadhar_file_name', 'pos_certificate_files');
|
||||
if ($aadharFile !== null) { $data['aadhar_file_name'] = $aadharFile; } else { unset($data['aadhar_file_name']);}
|
||||
|
||||
} catch (\RuntimeException $e) {
|
||||
return $this->respond([ 'status' => false, 'code' => 400, 'message' => $e->getMessage(), 'data' => $data ], 400);
|
||||
}
|
||||
|
||||
foreach ($data as $k => $v) {
|
||||
if ($v === '' || $v === null) {
|
||||
unset($data[$k]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// INSERT / UPDATE
|
||||
if (empty($id)) {
|
||||
$status = $posModel->insert($data);
|
||||
} else {
|
||||
$status = $posModel->update($id, $data);
|
||||
}
|
||||
|
||||
if ($status) {
|
||||
return $this->respond([ 'status' => true, 'code' => 200, 'message' => 'POS updated successfully', 'data' => $data ], 200);
|
||||
}
|
||||
|
||||
return $this->respond([ 'status' => false, 'code' => 400, 'message' => 'Failed to update', 'data' => $data ], 400);
|
||||
}
|
||||
elseif ($method === 'get') {
|
||||
|
||||
$id = $this->request->getGet('pk') ?? null;
|
||||
|
||||
$db = db_connect();
|
||||
|
||||
$builder = $db->table('partner_staff');
|
||||
|
||||
$data['manager_list'] = $builder->select('partner_staff.id, partner_staff.name')
|
||||
->where('partner_staff.is_active', 1)
|
||||
->where('partner_staff.role_id', 1)
|
||||
->get()
|
||||
->getResultArray();
|
||||
|
||||
|
||||
if (!empty($id)) {
|
||||
|
||||
$data['pos_list'] = $posModel
|
||||
->select('partner_pos.*, partner_staff.name AS manager_name')
|
||||
->join('partner_staff', 'partner_staff.id = partner_pos.manager_id', 'left')
|
||||
->where('partner_pos.id', $id)
|
||||
->orderBy('partner_pos.id', 'DESC')
|
||||
->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['pos_list'] = $posModel
|
||||
->select('partner_pos.*, ps.name AS manager_name')
|
||||
->join('partner_staff ps', 'ps.id = partner_pos.manager_id', 'left')
|
||||
->orderBy('partner_pos.id', 'DESC')
|
||||
->findAll();
|
||||
|
||||
|
||||
return $this->loadLayout('pos_list', ['data' => $data,'tab_name' => 'POS details','page_name' => 'POS details']);
|
||||
|
||||
} elseif ($method === 'delete') {
|
||||
|
||||
// $input = $this->request->getRawInput();
|
||||
$id = $this->request->getGet('pk'); // ✅ THIS
|
||||
$id = $id ?? null;
|
||||
|
||||
if (empty($id)) {
|
||||
return $this->respond([
|
||||
'status' => false,
|
||||
'code' => 404,
|
||||
'message' => 'No ID provided for deletion'
|
||||
], 200);
|
||||
}
|
||||
|
||||
$update_status = $posModel->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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function uploadPOSFile(string $fieldName, string $uploadDir)
|
||||
{
|
||||
$file = $this->request->getFile($fieldName);
|
||||
|
||||
if (!$file || !$file->isValid()) { return null; }
|
||||
|
||||
$allowedMime = [ 'image/jpg', 'image/jpeg', 'image/png', 'image/webp', 'application/pdf'];
|
||||
|
||||
if (!in_array($file->getMimeType(), $allowedMime)) { throw new \RuntimeException('Invalid file format'); }
|
||||
|
||||
$path = ROOTPATH . 'public/uploads/' . $uploadDir . '/';
|
||||
|
||||
if (!is_dir($path)) { mkdir($path, 0755, true); }
|
||||
|
||||
$newName = $file->getRandomName();
|
||||
$file->move($path, $newName);
|
||||
|
||||
return $newName;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -5,10 +5,12 @@ namespace App\Controllers;
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\BatchFileModel;
|
||||
use App\Models\EmployeePolicyModel;
|
||||
use App\Models\TpaApiDataModel;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use CodeIgniter\HTTP\IncomingRequest;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\API\ResponseTrait;
|
||||
use App\Controllers\Jobs;
|
||||
|
||||
class MediAssistApiController extends BaseController
|
||||
{
|
||||
@ -203,8 +205,18 @@ class MediAssistApiController extends BaseController
|
||||
|
||||
public function GetBenefDetails($requestData)
|
||||
{
|
||||
helper('api');
|
||||
// helper('api');
|
||||
// helper('TPADataCompareHelper');
|
||||
// $report = EmployeeCompareHelper::compareDbVsMediassist(
|
||||
// $dbRows,
|
||||
// $mediassistAPIdata
|
||||
// );
|
||||
// print_rr($report);
|
||||
// die();
|
||||
// print_r($requestData);die();
|
||||
|
||||
|
||||
//START OF THE PROGRAM
|
||||
$function_calling_type = $requestData['return_type'] ?? 'job';
|
||||
|
||||
try {
|
||||
@ -266,7 +278,6 @@ class MediAssistApiController extends BaseController
|
||||
return $this->respond(['status' => false, 'message' => 'employeePolicyData not found']);
|
||||
}
|
||||
}
|
||||
|
||||
$allBenef = [];
|
||||
$startIndex = 0;
|
||||
$range = 100;
|
||||
@ -326,6 +337,19 @@ class MediAssistApiController extends BaseController
|
||||
$startIndex += $range;
|
||||
} while ($startIndex < $totalCount);
|
||||
|
||||
//save API data as JSON for analysis
|
||||
$json = json_encode($allBenef, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
|
||||
// $filename = time() . '.json';
|
||||
$filePath = WRITEPATH . 'tmp/'.time().'_'.$requestData['file_id'].'.json';
|
||||
file_put_contents($filePath, $json);
|
||||
|
||||
//call a job for dump JSON data to DB
|
||||
$job_details = new Jobs();
|
||||
$r = Jobs::addJob(['job_name' => 'saveMediAssitAPIData', 'payload' => [
|
||||
'file_id' => $requestData['file_id'],
|
||||
'json_file_path' => $filePath ]]);
|
||||
|
||||
|
||||
// now update DB
|
||||
$updated = 0;
|
||||
$employee_policy_ids = [];
|
||||
@ -334,11 +358,10 @@ class MediAssistApiController extends BaseController
|
||||
$hasMatchForThisPolicy = false;
|
||||
|
||||
foreach ($allBenef as $row) {
|
||||
|
||||
if (
|
||||
strtolower(trim($policy_data['name'] ?? '')) == strtolower(trim($row['benefName'] ?? '')) &&
|
||||
($policy_data['emp_code'] ?? '') == ($row['priBenefEmpCode'] ?? '') &&
|
||||
strtolower(trim($policy_data['relationship'] ?? '')) == strtolower(trim($row['relName'] ?? '')) &&
|
||||
strtolower(trim($policy_data['relationship'] ?? '')) == strtolower(trim(str_replace('-', ' ', $row['relName'] ?? ''))) &&
|
||||
($policy_data['gender'] ?? '') == ($row['benefSex'] ?? '') &&
|
||||
($policy_data['dob'] ?? '') == (change_date_format($row['benefDOB'], 'd/m/Y H:i:s') ?? '')
|
||||
) {
|
||||
@ -721,6 +744,54 @@ class MediAssistApiController extends BaseController
|
||||
];
|
||||
}
|
||||
|
||||
public function saveMediAssitAPIData($array)
|
||||
{
|
||||
$file_id = $array['file_id'];
|
||||
$json = file_get_contents($array['json_file_path']);
|
||||
$records = json_decode($json, true);
|
||||
// log_message('error','saveMediAssitAPIData' . json_encode($array));//die();
|
||||
$file_model = new BatchFileModel();
|
||||
$file_info = $file_model->where('id', $file_id)->find();
|
||||
// dd($file_info);
|
||||
$tpaApiDataModel = new TpaApiDataModel();
|
||||
|
||||
// echo $file_id;die();
|
||||
//deactivate old data
|
||||
$tpaApiDataModel->set('is_active', 0)->where('file_id', $file_id)->update();
|
||||
|
||||
//covert tpa data to our model data
|
||||
$mappedRows = [];
|
||||
|
||||
foreach ($records as $row) {
|
||||
|
||||
$mappedRows[] = [
|
||||
'file_id' => $file_id, // ← pass from controller
|
||||
'emp_code' => trim($row['priBenefEmpCode'] ?? ''),
|
||||
|
||||
'name' => trim($row['benefName'] ?? ''),
|
||||
'dob' => !empty($row['benefDOB'])
|
||||
? date('Y-m-d', strtotime(str_replace('/', '-', $row['benefDOB'])))
|
||||
: null,
|
||||
|
||||
'relation' => trim($row['relName'] ?? null),
|
||||
'gender' => strtoupper($row['benefSex'] ?? null),
|
||||
'self' => strtolower($row['relName'] ?? '') === 'self' ? 1 : 0,
|
||||
|
||||
'tpa_id' => trim($row['benefMediAssistID'] ?? null),
|
||||
'age' => is_numeric($row['benefAge'] ?? null)
|
||||
? (int) $row['benefAge']
|
||||
: null,
|
||||
|
||||
'is_active' => 1,
|
||||
'created_by' => $file_info[0]['created_by'] ?? null,
|
||||
];
|
||||
}
|
||||
// log_message('error','COUNT' . count($mappedRows));
|
||||
// print_rr($mappedRows);//die();
|
||||
$result = $tpaApiDataModel->insertBatchWithChunkLog($mappedRows,500,('FILE_ID_'.$file_id));
|
||||
// unlink($file_array['json_file_path']); // delete temp json file
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -51,12 +51,14 @@ class PayoutController extends BaseController
|
||||
$data = $this->request->getPost();
|
||||
// print_r($data); die;
|
||||
|
||||
$agent_id = $data['agent_id'] ?? null;
|
||||
// $agent_id = $data['agent_id'] ?? null; because dropdown hided
|
||||
$pos_id = $data['pos_id'] ?? null;
|
||||
$status_id = $data['status_id'] ?? null;
|
||||
$start_date = $data['start_date'] ?? null;
|
||||
$end_date = $data['end_date'] ?? null;
|
||||
|
||||
$payout_data = $this->invoiceModel->invoiceList($agent_id, $status_id, $start_date, $end_date);
|
||||
// $payout_data = $this->invoiceModel->invoiceList($agent_id, $status_id, $start_date, $end_date); // because dropdown hided
|
||||
$payout_data = $this->invoiceModel->invoiceList($pos_id, $status_id, $start_date, $end_date);
|
||||
|
||||
$payout_data['payout_list_data'] = $payout_data;
|
||||
$payout_data = view('payout_list', $payout_data);
|
||||
@ -86,7 +88,8 @@ class PayoutController extends BaseController
|
||||
|
||||
// for list
|
||||
$data['payout_status'] = $this->payout_status;
|
||||
$data['agent_list'] = $this->invoiceModel->agentList();
|
||||
// $data['agent_list'] = $this->invoiceModel->agentList(); // because dropdown hided
|
||||
$data['pos_list'] = $this->invoiceModel->posList();
|
||||
$data['page_name'] = "Invoices";
|
||||
$payout_data['payout_list_data'] = $this->invoiceModel->invoiceList();
|
||||
$data['payout_list'] = view('payout_list', $payout_data);
|
||||
@ -204,8 +207,9 @@ class PayoutController extends BaseController
|
||||
|
||||
$title = $type === 'add' ? 'Add Payouts'
|
||||
: ($type === 'edit' ? 'Edit Payouts'
|
||||
: ($type === 'view' ? 'View Payouts'
|
||||
: ($type === 'adjustment' ? 'Payouts Adjustment'
|
||||
: 'Payouts'));
|
||||
: 'Payouts')));
|
||||
|
||||
$data['tab_name'] = $title;
|
||||
$data['page_name'] = $title;
|
||||
@ -215,10 +219,12 @@ class PayoutController extends BaseController
|
||||
if($type == 'add')
|
||||
{
|
||||
$data['agents'] = $this->invoiceModel->agentList(['is_active' => 1]); // common both add and edit
|
||||
$data['pos_list'] = $this->invoiceModel->posList(['is_active' => 1]); // common both add and edit
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['agents'] = $this->invoiceModel->agentList(); // common both add and edit
|
||||
$data['pos_list'] = $this->invoiceModel->posList(); // common both add and edit
|
||||
}
|
||||
// $data['checked_policy_numbers'] = [];
|
||||
// $data['invoice'] = [];
|
||||
@ -236,16 +242,21 @@ class PayoutController extends BaseController
|
||||
return $this->loadLayout('invoice_policy_mapping_add', $data);
|
||||
}
|
||||
|
||||
if (($type === 'edit' || $type === 'adjustment') && !empty($id)) {
|
||||
if (($type === 'edit' || $type === 'view' || $type === 'adjustment') && !empty($id)) {
|
||||
|
||||
$invoice = $this->invoiceModel->where('id', $id)->first();
|
||||
// print_r($invoice);die;
|
||||
$data['freeze_edit'] = $this->auditHistory->where('table_name', 'partner_invoice')->where('pk', $id)->countAllResults();
|
||||
|
||||
if($type === 'view'){ $data['freeze_edit'] = 1; }
|
||||
|
||||
$agentId = $invoice['agent_id'] ?? null;
|
||||
// $agentId = $invoice['agent_id'] ?? null;
|
||||
$posId = $invoice['pos_id'] ?? null;
|
||||
|
||||
$data['payouts'] = $this->invoiceModel->payoutList(2 ,$agentId,$id);
|
||||
$data['extra_payouts'] = $agentId ? $this->invoiceModel->payoutList(3, $agentId) : [];
|
||||
// $data['payouts'] = $this->invoiceModel->payoutList(2 ,$agentId,$id);
|
||||
// $data['extra_payouts'] = $agentId ? $this->invoiceModel->payoutList(3, $agentId) : [];
|
||||
$data['payouts'] = $this->invoiceModel->payoutList(2 ,$posId,$id);
|
||||
// print_r($data['payouts']);die;
|
||||
$data['extra_payouts'] = $posId ? $this->invoiceModel->payoutList(3, $posId) : [];
|
||||
|
||||
$invoice_items = $this->invoiceItemModel->where('invoice_id', $id)->findAll();
|
||||
|
||||
@ -439,7 +450,7 @@ class PayoutController extends BaseController
|
||||
$agentCode = $agent["agent_code"];
|
||||
|
||||
$today = date("Ymd");
|
||||
$likePattern = "INV/$agentCode/$today/%";
|
||||
$likePattern = "NIIB/$agentCode/$today/%";
|
||||
|
||||
$count = $this->invoiceModel
|
||||
->like("invoice_no", $likePattern)
|
||||
@ -447,7 +458,7 @@ class PayoutController extends BaseController
|
||||
|
||||
$nextNumber = $count + 1;
|
||||
|
||||
return "INV/$agentCode/$today/$nextNumber";
|
||||
return "NIIB/$agentCode/$today/$nextNumber";
|
||||
}
|
||||
|
||||
// private function generateInvoiceNumber()
|
||||
@ -518,6 +529,7 @@ class PayoutController extends BaseController
|
||||
|
||||
// Get invoice data from database
|
||||
$invoiceData = $this->getInvoiceData($invoiceId);
|
||||
// print_r($invoiceData);die;
|
||||
|
||||
if (empty($invoiceData)) {
|
||||
return $this->respond([
|
||||
@ -591,6 +603,27 @@ class PayoutController extends BaseController
|
||||
|
||||
}
|
||||
|
||||
// private function getInvoiceData($invoiceId)
|
||||
// {
|
||||
// $invoice_data = $this->invoiceModel
|
||||
// ->select('
|
||||
// partner_invoice.*,
|
||||
// pa.name as agent_name,
|
||||
// pa.email as agent_email,
|
||||
// pa.mobile as agent_mobile,
|
||||
// pa.address as agent_address,
|
||||
// pa.agent_code,
|
||||
// pa.certificate_file_name,
|
||||
// pa.commission_retain
|
||||
// ')
|
||||
// ->join('partner_agent pa', 'partner_invoice.agent_id = pa.id')
|
||||
// ->where('partner_invoice.is_active', 1)
|
||||
// ->where('partner_invoice.id', $invoiceId)
|
||||
// ->first();
|
||||
|
||||
// return $invoice_data;
|
||||
// }
|
||||
|
||||
private function getInvoiceData($invoiceId)
|
||||
{
|
||||
$invoice_data = $this->invoiceModel
|
||||
@ -604,9 +637,20 @@ class PayoutController extends BaseController
|
||||
pa.address as agent_address,
|
||||
pa.agent_code,
|
||||
pa.certificate_file_name,
|
||||
pa.commission_retain
|
||||
pa.commission_retain,
|
||||
pos.name as pos_name,
|
||||
pos.email as pos_email,
|
||||
pos.mobile as pos_mobile,
|
||||
pos.address as pos_address,
|
||||
pos.city as pos_city,
|
||||
pos.pincode as pos_pincode,
|
||||
pos.state as pos_state,
|
||||
pos.pos_code,
|
||||
pos.certificate_file_name as pos_certificate_file_name,
|
||||
pos.bank_name,pos.account_holder_name,pos.account_number,pos.ifsc_code,
|
||||
')
|
||||
->join('partner_agent pa', 'partner_invoice.agent_id = pa.id')
|
||||
->join('partner_agent pa', 'partner_invoice.agent_id = pa.id','left')
|
||||
->join('partner_pos pos', 'partner_invoice.pos_id = pos.id')
|
||||
->where('partner_invoice.is_active', 1)
|
||||
->where('partner_invoice.id', $invoiceId)
|
||||
->first();
|
||||
|
||||
@ -669,14 +669,43 @@
|
||||
->where('is_active', 1)
|
||||
->findAll();
|
||||
|
||||
// // Fetch Sales Team
|
||||
// $data['salse_team'] = $this->userModel
|
||||
// ->select('user_profiles.*,nhance_branch.id as nhance_branch_id, nhance_branch.branch_name as nhance_branch_name')
|
||||
// ->join('user_teams', 'user_profiles.id = user_teams.user_id')
|
||||
// ->join('nhance_branch', 'user_profiles.nhance_branch_id = nhance_branch.id','left')
|
||||
// ->where('user_teams.team_id', 5)
|
||||
// ->where('user_teams.is_active', 1)
|
||||
// ->where('user_profiles.is_active', 1)
|
||||
// ->findAll();
|
||||
|
||||
// // Fetch Partner Agent
|
||||
// $data['partner_agent'] = db_connect()->table('partner_agent')
|
||||
// ->where('is_active', 1)
|
||||
// ->get()
|
||||
// ->getResultArray();
|
||||
|
||||
// // Fetch ACM
|
||||
// $data['ACM'] = $this->userModel
|
||||
// ->where('role', 3) // Assuming `role` is in `user_profiles`
|
||||
// ->where('is_active', 1)
|
||||
// ->findAll();
|
||||
|
||||
// Fetch Sales Team
|
||||
$data['salse_team'] = $this->userModel
|
||||
->select('user_profiles.*,nhance_branch.id as nhance_branch_id, nhance_branch.branch_name as nhance_branch_name')
|
||||
->select('
|
||||
user_profiles.*,
|
||||
nhance_branch.id as nhance_branch_id,
|
||||
nhance_branch.branch_name as nhance_branch_name,
|
||||
rm.first_name AS rm_name
|
||||
')
|
||||
->join('user_teams', 'user_profiles.id = user_teams.user_id')
|
||||
->join('nhance_branch', 'user_profiles.nhance_branch_id = nhance_branch.id','left')
|
||||
->join('user_profiles AS rm', 'user_profiles.rm_id = rm.id', 'left')
|
||||
->where('user_teams.team_id', 5)
|
||||
->where('user_teams.is_active', 1)
|
||||
->where('user_profiles.is_active', 1)
|
||||
->groupBy('user_profiles.id', 'asc')
|
||||
->findAll();
|
||||
|
||||
// Fetch Partner Agent
|
||||
@ -687,12 +716,20 @@
|
||||
|
||||
// Fetch ACM
|
||||
$data['ACM'] = $this->userModel
|
||||
->where('role', 3) // Assuming `role` is in `user_profiles`
|
||||
->where('is_active', 1)
|
||||
->findAll();
|
||||
// echo '<pre>';
|
||||
->select('
|
||||
user_profiles.*,
|
||||
nhance_branch.id AS nhance_branch_id,
|
||||
nhance_branch.branch_name AS nhance_branch_name,
|
||||
rm.first_name AS rm_name
|
||||
')
|
||||
->join('user_teams', 'user_profiles.id = user_teams.user_id')
|
||||
->join('nhance_branch', 'user_profiles.nhance_branch_id = nhance_branch.id', 'left')
|
||||
->join('user_profiles AS rm', 'user_profiles.rm_id = rm.id', 'left')
|
||||
->where('user_profiles.role', 3)
|
||||
->where('user_profiles.is_active', 1)
|
||||
->groupBy('user_profiles.id', 'asc')
|
||||
->findAll();
|
||||
|
||||
// print_r($data['ppTeamsData']); die;
|
||||
|
||||
// dd($data);
|
||||
|
||||
@ -897,6 +934,12 @@
|
||||
{
|
||||
$data = $this->request->getPost();
|
||||
|
||||
$file_data = $this->request->getFiles() ?? null;
|
||||
$data['file_data'] = $file_data ?? null;
|
||||
|
||||
$vehicle_file_data = $this->request->getFiles() ?? null;
|
||||
$data['vehicle_file_data'] = $vehicle_file_data ?? null;
|
||||
|
||||
// print_r($data); die;
|
||||
|
||||
if (empty($data['policy_issue_date'])) {
|
||||
@ -1006,6 +1049,28 @@
|
||||
}
|
||||
}
|
||||
|
||||
// policy file upload
|
||||
if(isset($data['doc_name']) && isset($data['file_data']) && !empty($data['doc_name']) && !empty($data['file_data'])){
|
||||
$this->uploadFile($data['doc_name'], $data['file_data'], $insert);
|
||||
}
|
||||
|
||||
// policy file upload
|
||||
if(
|
||||
isset($data['other_docs_name']) && isset($data['vehicle_file_data']) && isset($data['client_id']) && isset($data['vehicle_id']) &&
|
||||
!empty($data['other_docs_name']) && !empty($data['vehicle_file_data']) && !empty($data['client_id']) && !empty($data['vehicle_id'])
|
||||
)
|
||||
{
|
||||
$vdd = [
|
||||
'other_docs_name' => $data['other_docs_name'],
|
||||
'file_data' => $data['vehicle_file_data'],
|
||||
'client_id' => $data['client_id'],
|
||||
'vehicle_id' => $data['vehicle_id'],
|
||||
];
|
||||
$clientController = new ClientController();
|
||||
$clientController->uploadVehicleFile($vdd);
|
||||
}
|
||||
|
||||
|
||||
$client_data = $this->clientModel->where('id', $data['client_id'])->first();
|
||||
$data['client_kyc'] = $this->clientKYCDocsModel->where('client_id', $data['client_id'])->findAll();
|
||||
|
||||
@ -1917,6 +1982,7 @@
|
||||
$data['client_kyc_primary_table'] = $clientController->generateKycPrimaryTable($data['client_id']);
|
||||
$data['client_kyc_other_table'] = $clientController->generateKycOthersTable($data['client_id']);
|
||||
$data['client_kyc_single_table'] = $clientController->generateKycSingleTable($data['client_id']);
|
||||
$data['client_kyc_dd_data'] = $clientController->fetch_dropdown($data['client_id']);
|
||||
|
||||
$data['vehicle_docs'] = $this->clientKYCDocsModel
|
||||
->where('client_id', $data['client_id'])
|
||||
@ -2833,20 +2899,23 @@
|
||||
//------------------------------------------------------------------------------------------------
|
||||
|
||||
//file upload function
|
||||
public function uploadFile()
|
||||
public function uploadFile($docs_name = null, $files = null, $pt_id = null)
|
||||
{
|
||||
$GoogleDriveController = new GoogleDriveController();
|
||||
$files = $this->request->getFiles();
|
||||
$doc_name = $this->request->getPost('doc_name[]');
|
||||
$pt_id = $this->request->getPost('pt_id');
|
||||
$client_policy_id = $this->request->getPost('client_policy_id');
|
||||
$data = $this->request->getPost();
|
||||
|
||||
|
||||
if(empty($docs_name) && empty($files) && empty($pt_id) && $this->request){
|
||||
$files = $this->request->getFiles();
|
||||
$docs_name = $this->request->getPost('doc_name');
|
||||
$pt_id = $this->request->getPost('pt_id');
|
||||
$client_policy_id = $this->request->getPost('client_policy_id');
|
||||
}
|
||||
|
||||
$uploadFilePath = WRITEPATH . 'uploads/client_kyc_documents';
|
||||
|
||||
$uploadData = [];
|
||||
|
||||
foreach ($data['doc_name'] as $key => $docName) {
|
||||
foreach ($docs_name as $key => $docName) {
|
||||
|
||||
// Get the corresponding file for this document name
|
||||
$file = $files['file'][$key];
|
||||
@ -2854,7 +2923,7 @@
|
||||
if (!empty($docName) && $file->isValid() && !$file->hasMoved()) {
|
||||
|
||||
// Upload the file
|
||||
$uploadedFileName = file_Upload($file, $uploadFilePath);
|
||||
$uploadedFileName = file_Upload_for_lead($file, $uploadFilePath);
|
||||
|
||||
if ($uploadedFileName) {
|
||||
// Prepare data for each document upload
|
||||
@ -2879,6 +2948,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($docs_name) && !empty($files) && !empty($pt_id) && !$this->request){
|
||||
return true;
|
||||
}
|
||||
|
||||
// print_r($uploadData); die;
|
||||
|
||||
// $uploadData = uploadFilesToGoogleDrive($files['file'], $doc_name, $pt_id);
|
||||
@ -3669,6 +3742,103 @@
|
||||
return array('status' => $ret_status, 'error_code' => $error_data['error_code'], 'error_data' => $error_data['error_data']);
|
||||
}
|
||||
|
||||
public function validateInsurerStatementNew($params)
|
||||
{
|
||||
helper('excel_util_helper');
|
||||
|
||||
//get file info
|
||||
$file_id = $params['file_id'];
|
||||
$file = $this->insurerStatements->find($file_id);
|
||||
// dd($file);
|
||||
|
||||
$date = new \DateTime($file['month']);
|
||||
|
||||
$month = $date->format('m');
|
||||
$year = $date->format('Y');
|
||||
|
||||
$error_data = ['error_code' => '', 'error_data' => []];
|
||||
$status = 'success';
|
||||
$ret_status = true;
|
||||
|
||||
$return = [];
|
||||
if (!isset($file)) {
|
||||
//file not found in DB
|
||||
return array('status' => false, 'msg' => 'statement file not found in DB');
|
||||
}
|
||||
$file_name_with_path = WRITEPATH . "/uploads/statements/" . $file['file_name'];
|
||||
|
||||
//check physical file
|
||||
if (!file_exists($file_name_with_path)) {
|
||||
//file not found update status and reason
|
||||
$message = "Physcial file not found";
|
||||
// echo $message;
|
||||
$this->myLogger->logme('error', ($message . ' for statement file id ' . $file_id));
|
||||
$this->insurerStatements->where('id', $file_id)->set(['file_status' => 'failed', 'reason' => json_encode(['error_code' => 0, 'error_data' => $message])])->update();
|
||||
return array('status' => false, 'error_code' => 0); //0 - Physcial file not found
|
||||
}
|
||||
|
||||
//get excel data to php array
|
||||
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name_with_path);
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
$highestRow = $sheet->getHighestRow();
|
||||
$highestColumn = $sheet->getHighestColumn();
|
||||
|
||||
$excel_data = $sheet->rangeToArray('A1:' . $highestColumn . $highestRow, null, true, true, true);
|
||||
unset($excel_data[0]);
|
||||
$excel_data = ExcelSanitizeHelper::sanitizeArrayData($excel_data);
|
||||
|
||||
//get no of line items and update in DB
|
||||
$line_items = 0;
|
||||
|
||||
// get uploaded month transactions data
|
||||
$source_data = $this->PTCOShareDetailsModel->getNonReconcileredPolicyTransactions(insurer_id: $file['insurer_id'], insurer_branch_id: $file['branch_id']);
|
||||
|
||||
// check policy no,insurer and etc in DB for this month
|
||||
// if all good return true, otherwise return false with messssage
|
||||
foreach ($excel_data as $excel_key => $excel_row) {
|
||||
|
||||
$is_row_empty = check_row_is_empty_or_null($excel_row);
|
||||
|
||||
if (!$is_row_empty) {
|
||||
|
||||
$is_source_found = 0;
|
||||
|
||||
$policy_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[1]); //policy_number from excel
|
||||
$policy_no = preg_replace( '/[\x{200B}\x{200C}\x{200D}\x{FEFF}\x{00A0}\x{200E}\x{200F}\x{202A}-\x{202E}]/u', '', $excel_row[1]); //policy_number from excel
|
||||
|
||||
$endorsement_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[2]??''); //endorsement number from excel
|
||||
$endorsement_no = preg_replace( '/[\x{200B}\x{200C}\x{200D}\x{FEFF}\x{00A0}\x{200E}\x{200F}\x{202A}-\x{202E}]/u', '', $excel_row[2]??''); //endorsement number from excel
|
||||
|
||||
foreach ($source_data as $source_key => $source_row) {
|
||||
|
||||
$source_endorsement_no = $source_row['endorsement_no'] !== null ? $source_row['endorsement_no'] : null;
|
||||
|
||||
if (($policy_no == $source_row['policy_no']) && $endorsement_no == $source_endorsement_no) {
|
||||
$is_source_found = 1;
|
||||
$line_items = $line_items + 1;
|
||||
unset($source_data[$source_key]);
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
|
||||
if ($is_source_found == 0) {
|
||||
$error_data['error_code'] = 1; //match not found
|
||||
$error_data['error_data'] = array_merge($error_data['error_data'], [$excel_row[0]]); //match not found
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($error_data['error_code']) {
|
||||
$status = 'failed';
|
||||
$ret_status = false;
|
||||
}
|
||||
|
||||
//update in DB
|
||||
$this->insurerStatements->where('id', $file_id)->set(['line_items' => $line_items, 'file_status' => $status, 'reason' => json_encode($error_data)])->update();
|
||||
return array('status' => $ret_status, 'error_code' => $error_data['error_code'], 'error_data' => $error_data['error_data']);
|
||||
}
|
||||
|
||||
|
||||
public function updateInsurerStatement($params)
|
||||
{
|
||||
@ -4960,7 +5130,7 @@
|
||||
$policy_transaction_data = [
|
||||
|
||||
'issuer' => 2,
|
||||
'issuer_branch' => $current_nhance_branch['id'] ?? null,
|
||||
'issuer_branch' => $salse['nhance_branch_id'] ?? null,
|
||||
'client_id' => $client_id,
|
||||
'policy_type_id' => 8,
|
||||
'insurer_id' => $current_insurer_branch_data['insurer_id'] ?? null,
|
||||
@ -4980,10 +5150,12 @@
|
||||
'month' => change_date_format($policy_issue_date, 'd/M/Y', 'Y-m-d'),
|
||||
'sales_generated_by' => $salse['id'] ?? null,
|
||||
'serviced_by' => $service['id'] ?? null,
|
||||
'salse_person_manager_id' => $salse['rm_id'] ?? null,
|
||||
'service_person_manager_id' => $service['rm_id'] ?? null,
|
||||
'service_person_branch_id' => $service['nhance_branch_id'] ?? null,
|
||||
'agent_id' => $current_agent_data['id'] ?? null,
|
||||
'agent_code' => $current_agent_data['agent_code'] ?? null,
|
||||
'file_id' => $params['file_id'],
|
||||
|
||||
'endorsement_no' => null,
|
||||
'client_branch_id' => null,
|
||||
'client_policy_id' => null,
|
||||
@ -5282,11 +5454,14 @@
|
||||
// -------------------------------------------
|
||||
// 1. First Stage: Check if vehicle already exists
|
||||
// -------------------------------------------
|
||||
foreach ($vehicle_data as $v) {
|
||||
if (strcasecmp(trim($v['vehicle_no']), $vehicle_number) === 0) {
|
||||
$vehicle_id = $v['id'];
|
||||
$client_id = $v['owner'];
|
||||
break;
|
||||
|
||||
if(strtolower(trim($vehicle_number)) != 'new'){
|
||||
foreach ($vehicle_data as $v) {
|
||||
if (strcasecmp(trim($v['vehicle_no']), $vehicle_number) === 0) {
|
||||
$vehicle_id = $v['id'];
|
||||
$client_id = $v['owner'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
695
app/Controllers/SalesController.php
Normal file
695
app/Controllers/SalesController.php
Normal file
@ -0,0 +1,695 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Api;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\SalesActualLeadModel;
|
||||
use App\Models\SalesContactPersonModel;
|
||||
use App\Models\SalesActivityModel;
|
||||
use App\Models\SalesLeadNoteModel;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use CodeIgniter\API\ResponseTrait;
|
||||
|
||||
class SalesController extends BaseController
|
||||
{
|
||||
use ResponseTrait;
|
||||
|
||||
protected $leadModel;
|
||||
protected $contactModel;
|
||||
protected $activityModel;
|
||||
protected $noteModel;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->leadModel = new SalesActualLeadModel();
|
||||
$this->contactModel = new SalesContactPersonModel();
|
||||
$this->activityModel = new SalesActivityModel();
|
||||
$this->noteModel = new SalesLeadNoteModel();
|
||||
}
|
||||
|
||||
// ==================== LEAD APIs ====================
|
||||
|
||||
/**
|
||||
* Get all leads with pagination and filters
|
||||
* GET /api/sales/leads
|
||||
*/
|
||||
public function getLeads()
|
||||
{
|
||||
try {
|
||||
$limit = $this->request->getGet('limit') ?? 10;
|
||||
$offset = $this->request->getGet('offset') ?? 0;
|
||||
|
||||
$filters = [
|
||||
'status' => $this->request->getGet('status'),
|
||||
'assigned_to' => $this->request->getGet('assigned_to'),
|
||||
'search' => $this->request->getGet('search'),
|
||||
];
|
||||
|
||||
$result = $this->leadModel->getLeadsWithFilters($filters, $limit, $offset);
|
||||
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
'data' => $result['data'],
|
||||
'total' => $result['total'],
|
||||
'limit' => $limit,
|
||||
'offset' => $offset
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return $this->fail($e->getMessage(), ResponseInterface::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get single lead with complete details
|
||||
* GET /api/sales/leads/{id}
|
||||
*/
|
||||
public function getLead($id)
|
||||
{
|
||||
try {
|
||||
$lead = $this->leadModel->getLeadComplete($id);
|
||||
|
||||
if (!$lead) {
|
||||
return $this->failNotFound('Lead not found');
|
||||
}
|
||||
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
'data' => $lead
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return $this->fail($e->getMessage(), ResponseInterface::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new lead
|
||||
* POST /api/sales/leads
|
||||
*/
|
||||
public function createLead()
|
||||
{
|
||||
try {
|
||||
$data = $this->request->getJSON(true);
|
||||
|
||||
// Set created_by and updated_by from authenticated user
|
||||
$data['created_by'] = $this->getUserId();
|
||||
$data['updated_by'] = $this->getUserId();
|
||||
|
||||
if (!$this->leadModel->insert($data)) {
|
||||
return $this->fail($this->leadModel->errors(), ResponseInterface::HTTP_BAD_REQUEST);
|
||||
}
|
||||
|
||||
$leadId = $this->leadModel->getInsertID();
|
||||
|
||||
// Insert contact persons if provided
|
||||
if (!empty($data['contact_persons'])) {
|
||||
foreach ($data['contact_persons'] as $contact) {
|
||||
$contact['lead_id'] = $leadId;
|
||||
$contact['created_by'] = $this->getUserId();
|
||||
$this->contactModel->insert($contact);
|
||||
}
|
||||
}
|
||||
|
||||
$lead = $this->leadModel->getLeadComplete($leadId);
|
||||
|
||||
return $this->respondCreated([
|
||||
'status' => 'success',
|
||||
'message' => 'Lead created successfully',
|
||||
'data' => $lead
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return $this->fail($e->getMessage(), ResponseInterface::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update lead
|
||||
* PUT /api/sales/leads/{id}
|
||||
*/
|
||||
public function updateLead($id)
|
||||
{
|
||||
try {
|
||||
if (!$this->leadModel->find($id)) {
|
||||
return $this->failNotFound('Lead not found');
|
||||
}
|
||||
|
||||
$data = $this->request->getJSON(true);
|
||||
$data['updated_by'] = $this->getUserId();
|
||||
|
||||
if (!$this->leadModel->update($id, $data)) {
|
||||
return $this->fail($this->leadModel->errors(), ResponseInterface::HTTP_BAD_REQUEST);
|
||||
}
|
||||
|
||||
$lead = $this->leadModel->getLeadComplete($id);
|
||||
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
'message' => 'Lead updated successfully',
|
||||
'data' => $lead
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return $this->fail($e->getMessage(), ResponseInterface::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete lead
|
||||
* DELETE /api/sales/leads/{id}
|
||||
*/
|
||||
public function deleteLead($id)
|
||||
{
|
||||
try {
|
||||
if (!$this->leadModel->find($id)) {
|
||||
return $this->failNotFound('Lead not found');
|
||||
}
|
||||
|
||||
$this->leadModel->delete($id);
|
||||
|
||||
return $this->respondDeleted([
|
||||
'status' => 'success',
|
||||
'message' => 'Lead deleted successfully'
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return $this->fail($e->getMessage(), ResponseInterface::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get lead statistics
|
||||
* GET /api/sales/leads/stats
|
||||
*/
|
||||
public function getLeadStats()
|
||||
{
|
||||
try {
|
||||
$userId = $this->request->getGet('user_id');
|
||||
$stats = $this->leadModel->getLeadStats($userId);
|
||||
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
'data' => $stats
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return $this->fail($e->getMessage(), ResponseInterface::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== CONTACT PERSON APIs ====================
|
||||
|
||||
/**
|
||||
* Get contacts for a lead
|
||||
* GET /api/sales/leads/{leadId}/contacts
|
||||
*/
|
||||
public function getContacts($leadId)
|
||||
{
|
||||
try {
|
||||
$contacts = $this->contactModel->getContactsByLead($leadId);
|
||||
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
'data' => $contacts
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return $this->fail($e->getMessage(), ResponseInterface::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create contact person
|
||||
* POST /api/sales/contacts
|
||||
*/
|
||||
public function createContact()
|
||||
{
|
||||
try {
|
||||
$data = $this->request->getJSON(true);
|
||||
$data['created_by'] = $this->getUserId();
|
||||
$data['updated_by'] = $this->getUserId();
|
||||
|
||||
if (!$this->contactModel->insert($data)) {
|
||||
return $this->fail($this->contactModel->errors(), ResponseInterface::HTTP_BAD_REQUEST);
|
||||
}
|
||||
|
||||
$contactId = $this->contactModel->getInsertID();
|
||||
$contact = $this->contactModel->find($contactId);
|
||||
|
||||
return $this->respondCreated([
|
||||
'status' => 'success',
|
||||
'message' => 'Contact created successfully',
|
||||
'data' => $contact
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return $this->fail($e->getMessage(), ResponseInterface::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update contact person
|
||||
* PUT /api/sales/contacts/{id}
|
||||
*/
|
||||
public function updateContact($id)
|
||||
{
|
||||
try {
|
||||
if (!$this->contactModel->find($id)) {
|
||||
return $this->failNotFound('Contact not found');
|
||||
}
|
||||
|
||||
$data = $this->request->getJSON(true);
|
||||
$data['updated_by'] = $this->getUserId();
|
||||
|
||||
if (!$this->contactModel->update($id, $data)) {
|
||||
return $this->fail($this->contactModel->errors(), ResponseInterface::HTTP_BAD_REQUEST);
|
||||
}
|
||||
|
||||
$contact = $this->contactModel->find($id);
|
||||
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
'message' => 'Contact updated successfully',
|
||||
'data' => $contact
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return $this->fail($e->getMessage(), ResponseInterface::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete contact person
|
||||
* DELETE /api/sales/contacts/{id}
|
||||
*/
|
||||
public function deleteContact($id)
|
||||
{
|
||||
try {
|
||||
if (!$this->contactModel->find($id)) {
|
||||
return $this->failNotFound('Contact not found');
|
||||
}
|
||||
|
||||
$this->contactModel->delete($id);
|
||||
|
||||
return $this->respondDeleted([
|
||||
'status' => 'success',
|
||||
'message' => 'Contact deleted successfully'
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return $this->fail($e->getMessage(), ResponseInterface::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set primary contact
|
||||
* PUT /api/sales/contacts/{id}/set-primary
|
||||
*/
|
||||
public function setPrimaryContact($id)
|
||||
{
|
||||
try {
|
||||
$contact = $this->contactModel->find($id);
|
||||
|
||||
if (!$contact) {
|
||||
return $this->failNotFound('Contact not found');
|
||||
}
|
||||
|
||||
$this->contactModel->setPrimaryContact($id, $contact['lead_id']);
|
||||
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
'message' => 'Primary contact updated successfully'
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return $this->fail($e->getMessage(), ResponseInterface::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== ACTIVITY APIs ====================
|
||||
|
||||
/**
|
||||
* Get all activities with filters
|
||||
* GET /api/sales/activities
|
||||
*/
|
||||
public function getActivities()
|
||||
{
|
||||
try {
|
||||
$limit = $this->request->getGet('limit') ?? 10;
|
||||
$offset = $this->request->getGet('offset') ?? 0;
|
||||
|
||||
$filters = [
|
||||
'status' => $this->request->getGet('status'),
|
||||
'activity_type' => $this->request->getGet('activity_type'),
|
||||
'assigned_to' => $this->request->getGet('assigned_to'),
|
||||
'date_from' => $this->request->getGet('date_from'),
|
||||
'date_to' => $this->request->getGet('date_to'),
|
||||
];
|
||||
|
||||
$result = $this->activityModel->getActivitiesWithFilters($filters, $limit, $offset);
|
||||
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
'data' => $result['data'],
|
||||
'total' => $result['total'],
|
||||
'limit' => $limit,
|
||||
'offset' => $offset
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return $this->fail($e->getMessage(), ResponseInterface::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get activities for a specific lead
|
||||
* GET /api/sales/leads/{leadId}/activities
|
||||
*/
|
||||
public function getLeadActivities($leadId)
|
||||
{
|
||||
try {
|
||||
$status = $this->request->getGet('status');
|
||||
$activities = $this->activityModel->getActivitiesByLead($leadId, $status);
|
||||
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
'data' => $activities
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return $this->fail($e->getMessage(), ResponseInterface::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get activity timeline for a lead
|
||||
* GET /api/sales/leads/{leadId}/timeline
|
||||
*/
|
||||
public function getActivityTimeline($leadId)
|
||||
{
|
||||
try {
|
||||
$timeline = $this->activityModel->getActivityTimeline($leadId);
|
||||
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
'data' => $timeline
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return $this->fail($e->getMessage(), ResponseInterface::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get upcoming activities for user
|
||||
* GET /api/sales/activities/upcoming
|
||||
*/
|
||||
public function getUpcomingActivities()
|
||||
{
|
||||
try {
|
||||
$userId = $this->getUserId();
|
||||
$days = $this->request->getGet('days') ?? 7;
|
||||
$limit = $this->request->getGet('limit') ?? 10;
|
||||
|
||||
$activities = $this->activityModel->getUpcomingActivities($userId, $days, $limit);
|
||||
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
'data' => $activities
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return $this->fail($e->getMessage(), ResponseInterface::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create activity
|
||||
* POST /api/sales/activities
|
||||
*/
|
||||
public function createActivity()
|
||||
{
|
||||
try {
|
||||
$data = $this->request->getJSON(true);
|
||||
$data['created_by'] = $this->getUserId();
|
||||
$data['updated_by'] = $this->getUserId();
|
||||
|
||||
if (!$this->activityModel->insert($data)) {
|
||||
return $this->fail($this->activityModel->errors(), ResponseInterface::HTTP_BAD_REQUEST);
|
||||
}
|
||||
|
||||
$activityId = $this->activityModel->getInsertID();
|
||||
$activity = $this->activityModel->find($activityId);
|
||||
|
||||
return $this->respondCreated([
|
||||
'status' => 'success',
|
||||
'message' => 'Activity created successfully',
|
||||
'data' => $activity
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return $this->fail($e->getMessage(), ResponseInterface::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update activity
|
||||
* PUT /api/sales/activities/{id}
|
||||
*/
|
||||
public function updateActivity($id)
|
||||
{
|
||||
try {
|
||||
if (!$this->activityModel->find($id)) {
|
||||
return $this->failNotFound('Activity not found');
|
||||
}
|
||||
|
||||
$data = $this->request->getJSON(true);
|
||||
$data['updated_by'] = $this->getUserId();
|
||||
|
||||
if (!$this->activityModel->update($id, $data)) {
|
||||
return $this->fail($this->activityModel->errors(), ResponseInterface::HTTP_BAD_REQUEST);
|
||||
}
|
||||
|
||||
$activity = $this->activityModel->find($id);
|
||||
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
'message' => 'Activity updated successfully',
|
||||
'data' => $activity
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return $this->fail($e->getMessage(), ResponseInterface::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Complete activity
|
||||
* POST /api/sales/activities/{id}/complete
|
||||
*/
|
||||
public function completeActivity($id)
|
||||
{
|
||||
try {
|
||||
$activity = $this->activityModel->find($id);
|
||||
|
||||
if (!$activity) {
|
||||
return $this->failNotFound('Activity not found');
|
||||
}
|
||||
|
||||
if ($activity['status'] === 'completed') {
|
||||
return $this->fail('Activity is already completed', ResponseInterface::HTTP_BAD_REQUEST);
|
||||
}
|
||||
|
||||
$data = $this->request->getJSON(true);
|
||||
$data['updated_by'] = $this->getUserId();
|
||||
|
||||
$this->activityModel->completeActivity($id, $data);
|
||||
|
||||
// Create follow-up activity if requested
|
||||
if (!empty($data['create_followup']) && $data['create_followup'] === true) {
|
||||
$followupData = [
|
||||
'lead_id' => $activity['lead_id'],
|
||||
'activity_type' => $data['followup_type'] ?? 'Call',
|
||||
'notes' => $data['followup_notes'] ?? '',
|
||||
'scheduled_date' => $data['followup_date'] ?? null,
|
||||
'assigned_to' => $activity['assigned_to'],
|
||||
'parent_activity_id' => $id,
|
||||
'created_by' => $this->getUserId(),
|
||||
'updated_by' => $this->getUserId(),
|
||||
];
|
||||
|
||||
$this->activityModel->insert($followupData);
|
||||
}
|
||||
|
||||
$updatedActivity = $this->activityModel->find($id);
|
||||
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
'message' => 'Activity completed successfully',
|
||||
'data' => $updatedActivity
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return $this->fail($e->getMessage(), ResponseInterface::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete activity
|
||||
* DELETE /api/sales/activities/{id}
|
||||
*/
|
||||
public function deleteActivity($id)
|
||||
{
|
||||
try {
|
||||
if (!$this->activityModel->find($id)) {
|
||||
return $this->failNotFound('Activity not found');
|
||||
}
|
||||
|
||||
$this->activityModel->delete($id);
|
||||
|
||||
return $this->respondDeleted([
|
||||
'status' => 'success',
|
||||
'message' => 'Activity deleted successfully'
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return $this->fail($e->getMessage(), ResponseInterface::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pending activities count
|
||||
* GET /api/sales/activities/pending-count
|
||||
*/
|
||||
public function getPendingCount()
|
||||
{
|
||||
try {
|
||||
$userId = $this->getUserId();
|
||||
$count = $this->activityModel->getPendingActivitiesCount($userId);
|
||||
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
'data' => ['count' => $count]
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return $this->fail($e->getMessage(), ResponseInterface::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== LEAD NOTES APIs ====================
|
||||
|
||||
/**
|
||||
* Get notes for a lead
|
||||
* GET /api/sales/leads/{leadId}/notes
|
||||
*/
|
||||
public function getLeadNotes($leadId)
|
||||
{
|
||||
try {
|
||||
$notes = $this->noteModel->getNotesByLead($leadId);
|
||||
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
'data' => $notes
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return $this->fail($e->getMessage(), ResponseInterface::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create note
|
||||
* POST /api/sales/notes
|
||||
*/
|
||||
public function createNote()
|
||||
{
|
||||
try {
|
||||
$data = $this->request->getJSON(true);
|
||||
$data['user_id'] = $this->getUserId();
|
||||
$data['created_by'] = $this->getUserId();
|
||||
$data['updated_by'] = $this->getUserId();
|
||||
|
||||
if (!$this->noteModel->insert($data)) {
|
||||
return $this->fail($this->noteModel->errors(), ResponseInterface::HTTP_BAD_REQUEST);
|
||||
}
|
||||
|
||||
$noteId = $this->noteModel->getInsertID();
|
||||
$note = $this->noteModel->find($noteId);
|
||||
|
||||
return $this->respondCreated([
|
||||
'status' => 'success',
|
||||
'message' => 'Note created successfully',
|
||||
'data' => $note
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return $this->fail($e->getMessage(), ResponseInterface::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update note
|
||||
* PUT /api/sales/notes/{id}
|
||||
*/
|
||||
public function updateNote($id)
|
||||
{
|
||||
try {
|
||||
$note = $this->noteModel->find($id);
|
||||
|
||||
if (!$note) {
|
||||
return $this->failNotFound('Note not found');
|
||||
}
|
||||
|
||||
// Check if user owns the note
|
||||
if ($note['user_id'] != $this->getUserId()) {
|
||||
return $this->failUnauthorized('You are not authorized to update this note');
|
||||
}
|
||||
|
||||
$data = $this->request->getJSON(true);
|
||||
$data['updated_by'] = $this->getUserId();
|
||||
|
||||
if (!$this->noteModel->update($id, $data)) {
|
||||
return $this->fail($this->noteModel->errors(), ResponseInterface::HTTP_BAD_REQUEST);
|
||||
}
|
||||
|
||||
$updatedNote = $this->noteModel->find($id);
|
||||
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
'message' => 'Note updated successfully',
|
||||
'data' => $updatedNote
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return $this->fail($e->getMessage(), ResponseInterface::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete note
|
||||
* DELETE /api/sales/notes/{id}
|
||||
*/
|
||||
public function deleteNote($id)
|
||||
{
|
||||
try {
|
||||
$note = $this->noteModel->find($id);
|
||||
|
||||
if (!$note) {
|
||||
return $this->failNotFound('Note not found');
|
||||
}
|
||||
|
||||
// Check if user owns the note
|
||||
if ($note['user_id'] != $this->getUserId()) {
|
||||
return $this->failUnauthorized('You are not authorized to delete this note');
|
||||
}
|
||||
|
||||
$this->noteModel->delete($id);
|
||||
|
||||
return $this->respondDeleted([
|
||||
'status' => 'success',
|
||||
'message' => 'Note deleted successfully'
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return $this->fail($e->getMessage(), ResponseInterface::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== HELPER METHODS ====================
|
||||
|
||||
/**
|
||||
* Get current user ID from session or JWT token
|
||||
* You'll need to implement this based on your authentication system
|
||||
*/
|
||||
private function getUserId()
|
||||
{
|
||||
// If using session
|
||||
if (session()->has('user_id')) {
|
||||
return session()->get('user_id');
|
||||
}
|
||||
|
||||
// If using JWT, decode token and get user_id
|
||||
// Example: return $this->decodeJWT()['user_id'];
|
||||
|
||||
// For development/testing, you can return a default value
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -371,6 +371,11 @@ class TicketController extends BaseController
|
||||
$data['insurer_list'] = $this->insurerModel->where('is_active', 1)->findAll();
|
||||
$data['tpa_list'] = $this->TPAModel->where('is_active', 1)->findAll();
|
||||
$data['ticket_data'] = $this->ticketSearch(1);
|
||||
$data['date_type'] = [
|
||||
'ticket_created_date' => 'Created Date',
|
||||
'ticket_updated_date' => 'Updated Date',
|
||||
];
|
||||
|
||||
return $this->loadLayout('ticket_search', $data);
|
||||
} else {
|
||||
|
||||
@ -401,6 +406,7 @@ class TicketController extends BaseController
|
||||
}
|
||||
else{
|
||||
$data['ticket_data'] = $this->ticketSearch();
|
||||
// print_r($data['ticket_data']);die;
|
||||
$html = view('ticket_list', $data);
|
||||
return $this->respond(['status' => true, 'html' => $html], 200);
|
||||
}
|
||||
@ -411,6 +417,7 @@ class TicketController extends BaseController
|
||||
public function ticketSearch($action = null)
|
||||
{
|
||||
$db = db_connect();
|
||||
$rawWhere = [];
|
||||
// log_message('error', 'Ticket Search Action: ' . $action);
|
||||
$subquery = $db->table('ticket_master tm')
|
||||
->select([
|
||||
@ -464,6 +471,7 @@ class TicketController extends BaseController
|
||||
'tm.insured_name',
|
||||
'c.short_name',
|
||||
'DATE_FORMAT(tm.created_at, "%d-%m-%Y") AS ticket_created_date',
|
||||
'DATE_FORMAT(tm.updated_at, "%d-%m-%Y") AS ticket_updated_date',
|
||||
'COALESCE(tat_category.tat, "0-6 Days") AS tat',
|
||||
|
||||
'tm.claim_status_id',
|
||||
@ -557,14 +565,24 @@ class TicketController extends BaseController
|
||||
} else {
|
||||
$search_data = $this->request->getPost();
|
||||
// print_r($search_data); die()
|
||||
$where = [];
|
||||
$where = [];
|
||||
foreach ($search_data as $search_objects => $key) {
|
||||
if ($key != null && $key != '' && $key != 0 && $search_objects != 'is_dashboard') {
|
||||
$where[$search_objects] = $key;
|
||||
|
||||
if($search_objects == "date_type" && $search_data[$search_objects] === 'ticket_created_date'){
|
||||
$startDate = date('Y-m-d 00:00:00', strtotime($search_data['start_date']));
|
||||
$endDate = date('Y-m-d 23:59:59', strtotime($search_data['end_date']));
|
||||
$rawWhere[] = "tm.created_at BETWEEN '$startDate' AND '$endDate'";
|
||||
}
|
||||
elseif($search_objects == "date_type" && $search_data[$search_objects] === 'ticket_updated_date'){
|
||||
$startDate = date('Y-m-d 00:00:00', strtotime($search_data['start_date']));
|
||||
$endDate = date('Y-m-d 23:59:59', strtotime($search_data['end_date']));
|
||||
$rawWhere[] = "tm.updated_at BETWEEN '$startDate' AND '$endDate'";
|
||||
}elseif($search_objects != "date_type" && $search_objects != "start_date" && $search_objects != "end_date"){
|
||||
$where[$search_objects] = $key;
|
||||
}
|
||||
}
|
||||
}
|
||||
// print_rr($where);
|
||||
|
||||
}
|
||||
$query = $db->table('ticket_master tm')
|
||||
->select([
|
||||
@ -584,6 +602,7 @@ class TicketController extends BaseController
|
||||
'tm.insured_name',
|
||||
'c.short_name',
|
||||
'DATE_FORMAT(tm.created_at, "%d-%m-%Y") AS ticket_created_date',
|
||||
'DATE_FORMAT(tm.updated_at, "%d-%m-%Y") AS ticket_updated_date',
|
||||
'COALESCE(tat_category.tat, "0-6 Days") AS tat',
|
||||
|
||||
'(SELECT first_name FROM user_profiles WHERE user_profiles.id = tm.acm_id) AS acm_name',
|
||||
@ -641,9 +660,14 @@ class TicketController extends BaseController
|
||||
->where('tm.is_active', 1)
|
||||
->where($where)
|
||||
->orderBy('tm.id', 'DESC');
|
||||
if (!empty($rawWhere)) {
|
||||
foreach ($rawWhere as $condition) {
|
||||
$query->where($condition, null, false); // raw SQL
|
||||
}
|
||||
}
|
||||
|
||||
$data = $query->get()->getResultArray();
|
||||
// dd($db->getLastQuery()->getQuery());
|
||||
// dd($db->getLastQuery()->getQuery());die;
|
||||
// dd($data);
|
||||
if ($action == 5){
|
||||
|
||||
|
||||
@ -585,44 +585,79 @@ class UserController extends AdminController
|
||||
try{
|
||||
// Listing
|
||||
if ($method === 'get') {
|
||||
$types = $this->partnerStaffModel->findAll();
|
||||
if (empty($types)) {
|
||||
return $this->response->setJSON(['status' => 'error','message' => 'No Staff found'])->setStatusCode(404);
|
||||
$manager = $this->partnerStaffModel->where('role_id',1)->findAll();
|
||||
if (empty($manager)) {
|
||||
return $this->response->setJSON(['status' => 'error','message' => 'No Manager found'])->setStatusCode(404);
|
||||
}
|
||||
return $this->response->setJSON(['status' => 'success','data' => $types])->setStatusCode(200);
|
||||
return $this->response->setJSON(['status' => 'success','data' => $manager])->setStatusCode(200);
|
||||
}
|
||||
|
||||
// add/update
|
||||
if ($method === 'post') {
|
||||
|
||||
$data = $this->request->getPost();
|
||||
if (!empty($data['id'])) {
|
||||
$text = "update";
|
||||
$data['updated_by'] = get_session_userid();
|
||||
$result = $this->partnerStaffModel->update($data['id'], $data);
|
||||
$updateID = $data['id'];
|
||||
} else {
|
||||
$text = "create";
|
||||
$data['role_id'] = 1;
|
||||
$data['created_by'] = get_session_userid();
|
||||
$insertID = $this->partnerStaffModel->insert($data);
|
||||
if($insertID){
|
||||
$details['manager_id'] = $insertID;
|
||||
$details['updated_by'] = get_session_userid();
|
||||
$this->partnerStaffModel->update($insertID, $details);
|
||||
$id = !empty($data['PrimaryKey']) ? $data['PrimaryKey'] : null;
|
||||
|
||||
// don't forgot same means just unset the key because partner_staff some UNIQUE KEY sets in table thats why
|
||||
if ($id) {
|
||||
$existing = $this->partnerStaffModel->find($id);
|
||||
if ($existing) {
|
||||
if ($data['email'] === $existing['email']) { unset($data['email']); }
|
||||
if ($data['mobile'] === $existing['mobile']) { unset($data['mobile']); }
|
||||
}
|
||||
$result = true;
|
||||
}
|
||||
|
||||
$id = isset($insertID) && !empty($insertID) ? $insertID : ($updateID ?? null);
|
||||
$errors = [];
|
||||
|
||||
// Check Email Duplicate (if it wasn't unset)
|
||||
if (isset($data['email'])) {
|
||||
$count = $this->partnerStaffModel->where('email', $data['email'])->countAllResults();
|
||||
if ($count > 0) $errors['email'] = "This email is already taken by another user.";
|
||||
}
|
||||
|
||||
// Check Mobile Duplicate (if it wasn't unset)
|
||||
if (isset($data['mobile'])) {
|
||||
$count = $this->partnerStaffModel->where('mobile', $data['mobile'])->countAllResults();
|
||||
if ($count > 0) $errors['mobile'] = "This mobile is already taken by another user.";
|
||||
}
|
||||
|
||||
// If there are duplicates, stop and return error
|
||||
if (!empty($errors)) {
|
||||
return $this->response->setJSON([
|
||||
'status' => 'error',
|
||||
'message' => 'Duplicate detected',
|
||||
'errors' => $errors
|
||||
])->setStatusCode(400);
|
||||
}
|
||||
|
||||
// --- Save/Update ---
|
||||
if ($id) {
|
||||
$text = "update";
|
||||
$data['updated_by'] = get_session_userid();
|
||||
|
||||
$result = $this->partnerStaffModel->update($updateID, $data);
|
||||
} else {
|
||||
$text = "create";
|
||||
$data['role_id'] = 1;
|
||||
$data['created_by'] = get_session_userid();
|
||||
$id = $this->partnerStaffModel->insert($data);
|
||||
if($id){
|
||||
$details['manager_id'] = $id;
|
||||
$details['updated_by'] = get_session_userid();
|
||||
$this->partnerStaffModel->update($id, $details);
|
||||
}
|
||||
$result = true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return $this->response->setJSON([
|
||||
'status' => $id ? 'success' : 'error',
|
||||
'message' => $id ? "Staff {$text}d successfully" : "Unable to {$text} staff. Please try again.",
|
||||
'id' => $id
|
||||
])->setStatusCode($id ? 200 : 400);
|
||||
}
|
||||
|
||||
}
|
||||
// delete
|
||||
if ($method === 'put') {
|
||||
$data = $this->request->getRawInput();
|
||||
|
||||
239
app/Helpers/TPADataCompareHelper.php
Normal file
239
app/Helpers/TPADataCompareHelper.php
Normal file
@ -0,0 +1,239 @@
|
||||
<?php
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
use DateTime;
|
||||
|
||||
class TPADataCompareHelper
|
||||
{
|
||||
/** Common fields to compare */
|
||||
public const COMPARE_FIELDS = ['name', 'dob', 'gender', 'relation'];
|
||||
|
||||
/* =========================
|
||||
Normalization utilities
|
||||
========================= */
|
||||
|
||||
public static function parseDateToYmd(?string $date): ?string
|
||||
{
|
||||
if (empty($date)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$formats = [
|
||||
'd/m/Y H:i:s',
|
||||
'd/m/Y',
|
||||
'Y-m-d H:i:s',
|
||||
'Y-m-d',
|
||||
'd-m-Y',
|
||||
];
|
||||
|
||||
foreach ($formats as $format) {
|
||||
$dt = DateTime::createFromFormat($format, $date);
|
||||
if ($dt !== false) {
|
||||
return $dt->format('Y-m-d');
|
||||
}
|
||||
}
|
||||
|
||||
$ts = strtotime($date);
|
||||
return $ts ? date('Y-m-d', $ts) : null;
|
||||
}
|
||||
|
||||
public static function normalizeName(?string $name): ?string
|
||||
{
|
||||
if ($name === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$name = trim($name);
|
||||
// $name = preg_replace('/\.+/', ' ', $name);
|
||||
// $name = preg_replace('/\s+/', ' ', $name);
|
||||
return mb_strtolower($name);
|
||||
}
|
||||
|
||||
public static function normalizeEmpId(?string $empId): ?string
|
||||
{
|
||||
if ($empId === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$empId = trim($empId);
|
||||
$empId = preg_replace('/[\s\-\/]/', '', $empId);
|
||||
return $empId === '' ? null : $empId;
|
||||
}
|
||||
|
||||
public static function normalizeGender(?string $gender): ?string
|
||||
{
|
||||
if ($gender === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$g = strtoupper(trim($gender));
|
||||
return in_array($g, ['M', 'MALE']) ? 'M'
|
||||
: (in_array($g, ['F', 'FEMALE']) ? 'F' : $g);
|
||||
}
|
||||
|
||||
public static function normalizeRelation(?string $relation): ?string
|
||||
{
|
||||
return $relation === null ? null : strtoupper(trim($relation));
|
||||
}
|
||||
|
||||
/* =========================
|
||||
Core normalization
|
||||
========================= */
|
||||
|
||||
public static function normalizeEmployees(
|
||||
array $rows,
|
||||
array $keyMap,
|
||||
?string $pkKey = null
|
||||
): array {
|
||||
$normalized = [];
|
||||
// print_r($rows);die();
|
||||
foreach ($rows as $index => $row) {
|
||||
// echo "Normalizing record #" . ($index + 1) . "\n";
|
||||
$item = [
|
||||
'pk' => $pkKey && isset($row[$pkKey]) ? $row[$pkKey] : null,
|
||||
'__raw' => $row,
|
||||
];
|
||||
|
||||
foreach ($keyMap as $canonical => $possibleKeys) {
|
||||
$value = null;
|
||||
|
||||
foreach ($possibleKeys as $key) {
|
||||
if (isset($row[$key]) && $row[$key] !== '') {
|
||||
$value = $row[$key];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch ($canonical) {
|
||||
case 'emp_id':
|
||||
$item['emp_id'] = self::normalizeEmpId($value);
|
||||
break;
|
||||
case 'name':
|
||||
$item['name'] = self::normalizeName($value);
|
||||
break;
|
||||
case 'dob':
|
||||
$item['dob'] = self::parseDateToYmd($value);
|
||||
break;
|
||||
case 'gender':
|
||||
$item['gender'] = self::normalizeGender($value);
|
||||
break;
|
||||
case 'relation':
|
||||
$item['relation'] = self::normalizeRelation($value);
|
||||
break;
|
||||
default:
|
||||
$item[$canonical] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($item['pk'])) {
|
||||
$normalized[$item['pk']] = $item;
|
||||
} else {
|
||||
$normalized['__no_emp_' . $index] = $item;
|
||||
}
|
||||
|
||||
// echo "Normalizing record #" . ($index + 1) . "\n";
|
||||
}
|
||||
|
||||
return $normalized;
|
||||
}
|
||||
|
||||
/* =========================
|
||||
Main comparison
|
||||
========================= */
|
||||
|
||||
public static function compareDbVsMediassist(
|
||||
array $dbData,
|
||||
array $mediassistAPIdata
|
||||
): array {
|
||||
// echo count($dbData) . " records in DB data\n";die();
|
||||
$dbKeyMap = [
|
||||
'emp_id' => ['emp_code'],
|
||||
'name' => ['name'],
|
||||
'dob' => ['dob'],
|
||||
'gender' => ['gender'],
|
||||
'relation' => ['relationship'],
|
||||
];
|
||||
|
||||
$mediassistKeyMap = [
|
||||
'emp_id' => ['priBenefEmpCode'],
|
||||
'name' => ['benefName', 'priBeneficiaryName'],
|
||||
'dob' => ['benefDOB'],
|
||||
'gender' => ['benefSex'],
|
||||
'relation' => ['relName'],
|
||||
];
|
||||
|
||||
$A = self::normalizeEmployees($dbData, $dbKeyMap, 'id');
|
||||
|
||||
$B = self::normalizeEmployees($mediassistAPIdata, $mediassistKeyMap);
|
||||
dd($B);
|
||||
$report = [
|
||||
'summary' => [
|
||||
'total_db' => count($A),
|
||||
'total_mediassist' => count($B),
|
||||
'matched' => 0,
|
||||
'mismatched' => 0,
|
||||
'only_in_db' => 0,
|
||||
'only_in_mediassist' => 0,
|
||||
],
|
||||
'exact_matches' => [],
|
||||
'field_mismatches' => [],
|
||||
'only_in_db' => [],
|
||||
'only_in_mediassist' => [],
|
||||
];
|
||||
|
||||
foreach ($A as $empId => $rowA) {
|
||||
|
||||
if (!isset($B[$empId])) {
|
||||
$report['only_in_db'][] = [
|
||||
'pk' => $rowA['pk'],
|
||||
'emp_id' => $empId,
|
||||
'data' => $rowA,
|
||||
];
|
||||
continue;
|
||||
}
|
||||
|
||||
$rowB = $B[$empId];
|
||||
$diff = [];
|
||||
|
||||
foreach (self::COMPARE_FIELDS as $field) {
|
||||
if (($rowA[$field] ?? null) !== ($rowB[$field] ?? null)) {
|
||||
$diff[$field] = [
|
||||
'db' => $rowA[$field] ?? null,
|
||||
'mediassist' => $rowB[$field] ?? null,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($diff)) {
|
||||
$report['exact_matches'][] = [
|
||||
'pk' => $rowA['pk'],
|
||||
'emp_id' => $empId,
|
||||
];
|
||||
$report['summary']['matched']++;
|
||||
} else {
|
||||
$report['field_mismatches'][] = [
|
||||
'pk' => $rowA['pk'],
|
||||
'emp_id' => $empId,
|
||||
'differences' => $diff,
|
||||
];
|
||||
$report['summary']['mismatched']++;
|
||||
}
|
||||
|
||||
unset($B[$empId]);
|
||||
}
|
||||
|
||||
foreach ($B as $empId => $rowB) {
|
||||
$report['only_in_mediassist'][] = [
|
||||
'pk' => null,
|
||||
'emp_id' => $empId,
|
||||
'data' => $rowB,
|
||||
];
|
||||
}
|
||||
|
||||
$report['summary']['only_in_db'] = count($report['only_in_db']);
|
||||
$report['summary']['only_in_mediassist'] = count($report['only_in_mediassist']);
|
||||
|
||||
return $report;
|
||||
}
|
||||
}
|
||||
363
app/Helpers/TPADataCompareHelper2.php
Normal file
363
app/Helpers/TPADataCompareHelper2.php
Normal file
@ -0,0 +1,363 @@
|
||||
<?php
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
use DateTime;
|
||||
|
||||
class TPADataCompareHelper2
|
||||
{
|
||||
// fields compared by default
|
||||
public const COMPARE_FIELDS = ['name', 'dob', 'gender', 'relation'];
|
||||
|
||||
// candidate unique id fields from MediAssist / Excel — prefer these when present
|
||||
public const MEDIASSIST_UNIQUE_IDS = [
|
||||
'benefMediAssistID',
|
||||
'benefSlNoasperInsurer',
|
||||
'benefNIAPersonID'
|
||||
];
|
||||
|
||||
/* -------------------------
|
||||
Normalization utilities
|
||||
------------------------- */
|
||||
|
||||
public static function parseDateToYmd(?string $date): ?string
|
||||
{
|
||||
if ($date === null || $date === '') return null;
|
||||
$formats = ['d/m/Y H:i:s','d/m/Y','Y-m-d H:i:s','Y-m-d','d-m-Y','d-m-Y H:i:s'];
|
||||
foreach ($formats as $f) {
|
||||
$dt = DateTime::createFromFormat($f, $date);
|
||||
if ($dt !== false) return $dt->format('Y-m-d');
|
||||
}
|
||||
$ts = strtotime($date);
|
||||
return $ts ? date('Y-m-d', $ts) : null;
|
||||
}
|
||||
|
||||
public static function normalizeName(?string $name): ?string
|
||||
{
|
||||
if ($name === null) return null;
|
||||
$s = trim($name);
|
||||
// $s = preg_replace('/\.+/', ' ', $s);
|
||||
// $s = preg_replace('/\s+/', ' ', $s);
|
||||
return mb_strtolower($s);
|
||||
}
|
||||
|
||||
public static function normalizeEmpId(?string $id): ?string
|
||||
{
|
||||
if ($id === null) return null;
|
||||
$s = trim($id);
|
||||
// $s = preg_replace('/[\s\-\/]/', '', $s);
|
||||
// $s = preg_replace('/[^\p{L}\p{N}]/u', '', $s);
|
||||
return $s === '' ? null : $s;
|
||||
}
|
||||
|
||||
public static function normalizeGender(?string $g): ?string
|
||||
{
|
||||
if ($g === null) return null;
|
||||
$u = strtoupper(trim($g));
|
||||
if (in_array($u, ['M','MALE'])) return 'M';
|
||||
if (in_array($u, ['F','FEMALE'])) return 'F';
|
||||
return $u;
|
||||
}
|
||||
|
||||
public static function normalizeRelation(?string $r): ?string
|
||||
{
|
||||
if ($r === null) return null;
|
||||
return strtoupper(trim($r));
|
||||
}
|
||||
|
||||
/* -------------------------------------
|
||||
Normalize rows -> canonical structure
|
||||
Returns array of items (not keyed), each item contains:
|
||||
- 'pk' (DB primary key or null)
|
||||
- 'emp_id' (employee code)
|
||||
- 'name','dob','gender','relation' (normalized)
|
||||
- '__raw' original row
|
||||
- '__rowid' generated unique row id for API rows (if needed)
|
||||
------------------------------------- */
|
||||
public static function normalizeRows(array $rows, array $keyMap, ?string $pkKey = null): array
|
||||
{
|
||||
$out = [];
|
||||
$idx = 0;
|
||||
foreach ($rows as $r) {
|
||||
$item = [
|
||||
'pk' => ($pkKey && isset($r[$pkKey])) ? $r[$pkKey] : null,
|
||||
'__raw' => $r,
|
||||
'__rowid' => null,
|
||||
];
|
||||
|
||||
// fill canonical fields
|
||||
foreach ($keyMap as $canonical => $candidates) {
|
||||
$val = null;
|
||||
foreach ($candidates as $k) {
|
||||
if (is_array($r) && array_key_exists($k, $r) && $r[$k] !== '') {
|
||||
$val = $r[$k];
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch ($canonical) {
|
||||
case 'emp_id': $item['emp_id'] = self::normalizeEmpId((string)$val); break;
|
||||
case 'name': $item['name'] = self::normalizeName((string)$val); break;
|
||||
case 'dob': $item['dob'] = self::parseDateToYmd((string)$val); break;
|
||||
case 'gender': $item['gender'] = self::normalizeGender((string)$val); break;
|
||||
case 'relation': $item['relation'] = self::normalizeRelation((string)$val); break;
|
||||
default: $item[$canonical] = $val;
|
||||
}
|
||||
}
|
||||
|
||||
// create a stable row id (for API rows without PK) so they remain unique
|
||||
$item['__rowid'] = $item['pk'] ?? ('api_row_' . $idx++);
|
||||
|
||||
$out[] = $item;
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/* -------------------------
|
||||
Build grouped index by emp_code:
|
||||
returns [ emp_code => [ item1, item2, ... ] ]
|
||||
Use '__no_emp' key for rows without emp_id
|
||||
------------------------- */
|
||||
public static function groupByEmpCode(array $items): array
|
||||
{
|
||||
$groups = [];
|
||||
foreach ($items as $it) {
|
||||
$key = $it['emp_id'] ?? '__no_emp';
|
||||
if ($key === null || $key === '') $key = '__no_emp';
|
||||
$groups[$key][] = $it;
|
||||
}
|
||||
return $groups;
|
||||
}
|
||||
|
||||
/* -------------------------
|
||||
Find a match for a DB row inside a mediassist group (array of items).
|
||||
Matching priority:
|
||||
1) unique ids present in mediassist (if db raw has any of those too)
|
||||
2) exact name + dob
|
||||
3) exact name + relation
|
||||
4) fuzzy name + dob (threshold %)
|
||||
If found, returns index of matched item in $group array; else null.
|
||||
Note: $group is passed by reference so matched item can be removed by caller.
|
||||
------------------------- */
|
||||
public static function findMatchInGroup(array $dbRow, array $group, int $fuzzyThreshold = 85): ?int
|
||||
{
|
||||
// 1) match on unique ids if DB row contains any of those (rare)
|
||||
// foreach (self::MEDIASSIST_UNIQUE_IDS as $uidField) {
|
||||
// $dbVal = $dbRow['__raw'][$uidField] ?? null;
|
||||
// if ($dbVal) {
|
||||
// foreach ($group as $i => $gItem) {
|
||||
// $gVal = $gItem['__raw'][$uidField] ?? null;
|
||||
// if ($gVal && (string)$gVal === (string)$dbVal) return $i;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// 2) match exact name + dob (both normalized)
|
||||
if (!empty($dbRow['name']) && !empty($dbRow['dob'])) {
|
||||
foreach ($group as $i => $gItem) {
|
||||
if (!empty($gItem['name']) && !empty($gItem['dob'])
|
||||
&& $dbRow['name'] === $gItem['name']
|
||||
&& $dbRow['dob'] === $gItem['dob']) {
|
||||
return $i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3) match exact name + relation (if dob missing or unreliable)
|
||||
if (!empty($dbRow['name']) && !empty($dbRow['relation'])) {
|
||||
foreach ($group as $i => $gItem) {
|
||||
if (!empty($gItem['name']) && !empty($gItem['relation'])
|
||||
&& $dbRow['name'] === $gItem['name']
|
||||
&& $dbRow['relation'] === $gItem['relation']) {
|
||||
return $i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 4) fuzzy name + dob (if dob present)
|
||||
if ($fuzzyThreshold > 0 && !empty($dbRow['name'])) {
|
||||
foreach ($group as $i => $gItem) {
|
||||
if (empty($gItem['name'])) continue;
|
||||
$score = 0.0;
|
||||
similar_text($dbRow['name'], $gItem['name'], $score); // percent
|
||||
$dobMatches = (!empty($dbRow['dob']) && !empty($gItem['dob']) && $dbRow['dob'] === $gItem['dob']);
|
||||
// require DOB match OR higher threshold if dob missing
|
||||
if ($dobMatches && $score >= max(60, $fuzzyThreshold - 10)) { // slightly relaxed
|
||||
return $i;
|
||||
}
|
||||
if (!$dobMatches && $score >= $fuzzyThreshold) {
|
||||
// if names are very similar even w/o dob, accept (cautious)
|
||||
return $i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// no match
|
||||
return null;
|
||||
}
|
||||
|
||||
/* -------------------------
|
||||
Main comparison routine (grouped matching)
|
||||
Options:
|
||||
- fuzzy_threshold (default 85)
|
||||
- try_global_search_if_emp_missing (bool, default false)
|
||||
------------------------- */
|
||||
public static function compareDbVsMediassistGrouped(
|
||||
array $dbRows,
|
||||
array $mediassistAPIdata,
|
||||
string $dbPkKey = 'id',
|
||||
array $options = [],
|
||||
array $dbKeyMap = null,
|
||||
array $mediassistKeyMap = null,
|
||||
): array {
|
||||
|
||||
|
||||
$dbKeyMap = [
|
||||
'emp_id' => ['emp_code'],
|
||||
'name' => ['name'],
|
||||
'dob' => ['dob'],
|
||||
'gender' => ['gender'],
|
||||
'relation' => ['relationship'],
|
||||
];
|
||||
|
||||
$mediassistKeyMap = [
|
||||
'emp_id' => ['priBenefEmpCode'],
|
||||
'name' => ['benefName', 'priBeneficiaryName'],
|
||||
'dob' => ['benefDOB'],
|
||||
'gender' => ['benefSex'],
|
||||
'relation' => ['relName'],
|
||||
];
|
||||
|
||||
|
||||
$fuzzyThreshold = $options['fuzzy_threshold'] ?? 85;
|
||||
$tryGlobalSearch = $options['try_global_search_if_emp_missing'] ?? false;
|
||||
|
||||
// normalize to lists
|
||||
$normDb = self::normalizeRows($dbRows, $dbKeyMap, $dbPkKey);
|
||||
$normApi = self::normalizeRows($mediassistAPIdata, $mediassistKeyMap, null);
|
||||
// dd($normApi);
|
||||
// group by emp_code
|
||||
$dbGroups = self::groupByEmpCode($normDb);
|
||||
$apiGroups = self::groupByEmpCode($normApi);
|
||||
|
||||
// prepare report
|
||||
$report = [
|
||||
'summary' => [
|
||||
'total_db' => count($normDb),
|
||||
'total_mediassist' => count($normApi),
|
||||
'matched' => 0,
|
||||
'mismatched' => 0,
|
||||
'only_in_db' => 0,
|
||||
'only_in_mediassist' => 0,
|
||||
],
|
||||
'exact_matches' => [],
|
||||
'field_mismatches' => [],
|
||||
'only_in_db' => [],
|
||||
'only_in_mediassist' => [],
|
||||
];
|
||||
|
||||
// For each db group (emp_code), try match each dbRow with api group entries
|
||||
foreach ($dbGroups as $empCode => $dbItems) {
|
||||
$apiItems = $apiGroups[$empCode] ?? [];
|
||||
|
||||
// We'll mutate a local copy of apiItems to mark matched items (so we can remove)
|
||||
$remainingApi = $apiItems;
|
||||
|
||||
foreach ($dbItems as $dbRow) {
|
||||
$matchedIndex = null;
|
||||
if (!empty($empCode) && !empty($remainingApi)) {
|
||||
$matchedIndex = self::findMatchInGroup($dbRow, $remainingApi, $fuzzyThreshold);
|
||||
}
|
||||
|
||||
// If empCode not present in API and global search allowed, try searching all API rows (costly)
|
||||
if ($matchedIndex === null && $tryGlobalSearch && empty($apiItems)) {
|
||||
// attempt global search across all api groups (can be heavy)
|
||||
foreach ($apiGroups as $gKey => $gList) {
|
||||
$mi = self::findMatchInGroup($dbRow, $gList, $fuzzyThreshold);
|
||||
if ($mi !== null) {
|
||||
// found in another group
|
||||
$matchedIndex = $mi;
|
||||
// use that group as remainingApi reference so we can remove matched later
|
||||
$remainingApi = $apiGroups[$gKey];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($matchedIndex !== null) {
|
||||
// found match — use that api row
|
||||
$apiMatch = $remainingApi[$matchedIndex];
|
||||
|
||||
// compare fields
|
||||
$diff = [];
|
||||
foreach (self::COMPARE_FIELDS as $f) {
|
||||
$vDb = $dbRow[$f] ?? null;
|
||||
$vApi = $apiMatch[$f] ?? null;
|
||||
if ($vDb !== $vApi) {
|
||||
$diff[$f] = ['db' => $vDb, 'mediassist' => $vApi];
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($diff)) {
|
||||
$report['exact_matches'][] = [
|
||||
'pk' => $dbRow['pk'],
|
||||
'emp_id' => $dbRow['emp_id'],
|
||||
'db_rowid' => $dbRow['__rowid'],
|
||||
'api_rowid' => $apiMatch['__rowid'],
|
||||
];
|
||||
$report['summary']['matched']++;
|
||||
} else {
|
||||
$report['field_mismatches'][] = [
|
||||
'pk' => $dbRow['pk'],
|
||||
'emp_id' => $dbRow['emp_id'],
|
||||
'db_rowid' => $dbRow['__rowid'],
|
||||
'api_rowid' => $apiMatch['__rowid'],
|
||||
'differences' => $diff
|
||||
];
|
||||
$report['summary']['mismatched']++;
|
||||
}
|
||||
|
||||
// remove matched api item from remainingApi (so it's not matched again)
|
||||
array_splice($remainingApi, $matchedIndex, 1);
|
||||
} else {
|
||||
// no match found for this dbRow inside api group => only_in_db
|
||||
$report['only_in_db'][] = [
|
||||
'pk' => $dbRow['pk'],
|
||||
'emp_id' => $dbRow['emp_id'],
|
||||
'db_rowid' => $dbRow['__rowid'],
|
||||
'data' => $dbRow
|
||||
];
|
||||
}
|
||||
} // end each dbRow
|
||||
|
||||
// after processing all dbRows in this empCode group, any remainingApi are only_in_mediassist
|
||||
foreach ($remainingApi as $leftApi) {
|
||||
$report['only_in_mediassist'][] = [
|
||||
'pk' => null,
|
||||
'emp_id' => $leftApi['emp_id'],
|
||||
'api_rowid' => $leftApi['__rowid'],
|
||||
'data' => $leftApi
|
||||
];
|
||||
}
|
||||
} // end each emp group
|
||||
|
||||
// Also handle any api groups whose emp_code does not exist in DB at all
|
||||
foreach ($apiGroups as $empCode => $apiItems) {
|
||||
if (isset($dbGroups[$empCode])) continue; // already handled
|
||||
foreach ($apiItems as $ai) {
|
||||
$report['only_in_mediassist'][] = [
|
||||
'pk' => null,
|
||||
'emp_id' => $ai['emp_id'],
|
||||
'api_rowid' => $ai['__rowid'],
|
||||
'data' => $ai
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// summary counts
|
||||
$report['summary']['only_in_db'] = count($report['only_in_db']);
|
||||
$report['summary']['only_in_mediassist'] = count($report['only_in_mediassist']);
|
||||
|
||||
return $report;
|
||||
}
|
||||
}
|
||||
@ -3041,6 +3041,11 @@ if (!function_exists('validate_indian_vehicle_number')) {
|
||||
function validate_indian_vehicle_number($number)
|
||||
{
|
||||
$number = strtoupper(trim($number));
|
||||
$new_vehicle = strtolower(trim($number));
|
||||
|
||||
if($new_vehicle == "new"){
|
||||
return ['status' => true, 'error' => null];
|
||||
}
|
||||
|
||||
// Normal Format:
|
||||
// 2 letters (state) + 2 digits (district) + 1 or 2 letters (series) + 4 digits
|
||||
@ -3120,9 +3125,18 @@ if (!function_exists('check_agent_exist')) {
|
||||
|
||||
if (!function_exists('check_rto_data')) {
|
||||
function check_rto_data($row, $rto_master)
|
||||
{
|
||||
{
|
||||
// Vehicle number from uploaded row
|
||||
$vehicle_no = strtoupper(trim($row[2])); // Example: TN10AB1234
|
||||
$new_vehicle = strtolower(trim($row[2]));
|
||||
|
||||
if($new_vehicle == "new"){
|
||||
return [
|
||||
'status' => true,
|
||||
'error' => null,
|
||||
'rto_data' => []
|
||||
];
|
||||
}
|
||||
|
||||
// Must be at least 4 characters to extract RTO
|
||||
if (strlen($vehicle_no) < 4) {
|
||||
|
||||
55
app/Models/FAQModel.php
Normal file
55
app/Models/FAQModel.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class FAQModel extends Model
|
||||
{
|
||||
|
||||
protected $table = 'faq';
|
||||
protected $primaryKey = 'id';
|
||||
protected $allowedFields = [
|
||||
'id',
|
||||
'category',
|
||||
'question',
|
||||
'answer',
|
||||
'created_on',
|
||||
'created_by',
|
||||
'updated_on',
|
||||
'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)
|
||||
{
|
||||
if (empty($data['data']['created_by'])) {
|
||||
$data['data']['created_by'] = get_session_userid();
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function checkAndUpdateUpdatedByValue(array $data)
|
||||
{
|
||||
if (empty($data['data']['updated_by'])) {
|
||||
$data['data']['updated_by'] = get_session_userid();
|
||||
}
|
||||
|
||||
$data['data']['updated_on'] = date('Y-m-d H:i:s');
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
@ -19,6 +19,25 @@ class FEContentModel extends Model
|
||||
"is_active",
|
||||
];
|
||||
|
||||
protected $beforeInsert = ["checkAndADDCreatedByValue"];
|
||||
protected $beforeUpdate = ["checkAndUpdateUpdatedByValue"];
|
||||
|
||||
protected function checkAndADDCreatedByValue(array $data)
|
||||
{
|
||||
if (empty($data['data']['created_by'])) {
|
||||
$data['data']['created_by'] = get_session_userid();
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function checkAndUpdateUpdatedByValue(array $data)
|
||||
{
|
||||
if (empty($data['data']['updated_by'])) {
|
||||
$data['data']['updated_by'] = get_session_userid();
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -23,6 +23,7 @@ class InvoiceModel extends Model
|
||||
'created_by',
|
||||
'updated_at',
|
||||
'payout_status',
|
||||
'broker_id'
|
||||
];
|
||||
|
||||
// Timestamps
|
||||
@ -74,8 +75,8 @@ class InvoiceModel extends Model
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
public function invoiceList($agent_id = null, $status_id = null, $start_date = null, $end_date = null)
|
||||
// public function invoiceList($agent_id = null, $status_id = null, $start_date = null, $end_date = null) because dropdown hided
|
||||
public function invoiceList($pos_id = null, $status_id = null, $start_date = null, $end_date = null)
|
||||
{
|
||||
$data = $this->select("
|
||||
partner_invoice.*,
|
||||
@ -104,14 +105,21 @@ class InvoiceModel extends Model
|
||||
WHEN payout_status = 2 THEN 'Completed'
|
||||
END AS status_text,
|
||||
|
||||
partner_agent.name as agent_name
|
||||
partner_agent.name as agent_name,
|
||||
partner_pos.name as pos_name
|
||||
|
||||
")
|
||||
->join('partner_agent', 'partner_invoice.agent_id = partner_agent.id')
|
||||
->join('partner_agent', 'partner_invoice.agent_id = partner_agent.id','left')
|
||||
->join('partner_pos', 'partner_invoice.pos_id = partner_pos.id')
|
||||
->where('partner_invoice.is_active', 1)
|
||||
->where('partner_invoice.broker_id', 1);
|
||||
|
||||
if(!empty($agent_id)){
|
||||
$data->where('partner_invoice.agent_id', $agent_id);
|
||||
// if(!empty($agent_id)){
|
||||
// $data->where('partner_invoice.agent_id', $agent_id);
|
||||
// } // because dropdown hided
|
||||
|
||||
if(!empty($pos_id)){
|
||||
$data->where('partner_invoice.pos_id', $pos_id);
|
||||
}
|
||||
|
||||
if(!empty($status_id)){
|
||||
@ -127,7 +135,8 @@ class InvoiceModel extends Model
|
||||
->where('partner_invoice.invoice_date <=', $endDate);
|
||||
}
|
||||
|
||||
if(!empty($agent_id) && !empty($status_id) && !empty($start_date) && !empty($end_date)){
|
||||
// if(!empty($agent_id) && !empty($status_id) && !empty($start_date) && !empty($end_date)){
|
||||
if(!empty($pos_id) && !empty($status_id) && !empty($start_date) && !empty($end_date)){
|
||||
|
||||
$fromDate = date('Y-m-d', strtotime('-60 days'));
|
||||
$toDate = date('Y-m-d 23:59:59');
|
||||
@ -152,6 +161,21 @@ class InvoiceModel extends Model
|
||||
return $this->db->table('partner_agent')->get()->getResultArray();
|
||||
}
|
||||
|
||||
public function posList(array $params = [])
|
||||
{
|
||||
$builder = $this->db->table('partner_pos')
|
||||
->select('partner_pos.*, partner_staff.name AS manager_name')
|
||||
->join('partner_staff', 'partner_staff.id = partner_pos.manager_id', 'left')
|
||||
->orderBy('partner_pos.id', 'DESC');
|
||||
|
||||
if (isset($params['is_active'])) {
|
||||
$builder->where('partner_pos.is_active', $params['is_active']);
|
||||
}
|
||||
|
||||
return $builder->get()->getResultArray();
|
||||
}
|
||||
|
||||
|
||||
public function utrSummary($invoice_id)
|
||||
{
|
||||
$data = $this->select("
|
||||
@ -193,7 +217,7 @@ class InvoiceModel extends Model
|
||||
}
|
||||
|
||||
|
||||
public function payoutList($flag, $agentId = null, $invoiceId = null)
|
||||
public function payoutList($flag, $posId = null, $invoiceId = null)
|
||||
{
|
||||
$builder = $this->db->table('policy_transaction pt')
|
||||
->select('
|
||||
@ -209,17 +233,20 @@ class InvoiceModel extends Model
|
||||
pii.commission_amount as paid_amount,
|
||||
pi.payout_status,
|
||||
pp.id as partner_policy_id,
|
||||
pp.policy_transaction_id
|
||||
pp.policy_transaction_id,
|
||||
pt.pos_id as posId
|
||||
')
|
||||
->join('partner_invoice_items pii','pii.policy_no = pt.policy_no','left')
|
||||
->join('partner_invoice pi','pi.id = pii.invoice_id','left')
|
||||
->join('partner_policy pp','pt.policy_no = pp.policy_number AND pt.agent_id = pp.agent_id AND pt.id = pp.policy_transaction_id')
|
||||
->where('pt.is_active',1)
|
||||
->where('pt.agent_id IS NOT NULL');
|
||||
->where('pt.pos_id IS NOT NULL');
|
||||
// ->where('pt.agent_id IS NOT NULL');
|
||||
|
||||
if ($flag == 1) { // Add mode
|
||||
// EXCLUDE all policies that exist in partner_invoice_items
|
||||
$builder->where("pt.id NOT IN (SELECT policy_id FROM partner_invoice_items)", null, false);
|
||||
$builder->where("pp.id NOT IN (SELECT policy_id FROM partner_invoice_items)", null, false);
|
||||
$builder->where("pt.policy_no NOT IN (SELECT policy_no FROM partner_invoice_items)", null, false);
|
||||
}
|
||||
|
||||
if ($flag == 2) { // Edit mode
|
||||
@ -228,16 +255,22 @@ class InvoiceModel extends Model
|
||||
if ($invoiceId) {
|
||||
$builder->where('pi.id', $invoiceId); // only policies of this invoice
|
||||
}
|
||||
if ($agentId) {
|
||||
$builder->where('pt.agent_id', $agentId);
|
||||
// if ($agentId) {
|
||||
// $builder->where('pt.agent_id', $agentId);
|
||||
// }
|
||||
if ($posId) {
|
||||
$builder->where('pt.pos_id', $posId);
|
||||
}
|
||||
}
|
||||
|
||||
if ($flag == 3) { // Extra policies
|
||||
// Policies not assigned to any invoice
|
||||
$builder->where('pii.id IS NULL', null, false);
|
||||
if ($agentId) {
|
||||
$builder->where('pt.agent_id', $agentId);
|
||||
// if ($agentId) {
|
||||
// $builder->where('pt.agent_id', $agentId);
|
||||
// }
|
||||
if ($posId) {
|
||||
$builder->where('pt.pos_id', $posId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
135
app/Models/PartnerPosModel.php
Normal file
135
app/Models/PartnerPosModel.php
Normal file
@ -0,0 +1,135 @@
|
||||
<?php namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class PartnerPosModel extends Model
|
||||
{
|
||||
// 1. Core Configuration
|
||||
|
||||
/**
|
||||
* @var string The database table that this model primarily works with.
|
||||
*/
|
||||
protected $table = 'partner_pos';
|
||||
|
||||
/**
|
||||
* @var string The name of the primary key field.
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* @var string The type of value the primary key is.
|
||||
*/
|
||||
protected $returnType = 'array'; // Can be 'array' or 'object' (e.g., \App\Entities\PartnerPos)
|
||||
|
||||
/**
|
||||
* @var bool Whether to use timestamps. We will handle them manually with $useTimestamps.
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
// 2. Timestamps and Dates
|
||||
|
||||
/**
|
||||
* @var bool Whether to use the automatic timestamps. Set to true if you use CI4's
|
||||
* default `created_at` and `updated_at` column names. Since you use custom names,
|
||||
* we set this to false and handle the fields manually in $allowedFields.
|
||||
*/
|
||||
protected $useTimestamps = true;
|
||||
|
||||
/**
|
||||
* @var string The field name for the creation timestamp.
|
||||
* We use `created_on` to match your table.
|
||||
*/
|
||||
protected $createdField = 'created_on';
|
||||
|
||||
/**
|
||||
* @var string The field name for the update timestamp.
|
||||
* We use `updated_on` to match your table.
|
||||
*/
|
||||
protected $updatedField = 'updated_on';
|
||||
|
||||
// Note: The `created_by` and `updated_by` fields need to be handled
|
||||
// in the controller/service layer before calling insert/update.
|
||||
|
||||
// 3. Allowed Fields
|
||||
|
||||
/**
|
||||
* @var array The fields that can be set during an insert or update operation.
|
||||
*/
|
||||
protected $allowedFields = [
|
||||
'name',
|
||||
'email',
|
||||
'mobile',
|
||||
'pos_code',
|
||||
'certificate_file_name',
|
||||
'gst','pan',
|
||||
'pan_file_name',
|
||||
'aadhar',
|
||||
'aadhar_file_name',
|
||||
'is_active',
|
||||
'updated_on',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'manager_id',
|
||||
'bank_name',
|
||||
'account_holder_name',
|
||||
'account_number',
|
||||
'ifsc_code',
|
||||
'address',
|
||||
'state',
|
||||
'city',
|
||||
'pincode',
|
||||
|
||||
// 'created_on' and 'updated_on' are handled by the Model,
|
||||
// but need to be in $allowedFields if $useTimestamps is false.
|
||||
// Since $useTimestamps is true and we customized the field names, CI4 handles them.
|
||||
];
|
||||
|
||||
// 4. Validation (Optional, but highly recommended in CI4)
|
||||
|
||||
// protected $validationRules = [
|
||||
// 'name' => 'required|min_length[3]',
|
||||
// 'email' => 'permit_empty|valid_email|is_unique[partner_pos.email,id,{id}]',
|
||||
// 'mobile' => 'permit_empty|numeric|max_length[20]|is_unique[partner_pos.mobile,id,{id}]',
|
||||
// 'manager_id' => 'required|integer',
|
||||
// ];
|
||||
|
||||
// protected $validationMessages = [
|
||||
// 'email' => [
|
||||
// 'is_unique' => 'Sorry, that email address is already registered.',
|
||||
// ],
|
||||
// ];
|
||||
|
||||
/**
|
||||
* @var bool Whether to skip validation during inserts and updates.
|
||||
*/
|
||||
protected $skipValidation = false;
|
||||
|
||||
/**
|
||||
* @var bool Whether to clean data for SQL Injection.
|
||||
*/
|
||||
protected $cleanValidationRules = true;
|
||||
|
||||
protected $beforeInsert = ["checkAndADDCreatedByValue"];
|
||||
protected $beforeUpdate = ["checkAndUpdateUpdatedByValue"];
|
||||
|
||||
protected function checkAndADDCreatedByValue(array $data)
|
||||
{
|
||||
if (empty($data['data']['created_by'])) {
|
||||
$data['data']['created_by'] = get_session_userid();
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function checkAndUpdateUpdatedByValue(array $data)
|
||||
{
|
||||
if (empty($data['data']['updated_by'])) {
|
||||
$data['data']['updated_by'] = get_session_userid();
|
||||
}
|
||||
|
||||
$data['data']['updated_on'] = date('Y-m-d H:i:s');
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
@ -16,7 +16,7 @@ class PartnerStaffModel extends Model
|
||||
protected $useSoftDeletes = false;
|
||||
|
||||
// allowed fields for insert/update
|
||||
protected $allowedFields = ['name','email','mobile','emp_id','role_id','email_otp','is_active','created_by','updated_by','manager_id'];
|
||||
protected $allowedFields = ['name','email','mobile','emp_id','role_id','email_otp','is_active','created_by','updated_by','manager_id','retention_rate','nhance_branch_id'];
|
||||
|
||||
// automatic timestamps
|
||||
protected $useTimestamps = true;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
166
app/Models/SalesActivityModel.php
Normal file
166
app/Models/SalesActivityModel.php
Normal file
@ -0,0 +1,166 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
/**
|
||||
* Activity Model
|
||||
*/
|
||||
class SalesActivityModel extends Model
|
||||
{
|
||||
protected $table = 'sales_activities';
|
||||
protected $primaryKey = 'activity_id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = false;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
'lead_id',
|
||||
'activity_type',
|
||||
'notes',
|
||||
'scheduled_date',
|
||||
'assigned_to',
|
||||
'status',
|
||||
'completion_notes',
|
||||
'completed_date',
|
||||
'parent_activity_id',
|
||||
'created_by',
|
||||
'updated_by'
|
||||
];
|
||||
|
||||
// Dates
|
||||
protected $useTimestamps = true;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
|
||||
// Validation
|
||||
protected $validationRules = [
|
||||
'lead_id' => 'required|integer',
|
||||
'activity_type' => 'required|in_list[Call,Email,Meeting,Demo,Share,Todo]',
|
||||
'notes' => 'required',
|
||||
'scheduled_date' => 'required|valid_date',
|
||||
'assigned_to' => 'required|integer',
|
||||
'status' => 'in_list[pending,completed]',
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
'lead_id' => [
|
||||
'required' => 'Lead ID is required',
|
||||
],
|
||||
'activity_type' => [
|
||||
'required' => 'Activity type is required',
|
||||
],
|
||||
'notes' => [
|
||||
'required' => 'Activity notes are required',
|
||||
],
|
||||
];
|
||||
|
||||
protected $skipValidation = false;
|
||||
|
||||
/**
|
||||
* Get activities by lead with user details
|
||||
*/
|
||||
public function getActivitiesByLead($leadId, $status = null)
|
||||
{
|
||||
$builder = $this->select('activities.*, user_profiles.username as assigned_to_name')
|
||||
->join('user_profiles', 'user_profiles.id = activities.assigned_to', 'left')
|
||||
->where('activities.lead_id', $leadId);
|
||||
|
||||
if ($status) {
|
||||
$builder->where('activities.status', $status);
|
||||
}
|
||||
|
||||
return $builder->orderBy('activities.scheduled_date', 'DESC')->findAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all activities with filters
|
||||
*/
|
||||
public function getActivitiesWithFilters($filters = [], $limit = 10, $offset = 0)
|
||||
{
|
||||
$builder = $this->select('activities.*, actual_leads.company_name, user_profiles.username as assigned_to_name')
|
||||
->join('actual_leads', 'actual_leads.lead_id = activities.lead_id', 'left')
|
||||
->join('user_profiles', 'user_profiles.id = activities.assigned_to', 'left');
|
||||
|
||||
if (!empty($filters['status'])) {
|
||||
$builder->where('activities.status', $filters['status']);
|
||||
}
|
||||
|
||||
if (!empty($filters['activity_type'])) {
|
||||
$builder->where('activities.activity_type', $filters['activity_type']);
|
||||
}
|
||||
|
||||
if (!empty($filters['assigned_to'])) {
|
||||
$builder->where('activities.assigned_to', $filters['assigned_to']);
|
||||
}
|
||||
|
||||
if (!empty($filters['date_from'])) {
|
||||
$builder->where('activities.scheduled_date >=', $filters['date_from']);
|
||||
}
|
||||
|
||||
if (!empty($filters['date_to'])) {
|
||||
$builder->where('activities.scheduled_date <=', $filters['date_to']);
|
||||
}
|
||||
|
||||
return [
|
||||
'data' => $builder->orderBy('activities.scheduled_date', 'DESC')
|
||||
->limit($limit, $offset)->findAll(),
|
||||
'total' => $builder->countAllResults(false)
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Complete an activity
|
||||
*/
|
||||
public function completeActivity($activityId, $completionData)
|
||||
{
|
||||
return $this->update($activityId, [
|
||||
'status' => 'completed',
|
||||
'completion_notes' => $completionData['completion_notes'],
|
||||
'completed_date' => date('Y-m-d H:i:s'),
|
||||
'updated_by' => $completionData['updated_by'] ?? null
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pending activities count by user
|
||||
*/
|
||||
public function getPendingActivitiesCount($userId)
|
||||
{
|
||||
return $this->where('assigned_to', $userId)
|
||||
->where('status', 'pending')
|
||||
->where('scheduled_date <=', date('Y-m-d H:i:s'))
|
||||
->countAllResults();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get upcoming activities for a user
|
||||
*/
|
||||
public function getUpcomingActivities($userId, $days = 7, $limit = 10)
|
||||
{
|
||||
$endDate = date('Y-m-d H:i:s', strtotime("+{$days} days"));
|
||||
|
||||
return $this->select('activities.*, actual_leads.company_name')
|
||||
->join('actual_leads', 'actual_leads.lead_id = activities.lead_id', 'left')
|
||||
->where('activities.assigned_to', $userId)
|
||||
->where('activities.status', 'pending')
|
||||
->where('activities.scheduled_date <=', $endDate)
|
||||
->orderBy('activities.scheduled_date', 'ASC')
|
||||
->limit($limit)
|
||||
->findAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get activity timeline for a lead
|
||||
*/
|
||||
public function getActivityTimeline($leadId)
|
||||
{
|
||||
return $this->select('activities.*, user_profiles.username as assigned_to_name')
|
||||
->join('user_profiles', 'user_profiles.id = activities.assigned_to', 'left')
|
||||
->where('activities.lead_id', $leadId)
|
||||
->orderBy('activities.scheduled_date', 'DESC')
|
||||
->findAll();
|
||||
}
|
||||
}
|
||||
145
app/Models/SalesActualLeadModel.php
Normal file
145
app/Models/SalesActualLeadModel.php
Normal file
@ -0,0 +1,145 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
/**
|
||||
* Lead Model
|
||||
* Handles all operations related to actual_leads table
|
||||
*/
|
||||
class SalesActualLeadModel extends Model
|
||||
{
|
||||
protected $table = 'sales_actual_leads';
|
||||
protected $primaryKey = 'lead_id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = false;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
'company_name',
|
||||
'email',
|
||||
'phone',
|
||||
'address',
|
||||
'website',
|
||||
'gst_number',
|
||||
'status',
|
||||
'assigned_to',
|
||||
'created_by',
|
||||
'updated_by'
|
||||
];
|
||||
|
||||
// Dates
|
||||
protected $useTimestamps = true;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
|
||||
// Validation
|
||||
protected $validationRules = [
|
||||
'company_name' => 'required|min_length[2]|max_length[255]',
|
||||
'email' => 'required|valid_email|max_length[255]',
|
||||
'phone' => 'required|min_length[10]|max_length[20]',
|
||||
'status' => 'in_list[New,Potential,Prospects,Non prospects]',
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
'company_name' => [
|
||||
'required' => 'Company name is required',
|
||||
],
|
||||
'email' => [
|
||||
'required' => 'Email is required',
|
||||
'valid_email' => 'Please provide a valid email address',
|
||||
],
|
||||
'phone' => [
|
||||
'required' => 'Phone number is required',
|
||||
],
|
||||
];
|
||||
|
||||
protected $skipValidation = false;
|
||||
|
||||
/**
|
||||
* Get lead with assigned user details
|
||||
*/
|
||||
public function getLeadWithUser($leadId)
|
||||
{
|
||||
return $this->select('actual_leads.*, user_profiles.username as assigned_to_name, user_profiles.email as assigned_to_email')
|
||||
->join('user_profiles', 'user_profiles.id = actual_leads.assigned_to', 'left')
|
||||
->where('actual_leads.lead_id', $leadId)
|
||||
->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all leads with pagination and filters
|
||||
*/
|
||||
public function getLeadsWithFilters($filters = [], $limit = 10, $offset = 0)
|
||||
{
|
||||
$builder = $this->select('actual_leads.*, user_profiles.username as assigned_to_name')
|
||||
->join('user_profiles', 'user_profiles.id = actual_leads.assigned_to', 'left');
|
||||
|
||||
if (!empty($filters['status'])) {
|
||||
$builder->where('actual_leads.status', $filters['status']);
|
||||
}
|
||||
|
||||
if (!empty($filters['assigned_to'])) {
|
||||
$builder->where('actual_leads.assigned_to', $filters['assigned_to']);
|
||||
}
|
||||
|
||||
if (!empty($filters['search'])) {
|
||||
$builder->groupStart()
|
||||
->like('actual_leads.company_name', $filters['search'])
|
||||
->orLike('actual_leads.email', $filters['search'])
|
||||
->orLike('actual_leads.phone', $filters['search'])
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
return [
|
||||
'data' => $builder->limit($limit, $offset)->findAll(),
|
||||
'total' => $builder->countAllResults(false)
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get lead with all related data (contacts, activities, notes)
|
||||
*/
|
||||
public function getLeadComplete($leadId)
|
||||
{
|
||||
$lead = $this->getLeadWithUser($leadId);
|
||||
|
||||
if (!$lead) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$contactModel = new SalesContactPersonModel();
|
||||
$activityModel = new SalesActivityModel();
|
||||
$noteModel = new SalesLeadNoteModel();
|
||||
|
||||
$lead['contact_persons'] = $contactModel->where('lead_id', $leadId)->findAll();
|
||||
$lead['activities'] = $activityModel->getActivitiesByLead($leadId);
|
||||
$lead['notes'] = $noteModel->getNotesByLead($leadId);
|
||||
|
||||
return $lead;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get leads statistics
|
||||
*/
|
||||
public function getLeadStats($userId = null)
|
||||
{
|
||||
$builder = $this->builder();
|
||||
|
||||
if ($userId) {
|
||||
$builder->where('assigned_to', $userId);
|
||||
}
|
||||
|
||||
$stats = [
|
||||
'total' => $builder->countAllResults(false),
|
||||
'new' => $builder->where('status', 'New')->countAllResults(false),
|
||||
'potential' => $builder->where('status', 'Potential')->countAllResults(false),
|
||||
'prospects' => $builder->where('status', 'Prospects')->countAllResults(false),
|
||||
'non_prospects' => $builder->where('status', 'Non prospects')->countAllResults(false),
|
||||
];
|
||||
|
||||
return $stats;
|
||||
}
|
||||
}
|
||||
95
app/Models/SalesContactPersonModel.php
Normal file
95
app/Models/SalesContactPersonModel.php
Normal file
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
/**
|
||||
* Contact Person Model
|
||||
*/
|
||||
class SalesContactPersonModel extends Model
|
||||
{
|
||||
protected $table = 'sales_contact_persons';
|
||||
protected $primaryKey = 'contact_id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = false;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
'lead_id',
|
||||
'name',
|
||||
'mobile',
|
||||
'designation',
|
||||
'email',
|
||||
'is_primary',
|
||||
'created_by',
|
||||
'updated_by'
|
||||
];
|
||||
|
||||
// Dates
|
||||
protected $useTimestamps = true;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
|
||||
// Validation
|
||||
protected $validationRules = [
|
||||
'lead_id' => 'required|integer',
|
||||
'name' => 'required|min_length[2]|max_length[100]',
|
||||
'mobile' => 'required|min_length[10]|max_length[20]',
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
'lead_id' => [
|
||||
'required' => 'Lead ID is required',
|
||||
],
|
||||
'name' => [
|
||||
'required' => 'Contact person name is required',
|
||||
],
|
||||
'mobile' => [
|
||||
'required' => 'Mobile number is required',
|
||||
],
|
||||
];
|
||||
|
||||
protected $skipValidation = false;
|
||||
|
||||
/**
|
||||
* Get all contacts for a lead
|
||||
*/
|
||||
public function getContactsByLead($leadId)
|
||||
{
|
||||
return $this->where('lead_id', $leadId)
|
||||
->orderBy('is_primary', 'DESC')
|
||||
->findAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get primary contact for a lead
|
||||
*/
|
||||
public function getPrimaryContact($leadId)
|
||||
{
|
||||
return $this->where('lead_id', $leadId)
|
||||
->where('is_primary', 1)
|
||||
->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a contact as primary (unset others)
|
||||
*/
|
||||
public function setPrimaryContact($contactId, $leadId)
|
||||
{
|
||||
$this->db->transStart();
|
||||
|
||||
// Unset all primary contacts for this lead
|
||||
$this->where('lead_id', $leadId)
|
||||
->set(['is_primary' => 0])
|
||||
->update();
|
||||
|
||||
// Set the specified contact as primary
|
||||
$this->update($contactId, ['is_primary' => 1]);
|
||||
|
||||
$this->db->transComplete();
|
||||
|
||||
return $this->db->transStatus();
|
||||
}
|
||||
}
|
||||
75
app/Models/SalesLeadNoteModel.php
Normal file
75
app/Models/SalesLeadNoteModel.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
|
||||
/**
|
||||
* Lead Note Model
|
||||
*/
|
||||
class SalesLeadNoteModel extends Model
|
||||
{
|
||||
protected $table = 'sales_lead_notes';
|
||||
protected $primaryKey = 'note_id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = false;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
'lead_id',
|
||||
'user_id',
|
||||
'note_text',
|
||||
'created_by',
|
||||
'updated_by'
|
||||
];
|
||||
|
||||
// Dates
|
||||
protected $useTimestamps = true;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
|
||||
// Validation
|
||||
protected $validationRules = [
|
||||
'lead_id' => 'required|integer',
|
||||
'user_id' => 'required|integer',
|
||||
'note_text' => 'required|min_length[3]',
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
'lead_id' => [
|
||||
'required' => 'Lead ID is required',
|
||||
],
|
||||
'note_text' => [
|
||||
'required' => 'Note text is required',
|
||||
],
|
||||
];
|
||||
|
||||
protected $skipValidation = false;
|
||||
|
||||
/**
|
||||
* Get notes by lead with user details
|
||||
*/
|
||||
public function getNotesByLead($leadId)
|
||||
{
|
||||
return $this->select('lead_notes.*, user_profiles.username')
|
||||
->join('user_profiles', 'user_profiles.id = lead_notes.user_id', 'left')
|
||||
->where('lead_notes.lead_id', $leadId)
|
||||
->orderBy('lead_notes.created_at', 'DESC')
|
||||
->findAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get notes by user
|
||||
*/
|
||||
public function getNotesByUser($userId, $limit = 20, $offset = 0)
|
||||
{
|
||||
return $this->select('lead_notes.*, actual_leads.company_name')
|
||||
->join('actual_leads', 'actual_leads.lead_id = lead_notes.lead_id', 'left')
|
||||
->where('lead_notes.user_id', $userId)
|
||||
->orderBy('lead_notes.created_at', 'DESC')
|
||||
->limit($limit, $offset)
|
||||
->findAll();
|
||||
}
|
||||
}
|
||||
108
app/Models/TpaApiDataModel.php
Normal file
108
app/Models/TpaApiDataModel.php
Normal file
@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class TpaApiDataModel extends Model
|
||||
{
|
||||
protected $table = 'tpa_api_data';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = false;
|
||||
|
||||
protected $allowedFields = [
|
||||
'file_id',
|
||||
'emp_code',
|
||||
'name',
|
||||
'dob',
|
||||
'relation',
|
||||
'gender',
|
||||
'self',
|
||||
'tpa_id',
|
||||
'age',
|
||||
'is_active',
|
||||
'desc',
|
||||
'created_by'
|
||||
];
|
||||
|
||||
// protected $useTimestamps = true;
|
||||
// protected $createdField = 'create_at';
|
||||
protected $updatedField = null;
|
||||
|
||||
// protected $dateFormat = 'datetime';
|
||||
|
||||
// protected $validationRules = [
|
||||
// 'file_id' => 'required|integer',
|
||||
// 'temp_code' => 'required|string|max_length[50]',
|
||||
// 'tname' => 'required|string|max_length[150]',
|
||||
// 'tgender' => 'permit_empty|in_list[M,F,O]',
|
||||
// 'tage' => 'permit_empty|integer'
|
||||
// ];
|
||||
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
|
||||
|
||||
|
||||
|
||||
public function insertBatchWithChunkLog( array $rows,int $chunkSize = 500,?string $logRef = null)
|
||||
{
|
||||
if (empty($rows)) {
|
||||
return [
|
||||
'status' => false,
|
||||
'inserted' => 0,
|
||||
'failed_batches' => 0,
|
||||
'message' => 'No data'
|
||||
];
|
||||
}
|
||||
|
||||
$db = \Config\Database::connect();
|
||||
$this->skipValidation(true);
|
||||
|
||||
$inserted = 0;
|
||||
$failedBatches = 0;
|
||||
$batchNo = 0;
|
||||
|
||||
foreach (array_chunk($rows, $chunkSize) as $chunk) {
|
||||
$batchNo++;
|
||||
|
||||
try {
|
||||
$db->transStart();
|
||||
|
||||
$this->insertBatch($chunk);
|
||||
|
||||
if ($db->transStatus() === false) {
|
||||
throw new \RuntimeException('DB transaction failed');
|
||||
}
|
||||
|
||||
$db->transComplete();
|
||||
$inserted += count($chunk);
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
$db->transRollback();
|
||||
$failedBatches++;
|
||||
|
||||
// 🔴 Batch-level error log
|
||||
log_message('error', json_encode([
|
||||
'type' => 'BATCH_INSERT_FAILED',
|
||||
'table' => $this->table,
|
||||
'batch_no' => $batchNo,
|
||||
'batch_size'=> count($chunk),
|
||||
'ref' => $logRef,
|
||||
'error' => $e->getMessage()
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'status' => $failedBatches === 0,
|
||||
'inserted' => $inserted,
|
||||
'failed_batches' => $failedBatches,
|
||||
'total_batches' => $batchNo
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
@ -489,9 +489,9 @@ table.dataTable tbody td {
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="nhance_branch_id">NHance Branch<span class="text-danger">*</span></label>
|
||||
<label for="nhance_branch_id">Nhance Branch<span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="nhance_branch_id" name="nhance_branch_id" required>
|
||||
<option value="">Select NHance Branch</option>
|
||||
<option value="">Select Nhance Branch</option>
|
||||
<?php foreach($NHanceBranchData as $value) { ?>
|
||||
<option value="<?= $value['id'] ?>"><?= $value['branch_name'] ?></option>
|
||||
<?php } ?>
|
||||
@ -594,7 +594,7 @@ table.dataTable tbody td {
|
||||
<div class="modal-dialog modal-dialog-centered modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">Add Nhance Partner </h4>
|
||||
<h4 class="modal-title">Add Nhance Partner Manager </h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
|
||||
@ -609,7 +609,7 @@ table.dataTable tbody td {
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="partner_name">Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="partner_name" placeholder="Ente Name" name="name" required>
|
||||
<input type="text" class="form-control" id="partner_name" placeholder="Enter Name" name="name" required>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="mobile_no">Mobile Number<span class="text-danger">*</span></label>
|
||||
@ -623,9 +623,27 @@ table.dataTable tbody td {
|
||||
<input type="text" class="form-control" id="email_addr" placeholder="Enter Email" name="email" data-parsley-trigger="change" data-parsley-type="email" required>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="retention_rate">Retention Rate<span class="text-danger">*</span></label>
|
||||
<!-- <input type="text" class="form-control" id="retention_rate" placeholder="Enter Retention Rate" name="retention_rate" required> -->
|
||||
<input type="text" class="form-control" id="retention_rate" name="retention_rate" placeholder="Enter Retention Rate" inputmode="decimal" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="partner_nhance_branch_id">Nhance Branch<span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="partner_nhance_branch_id" name="nhance_branch_id" required>
|
||||
<option value="">Select Nhance Branch</option>
|
||||
<?php foreach($NHanceBranchData as $value) { ?>
|
||||
<option value="<?= $value['id'] ?>"><?= $value['branch_name'] ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
<!-- <div class="form-group col-md-6">
|
||||
<label for="locn">Address</label>
|
||||
<textarea class="form-control" id="locn" name="address" placeholder="Enter address" rows="3" maxlength="1500"></textarea>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
|
||||
</div>
|
||||
@ -872,12 +890,18 @@ table.dataTable tbody td {
|
||||
$(document).ready(function () {
|
||||
|
||||
$('#nhance_branch_id').select2();
|
||||
$('#partner_nhance_branch_id').select2();
|
||||
|
||||
$('#rm_id').select2();
|
||||
|
||||
$('#nhance_branch_id')
|
||||
.val(null) // ✅ MUST be null
|
||||
.trigger('change.select2'); // ✅ correct trigger
|
||||
|
||||
$('#partner_nhance_branch_id')
|
||||
.val(null) // ✅ MUST be null
|
||||
.trigger('change.select2'); // ✅ correct trigger
|
||||
|
||||
|
||||
var incentiveMonthPicker = flatpickr("#incentive_month", {
|
||||
dateFormat: "Y-m-d", // real value stored (hidden)
|
||||
@ -1144,9 +1168,21 @@ table.dataTable tbody td {
|
||||
$('#partner_name').val(user.name);
|
||||
$('#email_addr').val(user.email);
|
||||
$('#mobile_no').val(user.mobile);
|
||||
$('#locn').val(user.address);
|
||||
// $('#locn').val(user.address);
|
||||
$('#retention_rate').val(user.retention_rate);
|
||||
if (user.nhance_branch_id !== null &&
|
||||
user.nhance_branch_id !== "" &&
|
||||
user.nhance_branch_id !== 0) {
|
||||
$('#partner_nhance_branch_id')
|
||||
.val(user.nhance_branch_id)
|
||||
.trigger('change.select2');
|
||||
} else {
|
||||
$('#partner_nhance_branch_id')
|
||||
.val(null) // ✅ MUST be null
|
||||
.trigger('change.select2'); // ✅ correct trigger
|
||||
}
|
||||
// $('#btnPartnerSubmit').html('Update');
|
||||
$('.modal-title').html('Update Nhance Partner');
|
||||
$('.modal-title').html('Update Nhance Partner Manager');
|
||||
let myModal = new bootstrap.Modal(document.getElementById('nhance-partner-modal'));
|
||||
myModal.show(); // open modal
|
||||
});
|
||||
@ -1154,10 +1190,12 @@ table.dataTable tbody td {
|
||||
$('body').on('click', '.btnPartnerDelete', function () {
|
||||
var partner_role = $(this).attr('data-role');
|
||||
var alertText = "You need to remove this user";
|
||||
if (partner_role == 2) {
|
||||
if (partner_role == 3) {
|
||||
alertText = "You need to remove this Staff";
|
||||
} else if (partner_role == 2) {
|
||||
alertText = "You need to remove this Handler";
|
||||
} else if (partner_role == 1) {
|
||||
alertText = "You need to remove this Manager and related agent and staff are also delete";
|
||||
alertText = "You need to remove this Manager and related Handler and Staff are also delete";
|
||||
}
|
||||
|
||||
Swal.fire({
|
||||
@ -1237,23 +1275,25 @@ table.dataTable tbody td {
|
||||
var name = document.getElementById('partner_name').value.trim();
|
||||
var mobile = document.getElementById('mobile_no').value.trim();
|
||||
var email = document.getElementById('email_addr').value.trim();
|
||||
var address = document.getElementById('locn').value.trim();
|
||||
|
||||
// var address = document.getElementById('locn').value.trim();
|
||||
var rate = document.getElementById('retention_rate').value.trim();
|
||||
var nb = document.getElementById('partner_nhance_branch_id').value.trim();
|
||||
|
||||
// Validation checks
|
||||
if (name === "" || mobile === "" || email === "") {
|
||||
console.log(name);
|
||||
console.log(mobile);
|
||||
console.log(email);
|
||||
if (name === "" || mobile === "" || email === "" || rate === "" || nb === "") {
|
||||
// console.log(name);
|
||||
// console.log(mobile);
|
||||
// console.log(email);
|
||||
toastr.warning('Please fill all required fields.', 'Warning');
|
||||
form.classList.add('was-validated');
|
||||
return;
|
||||
}
|
||||
|
||||
if (address.length > 1500) {
|
||||
toastr.error('Address cannot exceed 1500 characters', 'Warning');
|
||||
form.classList.add('was-validated');
|
||||
return;
|
||||
}
|
||||
// if (address.length > 1500) {
|
||||
// toastr.error('Address cannot exceed 1500 characters', 'Warning');
|
||||
// form.classList.add('was-validated');
|
||||
// return;
|
||||
// }
|
||||
|
||||
var mobilePattern = /^[6-9]\d{9}$/; // must start with 6–9 and be 10 digits
|
||||
if (!mobilePattern.test(mobile)) {
|
||||
@ -1395,11 +1435,18 @@ table.dataTable tbody td {
|
||||
</div>`
|
||||
];
|
||||
} else { // partner
|
||||
let roleName = "";
|
||||
switch(parseInt(row.role_id)) {
|
||||
case 1: roleName = "Manager"; break;
|
||||
case 2: roleName = "Handler"; break;
|
||||
case 3: roleName = "Staff"; break;
|
||||
default: roleName = "Others";
|
||||
}
|
||||
rowData = [
|
||||
row.name,
|
||||
row.email,
|
||||
row.mobile,
|
||||
row.role_id == 1 ? "Manager" : "Staff",
|
||||
roleName,
|
||||
`<span class="badge ${statusClass}">${statusText}</span>`,
|
||||
`<div class="btn-group dropdown">
|
||||
<a href="javascript:void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown">
|
||||
@ -1841,8 +1888,10 @@ table.dataTable tbody td {
|
||||
$('#email_addr').val('');
|
||||
$('#partner_id').val('');
|
||||
$('#mobile_no').val('');
|
||||
$('#locn').val('');
|
||||
$('.modal-title').html('Add Nhance Partner');
|
||||
// $('#locn').val('');
|
||||
$('#retention_rate').val('');
|
||||
$('#partner_nhance_branch_id').val('0');
|
||||
$('.modal-title').html('Add Nhance Partner Manager');
|
||||
$('#PartnerForm').attr('action', '<?php echo base_url('/user/partner');?>');
|
||||
let myModal = new bootstrap.Modal(document.getElementById('nhance-partner-modal'));
|
||||
myModal.show(); // open modal
|
||||
@ -1871,6 +1920,25 @@ table.dataTable tbody td {
|
||||
|
||||
}
|
||||
|
||||
|
||||
$('#retention_rate').on('input', function () {
|
||||
let value = this.value;
|
||||
|
||||
// Allow only digits and dot
|
||||
value = value.replace(/[^0-9.]/g, '');
|
||||
|
||||
// Allow only ONE dot
|
||||
const parts = value.split('.');
|
||||
if (parts.length > 2) {
|
||||
value = parts[0] + '.' + parts.slice(1).join('');
|
||||
}
|
||||
|
||||
// Allow max 2 decimals
|
||||
if (parts[1] && parts[1].length > 2) {
|
||||
value = parts[0] + '.' + parts[1].slice(0, 2);
|
||||
}
|
||||
|
||||
this.value = value;
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
@ -35,7 +35,7 @@
|
||||
|
||||
<div class="form-group col-md-3 file-input-group">
|
||||
<label for="file_input">Browser File<span class="text-danger">*</span></label>
|
||||
<input type="file" class="form-control file-input" id="kyc_docs_file" name="file_name" required accept=".pdf, .jpeg, .jpg, .png"
|
||||
<input type="file" class="form-control file-input" id="kyc_docs_file" name="file_name" required
|
||||
style="box-shadow: none !important; outline: none !important; border: none; height: unset !important;padding: 0px !important;background: transparent !important;">
|
||||
</div>
|
||||
|
||||
@ -278,7 +278,19 @@
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$(document).on('click', '.btn-download-kyc', function (e) {
|
||||
e.preventDefault(); // Prevent default link behavior
|
||||
// var kyc_id = $(this).attr('data-id');
|
||||
// var client_id = $(this).attr('data-client_id');
|
||||
var file = $(this).attr('data-file');
|
||||
if (file) {
|
||||
window.location.href = "<?= base_url('client/kyc/download_2') ?>/" + file;
|
||||
} else {
|
||||
toastr.warning('File is missing.');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// SOFT DELETE Functionality ---
|
||||
function deleteKycDoc(kyc_id,client_id) {
|
||||
@ -318,5 +330,29 @@
|
||||
});
|
||||
}
|
||||
|
||||
// Centralized Validation Function
|
||||
function validateFile(fileInput) {
|
||||
var file = fileInput.files[0];
|
||||
if (!file) {
|
||||
return true; // No file selected, considered valid or neutral
|
||||
}
|
||||
|
||||
var type = file.type;
|
||||
|
||||
// Check if the type is PDF or starts with 'image/'
|
||||
if (type === 'application/pdf' || type.startsWith('image/')) {
|
||||
return true; // Valid
|
||||
}
|
||||
|
||||
// Invalid format
|
||||
toastr.warning('Invalid file format. Only PDF or Image files are allowed.', 'WARNING!');
|
||||
$(fileInput).val(''); // clear file
|
||||
return false; // Invalid
|
||||
}
|
||||
|
||||
// Attach the centralized handler to BOTH classes
|
||||
$(document).on('change', '.file-input, .edit_file-input', function () {
|
||||
validateFile(this);
|
||||
});
|
||||
|
||||
</script>
|
||||
@ -12,8 +12,9 @@
|
||||
<td><?= esc($value['ui_docs_name']) ?></td>
|
||||
<td><?= esc($fileName) ?></td>
|
||||
<td>
|
||||
<a id="download_<?= esc($value['id']); ?>" data-id="<?= esc($value['id']); ?>" data-file="<?= $fileName ?>"
|
||||
class="mdi mdi-download mr-1 btn-download-kyc" style="font-size:18px;" download></a>
|
||||
<a class="mdi mdi-download mr-1 btn-download-kyc"
|
||||
data-file="<?= $fileName ?>"
|
||||
style="font-size:18px;"></a>
|
||||
|
||||
<a class="mdi mdi-pencil mr-1 btn-edit-kyc"
|
||||
data-id="<?= $value['id'] ?>"
|
||||
@ -24,6 +25,7 @@
|
||||
|
||||
<a class="mdi mdi-delete mr-1 btn-delete-kyc"
|
||||
data-id="<?= $value['id'] ?>"
|
||||
data-client_id="<?= $value['client_id'] ?>"
|
||||
style="font-size:18px;"></a>
|
||||
</td>
|
||||
</tr>
|
||||
@ -45,7 +47,7 @@
|
||||
<input type="file"
|
||||
name="file_name"
|
||||
id="kyc_docs_file_<?= $value['id'] ?>"
|
||||
class="form-control"
|
||||
class="form-control edit-file-input"
|
||||
style="box-shadow:none!important; outline:none!important; border:none; height:unset!important;padding: 0px !important;background: transparent !important;">
|
||||
</div>
|
||||
|
||||
|
||||
@ -99,12 +99,14 @@ $("#drive_file_upload_form").submit(function(event) {
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
if(res.status == true){
|
||||
toastr.success(res.message, 'Success');
|
||||
toastr.success(res.message, 'SUCCESS');
|
||||
appendFileTableBody(res.data.pt_files);
|
||||
}else{
|
||||
toastr.error(res.message, 'Error');
|
||||
toastr.warning(res.message, 'WARNING');
|
||||
}
|
||||
|
||||
$('#drive_file_upload_form')[0].reset();
|
||||
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
|
||||
356
app/Views/faq_list.php
Normal file
356
app/Views/faq_list.php
Normal file
@ -0,0 +1,356 @@
|
||||
<style>
|
||||
.dataTables_filter {
|
||||
position: absolute;
|
||||
}
|
||||
.dataTables_length label {height: 21px !important;}
|
||||
</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">Category</th>
|
||||
<th class="font-weight-medium">Question</th>
|
||||
<th class="font-weight-medium">Answer</th>
|
||||
<th class="font-weight-medium">Status</th>
|
||||
<th class="font-weight-medium">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if(isset($faq_list)) { $slno = 1; ?>
|
||||
<?php foreach($faq_list as $index => $row) { ?>
|
||||
<tr>
|
||||
<td class="text-center"><?= $slno++; ?></td>
|
||||
<td><?php $category = $row['category'] ? $row['category'] : 'N/A';
|
||||
echo (strlen($category) > 50)
|
||||
? htmlspecialchars(substr($category, 0, 50)) . "..."
|
||||
: htmlspecialchars($category);
|
||||
?></td>
|
||||
<td><?php $question = $row['question'] ? $row['question'] : 'N/A';
|
||||
echo (strlen($question) > 50)
|
||||
? htmlspecialchars(substr($question, 0, 50)) . "..."
|
||||
: htmlspecialchars($question);
|
||||
?></td>
|
||||
<td><?php $answer = $row['answer'] ? $row['answer'] : 'N/A';
|
||||
echo (strlen($answer) > 50)
|
||||
? htmlspecialchars(substr($answer, 0, 50)) . "..."
|
||||
: htmlspecialchars($answer);
|
||||
?></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="6" 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 modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="modalLabel">Add FAQ 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="FAQForm" enctype="multipart/form-data">
|
||||
<input type="hidden" name="faq_id" id="faq_id"/>
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="category">Category<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="category" name="category" placeholder="Enter Category" required>
|
||||
<small class="form-text text-muted text-end text-right">
|
||||
Please enter the sub-category separated by '/'. For Example: Category / Category-1 / Category-2
|
||||
</small>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="question">Question<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="question" name="question" placeholder="Enter Question" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="answer">Answer<span class="text-danger">*</span></label>
|
||||
<!-- <textarea id="answer" name="answer" class="form-control" required></textarea> -->
|
||||
<textarea id="answer" name="answer" class="form-control answer" rows="7">
|
||||
<!-- <h5>Hello {USER_NAME}, </h5>
|
||||
<p>We create simple, flat & responsive custom mail template.</p>
|
||||
<p>Please, write text here!</p> -->
|
||||
</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group text-right m-b-0">
|
||||
<button type="submit" class="btn app-btn-secondary" id="btnSubmit">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <script src="https://cdn.ckeditor.com/ckeditor5/39.0.1/classic/ckeditor.js"></script> -->
|
||||
<script>
|
||||
|
||||
// let faqEditor;
|
||||
let editor;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ClassicEditor
|
||||
// .create(document.querySelector('#answer'))
|
||||
// .then(editor => {
|
||||
// faqEditor = editor; // Save the instance here
|
||||
// })
|
||||
// .catch(error => { console.error(error); });
|
||||
|
||||
var table;
|
||||
$(document).ready(function () {
|
||||
//JoDit editor
|
||||
const editorConfig = {
|
||||
buttons: [
|
||||
"undo", "redo", "|",
|
||||
"paragraph",
|
||||
"bold", "italic", "strikethrough", "|",
|
||||
"superscript", "subscript", "|",
|
||||
"ul", "ol", "|",
|
||||
"outdent", "indent", "|",
|
||||
"blockquote", "table", "|",
|
||||
"align", "fontsize", "|",
|
||||
"source"
|
||||
],
|
||||
controls: {
|
||||
paragraph: {
|
||||
list: {
|
||||
p: "Normal",
|
||||
h1: "Heading 1",
|
||||
h2: "Heading 2",
|
||||
h3: "Heading 3",
|
||||
h4: "Heading 4"
|
||||
}
|
||||
}
|
||||
},
|
||||
fontsize: ["8px", "10px", "12px", "14px", "16px", "18px", "20px", "22px", "24px"], // Font sizes in pixels
|
||||
showPlaceholder: false,
|
||||
toolbarButtonSize: "small",
|
||||
toolbarAdaptive: false,
|
||||
saveHeightInStorage: true,
|
||||
minHeight: 400,
|
||||
height: 400, // Optional fixed height
|
||||
defaultMode: "1", // Start in WYSIWYG mode
|
||||
enableDragAndDropFileToEditor: true, // Allow file uploads via drag and drop
|
||||
placeholder: "Start typing here...", // Optional placeholder text
|
||||
};
|
||||
|
||||
|
||||
// 2. Initialize
|
||||
editor = Jodit.make("#answer", editorConfig);
|
||||
|
||||
var ticketsTable = $('#user-table');
|
||||
ticketsTable.DataTable({
|
||||
scrollX: true,
|
||||
// dom: "<'row'<'col-sm-7'f><'col-sm-5 text-right'B>>" + // Filter left, buttons right
|
||||
// "<'row'<'col-sm-12'tr>>" +
|
||||
// "<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
|
||||
dom: "<'row'<'col-sm-7'f><'col-sm-5 text-right'B>>" + // Filter left, buttons right
|
||||
"<'row'<'col-sm-12'tr>>" +
|
||||
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
|
||||
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
|
||||
buttons: [
|
||||
{
|
||||
text: 'Add',
|
||||
className: 'btn app-btn-primary mr-2',
|
||||
action: function(e, dt, node, config) {
|
||||
resetValues();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: 'FAQ-List',
|
||||
className: 'app-btn-primary ',
|
||||
exportOptions: {
|
||||
columns: ':not(:last-child)'
|
||||
},
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
language: {
|
||||
search: `
|
||||
<div class="datatable-search-wrapper" style="position:relative; display:inline-block;">
|
||||
_INPUT_
|
||||
<i class="mdi mdi-magnify datatable-search-icon"
|
||||
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666;"></i>
|
||||
<i class="mdi mdi-close-circle datatable-clear-icon"
|
||||
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666; display:none;"></i>
|
||||
</div>`,
|
||||
searchPlaceholder: "Search",
|
||||
emptyTable: '<div class="text-center text-muted">No Data found</div>'
|
||||
},
|
||||
paging: true, // Enable pagination
|
||||
pageLength: 10, // Set default number of rows per page (optional)
|
||||
// ordering: false,
|
||||
});
|
||||
});
|
||||
|
||||
$('.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 form = document.getElementById('FAQForm');
|
||||
let url = '<?= base_url('FAQ') ?>';
|
||||
let method = "POST";
|
||||
let faq_id = el ? $(el).data('id') : null;
|
||||
|
||||
let formData;
|
||||
|
||||
if (type === 'submit') {
|
||||
// CREATE FORMDATA FROM FORM
|
||||
formData = new FormData(form);
|
||||
formData.set('return_type', 'web');
|
||||
|
||||
} else if (type == 'edit') {
|
||||
method = "GET";
|
||||
if (faq_id) url += '?faq_id=' + faq_id ;
|
||||
$('#modalLabel').text('Edit FAQ Details');
|
||||
$('#FAQForm')[0].reset();
|
||||
|
||||
} else if (type == 'remove') {
|
||||
method = "DELETE";
|
||||
if (faq_id) url += '?faq_id=' + faq_id ;
|
||||
}
|
||||
|
||||
$('.loader, .loader-mask').fadeIn();
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: method,
|
||||
data: (type === 'submit') ? formData : null,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
dataType: 'json',
|
||||
success: function (response) {
|
||||
console.log('Response:', response);
|
||||
if (response.status === 'success' || response.status === true) {
|
||||
if (type == 'edit') {
|
||||
let record = response.data.faq_list[0]; // single record
|
||||
appendEditData(record);
|
||||
} else if(type == 'remove'){
|
||||
toastr.success(response.message, 'Success');
|
||||
// if(el) $(el).closest('tr').remove();
|
||||
window.location.reload();
|
||||
// window.location.href = "<?= base_url('FAQ?return_type=web') ?>";
|
||||
} else if(type == 'submit'){
|
||||
toastr.success(response.message, 'Success');
|
||||
var myModal = new bootstrap.Modal(document.getElementById('con-close-modal'));
|
||||
myModal.hide();
|
||||
$('#FAQForm')[0].reset();
|
||||
window.location.reload();
|
||||
}
|
||||
} else {
|
||||
toastr.warning(response.message, 'Warning');
|
||||
}
|
||||
$('.loader, .loader-mask').fadeOut();
|
||||
},
|
||||
error: function () {
|
||||
$('.loader, .loader-mask').fadeOut();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function resetValues(){
|
||||
$('#modalLabel').text('Add FAQ Details');
|
||||
$('#FAQForm')[0].reset();
|
||||
if (typeof editor !== 'undefined') {
|
||||
editor.value = '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function appendEditData(data) {
|
||||
$('#FAQForm')[0].reset();
|
||||
$('#faq_id').val(data.id);
|
||||
$('#category').val(data.category);
|
||||
$('#question').val(data.question);
|
||||
if (editor) {
|
||||
editor.value = data.answer || '';
|
||||
}
|
||||
openModal();
|
||||
}
|
||||
|
||||
|
||||
$('#FAQForm').on('submit', function(e) {
|
||||
e.preventDefault();
|
||||
const form = this;
|
||||
|
||||
// HTML5 built-in validation
|
||||
if (!form.checkValidity()) {
|
||||
form.reportValidity(); // shows required/pattern tooltips
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof editor !== 'undefined') {
|
||||
// Strip HTML tags and trim whitespace to see if there is actual text
|
||||
const plainText = editor.value.replace(/<[^>]*>/g, '').trim();
|
||||
|
||||
// Check if it's truly empty or just contains empty tags like <p><br></p>
|
||||
if (editor.value === '' || plainText === '') {
|
||||
toastr.warning("Answer is required", 'Warning');
|
||||
return; // Stop the function here
|
||||
}
|
||||
}
|
||||
|
||||
// If valid, submit via AJAX
|
||||
handleSaveEditAndDelete('submit');
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
506
app/Views/frontend_content_list.php
Normal file
506
app/Views/frontend_content_list.php
Normal file
@ -0,0 +1,506 @@
|
||||
<style>
|
||||
.dataTables_filter {
|
||||
position: absolute;
|
||||
}
|
||||
.dataTables_length label {height: 21px !important;}
|
||||
</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>
|
||||
<!-- `content` `notes` -->
|
||||
<th class="font-weight-medium">S.No.</th>
|
||||
<th class="font-weight-medium">Type</th>
|
||||
<th class="font-weight-medium">Content Section</th>
|
||||
<th class="font-weight-medium">Heading</th>
|
||||
<th class="font-weight-medium">Status</th>
|
||||
<th class="font-weight-medium">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if(isset($data['fe_list'])) { $slno = 1; ?>
|
||||
<?php foreach($data['fe_list'] as $index => $row) { ?>
|
||||
<tr>
|
||||
<td class="text-center"><?= $slno++; ?></td>
|
||||
<td><?= $row['type']; ?></td>
|
||||
<td><?= $row['content_section']; ?></td>
|
||||
<td><?= $row['heading']; ?></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-status="<?= $row['is_active']; ?>" 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="6" 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 modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="modalLabel">Add Front End Content</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="frontEndContentForm" enctype="multipart/form-data">
|
||||
<input type="hidden" name="fe_id" id="fe_id"/>
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
<div class="col-md-4">
|
||||
<label for="type">Type<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="type" name="type" placeholder="Enter Type" required>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label for="content_section">Content Section<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="content_section" name="content_section" placeholder="Enter Content Section" required>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label for="branch_name">Heading<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="heading" name="heading" placeholder="Enter Heading" required>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="content">Content<span class="text-danger">*</span></label>
|
||||
<textarea id="content" name="content" class="form-control content" rows="5">
|
||||
<!-- <h5>Hello {USER_NAME}, </h5>
|
||||
<p>We create simple, flat & responsive custom mail template.</p>
|
||||
<p>Please, write text here!</p> -->
|
||||
</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="notes">Notes<span class="text-danger">*</span></label>
|
||||
<textarea id="notes" name="notes" class="form-control notes" rows="5">
|
||||
<!-- <h5>Hello {USER_NAME}, </h5>
|
||||
<p>We create simple, flat & responsive custom mail template.</p>
|
||||
<p>Please, write text here!</p> -->
|
||||
</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group text-right m-b-0">
|
||||
<button type="submit" class="btn app-btn-secondary" id="btnSubmit">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var table;
|
||||
let content_editor;
|
||||
let notes_editor;
|
||||
$(document).ready(function () {
|
||||
// var baseUrl = '<?php echo base_url(); ?>';
|
||||
const editorConfig = {
|
||||
buttons: [
|
||||
"undo", "redo", "|",
|
||||
"paragraph",
|
||||
"bold", "italic", "strikethrough", "|",
|
||||
"superscript", "subscript", "|",
|
||||
"ul", "ol", "|",
|
||||
"outdent", "indent", "|",
|
||||
"blockquote", "table", "|",
|
||||
"align", "fontsize", "|",
|
||||
"source"
|
||||
],
|
||||
controls: {
|
||||
paragraph: {
|
||||
list: {
|
||||
p: "Normal",
|
||||
h1: "Heading 1",
|
||||
h2: "Heading 2",
|
||||
h3: "Heading 3",
|
||||
h4: "Heading 4"
|
||||
}
|
||||
}
|
||||
},
|
||||
fontsize: ["8px", "10px", "12px", "14px", "16px", "18px", "20px", "22px", "24px"], // Font sizes in pixels
|
||||
showPlaceholder: false,
|
||||
toolbarButtonSize: "small",
|
||||
toolbarAdaptive: false,
|
||||
saveHeightInStorage: true,
|
||||
minHeight: 400,
|
||||
height: 400, // Optional fixed height
|
||||
defaultMode: "1", // Start in WYSIWYG mode
|
||||
enableDragAndDropFileToEditor: true, // Allow file uploads via drag and drop
|
||||
placeholder: "Start typing here...", // Optional placeholder text
|
||||
};
|
||||
// const editorConfig = {
|
||||
// buttons: [
|
||||
// "undo", "redo", "|",
|
||||
// "paragraph",
|
||||
// "bold", "italic", "strikethrough", "|",
|
||||
// "superscript", "subscript", "|",
|
||||
// "ul", "ol", "|",
|
||||
// "outdent", "indent", "|",
|
||||
// "blockquote", "table", "|",
|
||||
// "align", "fontsize", "|",
|
||||
// "image", "video", "|", // <--- Added image and video here
|
||||
// "source"
|
||||
// ],
|
||||
// // Configuration for handling uploads
|
||||
// uploader: {
|
||||
// insertImageAsBase64URI: true, // Simple way to handle images without a backend
|
||||
// url: 'http://localhost/nhance/frontend_content_files',
|
||||
// format: 'json',
|
||||
// prepareData: function (formData) {
|
||||
// return formData;
|
||||
// },
|
||||
// process: function (resp) {
|
||||
// return {
|
||||
// files: resp.data.files,
|
||||
// baseurl: resp.data.baseurl,
|
||||
// error: resp.error,
|
||||
// msg: resp.msg
|
||||
// };
|
||||
// },
|
||||
// // This tells Jodit how to build the <img> tag
|
||||
// defaultHandlerSuccess: function (data) {
|
||||
// const url = data.baseurl + data.files[0];
|
||||
// this.selection.insertImage(url);
|
||||
// },
|
||||
// error: function (e) {
|
||||
// console.error("Upload Error: ", e);
|
||||
// }
|
||||
// },
|
||||
// // Configuration for the file browser (optional)
|
||||
// filebrowser: {
|
||||
// ajax: {
|
||||
// url: 'http://localhost/nhance/frontend_content_files',
|
||||
// data: {
|
||||
// action: 'files' // Custom parameter for your PHP logic
|
||||
// }
|
||||
// },
|
||||
// // This allows you to delete or rename files directly from the browser popup
|
||||
// removeButtons: [],
|
||||
// createNewFolder: false,
|
||||
// deleteFile: true,
|
||||
// },
|
||||
// controls: {
|
||||
// paragraph: {
|
||||
// list: {
|
||||
// p: "Normal",
|
||||
// h1: "Heading 1",
|
||||
// h2: "Heading 2",
|
||||
// h3: "Heading 3",
|
||||
// h4: "Heading 4"
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
// fontsize: ["8px", "10px", "12px", "14px", "16px", "18px", "20px", "22px", "24px"],
|
||||
// showPlaceholder: false,
|
||||
// toolbarButtonSize: "small",
|
||||
// toolbarAdaptive: false,
|
||||
// saveHeightInStorage: true,
|
||||
// minHeight: 400,
|
||||
// height: 400,
|
||||
// defaultMode: "1",
|
||||
// enableDragAndDropFileToEditor: true,
|
||||
// placeholder: "Start typing here...",
|
||||
// };
|
||||
content_editor = Jodit.make("#content", editorConfig);
|
||||
notes_editor = Jodit.make("#notes", editorConfig);
|
||||
|
||||
var ticketsTable = $('#user-table');
|
||||
ticketsTable.DataTable({
|
||||
scrollX: true,
|
||||
// dom: "<'row'<'col-sm-7'f><'col-sm-5 text-right'B>>" + // Filter left, buttons right
|
||||
// "<'row'<'col-sm-12'tr>>" +
|
||||
// "<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
|
||||
dom: "<'row'<'col-sm-7'f><'col-sm-5 text-right'B>>" + // Filter left, buttons right
|
||||
"<'row'<'col-sm-12'tr>>" +
|
||||
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
|
||||
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
|
||||
buttons: [
|
||||
{
|
||||
text: 'Add',
|
||||
className: 'btn app-btn-primary mr-2',
|
||||
action: function(e, dt, node, config) {
|
||||
resetValues();openModal();// $('#btnSubmit').removeClass('d-none');
|
||||
}
|
||||
},
|
||||
{
|
||||
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: 'Front End Content',
|
||||
className: 'app-btn-primary ',
|
||||
exportOptions: {
|
||||
columns: ':not(:last-child)'
|
||||
},
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
language: {
|
||||
search: `
|
||||
<div class="datatable-search-wrapper" style="position:relative; display:inline-block;">
|
||||
_INPUT_
|
||||
<i class="mdi mdi-magnify datatable-search-icon"
|
||||
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666;"></i>
|
||||
<i class="mdi mdi-close-circle datatable-clear-icon"
|
||||
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666; display:none;"></i>
|
||||
</div>`,
|
||||
searchPlaceholder: "Search",
|
||||
emptyTable: '<div class="text-center text-muted">No Data found</div>'
|
||||
},
|
||||
paging: true, // Enable pagination
|
||||
pageLength: 10, // Set default number of rows per page (optional)
|
||||
// ordering: false,
|
||||
});
|
||||
});
|
||||
|
||||
$('.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 Front End Content');
|
||||
// requestData.pk = pk;
|
||||
|
||||
// if(type == 'submit'){
|
||||
// $("#frontEndContentForm").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 Front End Content');
|
||||
// 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 form = document.getElementById('frontEndContentForm');
|
||||
let url = '<?= base_url('frontend_content') ?>';
|
||||
let method = "POST";
|
||||
let fe_id = el ? $(el).data('id') : null;
|
||||
let fe_status = 1;
|
||||
let formData;
|
||||
|
||||
|
||||
|
||||
if (type === 'submit') {
|
||||
// CREATE FORMDATA FROM FORM
|
||||
formData = new FormData(form);
|
||||
} else if (type == 'edit') {
|
||||
method = "GET";
|
||||
if (fe_id) url += '?fe_id=' + fe_id ;
|
||||
fe_status = el ? $(el).data('status') : 1;
|
||||
// $('#btnSubmit').addClass('d-none');
|
||||
// let name_text = fe_status ? "Edit" : "View";
|
||||
$('#modalLabel').text('Edit Front End Content');
|
||||
$('#frontEndContentForm')[0].reset();
|
||||
|
||||
} else if (type == 'remove') {
|
||||
method = "DELETE";
|
||||
if (fe_id) url += '?fe_id=' + fe_id ;
|
||||
}
|
||||
|
||||
// if (typeof fe_status !== 'undefined' && fe_status == 1) {
|
||||
// // $('#btnSubmit').addClass('d-none');
|
||||
// return; // optional: stop further actions
|
||||
// }else{
|
||||
// // $('#btnSubmit').removeClass('d-none');
|
||||
// }
|
||||
|
||||
$('.loader, .loader-mask').fadeIn();
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: method,
|
||||
data: (type === 'submit') ? formData : null,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
dataType: 'json',
|
||||
success: function (response) {
|
||||
console.log('Response:', response);
|
||||
if (response.status === 'success' || response.status === true) {
|
||||
if (type == 'edit') {
|
||||
let record = response.data.fe_list[0]; // single record
|
||||
appendEditData(record);
|
||||
} else if(type == 'remove'){
|
||||
toastr.success(response.message, 'Success');
|
||||
// if(el) $(el).closest('tr').remove();
|
||||
window.location.reload();
|
||||
} else if(type == 'submit'){
|
||||
toastr.success(response.message, 'Success');
|
||||
var myModal = new bootstrap.Modal(document.getElementById('con-close-modal'));
|
||||
myModal.hide();
|
||||
$('#frontEndContentForm')[0].reset();
|
||||
window.location.reload();
|
||||
}
|
||||
} else {
|
||||
toastr.warning(response.message, 'Warning');
|
||||
}
|
||||
$('.loader, .loader-mask').fadeOut();
|
||||
},
|
||||
error: function () {
|
||||
$('.loader, .loader-mask').fadeOut();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function resetValues(){
|
||||
$('#modalLabel').text('Add Front End Content');
|
||||
$('#frontEndContentForm')[0].reset();
|
||||
if (typeof content_editor !== 'undefined') {
|
||||
content_editor.value = '';
|
||||
}
|
||||
if (typeof notes_editor !== 'undefined') {
|
||||
notes_editor.value = '';
|
||||
}
|
||||
}
|
||||
|
||||
function appendEditData(data) {
|
||||
$('#frontEndContentForm')[0].reset();
|
||||
$('#fe_id').val(data.id);
|
||||
$('#type').val(data.type);
|
||||
$('#content_section').val(data.content_section);
|
||||
$('#heading').val(data.heading);
|
||||
// $('#content').val(data.content);
|
||||
// $('#notes').val(data.notes);
|
||||
if (content_editor) {
|
||||
content_editor.value = data.content || '';
|
||||
}
|
||||
if (notes_editor) {
|
||||
notes_editor.value = data.notes || '';
|
||||
}
|
||||
openModal();
|
||||
}
|
||||
|
||||
$('#frontEndContentForm').on('submit', function(e) {
|
||||
e.preventDefault();
|
||||
const form = this;
|
||||
|
||||
// HTML5 built-in validation
|
||||
if (!form.checkValidity()) {
|
||||
form.reportValidity(); // shows required/pattern tooltips
|
||||
return;
|
||||
}
|
||||
|
||||
// Content validation
|
||||
if (typeof content_editor !== 'undefined') {
|
||||
if (isEditorEmpty(content_editor.value)) {
|
||||
toastr.warning("Content is required", 'Warning');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Notes validation
|
||||
if (typeof notes_editor !== 'undefined') {
|
||||
if (isEditorEmpty(notes_editor.value)) {
|
||||
toastr.warning("Notes is required", 'Warning');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// If valid, submit via AJAX
|
||||
handleSaveEditAndDelete('submit');
|
||||
});
|
||||
|
||||
function isEditorEmpty(html) {
|
||||
if (!html) return true;
|
||||
|
||||
// Remove tags, , and trim
|
||||
const text = html
|
||||
.replace(/<[^>]*>/g, '')
|
||||
.replace(/ /g, '')
|
||||
.trim();
|
||||
|
||||
return text.length === 0;
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
@ -1,319 +0,0 @@
|
||||
<style>
|
||||
.dataTables_filter {
|
||||
position: absolute;
|
||||
}
|
||||
.dataTables_length label {height: 21px !important;}
|
||||
</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>
|
||||
<!-- `content` `notes` -->
|
||||
<th class="font-weight-medium">S.No.</th>
|
||||
<th class="font-weight-medium">Type</th>
|
||||
<th class="font-weight-medium">Content Section</th>
|
||||
<th class="font-weight-medium">Heading</th>
|
||||
<!-- <th class="font-weight-medium">Status</th> -->
|
||||
<th class="font-weight-medium">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if(isset($test)) { $slno = 1; ?>
|
||||
<?php foreach($test as $index => $row) { ?>
|
||||
<tr>
|
||||
<td class="text-center"><?= $slno++; ?></td>
|
||||
<td><?= $row['type']; ?></td>
|
||||
<td><?= $row['content_section']; ?></td>
|
||||
<td><?= $row['heading']; ?></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 modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="modalLabel">Add Front End Content</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
<div class="modal-body p-4">
|
||||
<form id="frontEndContentForm" enctype="multipart/form-data">
|
||||
<input type="hidden" name="pk" id="fe_id"/>
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
<div class="col-md-4">
|
||||
<label for="type">Type<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="type" name="type" placeholder="Enter Type" required>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label for="content_section">Content Section<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="content_section" name="content_section" placeholder="Enter Content Section" required>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label for="branch_name">Heading<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="heading" name="heading" placeholder="Enter Heading" required>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="btn app-btn-secondary waves-effect waves-light text-end" onclick="AddContentsAndNotes()">Add Contents And Notes</button>
|
||||
<table>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
<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
|
||||
dom: "<'row'<'col-sm-7'f><'col-sm-5 text-right'B>>" + // Filter left, buttons right
|
||||
"<'row'<'col-sm-12'tr>>" +
|
||||
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
|
||||
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
|
||||
buttons: [
|
||||
{
|
||||
text: 'Add',
|
||||
className: 'btn app-btn-primary mr-2',
|
||||
action: function(e, dt, node, config) {
|
||||
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: 'Front End Content',
|
||||
className: 'app-btn-primary ',
|
||||
exportOptions: {
|
||||
columns: ':not(:last-child)'
|
||||
},
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
language: {
|
||||
search: `
|
||||
<div class="datatable-search-wrapper" style="position:relative; display:inline-block;">
|
||||
_INPUT_
|
||||
<i class="mdi mdi-magnify datatable-search-icon"
|
||||
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666;"></i>
|
||||
<i class="mdi mdi-close-circle datatable-clear-icon"
|
||||
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666; display:none;"></i>
|
||||
</div>`,
|
||||
searchPlaceholder: "Search",
|
||||
emptyTable: '<div class="text-center text-muted">No Data found</div>'
|
||||
},
|
||||
paging: true, // Enable pagination
|
||||
pageLength: 10, // Set default number of rows per page (optional)
|
||||
// ordering: false,
|
||||
});
|
||||
});
|
||||
|
||||
$('.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 Front End Content');
|
||||
// requestData.pk = pk;
|
||||
|
||||
// if(type == 'submit'){
|
||||
// $("#frontEndContentForm").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 Front End Content');
|
||||
// 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'){
|
||||
$("#frontEndContentForm").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 Front End Content');
|
||||
$('#frontEndContentForm')[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();
|
||||
window.location.reload();
|
||||
} else if(type == 'submit'){
|
||||
toastr.success(response.message, 'Success');
|
||||
var myModal = new bootstrap.Modal(document.getElementById('con-close-modal'));
|
||||
myModal.hide();
|
||||
$('#frontEndContentForm')[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 Front End Content');
|
||||
$('#frontEndContentForm')[0].reset();
|
||||
}
|
||||
|
||||
function appendEditData(data){
|
||||
$('#fe_id').val(data[0]['id']);
|
||||
$('#branch_name').val(data[0]['branch_name']);
|
||||
openModal()
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -98,7 +98,7 @@ table.dataTable tbody td { padding: 4px 4px !important; }
|
||||
<label>Invoice Date <span class="text-danger"></span></label>
|
||||
<input class="form-control" type="date" id="invoiceDate" required value="<?= isset($invoice['invoice_date']) ? $invoice['invoice_date'] : '' ?>" >
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<!-- <div class="form-group col-md-3">
|
||||
<label for="agents"> Agents <span class="text-danger"></span></label>
|
||||
|
||||
<select class="form-control" id="agentSelect" name="agents_id" onchange="loadPolicies()" required>
|
||||
@ -114,6 +114,23 @@ table.dataTable tbody td { padding: 4px 4px !important; }
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div> -->
|
||||
<div class="form-group col-md-3">
|
||||
<label for="pos"> POS <span class="text-danger"></span></label>
|
||||
|
||||
<select class="form-control" id="posSelect" name="pos_id" onchange="loadPolicies()" required>
|
||||
<option value="">Select pos</option>
|
||||
<?php
|
||||
if(isset($pos_list) && count($pos_list)) {
|
||||
foreach($pos_list as $pos): ?>
|
||||
<option value="<?= $pos['id'] ?>"
|
||||
<?= isset($invoice['pos_id']) && $invoice['pos_id'] == $pos['id'] ? 'selected' : '' ?>>
|
||||
<?= $pos['name'] ?> - <?= $pos['pos_code'] ?>
|
||||
</option>
|
||||
<?php endforeach;
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label>Policy Till Date<span class="text-danger"></span></label>
|
||||
@ -481,17 +498,20 @@ table.dataTable tbody td { padding: 4px 4px !important; }
|
||||
}
|
||||
|
||||
|
||||
// ---- Filter policies by agent/date ----
|
||||
// ---- Filter policies by agent/POS/date ----
|
||||
function filterPolicies() {
|
||||
const fromDate = getEl('fromDate')?.value || '';
|
||||
const toDate = getEl('toDate')?.value || '';
|
||||
const agentId = getEl('agentSelect')?.value || '';
|
||||
// const agentId = getEl('agentSelect')?.value || '';
|
||||
const posId = getEl('posSelect')?.value || '';
|
||||
const policyTillDate = getEl('policyTillDate')?.value || '';
|
||||
|
||||
if (!agentId || agentId === '0') return toastr.warning('Please select an agent', 'Required');
|
||||
// if (!agentId || agentId === '0') return toastr.warning('Please select an agent', 'Required');
|
||||
if (!posId || posId === '0') return toastr.warning('Please select an POS', 'Required');
|
||||
|
||||
filteredPolicies = window.allPolicies.filter(p => {
|
||||
if (String(p.agentId) !== String(agentId)) return false;
|
||||
// if (String(p.agentId) !== String(agentId)) return false;
|
||||
// if (String(p.posId) !== String(posId)) return false;
|
||||
if (policyTillDate && p.date_db > policyTillDate) return false;
|
||||
if (fromDate && p.date_db < fromDate) return false;
|
||||
if (toDate && p.date_db > toDate) return false;
|
||||
@ -503,7 +523,9 @@ table.dataTable tbody td { padding: 4px 4px !important; }
|
||||
|
||||
// ---- Load policies for selected agent ----
|
||||
function loadPolicies() {
|
||||
const agentId = getEl('agentSelect')?.value || '';
|
||||
// const agentId = getEl('agentSelect')?.value || '';
|
||||
const posId = getEl('posSelect')?.value || '';
|
||||
console.log('-->',posId);
|
||||
const policyTillDate = getEl('policyTillDate')?.value || '';
|
||||
const list = getEl('policyListBody');
|
||||
if (!list) return;
|
||||
@ -518,16 +540,30 @@ table.dataTable tbody td { padding: 4px 4px !important; }
|
||||
|
||||
list.innerHTML = '';
|
||||
|
||||
if (!agentId || agentId === '0') {
|
||||
list.innerHTML = `<tr><td colspan="${colspan}" class="text-center text-danger">Please select an agent</td></tr>`;
|
||||
// if (!agentId || agentId === '0') {
|
||||
// list.innerHTML = `<tr><td colspan="${colspan}" class="text-center text-danger">Please select an agent</td></tr>`;
|
||||
// updateSummary();
|
||||
// reloadDataTable();
|
||||
// return;
|
||||
// }
|
||||
|
||||
// Filter policies for the selected agent
|
||||
// filteredPolicies = window.allPolicies.filter(p => {
|
||||
// if (String(p.agentId) !== String(agentId)) return false;
|
||||
// if (policyTillDate && p.date_db > policyTillDate) return false;
|
||||
// return true;
|
||||
// });
|
||||
|
||||
if (!posId || posId === '0') {
|
||||
list.innerHTML = `<tr><td colspan="${colspan}" class="text-center text-danger">Please select a POS</td></tr>`;
|
||||
updateSummary();
|
||||
reloadDataTable();
|
||||
return;
|
||||
}
|
||||
|
||||
// Filter policies for the selected agent
|
||||
// Filter policies for the selected POS
|
||||
filteredPolicies = window.allPolicies.filter(p => {
|
||||
if (String(p.agentId) !== String(agentId)) return false;
|
||||
if (String(p.posId) !== String(posId)) return false;
|
||||
if (policyTillDate && p.date_db > policyTillDate) return false;
|
||||
return true;
|
||||
});
|
||||
@ -652,8 +688,11 @@ table.dataTable tbody td { padding: 4px 4px !important; }
|
||||
|
||||
// ---- Show More Policies ----
|
||||
function showMorePolicies() {
|
||||
const agentId = getEl('agentSelect')?.value || '';
|
||||
if (!agentId) return toastr.warning('Please select an agent', 'Required');
|
||||
// const agentId = getEl('agentSelect')?.value || '';
|
||||
// if (!agentId) return toastr.warning('Please select an agent', 'Required');
|
||||
|
||||
const posId = getEl('posSelect')?.value || '';
|
||||
if (!posId) return toastr.warning('Please select an POS', 'Required');
|
||||
|
||||
if (!window.extraPolicies || window.extraPolicies.length === 0) {
|
||||
return toastr.info('No more policies available.', 'Information');
|
||||
@ -664,11 +703,13 @@ table.dataTable tbody td { padding: 4px 4px !important; }
|
||||
|
||||
// Filter extraPolicies: same agent + not already in filteredPolicies
|
||||
const newPolicies = window.extraPolicies.filter(p => {
|
||||
return String(p.agentId) === String(agentId) && !existingPolicyIds.has(p.id);
|
||||
// return String(p.agentId) === String(agentId) && !existingPolicyIds.has(p.id);
|
||||
return String(p.posId) === String(posId) && !existingPolicyIds.has(p.id);
|
||||
});
|
||||
|
||||
if (newPolicies.length === 0) {
|
||||
toastr.info('No more policies available for this agent.', 'Information');
|
||||
// toastr.info('No more policies available for this agent.', 'Information');
|
||||
toastr.info('No more policies available for this POS.', 'Information');
|
||||
return;
|
||||
}
|
||||
|
||||
@ -690,13 +731,15 @@ table.dataTable tbody td { padding: 4px 4px !important; }
|
||||
|
||||
// ---- Save invoice ----
|
||||
function saveInvoice() {
|
||||
const agentId = getEl('agentSelect')?.value || '';
|
||||
// const agentId = getEl('agentSelect')?.value || '';
|
||||
const posId = getEl('posSelect')?.value || '';
|
||||
const invoiceNo = getEl('invoiceNo')?.value || '';
|
||||
const invoiceDate = getEl('invoiceDate')?.value || '';
|
||||
const policyTillDate = getEl('policyTillDate')?.value || '';
|
||||
const invoiceID = getEl('invoiceID')?.value || '';
|
||||
|
||||
if (!agentId || agentId === '0') return toastr.warning('Please select an agent', 'Required');
|
||||
// if (!agentId || agentId === '0') return toastr.warning('Please select an agent', 'Required');
|
||||
if (!posId || posId === '0') return toastr.warning('Please select an pos', 'Required');
|
||||
if (!invoiceDate) return toastr.warning('Please select invoice date', 'Required');
|
||||
if (selectedPolicies.size === 0) return toastr.warning('Please select at least one policy', 'Required');
|
||||
|
||||
@ -728,10 +771,11 @@ table.dataTable tbody td { padding: 4px 4px !important; }
|
||||
const invoiceData = {
|
||||
invoice_id: invoiceID,
|
||||
invoice_no: invoiceNo,
|
||||
agent_id: agentId,
|
||||
// agent_id: agentId,
|
||||
invoice_date: invoiceDate,
|
||||
invoice_amount: totalAmount,
|
||||
policies: policies
|
||||
policies: policies,
|
||||
pos_id: posId
|
||||
};
|
||||
|
||||
// console.log(invoiceData);return true;
|
||||
@ -774,7 +818,8 @@ table.dataTable tbody td { padding: 4px 4px !important; }
|
||||
|
||||
const invoiceDateEl = getEl('invoiceDate');
|
||||
const policyTillDateEl = getEl('policyTillDate');
|
||||
const agentSelectEl = getEl('agentSelect');
|
||||
// const agentSelectEl = getEl('agentSelect');
|
||||
const posSelectEl = getEl('posSelect');
|
||||
|
||||
// Set max date (today)
|
||||
if (invoiceDateEl) invoiceDateEl.max = today;
|
||||
@ -783,20 +828,25 @@ table.dataTable tbody td { padding: 4px 4px !important; }
|
||||
if (invoiceType == 'add') {
|
||||
|
||||
// -------- ADD MODE --------
|
||||
if (agentSelectEl) agentSelectEl.value = '';
|
||||
// if (agentSelectEl) agentSelectEl.value = '';
|
||||
if (posSelectEl) posSelectEl.value = '';
|
||||
if (invoiceDateEl) invoiceDateEl.required = true;
|
||||
if (policyTillDateEl) policyTillDateEl.required = true;
|
||||
if (agentSelectEl) agentSelectEl.required = true;
|
||||
// if (agentSelectEl) agentSelectEl.required = true;
|
||||
if (posSelectEl) posSelectEl.required = true;
|
||||
|
||||
// Enable Select2
|
||||
$('#agentSelect').prop('disabled', false).select2();
|
||||
// $('#agentSelect').prop('disabled', false).select2();
|
||||
$('#posSelect').prop('disabled', false).select2();
|
||||
}
|
||||
else {
|
||||
// -------- EDIT,ADJUSTMENT MODE --------
|
||||
if (agentSelectEl) agentSelectEl.readOnly = true;
|
||||
// if (agentSelectEl) agentSelectEl.readOnly = true;
|
||||
if (posSelectEl) posSelectEl.readOnly = true;
|
||||
|
||||
// Disable Select2 (readonly)
|
||||
$('#agentSelect').prop('disabled', true);
|
||||
// $('#agentSelect').prop('disabled', true);
|
||||
$('#posSelect').prop('disabled', true);
|
||||
|
||||
// Remove red star (*) from label
|
||||
const agentLabel = document.querySelector('label[for="agents"] .text-danger');
|
||||
@ -810,9 +860,16 @@ table.dataTable tbody td { padding: 4px 4px !important; }
|
||||
if (getEl('policyTillDate')) getEl('policyTillDate').valueAsDate = new Date();
|
||||
}
|
||||
|
||||
const agentEl = getEl('agentSelect');
|
||||
if (agentEl) {
|
||||
agentEl.addEventListener('change', () => {
|
||||
// const agentEl = getEl('agentSelect');
|
||||
// if (agentEl) {
|
||||
// agentEl.addEventListener('change', () => {
|
||||
// selectedPolicies.clear();
|
||||
// loadPolicies();
|
||||
// });
|
||||
// }
|
||||
const posEl = getEl('posSelect');
|
||||
if (posEl) {
|
||||
posEl.addEventListener('change', () => {
|
||||
selectedPolicies.clear();
|
||||
loadPolicies();
|
||||
});
|
||||
@ -826,10 +883,12 @@ table.dataTable tbody td { padding: 4px 4px !important; }
|
||||
|
||||
if (policyTillDateEl) policyTillDateEl.addEventListener('change', loadPolicies);
|
||||
|
||||
if (agentEl && agentEl.value && agentEl.value !== '0') loadPolicies();
|
||||
// if (agentEl && agentEl.value && agentEl.value !== '0') loadPolicies();
|
||||
if (posEl && posEl.value && posEl.value !== '0') loadPolicies();
|
||||
else {
|
||||
const body = getEl('policyListBody');
|
||||
if (body) body.innerHTML = `<tr><td colspan="${colspan}" class="text-center">Please select an agent</td></tr>`;
|
||||
// if (body) body.innerHTML = `<tr><td colspan="${colspan}" class="text-center">Please select an agent</td></tr>`;
|
||||
if (body) body.innerHTML = `<tr><td colspan="${colspan}" class="text-center">Please select a POS</td></tr>`;
|
||||
reloadDataTable();
|
||||
}
|
||||
});
|
||||
@ -843,6 +902,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
// Determine if we should freeze edits
|
||||
const shouldFreeze =
|
||||
(freeze > 0 && type === 'view') ||
|
||||
(freeze > 0 && type === 'edit') ||
|
||||
(payout_status === 2 && (type === 'adjustment' || type === 'edit'));
|
||||
|
||||
|
||||
@ -95,6 +95,7 @@
|
||||
<div class="invoice-container">
|
||||
<table>
|
||||
|
||||
<!--
|
||||
<?php if(isset($agent_name)) : ?>
|
||||
<tr>
|
||||
<td colspan="3" class="header"><?= $agent_name ?></td>
|
||||
@ -106,7 +107,42 @@
|
||||
<td colspan="3" class="header"><?= $agent_address ?></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
-->
|
||||
|
||||
<?php if(isset($pos_name)) : ?>
|
||||
<tr>
|
||||
<td colspan="3" class="header"><?= $pos_name ?></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if(isset($pos_address) && !empty($pos_address)) :
|
||||
$pos_a = trim($pos_address ?? '');
|
||||
$pos_c = trim($pos_city ?? '');
|
||||
$pos_s = trim($pos_state ?? '');
|
||||
$pos_p = trim($pos_pincode ?? '');
|
||||
if ($pos_p === '0' || $pos_p === 0) {$pos_p = '';}
|
||||
$address = '';
|
||||
if ($pos_a && $pos_c && $pos_s && $pos_p) { $address = "$pos_a, <br>$pos_c, $pos_s - $pos_p.";
|
||||
} elseif ($pos_a && $pos_c && $pos_s) { $address = "$pos_a, <br>$pos_c, $pos_s.";
|
||||
} elseif ($pos_a && $pos_c && $pos_p) { $address = "$pos_a, <br>$pos_c - $pos_p.";
|
||||
} elseif ($pos_a && $pos_s && $pos_p) { $address = "$pos_a, <br>$pos_s - $pos_p.";
|
||||
} elseif ($pos_a && $pos_c) { $address = "$pos_a, <br>$pos_c.";
|
||||
} elseif ($pos_a && $pos_s) { $address = "$pos_a, <br>$pos_s.";
|
||||
} elseif ($pos_a && $pos_p) { $address = "$pos_a - $pos_p.";
|
||||
} elseif ($pos_c && $pos_s && $pos_p) { $address = "$pos_c, $pos_s - $pos_p.";
|
||||
} elseif ($pos_c && $pos_s) { $address = "$pos_c, $pos_s.";
|
||||
} elseif ($pos_c && $pos_p) { $address = "$pos_c - $pos_p.";
|
||||
} elseif ($pos_s && $pos_p) { $address = "$pos_s - $pos_p.";
|
||||
} elseif ($pos_a) { $address = "$pos_a<br>";
|
||||
} elseif ($pos_c) { $address = "$pos_c.";
|
||||
} elseif ($pos_s) { $address = "$pos_s.";
|
||||
} elseif ($pos_p) { $address = "$pos_p.";
|
||||
} else { $address = '-';}
|
||||
?>
|
||||
<tr>
|
||||
<td colspan="3" class="header"><?= $address ?></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<tr>
|
||||
<td class="section-header">Bill To:</td>
|
||||
<td class="section-header">Invoice No</td>
|
||||
@ -144,11 +180,18 @@
|
||||
<strong>Amount Payable in words : <?= isset($invoice_no) && !empty($invoice_amount) ? numberToWords((int)$invoice_amount) . ' Only' : "-" ?> </strong>
|
||||
</div>
|
||||
|
||||
<div class="bank-details">
|
||||
<!-- <div class="bank-details">
|
||||
<strong>BANK ACCOUNT DETAILS</strong><br>
|
||||
ACCOUNT NUMBER : <?= isset($agent_account_no) && !empty($agent_account_no) ? $agent_account_no : "-" ?><br>
|
||||
IFSC CODE : <?= isset($agent_ifsc_code) && !empty($agent_ifsc_code) ? $agent_ifsc_code : "-" ?><br>
|
||||
Bank NAME : <?= isset($agent_bank_name) && !empty($agent_bank_name) ? $agent_bank_name : "-" ?>
|
||||
</div> -->
|
||||
<div class="bank-details">
|
||||
<strong>BANK ACCOUNT DETAILS</strong><br>
|
||||
ACCOUNT HOLDER NAME : <?= isset($account_holder_name) && !empty($account_holder_name) ? $account_holder_name : "-" ?><br>
|
||||
ACCOUNT NUMBER : <?= isset($account_number) && !empty($account_number) ? $account_number : "-" ?><br>
|
||||
IFSC CODE : <?= isset($ifsc_code) && !empty($ifsc_code) ? $ifsc_code : "-" ?><br>
|
||||
Bank NAME : <?= isset($bank_name) && !empty($bank_name) ? $bank_name : "-" ?>
|
||||
</div>
|
||||
|
||||
<div class="signature">
|
||||
|
||||
@ -1808,6 +1808,9 @@
|
||||
<li>
|
||||
<a href="<?= base_url('/util/rtoMaster') ?>"> RTO </a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/util/partnerPOS') ?>"> POS </a>
|
||||
</li>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
@ -2095,6 +2098,9 @@
|
||||
<li>
|
||||
<a href="<?= base_url('/frontend_content') ?>">Front-end Content</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/FAQ?return_type=web') ?>"> FAQ </a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
@ -107,7 +107,7 @@
|
||||
text: 'Add',
|
||||
className: 'btn app-btn-primary mr-2',
|
||||
action: function(e, dt, node, config) {
|
||||
openModal()
|
||||
resetValues();openModal();
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -118,7 +118,7 @@
|
||||
{
|
||||
extend: 'csv',
|
||||
text: '<i class="mdi mdi-file-delimited " ></i><span class=" btn-custom"> CSV </span>',
|
||||
title: 'Policy-Tranction-Inception-List',
|
||||
title: 'NHance-Branch-List',
|
||||
className: 'app-btn-primary ',
|
||||
exportOptions: {
|
||||
columns: ':not(:last-child)'
|
||||
|
||||
@ -209,7 +209,8 @@
|
||||
<th class="font-weight-medium">UTR Total Amount</th>
|
||||
<th class="font-weight-medium">Balance</th>
|
||||
<th class="font-weight-medium">Status</th>
|
||||
<th class="font-weight-medium">Agent</th>
|
||||
<!-- <th class="font-weight-medium">Agent</th> -->
|
||||
<th class="font-weight-medium">POS</th>
|
||||
<th class="font-weight-medium">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -224,15 +225,17 @@
|
||||
<td> <?= format_indian_number($row['total_utr_amount']) ?> </td>
|
||||
<td> <?= format_indian_number($row['balance_amount']) ?> </td>
|
||||
<td> <?= $row['status_text'] ?> </td>
|
||||
<td> <?= $row['agent_name'] ?? " - " ?> </td>
|
||||
<!-- <td> <?= $row['agent_name'] ?? " - " ?> </td> -->
|
||||
<td> <?= $row['pos_name'] ?? " - " ?> </td>
|
||||
<td>
|
||||
<div class="btn-group dropdown">
|
||||
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<a class="dropdown-item" onclick="fetchUtrDetails(<?= $row['id'] ?>, '<?= $row['invoice_no'] ?>')"><i class="mdi mdi-bank-transfer mr-2 text-muted font-18 vertical-middle"></i>UTR</a>
|
||||
<a href="<?= base_url('payout/invoices?type=edit&id=' . $row['id']) ?>" class="dropdown-item"><i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
|
||||
<!-- <a href="<?= base_url('payout/invoices?type=edit&id=' . $row['id']) ?>" class="dropdown-item"><i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a> -->
|
||||
<a href="<?= base_url('payout/invoices?type=view&id=' . $row['id']) ?>" class="dropdown-item"><i class="mdi mdi-eye mr-2 text-muted font-18 vertical-middle"></i>View</a>
|
||||
<a href="<?= base_url('payout/invoices?type=adjustment&id=' . $row['id']) ?>" class="dropdown-item"><i class="mdi mdi-tune mr-2 text-muted font-18 vertical-middle"></i>Adjustment</a>
|
||||
<a onclick="fetchPreviewInvoiceDetails(<?= $row['id'] ?>, '<?= $row['invoice_no'] ?>')" class="dropdown-item"><i class="mdi mdi-eye mr-2 text-muted font-18 vertical-middle"></i>Preview Invoice</a>
|
||||
<a onclick="fetchPreviewInvoiceDetails(<?= $row['id'] ?>, '<?= $row['invoice_no'] ?>')" class="dropdown-item"><i class="mdi mdi-file mr-2 text-muted font-18 vertical-middle"></i>Preview Invoice</a>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
<div class="card-body">
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-3">
|
||||
<!-- <div class="form-group col-md-3">
|
||||
<label for="client_branch">Agents<span class="text-danger"></span></label>
|
||||
<select class="form-control" id="agent_id" name="agent_id">
|
||||
<option value="">Select Agent</option>
|
||||
@ -24,6 +24,17 @@
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
</div> -->
|
||||
<div class="form-group col-md-3">
|
||||
<label for="pos_id">POS<span class="text-danger"></span></label>
|
||||
<select class="form-control" id="pos_id" name="pos_id">
|
||||
<option value="">Select POS (Manager)</option>
|
||||
<?php if (isset($pos_list) && !empty($pos_list)) : ?>
|
||||
<?php foreach ($pos_list as $pos) : ?>
|
||||
<option value="<?= $pos['id']; ?>"><?= htmlspecialchars($pos['name'] . ' (' . $pos['manager_name'] . ')'); ?></option>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
@ -72,7 +83,8 @@
|
||||
let utrHasBeenChanged = false;
|
||||
|
||||
$(document).ready(function(){
|
||||
$('#agent_id').select2();
|
||||
// $('#agent_id').select2(); because dropdown hided
|
||||
$('#pos_id').select2();
|
||||
$('#startDate').val('');
|
||||
$('#endDate').val('');
|
||||
$('#reportrange').val('');
|
||||
@ -121,7 +133,8 @@
|
||||
|
||||
$('#clear-filters').on('click', function() {
|
||||
// Reset all select dropdowns to the first option
|
||||
$('#agent_id').val('').change();
|
||||
// $('#agent_id').val('').change(); because dropdown hided
|
||||
$('#pos_id').val('').change();
|
||||
$('#status_id').val('').change();
|
||||
|
||||
// Clear the date range inputs
|
||||
@ -135,14 +148,15 @@
|
||||
|
||||
function fetchPayoutList(internalCall = false)
|
||||
{
|
||||
let agent_id = $('#agent_id').val();
|
||||
// let agent_id = $('#agent_id').val(); because dropdown hided
|
||||
let pos_id = $('#pos_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});
|
||||
console.log({pos_id, status_id, start_date, end_date, internalCall, utrHasBeenChanged});
|
||||
|
||||
if(!internalCall){
|
||||
if (!agent_id && !status_id && !start_date && !end_date) {
|
||||
if (!pos_id && !status_id && !start_date && !end_date) {
|
||||
toastr.warning("Please select any one filter!", "WARNING");
|
||||
return false;
|
||||
}
|
||||
@ -152,7 +166,8 @@
|
||||
|
||||
// Data to send in the AJAX request
|
||||
let requestData = {
|
||||
agent_id: agent_id,
|
||||
// agent_id: agent_id, because dropdown hided
|
||||
pos_id: pos_id,
|
||||
status_id: status_id,
|
||||
start_date: start_date,
|
||||
end_date: end_date,
|
||||
|
||||
@ -2446,26 +2446,71 @@
|
||||
// }
|
||||
// }
|
||||
|
||||
// if(allocg == "EB"){
|
||||
// $('.hideter').hide();
|
||||
// $('.hidetp').hide();
|
||||
// $('.hidecoter').hide()
|
||||
// $('.hidecotp').hide()
|
||||
// }else{
|
||||
|
||||
// $('.hidetp').show();
|
||||
// if(is_co_pay_yes == 1){
|
||||
// $('.hidecotp').show();
|
||||
// $('#table_tr_7').show();
|
||||
// $('#table_tr_35').show();
|
||||
// $('#table_tr_3').show();
|
||||
// }else{
|
||||
// $('.hidecotp').hide();
|
||||
// $('#table_tr_7').hide();
|
||||
// $('#table_tr_35').hide();
|
||||
// $('#table_tr_3').hide();
|
||||
// }
|
||||
|
||||
// if(bap == 'Fire' || bap == 'Marine Cargo' || bap == 'Marine Hull'){
|
||||
// $('.hideter').show();
|
||||
// if(is_co_pay_yes == 1){
|
||||
// $('.hidecoter').show();
|
||||
// }else{
|
||||
// $('.hidecoter').hide();
|
||||
// }
|
||||
// }else{
|
||||
// $('.hideter').hide();
|
||||
// }
|
||||
// }
|
||||
|
||||
if(allocg == "EB"){
|
||||
|
||||
$('.hideter').hide();
|
||||
$('.hidetp').hide();
|
||||
$('.hidecoter').hide()
|
||||
$('.hidecotp').hide()
|
||||
}else{
|
||||
|
||||
} else if(allocg == "Non-EB"){
|
||||
|
||||
$('.hidetp').hide();
|
||||
$('.hidecotp').hide();
|
||||
|
||||
$('.hideter').show();
|
||||
if(is_co_pay_yes == 1){
|
||||
$('.hidecoter').show();
|
||||
}else{
|
||||
$('.hidecoter').hide();
|
||||
}
|
||||
|
||||
} else if(allocg == "Motor"){
|
||||
|
||||
$('.hideter').hide();
|
||||
$('.hidecoter').hide();
|
||||
|
||||
$('.hidetp').show();
|
||||
if(is_co_pay_yes == 1){
|
||||
$('.hidecotp').show();
|
||||
$('#table_tr_7').show();
|
||||
$('#table_tr_35').show();
|
||||
$('#table_tr_3').show();
|
||||
}else{
|
||||
$('.hidecotp').hide();
|
||||
$('#table_tr_7').hide();
|
||||
$('#table_tr_35').hide();
|
||||
$('#table_tr_3').hide();
|
||||
}
|
||||
|
||||
} else{
|
||||
|
||||
if(bap == 'Fire' || bap == 'Marine Cargo' || bap == 'Marine Hull'){
|
||||
$('.hideter').show();
|
||||
if(is_co_pay_yes == 1){
|
||||
|
||||
@ -325,6 +325,10 @@
|
||||
<input type="hidden" name="issuer" id="issuer" value="2">
|
||||
<input type="hidden" name="base_cd_amount" id="base_cd_amount">
|
||||
<input type="hidden" name="cd_amt_changed" id="cd_amt_changed" disabled>
|
||||
<input type="hidden" name="salse_person_manager_id" id="salse_person_manager_id">
|
||||
<input type="hidden" name="service_person_manager_id" id="service_person_manager_id">
|
||||
<input type="hidden" name="service_person_branch_id" id="service_person_branch_id">
|
||||
<input type="hidden" name="issuer_branch" id="issuer_branch">
|
||||
|
||||
<!-- <input type="hidden" id="cd_ac_no_for_edit"> -->
|
||||
<input type="hidden" id="premium_details_unique_id">
|
||||
@ -345,7 +349,7 @@
|
||||
</label>
|
||||
<div class="card mb-1">
|
||||
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion_0">
|
||||
<div class="card-body">
|
||||
<div class="card-body" style="background-color: #F5FFFF !important; border-radius: 10px; box-shadow: 4px 4px 4px 4px #00000040;">
|
||||
<div class="row">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="email"> Policy Type <span class="text-danger">*</span></label>
|
||||
@ -420,7 +424,7 @@
|
||||
</select>
|
||||
</div> -->
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<!-- <div class="form-group col-md-3">
|
||||
<label for="client_branch">Nhance Branch<span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="issuer_branch" name="issuer_branch" required>
|
||||
<option value="">Select Nhance Branch</option>
|
||||
@ -432,7 +436,8 @@
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -452,15 +457,15 @@
|
||||
<div class="col-md-12">
|
||||
<div id="accordion_1" class="mb-0">
|
||||
<label id="policyAccordion" class="m-1 d-flex justify-content-between align-items-center">
|
||||
<span class="font-color-black">Pre Sales</span>
|
||||
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseTwo"
|
||||
aria-expanded="true">
|
||||
<i id="icon" class="mdi mdi-chevron-up mr-1 text-primary" style="font-size: 28px;"></i>
|
||||
</a>
|
||||
<span class="font-color-black">Pre Sales</span>
|
||||
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseTwo"
|
||||
aria-expanded="true">
|
||||
<i id="icon" class="mdi mdi-chevron-up mr-1 text-primary" style="font-size: 28px;"></i>
|
||||
</a>
|
||||
</label>
|
||||
<div class="card mb-1">
|
||||
<div id="collapseTwo" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion_1">
|
||||
<div class="card-body">
|
||||
<div class="card-body" style="background-color: #F5FFFF !important; border-radius: 10px; box-shadow: 4px 4px 4px 4px #00000040;">
|
||||
<div class="row" id="policyholdernamediv" style="display: none;">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="bp_igst">Policyholder Name</label>
|
||||
@ -485,7 +490,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="row">
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
@ -654,6 +658,48 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Policy Docs Row -->
|
||||
<div class="row" id="policy_docs" style="display: none;">
|
||||
<div class="col-md-12">
|
||||
<div id="accordion_23" class="mb-0">
|
||||
<label id="policyAccordion" class="m-1 d-flex justify-content-between align-items-center">
|
||||
<span class="font-color-black">Policy Docs</span>
|
||||
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseTwentyTwo"
|
||||
aria-expanded="true">
|
||||
<i id="icon" class="mdi mdi-chevron-up mr-1 text-primary" style="font-size: 28px;"></i>
|
||||
</a>
|
||||
</label>
|
||||
<div class="card mb-1">
|
||||
<div id="collapseTwentyTwo" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion_23">
|
||||
<div class="card-body" id="policy_docs_div" style="background-color: #F5FFFF !important; border-radius: 10px; box-shadow: 4px 4px 4px 4px #00000040;">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Vehicle Docs Row -->
|
||||
<div class="row" id="vehicle_docs" style="display: none;">
|
||||
<div class="col-md-12">
|
||||
<div id="accordion_22" class="mb-0">
|
||||
<label id="policyAccordion" class="m-1 d-flex justify-content-between align-items-center">
|
||||
<span class="font-color-black">Vehicle Docs</span>
|
||||
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseTwentyThree"
|
||||
aria-expanded="true">
|
||||
<i id="icon" class="mdi mdi-chevron-up mr-1 text-primary" style="font-size: 28px;"></i>
|
||||
</a>
|
||||
</label>
|
||||
<div class="card mb-1">
|
||||
<div id="collapseTwentyThree" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion_22">
|
||||
<div class="card-body" id="vehicle_docs_div" style="background-color: #F5FFFF !important; border-radius: 10px; box-shadow: 4px 4px 4px 4px #00000040;">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- sales Row -->
|
||||
<div class="row" id="sales_row" style="display: none;">
|
||||
@ -668,7 +714,7 @@
|
||||
</label>
|
||||
<div class="card mb-1">
|
||||
<div id="collapseThree" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion_2">
|
||||
<div class="card-body">
|
||||
<div class="card-body" style="background-color: #F5FFFF !important; border-radius: 10px; box-shadow: 4px 4px 4px 4px #00000040;">
|
||||
<div class="row">
|
||||
|
||||
<div class="form-group col-md-3" id="base_policy_id" style="display: none;">
|
||||
@ -779,7 +825,7 @@
|
||||
name="renewal_date" placeholder="DD/MM/YYYY">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<!-- <div class="form-group col-md-3">
|
||||
<label for="sales_generated_by">Sales Generated By</label>
|
||||
<select class="form-control" id="sales_generated_by" name="sales_generated_by">
|
||||
<option value="" selected>Select Sales Person</option>
|
||||
@ -805,6 +851,65 @@
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div> -->
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="sales_generated_by" class="d-flex align-items-center">
|
||||
<span class="flex-grow-1">Sales Generated By</span>
|
||||
<small id="nhance_branch_info"
|
||||
class="text-right"
|
||||
style="font-size: x-small;">
|
||||
</small>
|
||||
<small id="salse_rm_info"
|
||||
class="text-right"
|
||||
style="font-size: x-small;">
|
||||
</small>
|
||||
</label>
|
||||
<select class="form-control" id="sales_generated_by" name="sales_generated_by" onchange="setNhanceBranch(this, 'nhance_branch_info'); setRM(this, 'salse_rm_info')" autocomplete="off">
|
||||
<option value="" selected>Select Sales Person</option>
|
||||
<?php if (isset($salse_team)) { ?>
|
||||
<?php foreach ($salse_team as $value) { ?>
|
||||
<option value="<?= $value['id'];?>"
|
||||
data-nbid="<?= $value['nhance_branch_id'];?>"
|
||||
data-nbname="<?= $value['nhance_branch_name'];?>"
|
||||
data-rmid="<?= $value['rm_id'];?>"
|
||||
data-rmname="<?= $value['rm_name'];?>"
|
||||
>
|
||||
<?= $value['first_name'];?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</select>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="serviced_by" class="d-flex align-items-center" >
|
||||
<span class="flex-grow-1">Serviced By</span>
|
||||
<small id="service_nhance_branch_info"
|
||||
class="text-right"
|
||||
style="font-size: x-small;">
|
||||
</small>
|
||||
<small id="service_rm_info"
|
||||
class="text-right"
|
||||
style="font-size: x-small;">
|
||||
</small>
|
||||
</label>
|
||||
<select class="form-control" id="serviced_by" name="serviced_by" onchange="setNhanceBranch(this, 'service_nhance_branch_info'); setRM(this, 'service_rm_info')">
|
||||
<option value="" selected>Select Service Person</option>
|
||||
<?php if (isset($ACM)) { ?>
|
||||
<?php foreach ($ACM as $value) { ?>
|
||||
<option value="<?= $value['id'];?>"
|
||||
data-nbid="<?= $value['nhance_branch_id'];?>"
|
||||
data-nbname="<?= $value['nhance_branch_name'];?>"
|
||||
data-rmid="<?= $value['rm_id'];?>"
|
||||
data-rmname="<?= $value['rm_name'];?>"
|
||||
>
|
||||
<?= $value['first_name'];?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@ -826,7 +931,7 @@
|
||||
</label>
|
||||
<div class="card mb-0">
|
||||
<div id="collapseFour" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion_3">
|
||||
<div class="card-body">
|
||||
<div class="card-body" style="background-color: #F5FFFF !important; border-radius: 10px; box-shadow: 4px 4px 4px 4px #00000040;">
|
||||
<div class="row d-none" id="add_more_row">
|
||||
<div class="col-md-2">
|
||||
<!-- <label for="setInsurerCount">Insurer Count : </label> -->
|
||||
@ -877,7 +982,7 @@
|
||||
<tr id="table_tr_4">
|
||||
<td>Base Premium</td>
|
||||
</tr>
|
||||
<tr class="hidetp" id="table_tr_5">
|
||||
<tr class="hidetp" id="table_tr_5" style="display: none;">
|
||||
<td id="tp_premium_td">TP Premium</td>
|
||||
</tr>
|
||||
<tr class="hideter" id="table_tr_6" style="display: none;">
|
||||
@ -1745,11 +1850,28 @@
|
||||
var is_co_pay_yes = $('#cop_yes').prop('checked') ? 1 : 0;
|
||||
|
||||
if(allocg == "EB"){
|
||||
|
||||
$('.hideter').hide();
|
||||
$('.hidetp').hide();
|
||||
$('.hidecoter').hide()
|
||||
$('.hidecotp').hide()
|
||||
}else{
|
||||
|
||||
} else if(allocg == "Non-EB"){
|
||||
|
||||
$('.hidetp').hide();
|
||||
$('.hidecotp').hide();
|
||||
|
||||
$('.hideter').show();
|
||||
if(is_co_pay_yes == 1){
|
||||
$('.hidecoter').show();
|
||||
}else{
|
||||
$('.hidecoter').hide();
|
||||
}
|
||||
|
||||
} else if(value == 8){
|
||||
|
||||
$('.hideter').hide();
|
||||
$('.hidecoter').hide();
|
||||
|
||||
$('.hidetp').show();
|
||||
if(is_co_pay_yes == 1){
|
||||
@ -1758,6 +1880,8 @@
|
||||
$('.hidecotp').hide();
|
||||
}
|
||||
|
||||
} else{
|
||||
|
||||
if(bap == 'Fire' || bap == 'Marine Cargo' || bap == 'Marine Hull'){
|
||||
$('.hideter').show();
|
||||
if(is_co_pay_yes == 1){
|
||||
@ -1770,6 +1894,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// do not remove this commented item
|
||||
// if(bap == 'Fire' || bap == 'Marine Cargo' || bap == 'Marine Hull'){
|
||||
// $('.hideter').show();
|
||||
@ -1827,7 +1952,7 @@
|
||||
$('#vhnodiv').show();
|
||||
$('#client_type_div').hide();
|
||||
$('#policyholdernamediv').hide();
|
||||
$('#hide_vehicle_tab').show();
|
||||
// $('#hide_vehicle_tab').show();
|
||||
$('#client_type').addClass('readonly-select ');
|
||||
$('#client_id').addClass('readonly-select ').select2('destroy');
|
||||
$('#client_branch_id').addClass('readonly-select ').select2('destroy');
|
||||
@ -1835,7 +1960,7 @@
|
||||
$('#vehicle_no').val("").select2();
|
||||
$('#vhnodiv').hide();
|
||||
$('#client_type_div').show();
|
||||
$('#hide_vehicle_tab').hide();
|
||||
// $('#hide_vehicle_tab').hide();
|
||||
$('#client_type').removeClass('readonly-select ');
|
||||
$('#client_id').removeClass('readonly-select ').select2();
|
||||
$('#client_branch_id').removeClass('readonly-select ').select2();
|
||||
@ -1896,6 +2021,14 @@
|
||||
$("select[name='cd_ac_no_for_child[]']").attr('required', 'required');
|
||||
}
|
||||
|
||||
if(value == 8){
|
||||
addHTMLInputForVehicleFileUpload(null, 'vehicle_docs_div')
|
||||
$('#vehicle_docs').show();
|
||||
}else{
|
||||
$('#vehicle_docs').hide();
|
||||
$('#vehicle_docs_div').empty();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
})
|
||||
@ -1935,7 +2068,7 @@
|
||||
$('[name="calc_policy_issue_date[]"]').each(function () {
|
||||
$(this).val('').removeClass('readonly-select');
|
||||
});
|
||||
|
||||
|
||||
let policy_issue_date = $('#policy_issue_date').val();
|
||||
if ($('#cop_yes').is(':checked') && $(this).is(':checked')) {
|
||||
$('#follower_policy_no_' + uniqueid).prop('readonly', true);
|
||||
@ -1945,6 +2078,20 @@
|
||||
$('#calc_policy_issue_date_1').val(policy_issue_date).addClass('readonly-select');
|
||||
}
|
||||
|
||||
if ($(this).is(':checked')) {
|
||||
// Hide all
|
||||
$('[name="cd_ac_no_for_child[]"]').hide();
|
||||
$('[id^="cd_current_balance_"]').hide();
|
||||
|
||||
// Show only current one
|
||||
$('#cd_ac_no_' + uniqueid).show();
|
||||
$('#cd_current_balance_' + uniqueid).show();
|
||||
} else {
|
||||
// Show all back
|
||||
$('[name="cd_ac_no_for_child[]"]').show();
|
||||
$('[id^="cd_current_balance_"]').show();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$(document).on('change', 'select[name="relationship[]"]', function() {
|
||||
@ -2333,6 +2480,10 @@
|
||||
$('#is_cd_reduce_from_bds').prop('checked', false);
|
||||
}
|
||||
|
||||
$('#vehicle_docs').hide();
|
||||
$('#vehicle_docs_div').empty();
|
||||
|
||||
|
||||
} else {
|
||||
console.log('No data found');
|
||||
}
|
||||
@ -2468,7 +2619,7 @@
|
||||
$('#sgst_' + input).val(isFinite($('#sgst_' + input).val()) ? $('#sgst_' + input).val() : 0);
|
||||
}
|
||||
|
||||
function amountCalculation(input) {
|
||||
function amountCalculation(input, name = null) {
|
||||
|
||||
console.log('############################## AMOUNT CALCULATION ############################################')
|
||||
console.log('amountCalculation : ' + input);
|
||||
@ -2653,7 +2804,7 @@
|
||||
// $('#variance_' + input).val(!isNaN(variance) && isFinite(variance) ? variance.toFixed(2) : '0.00');
|
||||
let policy_type_id = $('#policy_type_id').val();
|
||||
|
||||
if(policy_type_id > 7){
|
||||
if(policy_type_id > 7 && name == "base_premium[]"){
|
||||
checkCDAmountForBasePremium(input);
|
||||
}else{
|
||||
console.log("First Skip the Ajax Call these are group policies");
|
||||
@ -4013,7 +4164,58 @@
|
||||
|
||||
$('#cop_yes').change(function() {
|
||||
|
||||
var selectedOption = $('#policy_type_id').find('option:selected');
|
||||
var bap = selectedOption.data('bap');
|
||||
var allocg = selectedOption.data('allocg');
|
||||
var policy_type_id = $('#policy_type_id').val();
|
||||
|
||||
if(allocg == "EB"){
|
||||
|
||||
$('.hideter').hide();
|
||||
$('.hidetp').hide();
|
||||
$('.hidecoter').hide()
|
||||
$('.hidecotp').hide()
|
||||
|
||||
} else if(allocg == "Non-EB"){
|
||||
|
||||
$('.hidetp').hide();
|
||||
$('.hidecotp').hide();
|
||||
|
||||
$('.hideter').show();
|
||||
if($(this).is(':checked')){
|
||||
$('.hidecoter').show();
|
||||
}else{
|
||||
$('.hidecoter').hide();
|
||||
}
|
||||
|
||||
} else if(policy_type_id == 8){
|
||||
|
||||
$('.hideter').hide();
|
||||
$('.hidecoter').hide();
|
||||
|
||||
$('.hidetp').show();
|
||||
if($(this).is(':checked')){
|
||||
$('.hidecotp').show();
|
||||
}else{
|
||||
$('.hidecotp').hide();
|
||||
}
|
||||
|
||||
} else{
|
||||
|
||||
if(bap == 'Fire' || bap == 'Marine Cargo' || bap == 'Marine Hull'){
|
||||
$('.hideter').show();
|
||||
if($(this).is(':checked')){
|
||||
$('.hidecoter').show();
|
||||
}else{
|
||||
$('.hidecoter').hide();
|
||||
}
|
||||
}else{
|
||||
$('.hideter').hide();
|
||||
}
|
||||
}
|
||||
|
||||
if ($(this).is(':checked')) {
|
||||
|
||||
$('#add_more_row').removeClass('d-none');
|
||||
$('.payby').removeClass('d-none');
|
||||
$('#table_tr_2').show()
|
||||
@ -4021,12 +4223,6 @@
|
||||
$('#table_tr_7').show()
|
||||
$('#table_tr_35').show()
|
||||
|
||||
var selectedOption = $('#policy_type_id').find('option:selected');
|
||||
var bap = selectedOption.data('bap');
|
||||
var allocg = selectedOption.data('allocg');
|
||||
// console.log('allocg:', allocg);
|
||||
|
||||
|
||||
// do not remove this commented items
|
||||
// if(bap == 'Fire' || bap == 'Marine Cargo' || bap == 'Marine Hull'){
|
||||
// $('.hidecoter').show()
|
||||
@ -4042,31 +4238,31 @@
|
||||
// }
|
||||
// }
|
||||
|
||||
if(allocg == "EB"){
|
||||
$('.hideter').hide();
|
||||
$('.hidetp').hide();
|
||||
$('.hidecoter').hide()
|
||||
$('.hidecotp').hide()
|
||||
}else{
|
||||
// if(allocg == "EB"){
|
||||
// $('.hideter').hide();
|
||||
// $('.hidetp').hide();
|
||||
// $('.hidecoter').hide()
|
||||
// $('.hidecotp').hide()
|
||||
// }else{
|
||||
|
||||
$('.hidetp').show();
|
||||
if($(this).is(':checked')){
|
||||
$('.hidecotp').show();
|
||||
}else{
|
||||
$('.hidecotp').hide();
|
||||
}
|
||||
// $('.hidetp').show();
|
||||
// if($(this).is(':checked')){
|
||||
// $('.hidecotp').show();
|
||||
// }else{
|
||||
// $('.hidecotp').hide();
|
||||
// }
|
||||
|
||||
if(bap == 'Fire' || bap == 'Marine Cargo' || bap == 'Marine Hull'){
|
||||
$('.hideter').show();
|
||||
if($(this).is(':checked')){
|
||||
$('.hidecoter').show();
|
||||
}else{
|
||||
$('.hidecoter').hide();
|
||||
}
|
||||
}else{
|
||||
$('.hideter').hide();
|
||||
}
|
||||
}
|
||||
// if(bap == 'Fire' || bap == 'Marine Cargo' || bap == 'Marine Hull'){
|
||||
// $('.hideter').show();
|
||||
// if($(this).is(':checked')){
|
||||
// $('.hidecoter').show();
|
||||
// }else{
|
||||
// $('.hidecoter').hide();
|
||||
// }
|
||||
// }else{
|
||||
// $('.hideter').hide();
|
||||
// }
|
||||
// }
|
||||
|
||||
// $('input[name="co_share_per[]"], input[name="co_premium[]"]').each(function () {
|
||||
// $(this).val(''); // Clear value
|
||||
@ -4825,11 +5021,28 @@
|
||||
// }
|
||||
|
||||
if(allocg == "EB"){
|
||||
|
||||
$('.hideter').hide();
|
||||
$('.hidetp').hide();
|
||||
$('.hidecoter').hide()
|
||||
$('.hidecotp').hide()
|
||||
}else{
|
||||
|
||||
} else if(allocg == "Non-EB"){
|
||||
|
||||
$('.hidetp').hide();
|
||||
$('.hidecotp').hide();
|
||||
|
||||
$('.hideter').show();
|
||||
if(is_co_pay_yes == 1){
|
||||
$('.hidecoter').show();
|
||||
}else{
|
||||
$('.hidecoter').hide();
|
||||
}
|
||||
|
||||
} else if(policy_type_id == 8){
|
||||
|
||||
$('.hideter').hide();
|
||||
$('.hidecoter').hide();
|
||||
|
||||
$('.hidetp').show();
|
||||
if(is_co_pay_yes == 1){
|
||||
@ -4838,6 +5051,8 @@
|
||||
$('.hidecotp').hide();
|
||||
}
|
||||
|
||||
} else{
|
||||
|
||||
if(bap == 'Fire' || bap == 'Marine Cargo' || bap == 'Marine Hull'){
|
||||
$('.hideter').show();
|
||||
if(is_co_pay_yes == 1){
|
||||
@ -4850,6 +5065,32 @@
|
||||
}
|
||||
}
|
||||
|
||||
// if(allocg == "EB"){
|
||||
// $('.hideter').hide();
|
||||
// $('.hidetp').hide();
|
||||
// $('.hidecoter').hide()
|
||||
// $('.hidecotp').hide()
|
||||
// }else{
|
||||
|
||||
// $('.hidetp').show();
|
||||
// if(is_co_pay_yes == 1){
|
||||
// $('.hidecotp').show();
|
||||
// }else{
|
||||
// $('.hidecotp').hide();
|
||||
// }
|
||||
|
||||
// if(bap == 'Fire' || bap == 'Marine Cargo' || bap == 'Marine Hull'){
|
||||
// $('.hideter').show();
|
||||
// if(is_co_pay_yes == 1){
|
||||
// $('.hidecoter').show();
|
||||
// }else{
|
||||
// $('.hidecoter').hide();
|
||||
// }
|
||||
// }else{
|
||||
// $('.hideter').hide();
|
||||
// }
|
||||
// }
|
||||
|
||||
var std_bp = 0;
|
||||
var std_tp = 0;
|
||||
var std_tep = 0;
|
||||
@ -5493,16 +5734,18 @@
|
||||
});
|
||||
|
||||
$(document).on('change', '#insurerTable input, #insurerTable select, #insurerTable textarea', function() {
|
||||
// console.log('Changed in table:', $(this).attr('name'), 'Value:', $(this).val());
|
||||
getColumnIndexes()
|
||||
console.log('Changed in table:', $(this).attr('name'), 'Value:', $(this).val());
|
||||
getColumnIndexes(0, $(this).attr('name'))
|
||||
});
|
||||
|
||||
function getColumnIndexes(count = 0) {
|
||||
function getColumnIndexes(count = 0, name = null) {
|
||||
$('#insurerTable thead th').each(function(index) {
|
||||
if (index === 0) {
|
||||
console.log("Premium Table columnIndexes is", index);
|
||||
} else {
|
||||
amountCalculation(index);
|
||||
|
||||
amountCalculation(index, name);
|
||||
|
||||
if(count == 1){
|
||||
amountCalculation(index);
|
||||
}
|
||||
@ -6422,8 +6665,6 @@
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function generateShortName() {
|
||||
let clientInput = $("#client_name");
|
||||
let shortInput = $("#short_name");
|
||||
@ -6593,4 +6834,76 @@
|
||||
}
|
||||
}
|
||||
|
||||
function setNhanceBranch(select, show_id) {
|
||||
|
||||
if (!select || !select.options || select.selectedIndex < 0) {
|
||||
console.warn('No option selected yet');
|
||||
return;
|
||||
}
|
||||
|
||||
let selectedOption = select.options[select.selectedIndex];
|
||||
|
||||
let nbID = selectedOption.getAttribute('data-nbid');
|
||||
let nbName = selectedOption.getAttribute('data-nbname');
|
||||
|
||||
console.log('NB ID:', nbID);
|
||||
console.log('NB Name:', nbName);
|
||||
|
||||
if(show_id == "nhance_branch_info"){
|
||||
$('#issuer_branch').val(nbID ? nbID : '');
|
||||
}else{
|
||||
$('#service_person_branch_id').val(nbID ? nbID : '');
|
||||
}
|
||||
|
||||
let nbDiv = document.getElementById(show_id);
|
||||
|
||||
if (!nbID || !nbName) {
|
||||
nbDiv.innerHTML = '';
|
||||
nbDiv.classList.remove('show');
|
||||
return;
|
||||
}
|
||||
|
||||
nbDiv.innerHTML =
|
||||
'<span class="text-success">' + nbName + '</span>' +
|
||||
' <span class="vehicle-badge success">✓ Nhance Branch</span>';
|
||||
|
||||
nbDiv.classList.add('show');
|
||||
}
|
||||
|
||||
function setRM(select, show_id) {
|
||||
|
||||
if (!select || !select.options || select.selectedIndex < 0) {
|
||||
console.warn('No option selected yet');
|
||||
return;
|
||||
}
|
||||
|
||||
let selectedOption = select.options[select.selectedIndex];
|
||||
|
||||
let rmid = selectedOption.getAttribute('data-rmid');
|
||||
let rmname = selectedOption.getAttribute('data-rmname');
|
||||
|
||||
console.log('RM ID:', rmid);
|
||||
console.log('RM Name:', rmname);
|
||||
|
||||
if(show_id == "salse_rm_info"){
|
||||
$('#salse_person_manager_id').val(rmid ? rmid : '');
|
||||
}else{
|
||||
$('#service_person_manager_id').val(rmid ? rmid : '');
|
||||
}
|
||||
|
||||
let rmDiv = document.getElementById(show_id);
|
||||
|
||||
if (!rmid || !rmname) {
|
||||
rmDiv.innerHTML = '';
|
||||
rmDiv.classList.remove('show');
|
||||
return;
|
||||
}
|
||||
|
||||
rmDiv.innerHTML =
|
||||
'<span class="text-success">' + rmname + '</span>' +
|
||||
' <span class="vehicle-badge success">✓ RM</span>';
|
||||
|
||||
rmDiv.classList.add('show');
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
@ -1702,7 +1702,7 @@
|
||||
$('#follower_policy_no_' + uniqueid).prop('readonly', false);
|
||||
$('#calc_policy_issue_date_1').val(policy_issue_date).addClass('readonly-select');
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
$(document).on('change', 'select[name="relationship[]"]', function() {
|
||||
@ -2612,141 +2612,203 @@
|
||||
console.log('variance', variance);
|
||||
}
|
||||
|
||||
function co_share_percentage_calculation(input, extra = null){
|
||||
// function co_share_percentage_calculation(input, extra = null){
|
||||
|
||||
console.log('input', input)
|
||||
var inputs = $('input[name="co_share_per[]"]'); // Specifically select input elements
|
||||
console.log('Number of inputs:', inputs.length);
|
||||
// console.log('input', input)
|
||||
// var inputs = $('input[name="co_share_per[]"]'); // Specifically select input elements
|
||||
// console.log('Number of inputs:', inputs.length);
|
||||
|
||||
let insurer_count = insurer_count_array.length;
|
||||
console.log('insurer_count', insurer_count);
|
||||
console.log('insurer_count_array', insurer_count_array);
|
||||
// let insurer_count = insurer_count_array.length;
|
||||
// console.log('insurer_count', insurer_count);
|
||||
// console.log('insurer_count_array', insurer_count_array);
|
||||
|
||||
if(input){
|
||||
if(insurer_count == 2){
|
||||
// if ($('#cop_yes').is(':checked')) {
|
||||
// console.log('cop_yes checked', $('#cop_yes').is(':checked'));
|
||||
// if(input){
|
||||
// if(insurer_count == 2){
|
||||
|
||||
// Find the index of the value
|
||||
let index = insurer_count_array.indexOf(Number(input));
|
||||
let second_value_index = "";
|
||||
// // Find the index of the value
|
||||
// let index = insurer_count_array.indexOf(Number(input));
|
||||
// let second_value_index = "";
|
||||
|
||||
if (index !== -1) {
|
||||
// if (index !== -1) {
|
||||
|
||||
console.log(`Value ${input} exists at index ${index}.`);
|
||||
// console.log(`Value ${input} exists at index ${index}.`);
|
||||
|
||||
let beforeValue = index > 0 ? insurer_count_array[index - 1] : null;
|
||||
let afterValue = index < insurer_count_array.length - 1 ? insurer_count_array[index + 1] : null;
|
||||
// let beforeValue = index > 0 ? insurer_count_array[index - 1] : null;
|
||||
// let afterValue = index < insurer_count_array.length - 1 ? insurer_count_array[index + 1] : null;
|
||||
|
||||
if (beforeValue != null) {
|
||||
second_value_index = beforeValue;
|
||||
} else if (afterValue != null) {
|
||||
second_value_index = afterValue;
|
||||
}
|
||||
// if (beforeValue != null) {
|
||||
// second_value_index = beforeValue;
|
||||
// } else if (afterValue != null) {
|
||||
// second_value_index = afterValue;
|
||||
// }
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
let value1 = $('#co_share_per_' + input).val();
|
||||
let value2 = $('#co_share_per_' + second_value_index).val();
|
||||
// let value1 = $('#co_share_per_' + input).val();
|
||||
// let value2 = $('#co_share_per_' + second_value_index).val();
|
||||
|
||||
value1 = Number(value1);
|
||||
value2 = Number(value2);
|
||||
// value1 = Number(value1);
|
||||
// value2 = Number(value2);
|
||||
|
||||
console.log('value1', value1);
|
||||
console.log('value2', value2);
|
||||
// console.log('value1', value1);
|
||||
// console.log('value2', value2);
|
||||
|
||||
if(extra == "add"){
|
||||
// if(extra == "add"){
|
||||
|
||||
if(value2 == 0){
|
||||
value1 = 50;
|
||||
value2 = 50;
|
||||
}else{
|
||||
if(value2 == 100){
|
||||
value1 = 50;
|
||||
value2 = 50;
|
||||
}else{
|
||||
value1 = 100 - value2;
|
||||
}
|
||||
}
|
||||
// if(value2 == 0){
|
||||
// value1 = 50;
|
||||
// value2 = 50;
|
||||
// }else{
|
||||
// if(value2 == 100){
|
||||
// value1 = 50;
|
||||
// value2 = 50;
|
||||
// }else{
|
||||
// value1 = 100 - value2;
|
||||
// }
|
||||
// }
|
||||
|
||||
}else{
|
||||
// }else{
|
||||
|
||||
if(value1 == 100){
|
||||
value2 = 0;
|
||||
}else{
|
||||
value2 = 100 - value1;
|
||||
}
|
||||
}
|
||||
// if(value1 == 100){
|
||||
// value2 = 0;
|
||||
// }else{
|
||||
// value2 = 100 - value1;
|
||||
// }
|
||||
// }
|
||||
|
||||
console.log('value1', value1);
|
||||
console.log('value2', value2);
|
||||
// console.log('value1', value1);
|
||||
// console.log('value2', value2);
|
||||
|
||||
$('#co_share_per_' + input).val(value1);
|
||||
$('#co_share_per_' + second_value_index).val(value2);
|
||||
// $('#co_share_per_' + input).val(value1);
|
||||
// $('#co_share_per_' + second_value_index).val(value2);
|
||||
|
||||
}else if(insurer_count > 2){
|
||||
// }else if(insurer_count > 2){
|
||||
|
||||
let total_val = 0;
|
||||
// let total_val = 0;
|
||||
|
||||
// Calculate the total sum of input values
|
||||
inputs.each(function () {
|
||||
let val = Number($(this).val()) || 0;
|
||||
if(val == 0){
|
||||
$(this).val(0)
|
||||
}
|
||||
total_val += val;
|
||||
});
|
||||
// // Calculate the total sum of input values
|
||||
// inputs.each(function () {
|
||||
// let val = Number($(this).val()) || 0;
|
||||
// if(val == 0){
|
||||
// $(this).val(0)
|
||||
// }
|
||||
// total_val += val;
|
||||
// });
|
||||
|
||||
// if (total_val < 100) {
|
||||
// let remaining_val = 100 - total_val; // Calculate the remaining value
|
||||
// // if (total_val < 100) {
|
||||
// // let remaining_val = 100 - total_val; // Calculate the remaining value
|
||||
|
||||
// // Assign the remaining value to the first empty input
|
||||
// let assigned = false;
|
||||
// inputs.each(function () {
|
||||
// let current_val = Number($(this).val()) || 0;
|
||||
// if (current_val === 0 && !assigned) { // Assign only once
|
||||
// $(this).val(remaining_val);
|
||||
// assigned = true;
|
||||
// } else if (current_val === 0) {
|
||||
// $(this).val(0); // Set other empty inputs to 0
|
||||
// }
|
||||
// });
|
||||
// } else if (total_val > 100) {
|
||||
// toastr.warning('Sum of the co-share is greater than 100');
|
||||
// }
|
||||
// // // Assign the remaining value to the first empty input
|
||||
// // let assigned = false;
|
||||
// // inputs.each(function () {
|
||||
// // let current_val = Number($(this).val()) || 0;
|
||||
// // if (current_val === 0 && !assigned) { // Assign only once
|
||||
// // $(this).val(remaining_val);
|
||||
// // assigned = true;
|
||||
// // } else if (current_val === 0) {
|
||||
// // $(this).val(0); // Set other empty inputs to 0
|
||||
// // }
|
||||
// // });
|
||||
// // } else if (total_val > 100) {
|
||||
// // toastr.warning('Sum of the co-share is greater than 100');
|
||||
// // }
|
||||
|
||||
}
|
||||
}else{
|
||||
inputs.each(function (index) {
|
||||
if (inputs.length === 1) {
|
||||
$(this).val(100);
|
||||
} else if(inputs.length === 2) {
|
||||
let first = $('#co_share_per_1').val();
|
||||
first = Number(first)
|
||||
let second_val = 100 - first;
|
||||
// }
|
||||
// }else{
|
||||
// inputs.each(function (index) {
|
||||
// if (inputs.length === 1) {
|
||||
// $(this).val(100);
|
||||
// } else if(inputs.length === 2) {
|
||||
// let first = $('#co_share_per_1').val();
|
||||
// first = Number(first)
|
||||
// let second_val = 100 - first;
|
||||
|
||||
if (index === 1) {
|
||||
$(this).val(second_val);
|
||||
}
|
||||
}
|
||||
});
|
||||
// if (index === 1) {
|
||||
// $(this).val(second_val);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
|
||||
}
|
||||
// }
|
||||
// }
|
||||
|
||||
let val_sum = 0;
|
||||
// let val_sum = 0;
|
||||
|
||||
inputs.each(function () {
|
||||
let val = Number($(this).val()) || 0;
|
||||
val_sum += val;
|
||||
});
|
||||
// inputs.each(function () {
|
||||
// let val = Number($(this).val()) || 0;
|
||||
// val_sum += val;
|
||||
// });
|
||||
|
||||
if (val_sum > 100) {
|
||||
toastr.warning('Sum of the co-share is greater than 100', 'WARNING');
|
||||
}
|
||||
// if ($('#cop_yes').is(':checked')) {
|
||||
// if (val_sum > 100) {
|
||||
// toastr.warning('Sum of the co-share is greater than 100', 'WARNING');
|
||||
// }
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
function co_share_percentage_calculation(changedEl = null) {
|
||||
|
||||
let inputs = $('input[name="co_share_per[]"]');
|
||||
let count = inputs.length;
|
||||
let copChecked = $('#cop_yes').is(':checked');
|
||||
|
||||
/* =========================
|
||||
COP UNCHECKED
|
||||
========================= */
|
||||
if (!copChecked) {
|
||||
inputs.val('');
|
||||
return;
|
||||
}
|
||||
|
||||
/* =========================
|
||||
AUTO MODE (default / fetch / add / remove)
|
||||
========================= */
|
||||
if (changedEl === null) {
|
||||
|
||||
// Single card → empty (means 100)
|
||||
if (count === 1) {
|
||||
inputs.val('');
|
||||
return;
|
||||
}
|
||||
|
||||
// Multiple cards → auto split
|
||||
let split = (100 / count).toFixed(2);
|
||||
inputs.val(split);
|
||||
return;
|
||||
}
|
||||
|
||||
/* =========================
|
||||
USER MODE (manual edit)
|
||||
========================= */
|
||||
let sum = 0;
|
||||
let userTouched = false;
|
||||
|
||||
inputs.each(function () {
|
||||
let v = $(this).val();
|
||||
|
||||
if (v !== '') {
|
||||
userTouched = true;
|
||||
sum += Number(v) || 0;
|
||||
}
|
||||
});
|
||||
|
||||
// Show warning ONLY if user changed something
|
||||
if (userTouched && sum > 100) {
|
||||
toastr.warning(
|
||||
'Sum of the co-share is greater than 100',
|
||||
'WARNING'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$(document).on('change', '[name="base_premium"], [name="co_share_per[]"]', function() {
|
||||
|
||||
console.log('Triggered change event.');
|
||||
console.log('Triggered change event. base_premium');
|
||||
|
||||
// Get the first non-empty base premium value
|
||||
// let basePremium = $('input[name="base_premium[]"]').toArray()
|
||||
@ -3276,7 +3338,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
function addCDAccountNumber(input)
|
||||
function addCDAccountNumber_old(input)
|
||||
{
|
||||
var val = $(input).val();
|
||||
var uniqueid = $(input).data('count');
|
||||
@ -3328,6 +3390,93 @@
|
||||
}
|
||||
}
|
||||
|
||||
function addCDAccountNumber(input)
|
||||
{
|
||||
|
||||
var $input = $(input);
|
||||
var val = $input.val();
|
||||
var uniqueid = $input.data('count');
|
||||
|
||||
var client_id = $('#client_id').val();
|
||||
var insurer_id = $('#follow_insurer_id_' + uniqueid).val();
|
||||
|
||||
var isCurrentLeader = $('#co_share_type_' + uniqueid).is(':checked');
|
||||
var isAnyLeaderSelected = $('input[name="co_share_type[]"]:checked').length > 0;
|
||||
var cop_yes = $('#cop_yes').is(':checked');
|
||||
|
||||
|
||||
|
||||
// Missing base data
|
||||
if (!client_id || !insurer_id) {
|
||||
toastr.warning('Client or Insurer does not exist.', 'WARNING!');
|
||||
return;
|
||||
}
|
||||
|
||||
// COP enabled but no leader selected
|
||||
if (cop_yes && !isAnyLeaderSelected) {
|
||||
toastr.warning('Please select a Leader.', 'WARNING!');
|
||||
$input.val('');
|
||||
return;
|
||||
}
|
||||
|
||||
// CD allowed only for leader
|
||||
if (cop_yes && !isCurrentLeader) {
|
||||
|
||||
toastr.warning(
|
||||
'CD account number allowed only for Leader.',
|
||||
'WARNING!'
|
||||
);
|
||||
|
||||
// Clear current select
|
||||
$input.val('');
|
||||
|
||||
// Disable CD for NON-leaders, enable only leader, clear balance div
|
||||
$('select.follow_insurer_cd').each(function () {
|
||||
|
||||
var count = $(this).data('count');
|
||||
var isLeaderRow = $('#co_share_type_' + count).is(':checked');
|
||||
|
||||
// Get the corresponding balance div
|
||||
var balanceDiv = document.getElementById('cd_current_balance_info_' + count);
|
||||
|
||||
if (!isLeaderRow) {
|
||||
$(this)
|
||||
.prop('disabled', true)
|
||||
.removeAttr('required')
|
||||
.val('');
|
||||
|
||||
// Clear balance div if it exists
|
||||
if (balanceDiv) {
|
||||
balanceDiv.innerHTML = "";
|
||||
}
|
||||
|
||||
} else {
|
||||
$(this)
|
||||
.prop('disabled', false)
|
||||
.attr('required', true);
|
||||
}
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// ➕ Add CD
|
||||
if (val === 'add_cd') {
|
||||
$('#premium_details_unique_id').val(uniqueid);
|
||||
new bootstrap.Modal(
|
||||
document.getElementById('cd_form_modal')
|
||||
).show();
|
||||
$input.val('');
|
||||
return;
|
||||
}
|
||||
|
||||
// ✅ Valid selection (leader only)
|
||||
$('#cd_ac_pk_for_leader').val(val);
|
||||
getCdAmount(val, uniqueid);
|
||||
}
|
||||
|
||||
|
||||
function restrictCDACNO(currentSelect){
|
||||
|
||||
const selectedValue = $(currentSelect).val();
|
||||
@ -3780,85 +3929,160 @@
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
|
||||
$('#cop_yes').change(function() {
|
||||
// $('#cop_yes').change(function() {
|
||||
|
||||
if ($(this).is(':checked')) {
|
||||
$('.add-insurer-button').removeClass('d-none');
|
||||
$('.payby').removeClass('d-none');
|
||||
$('.card_group_2').show()
|
||||
$('.card_group_3').show()
|
||||
$('.card_group_7').show()
|
||||
$('.card_group_35').removeClass('d-none');
|
||||
// if ($(this).is(':checked')) {
|
||||
// $('.add-insurer-button').removeClass('d-none');
|
||||
// $('.payby').removeClass('d-none');
|
||||
// $('.card_group_2').show()
|
||||
// $('.card_group_3').show()
|
||||
// $('.card_group_7').show()
|
||||
// $('.card_group_35').removeClass('d-none');
|
||||
|
||||
var selectedOption = $('#policy_type_id').find('option:selected');
|
||||
var bap = selectedOption.data('bap');
|
||||
var allocg = selectedOption.data('allocg');
|
||||
// console.log('allocg:', allocg);
|
||||
// var selectedOption = $('#policy_type_id').find('option:selected');
|
||||
// var bap = selectedOption.data('bap');
|
||||
// var allocg = selectedOption.data('allocg');
|
||||
// // console.log('allocg:', allocg);
|
||||
|
||||
|
||||
// do not remove this commented items
|
||||
// if(bap == 'Fire' || bap == 'Marine Cargo' || bap == 'Marine Hull'){
|
||||
// $('.hidecoter').show()
|
||||
// $('.hidecotp').hide()
|
||||
// }else{
|
||||
// // do not remove this commented items
|
||||
// // if(bap == 'Fire' || bap == 'Marine Cargo' || bap == 'Marine Hull'){
|
||||
// // $('.hidecoter').show()
|
||||
// // $('.hidecotp').hide()
|
||||
// // }else{
|
||||
|
||||
// if(bap == 'Motor'){
|
||||
// $('.hidecotp').show()
|
||||
// $('.hidecoter').hide()
|
||||
// }else{
|
||||
// $('.hidecoter').hide()
|
||||
// $('.hidecotp').hide()
|
||||
// }
|
||||
// }
|
||||
// // if(bap == 'Motor'){
|
||||
// // $('.hidecotp').show()
|
||||
// // $('.hidecoter').hide()
|
||||
// // }else{
|
||||
// // $('.hidecoter').hide()
|
||||
// // $('.hidecotp').hide()
|
||||
// // }
|
||||
// // }
|
||||
|
||||
if(allocg == "EB"){
|
||||
$('.hideter').hide();
|
||||
$('.hidetp').hide();
|
||||
$('.hidecoter').hide()
|
||||
$('.hidecotp').hide()
|
||||
}else{
|
||||
// if(allocg == "EB"){
|
||||
// $('.hideter').hide();
|
||||
// $('.hidetp').hide();
|
||||
// $('.hidecoter').hide()
|
||||
// $('.hidecotp').hide()
|
||||
// }else{
|
||||
|
||||
$('.hidetp').show();
|
||||
if($(this).is(':checked')){
|
||||
$('.hidecotp').show();
|
||||
}else{
|
||||
$('.hidecotp').hide();
|
||||
}
|
||||
// $('.hidetp').show();
|
||||
// if($(this).is(':checked')){
|
||||
// $('.hidecotp').show();
|
||||
// }else{
|
||||
// $('.hidecotp').hide();
|
||||
// }
|
||||
|
||||
if(bap == 'Fire' || bap == 'Marine Cargo' || bap == 'Marine Hull'){
|
||||
$('.hideter').show();
|
||||
if($(this).is(':checked')){
|
||||
$('.hidecoter').show();
|
||||
}else{
|
||||
$('.hidecoter').hide();
|
||||
}
|
||||
}else{
|
||||
$('.hideter').hide();
|
||||
}
|
||||
}
|
||||
// if(bap == 'Fire' || bap == 'Marine Cargo' || bap == 'Marine Hull'){
|
||||
// $('.hideter').show();
|
||||
// if($(this).is(':checked')){
|
||||
// $('.hidecoter').show();
|
||||
// }else{
|
||||
// $('.hidecoter').hide();
|
||||
// }
|
||||
// }else{
|
||||
// $('.hideter').hide();
|
||||
// }
|
||||
// }
|
||||
|
||||
// $('input[name="co_share_per[]"], input[name="co_premium[]"]').each(function () {
|
||||
// $(this).val(''); // Clear value
|
||||
// console.log('Input cleared:', $(this).attr('name')); // Log cleared input
|
||||
// });
|
||||
// // $('input[name="co_share_per[]"], input[name="co_premium[]"]').each(function () {
|
||||
// // $(this).val(''); // Clear value
|
||||
// // console.log('Input cleared:', $(this).attr('name')); // Log cleared input
|
||||
// // });
|
||||
|
||||
} else {
|
||||
$('.add-insurer-button').addClass('d-none');
|
||||
$('.payby').addClass('d-none');
|
||||
// $('#bro_payable_by').prop('checked', false);
|
||||
$('.card_group_2').hide()
|
||||
$('.card_group_3').hide()
|
||||
$('.card_group_7').hide()
|
||||
$('.card_group_35').addClass('d-none');
|
||||
$('.hidecoter').hide()
|
||||
$('.hidecotp').hide()
|
||||
// } else {
|
||||
// $('.add-insurer-button').addClass('d-none');
|
||||
// $('.payby').addClass('d-none');
|
||||
// // $('#bro_payable_by').prop('checked', false);
|
||||
// $('.card_group_2').hide()
|
||||
// $('.card_group_3').hide()
|
||||
// $('.card_group_7').hide()
|
||||
// $('.card_group_35').addClass('d-none');
|
||||
// $('.hidecoter').hide()
|
||||
// $('.hidecotp').hide()
|
||||
|
||||
// $('input[name="co_share_per[]"], input[name="co_premium[]"]').each(function () {
|
||||
// $(this).val(''); // Clear value
|
||||
// console.log('Input cleared:', $(this).attr('name')); // Log cleared input
|
||||
// });
|
||||
// // $('input[name="co_share_per[]"], input[name="co_premium[]"]').each(function () {
|
||||
// // $(this).val(''); // Clear value
|
||||
// // console.log('Input cleared:', $(this).attr('name')); // Log cleared input
|
||||
// // });
|
||||
// }
|
||||
// });
|
||||
|
||||
$('#cop_yes').change(function () {
|
||||
|
||||
const isCoPayYes = $(this).is(':checked');
|
||||
|
||||
const selectedOption = $('#policy_type_id option:selected');
|
||||
const bap = selectedOption.data('bap');
|
||||
const allocg = selectedOption.data('allocg');
|
||||
|
||||
const $allPremiumCols = $('.csslabel, .cssbp, .csstp, .csstep');
|
||||
|
||||
/* =========================
|
||||
VISIBILITY LOGIC
|
||||
========================= */
|
||||
if (isCoPayYes) {
|
||||
|
||||
$('.add-insurer-button, .payby').removeClass('d-none');
|
||||
$('.card_group_2, .card_group_3, .card_group_7').show();
|
||||
$('.card_group_35').removeClass('d-none');
|
||||
|
||||
if (allocg === "EB") {
|
||||
$('.hideter, .hidetp, .hidecoter, .hidecotp').hide();
|
||||
} else {
|
||||
|
||||
$('.hidetp').show();
|
||||
$('.hidecotp').show();
|
||||
|
||||
if (['Fire','Marine Cargo','Marine Hull'].includes(bap)) {
|
||||
$('.hideter, .hidecoter').show();
|
||||
} else {
|
||||
$('.hideter, .hidecoter').hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
|
||||
$('.add-insurer-button, .payby').addClass('d-none');
|
||||
$('.card_group_2, .card_group_3, .card_group_7').hide();
|
||||
$('.card_group_35').addClass('d-none');
|
||||
|
||||
$('.hideter, .hidetp, .hidecoter, .hidecotp').hide();
|
||||
}
|
||||
|
||||
/* =========================
|
||||
COLUMN LAYOUT LOGIC
|
||||
========================= */
|
||||
$allPremiumCols
|
||||
.filter(':visible')
|
||||
.removeClass('col-3 col-4 col-6');
|
||||
|
||||
if (allocg === "EB") {
|
||||
|
||||
$allPremiumCols
|
||||
.filter(':visible')
|
||||
.addClass('col-6');
|
||||
|
||||
} else if (['Fire','Marine Cargo','Marine Hull'].includes(bap)) {
|
||||
|
||||
$allPremiumCols
|
||||
.filter(':visible')
|
||||
.addClass('col-3');
|
||||
|
||||
} else {
|
||||
|
||||
$allPremiumCols
|
||||
.filter(':visible')
|
||||
.addClass('col-4');
|
||||
}
|
||||
|
||||
/* =========================
|
||||
CO-SHARE RECALC
|
||||
========================= */
|
||||
co_share_percentage_calculation();
|
||||
});
|
||||
|
||||
|
||||
$('#client_type').change(function() {
|
||||
|
||||
@ -4348,7 +4572,7 @@
|
||||
style="font-size: x-small;">
|
||||
</small>
|
||||
</label>
|
||||
<select class="form-control follow_insurer_cd" data-count="${insurerCount}" id="cd_ac_no_${insurerCount}" name="cd_ac_no_for_child[]" onchange="addCDAccountNumber(this); restrictCDACNO(this);">
|
||||
<select class="form-control follow_insurer_cd" data-count="${insurerCount}" id="cd_ac_no_${insurerCount}" name="cd_ac_no_for_child[]" onchange="addCDAccountNumber(this);">
|
||||
<option value="" selected>Select CD No</option>
|
||||
<option value="add_cd"> + Add CD No</option>
|
||||
</select>
|
||||
|
||||
@ -574,12 +574,14 @@ $(document).ready(function() {
|
||||
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
|
||||
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
|
||||
buttons: [
|
||||
{
|
||||
{
|
||||
text: '<i class="mdi mdi-plus" ></i><span class=" btn-custom"> Add </span>',
|
||||
className: 'btn app-btn-primary mr-2',
|
||||
action: function (e, dt, node, config) {
|
||||
hide_list_show_add();
|
||||
addInsurerColumn() ;
|
||||
addInsurerColumn();
|
||||
addHTMLInput(null, 'policy_docs_div');
|
||||
$('#policy_docs').show()
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -720,6 +722,7 @@ function hide_list_show_add()
|
||||
$('#inception_filter').hide()
|
||||
$('#policyholdernamediv').hide();
|
||||
$('.branchdiv').show();
|
||||
|
||||
}
|
||||
|
||||
function show_list_hide_add()
|
||||
@ -1000,23 +1003,33 @@ function getPolicyDetailsByPolicyId(input)
|
||||
}
|
||||
}
|
||||
|
||||
function addHTMLInput(data = null)
|
||||
{
|
||||
const container = document.getElementById('dynamic-form-container');
|
||||
function addHTMLInput(data = null, container_id = 'dynamic-form-container')
|
||||
{
|
||||
console.log('container_id', container_id);
|
||||
const container = document.getElementById(container_id);
|
||||
|
||||
let required = ''
|
||||
let required_star = ''
|
||||
if(container_id == 'dynamic-form-container'){
|
||||
required = 'required';
|
||||
required_star = '*';
|
||||
}
|
||||
console.log('container', container);
|
||||
|
||||
const newRow = document.createElement('div');
|
||||
newRow.className = 'form-row dynamic-form-row';
|
||||
newRow.innerHTML = `
|
||||
<div class="form-group col-md-5">
|
||||
<label for="file_name">Document Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="docs_name" name="doc_name[]" placeholder="Enter file name" required>
|
||||
<label for="file_name">Document Name<span class="text-danger">${required_star}</span></label>
|
||||
<input type="text" class="form-control" id="docs_name" name="doc_name[]" placeholder="Enter file name" ${required}>
|
||||
</div>
|
||||
<div class="form-group col-md-5">
|
||||
<label for="file">Upload File<span class="text-danger">*</span></label>
|
||||
<input type="file" class="form-control" id="file_name" name="file[]" required>
|
||||
<label for="file">Upload File<span class="text-danger">${required_star}</span></label>
|
||||
<input type="file" class="form-control" id="file_name" name="file[]" ${required}>
|
||||
</div>
|
||||
<div class="form-group col-md-2" style="position: relative;top: 28px;">
|
||||
<a class="btn btn-danger waves-effect waves-light" onclick="removeHTMLInput(this)">x</a>
|
||||
<a class="btn btn-primary waves-effect waves-light mr-1" onclick="addHTMLInput(this)">+</a>
|
||||
<a class="btn btn-danger waves-effect waves-light" onclick="removeHTMLInput(this, '${container_id}')">x</a>
|
||||
<a class="btn btn-primary waves-effect waves-light mr-1" onclick="addHTMLInput(null, '${container_id}')">+</a>
|
||||
</div>
|
||||
`;
|
||||
container.appendChild(newRow);
|
||||
@ -1027,9 +1040,9 @@ function addHTMLInput(data = null)
|
||||
}
|
||||
}
|
||||
|
||||
function removeHTMLInput(element)
|
||||
function removeHTMLInput(element, container_id)
|
||||
{
|
||||
const container = document.getElementById('dynamic-form-container');
|
||||
const container = document.getElementById(container_id);
|
||||
const rows = container.querySelectorAll('.dynamic-form-row');
|
||||
|
||||
if (rows.length > 1) {
|
||||
@ -1179,23 +1192,30 @@ function validateForm()
|
||||
return checkInputs(); // Call checkInputs before form submission
|
||||
}
|
||||
|
||||
function addHTMLInputForVehicleFileUpload(data = null)
|
||||
{
|
||||
const container = document.getElementById('dynamic-form-container-for-vehicle-file-upload');
|
||||
function addHTMLInputForVehicleFileUpload(data = null, container_id = 'dynamic-form-container-for-vehicle-file-upload')
|
||||
{
|
||||
let required = ''
|
||||
let required_star = ''
|
||||
if(container_id == 'dynamic-form-container-for-vehicle-file-upload'){
|
||||
required = 'required';
|
||||
required_star = '*';
|
||||
}
|
||||
|
||||
const container = document.getElementById(container_id);
|
||||
const newRow = document.createElement('div');
|
||||
newRow.className = 'form-row dynamic-form-row';
|
||||
newRow.innerHTML = `
|
||||
<div class="form-group col-md-5">
|
||||
<label for="file_name">Document Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="docs_name" name="other_docs_name[]" placeholder="Enter file name" required>
|
||||
<label for="file_name">Document Name<span class="text-danger">${required_star}</span></label>
|
||||
<input type="text" class="form-control" id="docs_name" name="other_docs_name[]" placeholder="Enter file name" ${required}>
|
||||
</div>
|
||||
<div class="form-group col-md-5">
|
||||
<label for="file">Upload File<span class="text-danger">*</span></label>
|
||||
<input type="file" class="form-control" id="file_name" name="file_name[]" required>
|
||||
<label for="file">Upload File<span class="text-danger">${required_star}</span></label>
|
||||
<input type="file" class="form-control" id="file_name" name="file_name[]" ${required}>
|
||||
</div>
|
||||
<div class="form-group col-md-2" style="position: relative;top: 28px;">
|
||||
<a class="btn btn-danger waves-effect waves-light" onclick="removeHTMLInputForVehicleFileUpload(this)">x</a>
|
||||
<a class="btn btn-primary waves-effect waves-light mr-1" onclick="addHTMLInputForVehicleFileUpload(this)">+</a>
|
||||
<a class="btn btn-danger waves-effect waves-light" onclick="removeHTMLInputForVehicleFileUpload(this, '${container_id}')">x</a>
|
||||
<a class="btn btn-primary waves-effect waves-light mr-1" onclick="addHTMLInputForVehicleFileUpload(null, '${container_id}')">+</a>
|
||||
</div>
|
||||
`;
|
||||
container.appendChild(newRow);
|
||||
@ -1244,9 +1264,9 @@ function appendVehicleFileTableBody(data)
|
||||
});
|
||||
}
|
||||
|
||||
function removeHTMLInputForVehicleFileUpload(element)
|
||||
function removeHTMLInputForVehicleFileUpload(element, container_id)
|
||||
{
|
||||
const container = document.getElementById('dynamic-form-container-for-vehicle-file-upload');
|
||||
const container = document.getElementById(container_id);
|
||||
const rows = container.querySelectorAll('.dynamic-form-row');
|
||||
|
||||
if (rows.length > 1) {
|
||||
|
||||
484
app/Views/pos_list.php
Normal file
484
app/Views/pos_list.php
Normal file
@ -0,0 +1,484 @@
|
||||
<style>
|
||||
.dataTables_filter {
|
||||
position: absolute;
|
||||
}
|
||||
.dataTables_length label {height: 21px !important;}
|
||||
</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">Manager</th>
|
||||
<th class="font-weight-medium">POS Name</th>
|
||||
<th class="font-weight-medium">POS Code</th>
|
||||
<th class="font-weight-medium">Email</th>
|
||||
<th class="font-weight-medium">Mobile</th>
|
||||
<th class="font-weight-medium">Status</th>
|
||||
<th class="font-weight-medium">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if(isset($data['pos_list'])) { $slno = 1; ?>
|
||||
<?php foreach($data['pos_list'] as $index => $row) { ?>
|
||||
<tr>
|
||||
<td class="text-center"><?= $slno++; ?></td>
|
||||
<td><?= $row['manager_name']; ?></td>
|
||||
<td><?= $row['name']; ?></td>
|
||||
<td><?= $row['pos_code']; ?></td>
|
||||
<td><?= $row['email']; ?></td>
|
||||
<td><?= $row['mobile']; ?></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 modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="modalLabel">Add POS 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="partnerPOSForm" enctype="multipart/form-data"> -->
|
||||
<form id="partnerPOSForm" enctype="multipart/form-data">
|
||||
<input type="hidden" name="pk" id="pos_id"/>
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="manager_id">Manager<span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="manager_id" name="manager_id" required>
|
||||
<option value="" selected>Select Manager</option>
|
||||
<?php if (!empty($data['manager_list'])): ?>
|
||||
<?php foreach ($data['manager_list'] as $value): ?>
|
||||
<option value="<?= esc($value['id']) ?>">
|
||||
<?= esc($value['name']) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="name">Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="name" name="name" placeholder="Enter Name" required>
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="pos_code">POS Code<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="pos_code" name="pos_code" placeholder="Enter Code" required>
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="email">Email<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="email" name="email" placeholder="Enter Email" required>
|
||||
<small id="email_error" class="text-danger d-none"></small>
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="mobile">Mobile<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="mobile" name="mobile" placeholder="Enter Mobile" maxlength="10" inputmode="numeric" pattern="[0-9]{10}" required>
|
||||
<small id="mobile_error" class="text-danger d-none"></small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="address">Address<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="address" name="address" placeholder="Enter Address" required>
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="city">City<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="city" name="city" placeholder="Enter City" required>
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="state">State<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="state" name="state" placeholder="Enter State" required>
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="pincode">Pincode<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="pincode" name="pincode" placeholder="Enter Pincode" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="aadhar">Aadhaar Number<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="aadhar" name="aadhar" placeholder="Enter Aadhaar Number" maxlength="12" inputmode="numeric" pattern="[0-9]{12}" required>
|
||||
<small id="aadhar_error" class="text-danger d-none"></small>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="pan">PAN Number<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="pan" name="pan" placeholder="Enter PAN Number" maxlength="10" style="text-transform:uppercase" pattern="[A-Z]{5}[0-9]{4}[A-Z]{1}" required>
|
||||
<small id="pan_error" class="text-danger d-none"></small>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="gst">GST Number</label>
|
||||
<input type="text" class="form-control" id="gst" name="gst" placeholder="Enter GST Number">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="aadhar_file_name">Aadhar</label>
|
||||
<div class="input-icon">
|
||||
<input type="file" class="form-control" name="aadhar_file_name" id="aadhar_file_name" accept="image/*,application/pdf">
|
||||
<i class="mdi mdi-upload additional-icon"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="pan_file_name">PAN</label>
|
||||
<div class="input-icon">
|
||||
<input type="file" class="form-control" name="pan_file_name" id="pan_file_name" accept="image/*,application/pdf">
|
||||
<i class="mdi mdi-upload additional-icon"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="certificate_file_name">Certificate</label>
|
||||
<div class="input-icon">
|
||||
<input type="file" class="form-control" name="certificate_file_name" id="certificate_file_name" accept="image/*,application/pdf">
|
||||
<i class="mdi mdi-upload additional-icon"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<!-- <legend>Bank Details</legend> -->
|
||||
<div class="form-group col-md-3">
|
||||
<label for="bank_name">Bank Name</label>
|
||||
<input type="text" id="bank_name" name="bank_name" class="form-control" placeholder="Enter Bank Name">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="account_holder_name">Account Holder Name</label>
|
||||
<input type="text" id="account_holder_name" name="account_holder_name" class="form-control" placeholder="Enter Account Holder Name">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="account_number">Account Number</label>
|
||||
<input type="text" id="account_number" name="account_number" class="form-control" placeholder="Enter Account Number">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="ifsc_code">IFSC Code</label>
|
||||
<input type="text" id="ifsc_code" name="ifsc_code" class="form-control" placeholder="Enter IFSC Code">
|
||||
</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> -->
|
||||
<button type="submit" class="btn app-btn-secondary" id="btnSubmit">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var table;
|
||||
$(document).ready(function () {
|
||||
$('#manager_id').select2();
|
||||
var ticketsTable = $('#user-table');
|
||||
ticketsTable.DataTable({
|
||||
scrollX: true,
|
||||
// dom: "<'row'<'col-sm-7'f><'col-sm-5 text-right'B>>" + // Filter left, buttons right
|
||||
// "<'row'<'col-sm-12'tr>>" +
|
||||
// "<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
|
||||
dom: "<'row'<'col-sm-7'f><'col-sm-5 text-right'B>>" + // Filter left, buttons right
|
||||
"<'row'<'col-sm-12'tr>>" +
|
||||
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
|
||||
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
|
||||
buttons: [
|
||||
{
|
||||
text: 'Add',
|
||||
className: 'btn app-btn-primary mr-2',
|
||||
action: function(e, dt, node, config) {
|
||||
resetValues();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: 'POS-List',
|
||||
className: 'app-btn-primary ',
|
||||
exportOptions: {
|
||||
columns: ':not(:last-child)'
|
||||
},
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
language: {
|
||||
search: `
|
||||
<div class="datatable-search-wrapper" style="position:relative; display:inline-block;">
|
||||
_INPUT_
|
||||
<i class="mdi mdi-magnify datatable-search-icon"
|
||||
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666;"></i>
|
||||
<i class="mdi mdi-close-circle datatable-clear-icon"
|
||||
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666; display:none;"></i>
|
||||
</div>`,
|
||||
searchPlaceholder: "Search",
|
||||
emptyTable: '<div class="text-center text-muted">No Data found</div>'
|
||||
},
|
||||
paging: true, // Enable pagination
|
||||
pageLength: 10, // Set default number of rows per page (optional)
|
||||
// ordering: false,
|
||||
});
|
||||
});
|
||||
|
||||
$('.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 form = document.getElementById('partnerPOSForm');
|
||||
let url = '<?= base_url('util/partnerPOS') ?>';
|
||||
let method = "POST";
|
||||
let pk = el ? $(el).data('id') : null;
|
||||
|
||||
let formData;
|
||||
|
||||
if (type === 'submit') {
|
||||
|
||||
// if (!form.checkValidity()) {
|
||||
// form.reportValidity();
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (!validateForm()) return;
|
||||
|
||||
// CREATE FORMDATA FROM FORM
|
||||
formData = new FormData(form);
|
||||
|
||||
// OPTIONAL: re-append file inputs (safe for edit mode)
|
||||
$('#partnerPOSForm input[type="file"]').each(function () {
|
||||
if (this.files.length > 0) {
|
||||
formData.set(this.name, this.files[0]); // use set(), not append()
|
||||
}
|
||||
});
|
||||
|
||||
} else if (type == 'edit') {
|
||||
method = "GET";
|
||||
if (pk) url += '?pk=' + pk;
|
||||
$('#modalLabel').text('Edit POS Details');
|
||||
$('#partnerPOSForm')[0].reset();
|
||||
|
||||
} else if (type == 'remove') {
|
||||
method = "DELETE";
|
||||
if (pk) url += '?pk=' + pk;
|
||||
}
|
||||
|
||||
$('.loader, .loader-mask').fadeIn();
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: method,
|
||||
data: (type === 'submit') ? formData : null,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function (response) {
|
||||
console.log('Response:', response);
|
||||
if (response.status) {
|
||||
if(type == 'edit'){
|
||||
let record = response.data.pos_list[0]; // single record
|
||||
appendEditData(record);
|
||||
} else if(type == 'remove'){
|
||||
toastr.success(response.message, 'Success');
|
||||
// if(el) $(el).closest('tr').remove();
|
||||
window.location.reload();
|
||||
} else if(type == 'submit'){
|
||||
toastr.success(response.message, 'Success');
|
||||
var myModal = new bootstrap.Modal(document.getElementById('con-close-modal'));
|
||||
myModal.hide();
|
||||
$('#partnerPOSForm')[0].reset();
|
||||
window.location.reload();
|
||||
}
|
||||
} else {
|
||||
toastr.warning(response.message, 'Warning');
|
||||
}
|
||||
$('.loader, .loader-mask').fadeOut();
|
||||
},
|
||||
error: function () {
|
||||
$('.loader, .loader-mask').fadeOut();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function resetValues(){
|
||||
$('#modalLabel').text('Add POS Details');
|
||||
$('#partnerPOSForm')[0].reset();
|
||||
$('#manager_id').val(null).trigger('change');
|
||||
|
||||
}
|
||||
|
||||
|
||||
function appendEditData(data){
|
||||
$('#pos_id').val(data.id);
|
||||
$('#name').val(data.name);
|
||||
$('#email').val(data.email);
|
||||
$('#mobile').val(data.mobile);
|
||||
$('#pos_code').val(data.pos_code);
|
||||
|
||||
// Instead of setting the file input
|
||||
$('#current_file_name').text(data['certificate_file_name'] || 'No file uploaded');
|
||||
|
||||
$('#aadhar').val(data.aadhar);
|
||||
$('#aadhar_file_name').text(data['aadhar_file_name'] || 'No file uploaded');
|
||||
|
||||
$('#pan').val(data.pan);
|
||||
$('#pan_file_name').text(data['pan_file_name'] || 'No file uploaded');
|
||||
|
||||
$('#bank_name').val(data.bank_name);
|
||||
$('#account_holder_name').val(data.account_holder_name);
|
||||
$('#account_number').val(data.account_number);
|
||||
$('#ifsc_code').val(data.ifsc_code);
|
||||
|
||||
$('#gst').val(data.gst);
|
||||
|
||||
$('#state').val(data.state);
|
||||
$('#city').val(data.city);
|
||||
$('#pincode').val(data.pincode);
|
||||
$('#address').val(data.address);
|
||||
|
||||
openModal();
|
||||
$('#con-close-modal').one('shown.bs.modal', function () {
|
||||
$('#manager_id').val(data.manager_id).trigger('change');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
$('#aadhar').on('input', function () {
|
||||
this.value = this.value.replace(/[^0-9]/g, '');
|
||||
});
|
||||
|
||||
$('#pan').on('input', function () {
|
||||
this.value = this.value.toUpperCase().replace(/[^A-Z0-9]/g, '');
|
||||
});
|
||||
|
||||
$('#mobile').on('input', function () {
|
||||
this.value = this.value.replace(/[^0-9]/g, '');
|
||||
});
|
||||
|
||||
|
||||
|
||||
$('#partnerPOSForm').on('submit', function(e) {
|
||||
e.preventDefault();
|
||||
const form = this;
|
||||
|
||||
// HTML5 built-in validation
|
||||
if (!form.checkValidity()) {
|
||||
form.reportValidity(); // shows required/pattern tooltips
|
||||
return;
|
||||
}
|
||||
|
||||
// Custom validation
|
||||
if (!validateForm()) return;
|
||||
|
||||
// If valid, submit via AJAX
|
||||
handleSaveEditAndDelete('submit');
|
||||
});
|
||||
|
||||
|
||||
function validateForm() {
|
||||
let isValid = true;
|
||||
|
||||
// Clear old errors
|
||||
$('.text-danger').addClass('d-none').text('');
|
||||
|
||||
// Regex patterns
|
||||
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||
const mobileRegex = /^[6-9]\d{9}$/;
|
||||
const aadharRegex = /^\d{12}$/;
|
||||
const panRegex = /^[A-Z]{5}[0-9]{4}[A-Z]$/;
|
||||
|
||||
// EMAIL
|
||||
const email = $('#email').val().trim();
|
||||
if (email === '') {
|
||||
$('#email_error').text('Email is required').removeClass('d-none');
|
||||
isValid = false;
|
||||
} else if (!emailRegex.test(email)) {
|
||||
$('#email_error').text('Enter a valid email').removeClass('d-none');
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
// MOBILE
|
||||
const mobile = $('#mobile').val().trim();
|
||||
if (mobile === '') {
|
||||
$('#mobile_error').text('Mobile number is required').removeClass('d-none');
|
||||
isValid = false;
|
||||
} else if (!mobileRegex.test(mobile)) {
|
||||
$('#mobile_error').text('Enter a valid 10-digit mobile number').removeClass('d-none');
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
// AADHAAR
|
||||
const aadhar = $('#aadhar').val().trim();
|
||||
if (aadhar === '') {
|
||||
$('#aadhar_error').text('Aadhaar is required').removeClass('d-none');
|
||||
isValid = false;
|
||||
} else if (!aadharRegex.test(aadhar)) {
|
||||
$('#aadhar_error').text('Aadhaar must be 12 digits').removeClass('d-none');
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
// PAN
|
||||
const pan = $('#pan').val().trim();
|
||||
if (pan === '') {
|
||||
$('#pan_error').text('PAN is required').removeClass('d-none');
|
||||
isValid = false;
|
||||
} else if (!panRegex.test(pan)) {
|
||||
$('#pan_error').text('Invalid PAN format (AAAPA1234A)').removeClass('d-none');
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
return isValid;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
<li class="nav-item" id="hide_file_upload" style="display: none;">
|
||||
<a href="#fileupload" data-toggle="tab" aria-expanded="true" class="nav-link px-3 py-2" id="kyc_tab">
|
||||
<span class="mr-1"><i class="mdi mdi-file"></i></span>
|
||||
<span class="d-none d-sm-inline-block">File Upload</span>
|
||||
<span class="d-none d-sm-inline-block">Policy Docs</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item" id="hide_vehicle_tab" style="display: none;">
|
||||
|
||||
@ -54,11 +54,15 @@ table.dataTable tbody td {
|
||||
</div>
|
||||
|
||||
<div class="badge-container">
|
||||
Total Rewards: <span class="text-primary" id="total_rewards">0.00</span>
|
||||
IRDA Amount : <span class="text-primary" id="total_irda">0.00</span>
|
||||
</div>
|
||||
|
||||
<div class="badge-container">
|
||||
Total IRDA Revenue INR: <span class="text-primary" id="total_irda">0.00</span>
|
||||
Rewards: <span class="text-primary" id="total_rewards">0.00</span>
|
||||
</div>
|
||||
|
||||
<div class="badge-container">
|
||||
Revenue: <span class="text-primary" id="total_revenue">0.00</span>
|
||||
</div>
|
||||
|
||||
<div class="badge-container">
|
||||
@ -84,7 +88,7 @@ table.dataTable tbody td {
|
||||
<th style="display: none;">Business Type</th>
|
||||
<th style="display: none;">Client Type</th>
|
||||
<th>Insured Name</th>
|
||||
<th style="text-align:center;">Policy /<br>Endorsement</th>
|
||||
<th style="text-align:center;">Transaction Type</th>
|
||||
<th>Policy Type</th>
|
||||
<th style="display: none;">BAP Group</th>
|
||||
<th style="display: none;">Vehicle Number</th>
|
||||
@ -99,23 +103,60 @@ table.dataTable tbody td {
|
||||
<th style="display: none;">Reference</th>
|
||||
<th style="display: none;">Remarks</th>
|
||||
<th>BP Premium</th>
|
||||
<th>TP/Ter Premium</th>
|
||||
<th>TP Premium</th>
|
||||
<th style="text-align:center;">Premium <br>(without GST)</th>
|
||||
<!-- <th style="display: none;">GST @ 18%</th> -->
|
||||
<th style="display: none;">Total Premium</th>
|
||||
<th>BP%</th>
|
||||
<th>TP/Ter%</th>
|
||||
<th>Agreed BP %</th>
|
||||
<th>Agreed TP %</th>
|
||||
<th style="display: none;">Rewards</th>
|
||||
<th>Agreed Amount</th>
|
||||
<th>Invoiced Amount</th>
|
||||
<th>Outstanding Amount</th>
|
||||
|
||||
<th style="display: none;">Salse Person</th>
|
||||
<th style="display: none;">Service Person</th>
|
||||
<th style="display: none;">Nhance Branch</th>
|
||||
<th style="display: none;">Salse Person Branch</th>
|
||||
<th style="display: none;">Installment</th>
|
||||
<th style="display: none;">Data Received Date</th>
|
||||
<th style="display: none;">Renewal Date</th>
|
||||
|
||||
|
||||
<th style="display: none;">Co-Premium</th>
|
||||
<th style="display: none;">Remuneration Pay By Leader</th>
|
||||
|
||||
<th style="display: none;">Salse Person Manager</th>
|
||||
<th style="display: none;">Service Person Manager</th>
|
||||
<th style="display: none;">Service Person Branch</th>
|
||||
|
||||
<th style="display: none;">Rollover Date</th>
|
||||
|
||||
<th style="display: none;">Policyholder Name</th>
|
||||
<th style="display: none;">Insured (Same as Proposer)</th>
|
||||
|
||||
<th style="display: none;">Follower Policy No</th>
|
||||
|
||||
<th style="display: none;">Co-Share %</th>
|
||||
<th style="display: none;">Non Commissional <br> Premium Amount</th>
|
||||
|
||||
<th style="display: none;">CGST</th>
|
||||
<th style="display: none;">SGST</th>
|
||||
<th style="display: none;">IGST</th>
|
||||
|
||||
<th style="display: none;">Stamp Duty</th>
|
||||
|
||||
<th style="display: none;">Standard BP %</th>
|
||||
<th style="display: none;">Standard TP %</th>
|
||||
|
||||
<th style="display: none;">Actual BP Amount</th>
|
||||
<th style="display: none;">Actual TP Amount</th>
|
||||
|
||||
<th style="display: none;">Actual BP %</th>
|
||||
<th style="display: none;">Actual TP %</th>
|
||||
|
||||
<th style="display: none;">Actual BP Remuneration Amount</th>
|
||||
<th style="display: none;">Actual TP Remuneration Amount</th>
|
||||
|
||||
<th style="display: none;">CD Account No</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -148,13 +189,14 @@ table.dataTable tbody td {
|
||||
<td style="display: none;"><?php echo empty($row['policy_end_date']) ? 'N/A' : date('d/m/Y', strtotime($row['policy_end_date'])); ?></td>
|
||||
<td style="display: none;"><?php echo $row['ref'] ?: 'N/A'; ?></td>
|
||||
<td style="display: none;"><?php echo $row['remarks'] ?: 'N/A'; ?></td>
|
||||
|
||||
<td class="right-align-input"><?php echo ($row['total_irda_amt'] != 0.00) ? ($row['bp_amt'] ?: '0.00') : '0.00'; ?></td>
|
||||
<td class="right-align-input"><?php echo $row['tp_or_ter'] ?: '0.00'; ?></td>
|
||||
<td class="right-align-input"><?php echo ($row['total_irda_amt'] != 0.00) ? ($row['tp_or_ter'] ?: '0.00') : '0.00'; ?></td>
|
||||
<td class="right-align-input"><?php echo ($row['total_irda_amt'] != 0.00) ? ($row['premium_wo_gst'] ?: '0.00') : '0.00'; ?></td>
|
||||
<!-- <td class="right-align-input" style="display: none;"><?php echo $row['gst_amount']; ?></td> -->
|
||||
<td class="right-align-input" style="display: none;"><?php echo $row['total_premium'] ?: '0.00'; ?></td>
|
||||
<td class="right-align-input"><?php echo $row['agreed_bp_per'] ?: '0.00'; ?>%</td>
|
||||
<td class="right-align-input"><?php echo $row['agreed_tp_or_ter_per'] ?: '0.00';?>%</td>
|
||||
<td class="right-align-input" style="display: none;"><?php echo ($row['total_irda_amt'] != 0.00) ? ($row['total_premium'] ?: '0.00') : '0.00'; ?></td>
|
||||
<td class="right-align-input"><?php echo ($row['total_irda_amt'] != 0.00) ? ($row['agreed_bp_per'] ?: '0.00') : '0.00'; ?>%</td>
|
||||
<td class="right-align-input"><?php echo ($row['total_irda_amt'] != 0.00) ? ($row['agreed_tp_or_ter_per'] ?: '0.00') : '0.00'; ?>%</td>
|
||||
<td class="right-align-input" style="display: none;"><?php echo isset($row['reward']) ? $row['reward'] : '0.00'; ?></td>
|
||||
|
||||
<?php
|
||||
@ -169,7 +211,8 @@ table.dataTable tbody td {
|
||||
$exp_amt = isset($row['exp_amt']) && $row['exp_amt'] !== '' ? (float)$row['exp_amt'] : 0;
|
||||
// $max_amount = max($irda_amt, $exp_amt);
|
||||
// $total_irda_amt = number_format($max_amount, 2, '.', '');
|
||||
$total_irda_amt = empty($row['total_irda_amt']) ? $row['exp_amt'] : $row['total_irda_amt'];
|
||||
// $total_irda_amt = empty($row['total_irda_amt']) ? $row['exp_amt'] : $row['total_irda_amt'];
|
||||
$total_irda_amt = $row['total_irda_amt'] ?? '0.00';
|
||||
?>
|
||||
<td class="right-align-input" onclick="showCoShareStatementDetails(this)" data-id="<?= $row['pt_id'] ?>"><?php echo $total_irda_amt; ?></td>
|
||||
<td class="right-align-input"><?php echo empty($row['billed_amt']) ? '0.00' : $row['billed_amt'] ?></td>
|
||||
@ -189,7 +232,9 @@ table.dataTable tbody td {
|
||||
<td class="right-align-input">
|
||||
<?php echo
|
||||
// number_format((float)$unbilled_amt,2, '.', '')
|
||||
number_format((float)$row['unbilled_amount'],2, '.', '');
|
||||
// number_format((float) ($row['unbilled_amount'] ?: 0), 2, '.', '');
|
||||
$unbilled = isset($row['unbilled_amount']) ? $row['unbilled_amount'] : '0.00';
|
||||
number_format($unbilled, 2, '.', '');
|
||||
?>
|
||||
</td>
|
||||
<td style="display: none;"><?php echo $row['salse_person_name'] ?: 'N/A'; ?></td>
|
||||
@ -198,6 +243,44 @@ table.dataTable tbody td {
|
||||
<td style="display: none;"><?php echo $row['installment'] ?: 'N/A'; ?></td>
|
||||
<td style="display: none;"><?php echo empty($row['data_received_date']) ? 'N/A' : date('d/m/Y', strtotime($row['data_received_date'])) ?></td>
|
||||
<td style="display: none;"><?php echo empty($row['renewal_date']) ? 'N/A' : date('d/m/Y', strtotime($row['renewal_date'])) ?></td>
|
||||
|
||||
<td style="display:none;"><?php echo $row['co_share'] ?? 'No'; ?></td>
|
||||
<td style="display:none;"><?php echo $row['bro_payable_by'] ?? 'No'; ?></td>
|
||||
|
||||
<td style="display:none;"><?php echo $row['salse_manager_name'] ?: 'N/A'; ?></td>
|
||||
<td style="display:none;"><?php echo $row['service_manager_name'] ?: 'N/A'; ?></td>
|
||||
<td style="display:none;"><?php echo $row['service_branch'] ?: 'N/A'; ?></td>
|
||||
|
||||
<td style="display:none;"><?php echo empty($row['rollover_date']) ? 'N/A' : change_date_format($row['rollover_date'], 'Y-m-d', 'd/m/Y') ?? 'N/A'; ?> </td>
|
||||
|
||||
<td style="display:none;"><?php echo $row['policy_holder_name'] ?: 'N/A'; ?></td>
|
||||
<td style="display:none;"><?php echo $row['same_as_proposer'] ?? 'No'; ?></td>
|
||||
|
||||
<td style="display:none;"><?php echo $row['follower_policy_no'] ?: 'N/A'; ?></td>
|
||||
|
||||
<td style="display:none;"><?php echo number_format((float)($row['co_share_per'] ?? 0), 2); ?></td>
|
||||
|
||||
<td style="display:none;"><?php echo number_format((float)($row['non_comm_per_amt'] ?? 0), 2); ?></td>
|
||||
|
||||
<td style="display:none;"><?php echo number_format((float)($row['bp_igst'] ?? 0), 2); ?></td>
|
||||
<td style="display:none;"><?php echo number_format((float)($row['bp_sgst'] ?? 0), 2); ?></td>
|
||||
<td style="display:none;"><?php echo number_format((float)($row['bp_cgst'] ?? 0), 2); ?></td>
|
||||
|
||||
<td style="display:none;"><?php echo number_format((float)($row['stamp_duty'] ?? 0), 2); ?></td>
|
||||
|
||||
<td style="display:none;"><?php echo number_format((float)($row['standerd_bp_per'] ?? 0), 2); ?></td>
|
||||
<td style="display:none;"><?php echo number_format((float)($row['standerd_tp_per'] ?? 0), 2); ?></td>
|
||||
|
||||
<td style="display:none;"><?php echo number_format((float)($row['actual_bp_amt'] ?? 0), 2); ?></td>
|
||||
<td style="display:none;"><?php echo number_format((float)($row['actual_tp_amt'] ?? 0), 2); ?></td>
|
||||
|
||||
<td style="display:none;"><?php echo number_format((float)($row['actual_bp_per'] ?? 0), 2); ?></td>
|
||||
<td style="display:none;"><?php echo number_format((float)($row['actual_tp_per'] ?? 0), 2); ?></td>
|
||||
|
||||
<td style="display:none;"><?php echo number_format((float)($row['actual_tep_brokerage_amt'] ?? 0), 2); ?></td>
|
||||
<td style="display:none;"><?php echo number_format((float)($row['actual_tp_brokerage_amt'] ?? 0), 2); ?></td>
|
||||
|
||||
<td style="display:none;"><?php echo $row['cd_ac_no'] ?: 'N/A'; ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
@ -602,12 +685,15 @@ $(document).ready(function() {
|
||||
var totalRewards = getTotal(24);
|
||||
var totalIrda = getTotal(25);
|
||||
var totalBilled = getTotal(26);
|
||||
var totalRevenue = parseFloat(totalIrda) + parseFloat(totalRewards);
|
||||
// var totalUnbilled = getTotal(27);
|
||||
|
||||
// Update the totals section above the table
|
||||
$('#total_premium').text(totalPremium.toFixed(2));
|
||||
$('#total_rewards').text(totalRewards.toFixed(2));
|
||||
$('#total_irda').text(totalIrda.toFixed(2));
|
||||
// $('#total_revenue').text(totalRevenue.toFixed(2));
|
||||
$('#total_revenue').text(totalIrda.toFixed(2));
|
||||
$('#total_billed').text(totalBilled.toFixed(2));
|
||||
// $('#total_unbilled').text(totalUnbilled.toFixed(2));
|
||||
var totalUnbilled = getUniqueUnbilled(27);
|
||||
|
||||
@ -39,6 +39,24 @@
|
||||
.arrow.rotate {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
|
||||
/* Ensure the dropdown matches the width of the input field */
|
||||
/* .select2-container {
|
||||
width: 100% !important;
|
||||
} */
|
||||
|
||||
/* Ensure the dropdown appears ABOVE the modal and is visible */
|
||||
/* .select2-container--open {
|
||||
z-index: 9999999 !important;
|
||||
} */
|
||||
|
||||
/* Fix for the "empty" or "misaligned" look in your screenshot */
|
||||
/* .select2-results__option {
|
||||
display: block !important;
|
||||
width: 100%;
|
||||
clear: both;
|
||||
} */
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
@ -491,20 +509,129 @@
|
||||
|
||||
// }
|
||||
|
||||
// function appendClientsForMobileSearch(data) {
|
||||
// let $select = $('#mobile_emp_client_data_list');
|
||||
// $select.empty();
|
||||
|
||||
// let options = '<option value="0">Select Client</option>';
|
||||
|
||||
// $.each(data, function(index, item) {
|
||||
// options += `<option value="${item.id}">${item.short_name}</option>`;
|
||||
// });
|
||||
|
||||
// $select.html(options);
|
||||
// $select.select2(); // ✅ Only once
|
||||
// }
|
||||
|
||||
function appendClientsForMobileSearch(data) {
|
||||
let $select = $('#mobile_emp_client_data_list');
|
||||
$select.empty();
|
||||
|
||||
let options = '<option value="0">Select Client</option>';
|
||||
|
||||
$.each(data, function(index, item) {
|
||||
options += `<option value="${item.id}">${item.short_name}</option>`;
|
||||
$.each(data, function (index, item) {
|
||||
|
||||
let safeName = item.client_name.slice(0, 12) + "...";
|
||||
let safeShortName = item.short_name;
|
||||
|
||||
options += `<option value="${item.id}">
|
||||
${safeShortName} - ${safeName}
|
||||
</option>`;
|
||||
});
|
||||
|
||||
$select.html(options);
|
||||
$select.select2(); // ✅ Only once
|
||||
$select.html(options).select2(); // init once
|
||||
}
|
||||
|
||||
|
||||
// function appendClientsForMobileSearch(data) {
|
||||
// let $select = $('#mobile_emp_client_data_list');
|
||||
|
||||
// // 1. Destroy any existing Select2 to ensure our new settings apply
|
||||
// if ($select.data('select2')) {
|
||||
// $select.select2('destroy');
|
||||
// }
|
||||
|
||||
// // 2. Re-build the options
|
||||
// $select.empty();
|
||||
// let options = '<option value="0">Select Client</option>';
|
||||
// $.each(data, function(index, item) {
|
||||
// // Store both names in data attributes
|
||||
// options += `<option value="${item.id}"
|
||||
// data-shortname="${item.short_name}"
|
||||
// data-fullname="${item.client_name}">
|
||||
// ${item.short_name}
|
||||
// </option>`;
|
||||
// });
|
||||
// $select.html(options);
|
||||
|
||||
// // 3. Initialize Select2 with the template logic
|
||||
// $select.select2({
|
||||
// dropdownParent: $('.modal-body').length ? $('.modal-body') : $(document.body), // Fix for modals
|
||||
// escapeMarkup: function(m) { return m; }, // This allows HTML to render
|
||||
// templateResult: function(data) {
|
||||
// // Check if it's the placeholder
|
||||
// if (!data.id || data.id == "0") return data.text;
|
||||
|
||||
// // Get data from the attributes we saved in step 2
|
||||
// let short = $(data.element).data('shortname');
|
||||
// let full = $(data.element).data('fullname');
|
||||
|
||||
// // Return the two-line HTML string
|
||||
// return `
|
||||
// <div style="line-height: 1.2; padding: 4px 0;">
|
||||
// <div style="font-weight: bold;">${short}</div>
|
||||
// <div style="font-size: 0.75em; color: #6c757d;">${full}</div>
|
||||
// </div>
|
||||
// `;
|
||||
// },
|
||||
// templateSelection: function(data) {
|
||||
// if (!data.id || data.id == "0") return data.text;
|
||||
// // Only show short name in the selection box
|
||||
// return $(data.element).data('shortname');
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// function appendClientsForMobileSearch(data) {
|
||||
// let $select = $('#mobile_emp_client_data_list');
|
||||
|
||||
// // Destroy existing instance to reset position logic
|
||||
// if ($select.data('select2')) {
|
||||
// $select.select2('destroy');
|
||||
// }
|
||||
// $select.empty();
|
||||
|
||||
// // Initialize Select2
|
||||
// $select.select2({
|
||||
// // THIS IS KEY: Attach the dropdown to the modal container
|
||||
// // Replace '.modal' with your specific modal ID if needed (e.g., '#myModal')
|
||||
// dropdownParent: $select.closest('.modal'),
|
||||
|
||||
// data: $.map(data, function (item) {
|
||||
// return {
|
||||
// id: item.id,
|
||||
// text: item.short_name,
|
||||
// full: item.client_name // Passing extra data here
|
||||
// };
|
||||
// }),
|
||||
// escapeMarkup: function(m) { return m; },
|
||||
// templateResult: function (item) {
|
||||
// if (!item.id || item.id == "0") return item.text;
|
||||
|
||||
// // Using template literals for the two lines
|
||||
// return `
|
||||
// <div style="padding: 5px; line-height: 1.2;">
|
||||
// <div style="font-weight: bold; color: #333;">${item.text}</div>
|
||||
// <div style="font-size: 11px; color: #6c757d;">${item.full}</div>
|
||||
// </div>
|
||||
// `;
|
||||
// },
|
||||
// templateSelection: function (item) {
|
||||
// return item.text; // Only show short name when closed
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
//append the clients branch data to the modal
|
||||
function appendBranch(data) {
|
||||
$('#emp_client_branch_data_list').empty();
|
||||
|
||||
@ -25,6 +25,10 @@ table.dataTable tbody td {
|
||||
margin-left: 20px !important;
|
||||
}
|
||||
.dataTables_length label {height: 21px !important;}
|
||||
.text-custom-grey{
|
||||
font-size: 0.65em;
|
||||
color: #6c757d !important;
|
||||
}
|
||||
|
||||
</style>
|
||||
<style>
|
||||
@ -48,7 +52,7 @@ table.dataTable tbody td {
|
||||
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="card-body" style="padding : 0 1.5rem 0 1.5rem !important">
|
||||
<div class="row" style="padding-bottom: 10px;">
|
||||
<div class="col-6" style="align-self: center;">
|
||||
<h4 style="position: relative;">Claim List </h4>
|
||||
@ -161,10 +165,17 @@ table.dataTable tbody td {
|
||||
}
|
||||
?>
|
||||
</span>
|
||||
<?php if (!empty($row['ticket_updated_date'])): ?>
|
||||
<span class="text-custom-grey"><br><?= "Updated at ".$row['ticket_updated_date']; ?></span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
|
||||
<td><?php echo str_replace("Claim-", "", $ticket_type[$row['ticket_type_id']] ?? 'N/A'); ?></td>
|
||||
<td><?php echo $row['claim_no'] ?: 'N/A' ; ?></td>
|
||||
<td><?php echo $row['claim_no'] ?: 'N/A' ; ?>
|
||||
<?php if (!empty($row['ticket_created_date'])): ?>
|
||||
<span class="text-custom-grey"><br><?= "Created at ".$row['ticket_created_date']; ?></span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td><?php echo $row['tpa_no'] ?: 'N/A'; ?></td>
|
||||
<td><?php echo $row['emp_code'] ?: 'N/A'; ?></td>
|
||||
<td><?php echo $row['emp_name'] ?: 'N/A'; ?></td>
|
||||
|
||||
@ -6,9 +6,9 @@
|
||||
</style>
|
||||
|
||||
<div class="container-fluid-min">
|
||||
<div class="row">
|
||||
<div class="row" style="margin-bottom: -12px;">
|
||||
<div class="col-12" style="margin-top: -12px;">
|
||||
<div class="card-body">
|
||||
<div class="card-body" style="padding : 1.5rem 1.5rem 0 1.5rem !important">
|
||||
<div id="accordion" class="mb-3">
|
||||
<div class="card mb-1">
|
||||
<h4>
|
||||
@ -121,6 +121,30 @@
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label>Date Type<span class="text-danger"></span></label>
|
||||
<select class="form-control" id="date_type" name="date_type" onchange="hideDateField()">
|
||||
<option value="0">Select Date Type</option>
|
||||
<?php
|
||||
if (isset($date_type) && count($date_type)) {
|
||||
foreach ($date_type as $key => $value) {
|
||||
echo "<option value='" . $key . "'>" . $value . "</option>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3" style="display: none;" id="date_div">
|
||||
<label>Date<span class="text-danger"></span></label>
|
||||
<div class="input-icon">
|
||||
<input type="text" id="reportrange" class="form-control" readonly style="caret-color: transparent;">
|
||||
<i class="mdi mdi-calendar-blank-outline additional-icon"></i>
|
||||
</div>
|
||||
<input type="hidden" id="startDate">
|
||||
<input type="hidden" id="endDate">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-12 text-right m-b-0" style="margin-bottom: -15px;">
|
||||
<a href="#" class="btn btn-secondary" id="clear-filters">Clear</a>
|
||||
<a class="btn btn-primary" id="get-emp-list" onclick="fetchTicketListData();">Submit</a>
|
||||
@ -192,6 +216,10 @@
|
||||
var insurer_id = $('#insurer_id').val();
|
||||
var tpa_id = $('#tpa_id').val();
|
||||
|
||||
var start_date = $('#startDate').val();
|
||||
var end_date = $('#endDate').val();
|
||||
var date_type = $('#date_type').val();
|
||||
|
||||
var requestData = {
|
||||
ticket_type_id: ticket_type,
|
||||
pod_no: pod_no,
|
||||
@ -203,6 +231,9 @@
|
||||
client_id: client_id,
|
||||
insurer_id: insurer_id,
|
||||
tpa_id: tpa_id,
|
||||
start_date: start_date,
|
||||
end_date: end_date,
|
||||
date_type: date_type,
|
||||
};
|
||||
|
||||
let filterData = requestData;
|
||||
@ -294,12 +325,59 @@
|
||||
$('#client_id').val(filterData.client_id);
|
||||
$('#insurer_id').val(filterData.insurer_id);
|
||||
$('#tpa_id').val(filterData.tpa_id);
|
||||
|
||||
$('#date_type').val(filterData.date_type);
|
||||
if(filterData.date_type == '0'){
|
||||
$('#date_div').hide();
|
||||
}else{
|
||||
$('#date_div').show();
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<script>
|
||||
|
||||
$(function() {
|
||||
|
||||
const url = new URL(window.location.href);
|
||||
const params = new URLSearchParams(url.search);
|
||||
|
||||
// Get start and end dates from URL parameters, or use default values
|
||||
const startDateParam = params.get('start_date') || moment().subtract(29, 'days').format('DD-MM-YYYY');
|
||||
const endDateParam = params.get('end_date') || moment().format('DD-MM-YYYY');
|
||||
|
||||
// Parse the dates to moment objects
|
||||
var start = moment(startDateParam, 'DD-MM-YYYY');
|
||||
var end = moment(endDateParam, 'DD-MM-YYYY');
|
||||
|
||||
// var start = moment().subtract(29, 'days');
|
||||
// var end = moment();
|
||||
|
||||
function cb(start, end) {
|
||||
$('#reportrange').html(start.format('D-MM-YYYY') + ' - ' + end.format('D-MM-YYYY'));
|
||||
$('#startDate').val(start.format('DD-MM-YYYY'));
|
||||
$('#endDate').val(end.format('DD-MM-YYYY'));
|
||||
}
|
||||
|
||||
$('#reportrange').daterangepicker({
|
||||
startDate: start,
|
||||
endDate: end,
|
||||
locale: {
|
||||
format: 'DD-MM-YYYY'
|
||||
},
|
||||
ranges: {
|
||||
'Today': [moment(), moment()],
|
||||
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
|
||||
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
|
||||
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
|
||||
'This Month': [moment().startOf('month'), moment().endOf('month')],
|
||||
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
|
||||
}
|
||||
}, cb);
|
||||
|
||||
cb(start, end);
|
||||
|
||||
|
||||
$(document).on('click', '#clear-filters', function(e) {
|
||||
|
||||
e.preventDefault(); // Stops the browser from following the link
|
||||
@ -317,7 +395,37 @@
|
||||
$('#tpa_id').val('0');
|
||||
$('#client_id').val('0');
|
||||
$('#insurer_id').val('0');
|
||||
$('#date_div').hide();
|
||||
$('#date_type').val('0');
|
||||
$('#start_date').val('');
|
||||
$('#end_date').val('');
|
||||
|
||||
// Reset the date range picker to default
|
||||
$('#reportrange').data('daterangepicker').setStartDate(moment().subtract(29, 'days'));
|
||||
$('#reportrange').data('daterangepicker').setEndDate(moment());
|
||||
cb(start, end); // Update the displayed date range
|
||||
|
||||
localStorage.setItem('filterData', JSON.stringify(filterData));
|
||||
window.location.href = "<?= base_url("/ticket/list") ?>";
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function hideDateField(input = null)
|
||||
{
|
||||
let val = $('#date_type').val();
|
||||
|
||||
if(input){
|
||||
val = input;
|
||||
}
|
||||
|
||||
if(val != 0){
|
||||
$('#date_div').show();
|
||||
}else{
|
||||
$('#date_div').hide();
|
||||
$('#start_date').val('');
|
||||
$('#end_date').val('');
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
@ -163,10 +163,11 @@
|
||||
<tr>
|
||||
<th>S.No </th>
|
||||
<th>Client </th>
|
||||
<th>Client Branch </th>
|
||||
<th>Insurer </th>
|
||||
<!-- <th>Client Branch </th> -->
|
||||
<!-- <th>Insurer </th> -->
|
||||
<th>Insurer Branch </th>
|
||||
<th>Policy </th>
|
||||
<th>Policy Type </th>
|
||||
<th>Policy No </th>
|
||||
<th>Endorsement No </th>
|
||||
<th>Premium </th>
|
||||
<th>Statement Premium </th>
|
||||
@ -182,10 +183,11 @@
|
||||
<tr>
|
||||
<td class="text-center"><?= $index + 1 ?></td>
|
||||
<td><?php echo $row['client_name']; ?></td>
|
||||
<td><?php echo $row['client_branch_name']; ?></td>
|
||||
<td><?php echo $row['insurer_name']; ?></td>
|
||||
<!-- <td><?php //echo $row['client_branch_name']; ?></td>
|
||||
<td><?php //echo $row['insurer_name']; ?></td> -->
|
||||
<td><?php echo $row['insurer_branch_name']; ?></td>
|
||||
<td><?php echo $row['policy_type'] .' - '. $row['policy_no']; ?></td>
|
||||
<td><?php echo $row['policy_type']; ?></td>
|
||||
<td><?php echo $row['policy_no']; ?></td>
|
||||
<td><?php echo $row['endorsement_no']; ?></td>
|
||||
<td class="right-align-input"><?php echo $row['original_premium']; ?></td>
|
||||
<td class="right-align-input"><?php echo isset($row['statement_premium']) ? $row['statement_premium'] : '0.00'; ?></td>
|
||||
@ -198,7 +200,6 @@
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div>
|
||||
</div>
|
||||
</div><!-- end col -->
|
||||
@ -206,8 +207,8 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
let client_list = [];
|
||||
let branch_list = [];
|
||||
let policy_list = [];
|
||||
@ -216,9 +217,7 @@
|
||||
|
||||
// Datatable document ready
|
||||
$(document).ready(function() {
|
||||
|
||||
var ticketsTable = $('#scroll-horizontal-datatable');
|
||||
|
||||
if (ticketsTable.length) {
|
||||
ticketsTable.DataTable({
|
||||
scrollX: true,
|
||||
@ -285,237 +284,234 @@
|
||||
searchPlaceholder: "Search",
|
||||
emptyTable: '<div class="text-center text-muted">No Data found</div>'
|
||||
},
|
||||
paging: true, // Enable pagination
|
||||
pageLength: 25 // Set default number of rows per page (optional)
|
||||
});
|
||||
} else {
|
||||
console.error("Table not found.");
|
||||
paging: true, // Enable pagination
|
||||
pageLength: 25 // Set default number of rows per page (optional)
|
||||
});
|
||||
} else {
|
||||
console.error("Table not found.");
|
||||
}
|
||||
});
|
||||
|
||||
$(document).ready(function() {
|
||||
getClientAndBranchAndPolicy()
|
||||
getURLParams()
|
||||
$('#client_id').select2();
|
||||
$('#client_branch_id').select2();
|
||||
$('#insurer_id').select2();
|
||||
$('#insurer_branch_id').select2();
|
||||
$('#client_policy_id').select2();
|
||||
$('#policy_type_id').select2();
|
||||
})
|
||||
|
||||
function fetchEmpolyeeList(event){
|
||||
event.preventDefault(); // Prevent default action
|
||||
|
||||
var start_date = $('#startDate').val();
|
||||
var end_date = $('#endDate').val();
|
||||
var client_id = $('#client_id').val();
|
||||
var insurer_id = $('#insurer_id').val();
|
||||
var policy_type_id = $('#policy_type_id').val();
|
||||
var date_type = $('#date_type').val();
|
||||
var issuer = $('#issuer').val();
|
||||
var client_branch_id = $('#client_branch_id').val();
|
||||
var insurer_branch_id = $('#insurer_branch_id').val();
|
||||
var client_policy_id = $('#client_policy_id').val();
|
||||
|
||||
console.log(start_date + '-' + end_date);
|
||||
|
||||
var queryParams = {
|
||||
start_date: start_date,
|
||||
end_date: end_date,
|
||||
client_id: client_id,
|
||||
insurer_id: insurer_id,
|
||||
policy_type_id: policy_type_id,
|
||||
date_type: date_type,
|
||||
issuer: issuer,
|
||||
client_branch_id: client_branch_id,
|
||||
insurer_branch_id: insurer_branch_id,
|
||||
client_policy_id: client_policy_id,
|
||||
};
|
||||
|
||||
const queryString = objectToQueryString(queryParams);
|
||||
const apiURL = $('#get-emp-list').attr('href') + "?" + queryString;
|
||||
console.log(apiURL);
|
||||
window.location.href = apiURL;
|
||||
}
|
||||
});
|
||||
|
||||
$(document).ready(function() {
|
||||
getClientAndBranchAndPolicy()
|
||||
getURLParams()
|
||||
$('#client_id').select2();
|
||||
$('#client_branch_id').select2();
|
||||
$('#insurer_id').select2();
|
||||
$('#insurer_branch_id').select2();
|
||||
$('#client_policy_id').select2();
|
||||
$('#policy_type_id').select2();
|
||||
})
|
||||
function objectToQueryString(obj) {
|
||||
return Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join('&');
|
||||
}
|
||||
|
||||
function fetchEmpolyeeList(event)
|
||||
{
|
||||
event.preventDefault(); // Prevent default action
|
||||
function getURLParams() {
|
||||
const url = new URL(window.location.href);
|
||||
const params = new URLSearchParams(url.search);
|
||||
|
||||
var start_date = $('#startDate').val();
|
||||
var end_date = $('#endDate').val();
|
||||
var client_id = $('#client_id').val();
|
||||
var insurer_id = $('#insurer_id').val();
|
||||
var policy_type_id = $('#policy_type_id').val();
|
||||
var date_type = $('#date_type').val();
|
||||
var issuer = $('#issuer').val();
|
||||
var client_branch_id = $('#client_branch_id').val();
|
||||
var insurer_branch_id = $('#insurer_branch_id').val();
|
||||
var client_policy_id = $('#client_policy_id').val();
|
||||
const startDate = params.get('start_date') || 0; // Default to 0 if not found
|
||||
const endDate = params.get('end_date') || 0; // Default to 0 if not found
|
||||
const client_id = params.get('client_id') || 0; // Default to 0 if not found
|
||||
const insurer_id = params.get('insurer_id') || 0; // Default to 0 if not found
|
||||
const policy_type_id = params.get('policy_type_id') || 0; // Default to 0 if not found
|
||||
const date_type = params.get('date_type') || 0; // Default to 0 if not found
|
||||
const issuer = params.get('issuer') || 0; // Default to 0 if not found
|
||||
const client_branch_id = params.get('client_branch_id') || 0; // Default to 0 if not found
|
||||
const insurer_branch_id = params.get('insurer_branch_id') || 0; // Default to 0 if not found
|
||||
const client_policy_id = params.get('client_policy_id') || 0; // Default to 0 if not found
|
||||
|
||||
console.log(start_date + '-' + end_date);
|
||||
hideDateField(date_type)
|
||||
|
||||
var queryParams = {
|
||||
start_date: start_date,
|
||||
end_date: end_date,
|
||||
client_id: client_id,
|
||||
insurer_id: insurer_id,
|
||||
policy_type_id: policy_type_id,
|
||||
date_type: date_type,
|
||||
issuer: issuer,
|
||||
client_branch_id: client_branch_id,
|
||||
insurer_branch_id: insurer_branch_id,
|
||||
client_policy_id: client_policy_id,
|
||||
};
|
||||
console.log('startDate', startDate)
|
||||
console.log('endDate', endDate)
|
||||
console.log('client_id', client_id)
|
||||
console.log('insurer_id', insurer_id)
|
||||
console.log('policy_type_id', policy_type_id)
|
||||
console.log('date_type', date_type)
|
||||
console.log('issuer', issuer)
|
||||
console.log('client_branch_id', client_branch_id)
|
||||
console.log('insurer_branch_id', insurer_branch_id)
|
||||
console.log('client_policy_id', client_policy_id)
|
||||
|
||||
const queryString = objectToQueryString(queryParams);
|
||||
const apiURL = $('#get-emp-list').attr('href') + "?" + queryString;
|
||||
console.log(apiURL);
|
||||
window.location.href = apiURL;
|
||||
}
|
||||
// Log the values or use them as needed
|
||||
console.log('Start Date:', startDate);
|
||||
console.log('End Date:', endDate);
|
||||
|
||||
function objectToQueryString(obj) {
|
||||
return Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join('&');
|
||||
}
|
||||
|
||||
function getURLParams()
|
||||
{
|
||||
const url = new URL(window.location.href);
|
||||
const params = new URLSearchParams(url.search);
|
||||
|
||||
const startDate = params.get('start_date') || 0; // Default to 0 if not found
|
||||
const endDate = params.get('end_date') || 0; // Default to 0 if not found
|
||||
const client_id = params.get('client_id') || 0; // Default to 0 if not found
|
||||
const insurer_id = params.get('insurer_id') || 0; // Default to 0 if not found
|
||||
const policy_type_id = params.get('policy_type_id') || 0; // Default to 0 if not found
|
||||
const date_type = params.get('date_type') || 0; // Default to 0 if not found
|
||||
const issuer = params.get('issuer') || 0; // Default to 0 if not found
|
||||
const client_branch_id = params.get('client_branch_id') || 0; // Default to 0 if not found
|
||||
const insurer_branch_id = params.get('insurer_branch_id') || 0; // Default to 0 if not found
|
||||
const client_policy_id = params.get('client_policy_id') || 0; // Default to 0 if not found
|
||||
|
||||
hideDateField(date_type)
|
||||
|
||||
console.log('startDate', startDate)
|
||||
console.log('endDate', endDate)
|
||||
console.log('client_id', client_id)
|
||||
console.log('insurer_id', insurer_id)
|
||||
console.log('policy_type_id', policy_type_id)
|
||||
console.log('date_type', date_type)
|
||||
console.log('issuer', issuer)
|
||||
console.log('client_branch_id', client_branch_id)
|
||||
console.log('insurer_branch_id', insurer_branch_id)
|
||||
console.log('client_policy_id', client_policy_id)
|
||||
|
||||
// Log the values or use them as needed
|
||||
console.log('Start Date:', startDate);
|
||||
console.log('End Date:', endDate);
|
||||
|
||||
if (startDate != 0 && endDate != 0) {
|
||||
setTimeout(function(){
|
||||
$('#start_date').val(startDate)
|
||||
$('#end_date').val(endDate)
|
||||
$('#client_id').val(client_id).change()
|
||||
$('#insurer_id').val(insurer_id).change()
|
||||
$('#policy_type_id').val(policy_type_id).change()
|
||||
$('#date_type').val(date_type)
|
||||
$('#issuer').val(issuer)
|
||||
if (startDate != 0 && endDate != 0) {
|
||||
setTimeout(function(){
|
||||
$('#client_branch_id').val(client_branch_id).change()
|
||||
$('#insurer_branch_id').val(insurer_branch_id).change()
|
||||
$('#start_date').val(startDate)
|
||||
$('#end_date').val(endDate)
|
||||
$('#client_id').val(client_id).change()
|
||||
$('#insurer_id').val(insurer_id).change()
|
||||
$('#policy_type_id').val(policy_type_id).change()
|
||||
$('#date_type').val(date_type)
|
||||
$('#issuer').val(issuer)
|
||||
setTimeout(function(){
|
||||
$('#client_policy_id').val(client_policy_id).change();
|
||||
}, 1000);
|
||||
}, 2000)
|
||||
},2000)
|
||||
$('#client_branch_id').val(client_branch_id).change()
|
||||
$('#insurer_branch_id').val(insurer_branch_id).change()
|
||||
setTimeout(function(){
|
||||
$('#client_policy_id').val(client_policy_id).change();
|
||||
}, 1000);
|
||||
}, 2000)
|
||||
},2000)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$(function() {
|
||||
|
||||
const url = new URL(window.location.href);
|
||||
const params = new URLSearchParams(url.search);
|
||||
|
||||
// Get start and end dates from URL parameters, or use default values
|
||||
const startDateParam = params.get('start_date') || moment().subtract(29, 'days').format('DD-MM-YYYY');
|
||||
const endDateParam = params.get('end_date') || moment().format('DD-MM-YYYY');
|
||||
|
||||
// Parse the dates to moment objects
|
||||
var start = moment(startDateParam, 'DD-MM-YYYY');
|
||||
var end = moment(endDateParam, 'DD-MM-YYYY');
|
||||
|
||||
// var start = moment().subtract(29, 'days');
|
||||
// var end = moment();
|
||||
|
||||
function cb(start, end) {
|
||||
$('#reportrange').html(start.format('D-MM-YYYY') + ' - ' + end.format('D-MM-YYYY'));
|
||||
$('#startDate').val(start.format('DD-MM-YYYY'));
|
||||
$('#endDate').val(end.format('DD-MM-YYYY'));
|
||||
}
|
||||
|
||||
$('#reportrange').daterangepicker({
|
||||
startDate: start,
|
||||
endDate: end,
|
||||
locale: { format: 'DD-MM-YYYY' },
|
||||
ranges: {
|
||||
'Today': [moment(), moment()],
|
||||
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
|
||||
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
|
||||
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
|
||||
'This Month': [moment().startOf('month'), moment().endOf('month')],
|
||||
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month')
|
||||
.endOf('month')
|
||||
]
|
||||
}
|
||||
}, cb);
|
||||
|
||||
cb(start, end);
|
||||
|
||||
$('#clear-filters').on('click', function() {
|
||||
// Reset all select dropdowns to the first option
|
||||
$('#client_id').val('0').change();
|
||||
$('#insurer_id').val('0').change();
|
||||
$('#policy_type_id').val('0').change();
|
||||
$('#date_type').val('0');
|
||||
$('#issuer').val('0');
|
||||
$('#date_div').hide()
|
||||
|
||||
// Reset the date range picker to default
|
||||
$('#reportrange').data('daterangepicker').setStartDate(moment().subtract(29, 'days'));
|
||||
$('#reportrange').data('daterangepicker').setEndDate(moment());
|
||||
cb(start, end); // Update the displayed date range
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function hideDateField(input = null) {
|
||||
let val = $('#date_type').val();
|
||||
|
||||
if (input) {
|
||||
val = input;
|
||||
}
|
||||
|
||||
if (val != 0) {
|
||||
$('#date_div').show()
|
||||
} else {
|
||||
$('#date_div').hide()
|
||||
}
|
||||
}
|
||||
$(function() {
|
||||
|
||||
function sendPolicyTransactionID(event, pt_id) {
|
||||
event.preventDefault(); // Prevent default action
|
||||
const url = new URL(window.location.href);
|
||||
const params = new URLSearchParams(url.search);
|
||||
|
||||
console.log(pt_id);
|
||||
// Get start and end dates from URL parameters, or use default values
|
||||
const startDateParam = params.get('start_date') || moment().subtract(29, 'days').format('DD-MM-YYYY');
|
||||
const endDateParam = params.get('end_date') || moment().format('DD-MM-YYYY');
|
||||
|
||||
var queryParams = {
|
||||
pt_id: pt_id,
|
||||
};
|
||||
// Parse the dates to moment objects
|
||||
var start = moment(startDateParam, 'DD-MM-YYYY');
|
||||
var end = moment(endDateParam, 'DD-MM-YYYY');
|
||||
|
||||
const queryString = objectToQueryString(queryParams);
|
||||
const apiURL = $('#get-policy-list').attr('href') + "?" + queryString;
|
||||
console.log(apiURL);
|
||||
window.location.href = apiURL;
|
||||
}
|
||||
// var start = moment().subtract(29, 'days');
|
||||
// var end = moment();
|
||||
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
function cb(start, end) {
|
||||
$('#reportrange').html(start.format('D-MM-YYYY') + ' - ' + end.format('D-MM-YYYY'));
|
||||
$('#startDate').val(start.format('DD-MM-YYYY'));
|
||||
$('#endDate').val(end.format('DD-MM-YYYY'));
|
||||
}
|
||||
|
||||
//featch client, client branch, insurer, insurer branch and client policy list data
|
||||
function getClientAndBranchAndPolicy()
|
||||
{
|
||||
$.ajax({
|
||||
url: '<?= base_url("/util/getClientAndBranchAndPolicy") ?>',
|
||||
type: "GET",
|
||||
dataType: 'json',
|
||||
success: function(res) {
|
||||
|
||||
console.log('getClientAndBranchAndPolicy', res);
|
||||
if(res.status == true){
|
||||
client_list = res.client_data;
|
||||
branch_list = res.branch_data;
|
||||
policy_list = res.policy_data;
|
||||
insurer_list = res.insurer_data;
|
||||
insurer_branch_list = res.insurer_branch_data;
|
||||
appendClients(res.client_data);
|
||||
appendInsurer(res.insurer_data);
|
||||
}else{
|
||||
console.log('No data found');
|
||||
$('#reportrange').daterangepicker({
|
||||
startDate: start,
|
||||
endDate: end,
|
||||
locale: { format: 'DD-MM-YYYY' },
|
||||
ranges: {
|
||||
'Today': [moment(), moment()],
|
||||
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
|
||||
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
|
||||
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
|
||||
'This Month': [moment().startOf('month'), moment().endOf('month')],
|
||||
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month')
|
||||
.endOf('month')
|
||||
]
|
||||
}
|
||||
}, cb);
|
||||
|
||||
cb(start, end);
|
||||
|
||||
$('#clear-filters').on('click', function() {
|
||||
// Reset all select dropdowns to the first option
|
||||
$('#client_id').val('0').change();
|
||||
$('#insurer_id').val('0').change();
|
||||
$('#policy_type_id').val('0').change();
|
||||
$('#date_type').val('0');
|
||||
$('#issuer').val('0');
|
||||
$('#date_div').hide()
|
||||
|
||||
// Reset the date range picker to default
|
||||
$('#reportrange').data('daterangepicker').setStartDate(moment().subtract(29, 'days'));
|
||||
$('#reportrange').data('daterangepicker').setEndDate(moment());
|
||||
cb(start, end); // Update the displayed date range
|
||||
});
|
||||
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function hideDateField(input = null) {
|
||||
let val = $('#date_type').val();
|
||||
|
||||
if (input) {
|
||||
val = input;
|
||||
}
|
||||
|
||||
if (val != 0) {
|
||||
$('#date_div').show()
|
||||
} else {
|
||||
$('#date_div').hide()
|
||||
}
|
||||
}
|
||||
|
||||
function sendPolicyTransactionID(event, pt_id) {
|
||||
event.preventDefault(); // Prevent default action
|
||||
|
||||
console.log(pt_id);
|
||||
|
||||
var queryParams = {
|
||||
pt_id: pt_id,
|
||||
};
|
||||
|
||||
const queryString = objectToQueryString(queryParams);
|
||||
const apiURL = $('#get-policy-list').attr('href') + "?" + queryString;
|
||||
console.log(apiURL);
|
||||
window.location.href = apiURL;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
|
||||
//featch client, client branch, insurer, insurer branch and client policy list data
|
||||
function getClientAndBranchAndPolicy(){
|
||||
$.ajax({
|
||||
url: '<?= base_url("/util/getClientAndBranchAndPolicy") ?>',
|
||||
type: "GET",
|
||||
dataType: 'json',
|
||||
success: function(res) {
|
||||
|
||||
console.log('getClientAndBranchAndPolicy', res);
|
||||
if(res.status == true){
|
||||
client_list = res.client_data;
|
||||
branch_list = res.branch_data;
|
||||
policy_list = res.policy_data;
|
||||
insurer_list = res.insurer_data;
|
||||
insurer_branch_list = res.insurer_branch_data;
|
||||
appendClients(res.client_data);
|
||||
appendInsurer(res.insurer_data);
|
||||
}else{
|
||||
console.log('No data found');
|
||||
}
|
||||
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
getClientAndBranchAndPolicy()
|
||||
|
||||
@ -102,12 +102,14 @@ $("#vehicle_file_upload_form").submit(function(event) {
|
||||
console.log(res);
|
||||
|
||||
if(res.status == true){
|
||||
toastr.success(res.message, 'Success');
|
||||
toastr.success(res.message, 'SUCCESS');
|
||||
appendVehicleFileTableBody(res.vehicle_docs);
|
||||
}else{
|
||||
toastr.error(res.message, 'Error');
|
||||
toastr.warning(res.message, 'WARNING');
|
||||
}
|
||||
|
||||
$('#vehicle_file_upload_form')[0].reset();
|
||||
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
|
||||
@ -212,6 +212,8 @@
|
||||
<label for="description" class="control-label">Description<span class="text-danger">*</span></label>
|
||||
<textarea class="form-control" id="description"
|
||||
placeholder="Write something about the transaction" required></textarea>
|
||||
<input type="hidden" id="cd_ac_pk" value="<?php echo $depositdata[0]->cd_ac_pk?>">
|
||||
<input type="hidden" id="cd_ac_no" value="<?php echo $depositdata[0]->cd_ac_no?>">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -392,6 +394,8 @@
|
||||
var transactionTypeValue = $('input[name="transactionMode"]:checked').val();
|
||||
var subType = "";
|
||||
var record_date = $('#record_date').val();
|
||||
var cd_ac_no = $('#cd_ac_no').val();
|
||||
var cd_ac_pk = $('#cd_ac_pk').val();
|
||||
|
||||
if (amount == "") {
|
||||
toastr.warning('Amount field is required')
|
||||
@ -432,7 +436,8 @@
|
||||
console.log('clientId ', clientId)
|
||||
console.log('insurerId ', insurerId)
|
||||
console.log('subType ', subType)
|
||||
|
||||
console.log('cd_ac_pk ', cd_ac_pk)
|
||||
console.log('cd_ac_no ', cd_ac_no)
|
||||
|
||||
// Send data to the server using Ajax
|
||||
$.ajax({
|
||||
@ -445,7 +450,9 @@
|
||||
sub_type_id: subType, // Include sub_type_id
|
||||
client_id: clientId,
|
||||
insurer_id: insurerId,
|
||||
record_date: record_date
|
||||
record_date: record_date,
|
||||
cd_ac_pk: cd_ac_pk,
|
||||
cd_ac_no: cd_ac_no
|
||||
},
|
||||
success: function(response) {
|
||||
// Handle success response
|
||||
|
||||
Loading…
Reference in New Issue
Block a user