MERGE_TEST_ROLLOVER&BDS_INSTALLMENT
This commit is contained in:
commit
a687e8a3bc
@ -332,7 +332,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->get("send_manual_ecard/(:any)", "DashboardController::sendManualEcard/$1");
|
||||
$routes->get("get_client_policy_list_for_remainder/(:any)", "EmployeeController::get_client_policy_list_for_remainder/$1");
|
||||
$routes->get("get_client_branch_data/(:any)", "ClientController::get_client_branch_data/$1");
|
||||
$routes->get("getLevelContects", "LeadsController::getLevelContects");
|
||||
$routes->get("getLevelContects", "LeadsControllerg::getLevelContects");
|
||||
$routes->get("get_emp_master_data_for_update/(:any)", "EmployeeController::get_emp_master_data_for_update/$1");
|
||||
$routes->get("send_mail_for_individual_employee_ecard/(:any)", "EmployeeController::send_mail_for_individual_employee_ecard/$1");
|
||||
$routes->post("update_emp_data", "EmployeeController::update_emp_data");
|
||||
@ -365,6 +365,9 @@ $routes->cli("cli/sendInstallmentRemainderMail","PolicyTransactionController::se
|
||||
|
||||
$routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) {
|
||||
|
||||
$routes->post("getMoreInfo","PolicyTransactionController::getMoreInfo");
|
||||
$routes->post("saveInstallment","PolicyTransactionController::saveInstallment");
|
||||
|
||||
$routes->group("inception", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->match(['get', 'post'], 'list', 'PolicyTransactionController::viewInception');
|
||||
$routes->post("create", "PolicyTransactionController::createInceptionPolicy");
|
||||
|
||||
@ -1243,40 +1243,8 @@ class ClientController extends AdminController
|
||||
|
||||
$data['created_by'] = get_session_userid();
|
||||
|
||||
$policy_tranction_data = [
|
||||
|
||||
'issuer' => 2,
|
||||
'client_id' => $this->request->getPost('client_id'),
|
||||
'client_branch_id' => $this->request->getPost('client_branch_id'),
|
||||
'insurer_id' => $insurerId,
|
||||
'insurer_branch_id' => $insurerBranchId,
|
||||
'issue_type' => 1,
|
||||
'policy_no' => $this->request->getPost('policy_no'),
|
||||
'cd_ac_pk' => $this->request->getPost('cd_ac_no'),
|
||||
'policy_issue_date' => date('Y-m-d'),
|
||||
'policy_start_date' => change_date_format($this->request->getPost('policy_start_date'), 'd-m-Y', 'Y-m-d'),
|
||||
'policy_end_date' => change_date_format($this->request->getPost('policy_end_date'), 'd-m-Y', 'Y-m-d'),
|
||||
'action_type' => 'inception',
|
||||
'status' => 'pending',
|
||||
'created_by' => get_session_userid(),
|
||||
];
|
||||
|
||||
|
||||
$insert = $this->clientPolicyModel->insert($data);
|
||||
if ($insert) {
|
||||
|
||||
$policy_tranction_data['client_policy_id'] = $insert;
|
||||
$policy_tranction_data_insert = $this->policyTransactionModel->insert($data);
|
||||
if ($policy_tranction_data_insert) {
|
||||
$statusData = [
|
||||
'policy_tran_id' => $policy_tranction_data_insert,
|
||||
'status' => 'pending',
|
||||
'created_by' => get_session_userid(),
|
||||
];
|
||||
$this->policyTransactionStatusModel->insert($statusData);
|
||||
}
|
||||
|
||||
|
||||
$clientPoliceData = $this->clientPolicyModel->getClientPolicyByClientId($this->request->getPost('client_id'));
|
||||
$clientPoliceData['role'] = get_role_id();
|
||||
return $this->respond(['status' => true, 'code' => 200, 'data' => $clientPoliceData, 'method' => 'CERATE', 'post_data' => $data], 200);
|
||||
@ -3839,13 +3807,13 @@ class ClientController extends AdminController
|
||||
'dob' => change_date_format($postData['dob'],'d/m/Y','Y-m-d'),
|
||||
'aadhar' => $postData['aadhar'],
|
||||
'phone' => $postData['phone'],
|
||||
'email' => $postData['email'],
|
||||
'entity_type_id' => 7
|
||||
]);
|
||||
} else {
|
||||
$client_data['entity_type_id'] = $postData['entity_type_id'];
|
||||
}
|
||||
|
||||
// print_rr($client_data);die();
|
||||
// Insert client data
|
||||
$client_insert = $this->clientModel->insert($client_data);
|
||||
|
||||
@ -3871,6 +3839,8 @@ class ClientController extends AdminController
|
||||
'contact_type' => 'client',
|
||||
'name' => $postData['name'],
|
||||
'mobile' => $postData['mobile'],
|
||||
'email' => $postData['email'],
|
||||
|
||||
];
|
||||
$this->levelContactModel->insert($contact_data);
|
||||
}
|
||||
@ -4050,7 +4020,8 @@ class ClientController extends AdminController
|
||||
->join('clients', 'client_branch.client_id = clients.id')
|
||||
->where(['client_branch.id' => $id, 'client_branch.is_active' => 1])
|
||||
->first();
|
||||
$branch_contact_data = $this->levelContactModel->where(['ref_id' => $id, 'contact_type' => 'client', 'is_active' => 1])->orderBy('id','asc')->first();
|
||||
$branch_contact_data = $this->levelContactModel->where(['ref_id' => $id, 'contact_type' => 'client', 'is_active' => 1])->findAll();
|
||||
// print_rr($branch_contact_data);die();
|
||||
return $this->respond(['status' => true, 'code' => 200, 'data' => $branch_data, 'contact' => $branch_contact_data], 200);
|
||||
} else {
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'no data found'], 200);
|
||||
@ -4664,6 +4635,13 @@ class ClientController extends AdminController
|
||||
// $EmpDataServiceController->importDeletionValidation(['file_id' => 171]);
|
||||
// $EmpDataServiceController->importDeletionUpdateEndorsementID(['file_id' => 171]);
|
||||
// $EmpDataServiceController->importCorrectionUpdateEndorsementID(['file_id' => 188]);
|
||||
|
||||
$params = [
|
||||
'client_policy_id' => 6090,
|
||||
'action_type' => "inception",
|
||||
];
|
||||
$res = $EmpDataServiceController->makeEntryForBDSPolicyTransaction($params);
|
||||
dd($res);
|
||||
|
||||
// $array = [
|
||||
// "employeeIds" => ["12800", "12798", "12797", "12799"],
|
||||
|
||||
@ -28,6 +28,11 @@ use App\Models\CDMasterModel;
|
||||
use App\Models\InsurerExcelExportTemplateModel;
|
||||
use App\Models\ClientBranchModel;
|
||||
use App\Models\EndorsementModel;
|
||||
use App\Models\BdsPlacementModel;
|
||||
use App\Models\LeadsModel;
|
||||
use App\Models\LeadInstallmentPaymentDetails;
|
||||
use App\Models\PolicyTransactionModel;
|
||||
use App\Models\PTCOShareDetailsModel;
|
||||
|
||||
use App\Controllers\Jobs;
|
||||
use App\Controllers\JobWorker;
|
||||
@ -60,6 +65,11 @@ class EmpDataServiceController extends BaseController
|
||||
protected $excelExportTemplateModel;
|
||||
protected $clientBranchModel;
|
||||
protected $endorsementModel;
|
||||
protected $BdsPlacementModel;
|
||||
protected $leadsModel;
|
||||
protected $leadInstallmentPaymentDetailesModel;
|
||||
protected $policyTransactionModel;
|
||||
protected $PTCOShareDetailsModel;
|
||||
|
||||
|
||||
public function __construct()
|
||||
@ -83,6 +93,11 @@ class EmpDataServiceController extends BaseController
|
||||
$this->excelExportTemplateModel = new InsurerExcelExportTemplateModel();
|
||||
$this->clientBranchModel = new ClientBranchModel();
|
||||
$this->endorsementModel = new EndorsementModel();
|
||||
$this->BdsPlacementModel = new BdsPlacementModel();
|
||||
$this->leadsModel = new LeadsModel();
|
||||
$this->leadInstallmentPaymentDetailesModel = new LeadInstallmentPaymentDetails();
|
||||
$this->policyTransactionModel = new PolicyTransactionModel();
|
||||
$this->PTCOShareDetailsModel = new PTCOShareDetailsModel();
|
||||
|
||||
}
|
||||
|
||||
@ -1976,6 +1991,13 @@ class EmpDataServiceController extends BaseController
|
||||
'user_id' => $user_id,
|
||||
]]);
|
||||
|
||||
$r = Jobs::addJob(['job_name' => 'makeEntryForBDSPolicyTransaction', 'payload' => [
|
||||
'client_policy_id' => $client_policy_id ?? null,
|
||||
'endorsement_no' => $endorsement_id ?? null,
|
||||
'emp_count' => $emp_count ?? null,
|
||||
'action_type' => $file['event_type'] ?? null,
|
||||
]]);
|
||||
|
||||
// $this->cashDepositCalculationForInception($depositeData);
|
||||
// $this->sendMailForDownloadingECard($emp_policy_ids);
|
||||
|
||||
@ -2400,6 +2422,13 @@ class EmpDataServiceController extends BaseController
|
||||
$file_data = $this->getDataByFileId($file_id, 'success');
|
||||
$this->setPullNotification($file_data);
|
||||
|
||||
$r = Jobs::addJob(['job_name' => 'makeEntryForBDSPolicyTransaction', 'payload' => [
|
||||
'client_policy_id' => $client_policy_id ?? null,
|
||||
'endorsement_no' => $endorsement_id[0] ?? null,
|
||||
'emp_count' => $emp_count ?? null,
|
||||
'action_type' => $file['event_type'] ?? null,
|
||||
]]);
|
||||
|
||||
|
||||
//import file to upload Google Drive
|
||||
// if(excelFileGDriveUpload($file_id, 'batch_file')){
|
||||
@ -3024,6 +3053,13 @@ class EmpDataServiceController extends BaseController
|
||||
'user_id' => $user_id,
|
||||
]]);
|
||||
|
||||
$r = Jobs::addJob(['job_name' => 'makeEntryForBDSPolicyTransaction', 'payload' => [
|
||||
'client_policy_id' => $client_policy_id ?? null,
|
||||
'endorsement_no' => $endorsement_id ?? null,
|
||||
'emp_count' => $emp_count ?? null,
|
||||
'action_type' => $file['event_type'] ?? null,
|
||||
]]);
|
||||
|
||||
}
|
||||
|
||||
$file_data = $this->getDataByFileId($file_id, 'success');
|
||||
@ -3498,6 +3534,13 @@ class EmpDataServiceController extends BaseController
|
||||
'policy_name' => $policy_name['policy_name'],
|
||||
'user_id' => $user_id,
|
||||
]]);
|
||||
|
||||
$r = Jobs::addJob(['job_name' => 'makeEntryForBDSPolicyTransaction', 'payload' => [
|
||||
'client_policy_id' => $client_policy_id ?? null,
|
||||
'endorsement_no' => $endorsement_id ?? null,
|
||||
'emp_count' => $emp_count ?? null,
|
||||
'action_type' => $file['event_type'] ?? null,
|
||||
]]);
|
||||
}
|
||||
|
||||
$file_data = $this->getDataByFileId($file_id, 'success');
|
||||
@ -4675,7 +4718,171 @@ class EmpDataServiceController extends BaseController
|
||||
$this->myLogger->logme('error',"storeEndorsementNumber --- Function execution completed for file_id: $file_id");
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
public function makeEntryForBDSPolicyTransaction($params)
|
||||
{
|
||||
try {
|
||||
$this->myLogger->logme("error", "makeEntryForBDSPolicyTransaction() started: " . json_encode(['params' => $params]));
|
||||
|
||||
if (empty($params) || !isset($params['client_policy_id']) || empty($params['client_policy_id'])) {
|
||||
$this->myLogger->logme("error", "Invalid parameters provided: " . json_encode(['params' => $params]));
|
||||
return ['status' => "Failed", 'message' => "Client Policy ID is missing or empty", 'data' => ['params' => $params]];
|
||||
}
|
||||
|
||||
if (!isset($params['action_type']) || empty($params['action_type'])) {
|
||||
$this->myLogger->logme("error", "Invalid action type: " . json_encode(['params' => $params]));
|
||||
return ['status' => "Failed", 'message' => "Action type is missing or empty", 'data' => ['params' => $params]];
|
||||
}
|
||||
|
||||
$policy_data = $this->clientPolicyModel
|
||||
->where('id', $params['client_policy_id'])
|
||||
->where('is_active', 1)
|
||||
->first();
|
||||
|
||||
if (empty($policy_data)) {
|
||||
$this->myLogger->logme("error", "No policy data found: " . json_encode(['client_policy_id' => $params['client_policy_id']]));
|
||||
return ['status' => "Failed", 'message' => "No policy data found for the given client policy ID", 'data' => ['params' => $params]];
|
||||
}
|
||||
|
||||
$lead_data = $this->leadsModel
|
||||
->where('is_policy_created', $params['client_policy_id'])
|
||||
->where('is_active', 1)
|
||||
->first();
|
||||
|
||||
if (empty($lead_data)) {
|
||||
$this->myLogger->logme("error", "No lead data found: " . json_encode(['client_policy_id' => $params['client_policy_id']]));
|
||||
return ['status' => "Failed", 'message' => "No lead data found for the given client policy ID", 'data' => ['params' => $params]];
|
||||
}
|
||||
|
||||
$this->myLogger->logme("error", "Constructing policy transaction data: " . json_encode(['policy_data' => $policy_data, 'lead_data' => $lead_data]));
|
||||
|
||||
$policyTransactionData = $this->constructBDSData($policy_data, $lead_data, $params);
|
||||
|
||||
$insert_id = $this->policyTransactionModel->insert($policyTransactionData);
|
||||
|
||||
if (!$insert_id) {
|
||||
$this->myLogger->logme("error", "Failed to insert into policy_transaction: " . json_encode($policyTransactionData));
|
||||
return ['status' => "Failed", 'message' => "Failed to insert policy transaction record", 'data' => ['params' => $params]];
|
||||
}
|
||||
|
||||
$this->myLogger->logme("error", "Policy transaction inserted successfully: " . json_encode(['insert_id' => $insert_id]));
|
||||
|
||||
//do not remove this commented item
|
||||
// $coShareDetails = $this->ConstructPTShareData($policy_data, $insert_id);
|
||||
// $pt_co_share_id = $this->PTCOShareDetailsModel->insert($coShareDetails);
|
||||
|
||||
// $this->myLogger->logme("error", "PT Co share data inserted successfully: " . json_encode(['pt_co_share_id' => $pt_co_share_id]));
|
||||
|
||||
$lead_installment_data = $this->leadInstallmentPaymentDetailesModel
|
||||
->select('lead_id, installment_amount, payment_date, utr_no')
|
||||
->where('lead_id', $lead_data['id'])
|
||||
->where('is_active', 1)
|
||||
->findAll();
|
||||
|
||||
if (!empty($lead_installment_data) && (isset($params['action_type']) && $params['action_type'] == "inception")) {
|
||||
$this->myLogger->logme("error", "Found lead installment data: " . json_encode($lead_installment_data));
|
||||
|
||||
$installment_ids = $this->constructInstallmentData($lead_installment_data, $insert_id);
|
||||
|
||||
$this->myLogger->logme("error", "Installment data inserted: " . json_encode(['installment_ids' => $installment_ids]));
|
||||
}else{
|
||||
$this->myLogger->logme("error", "Failed to insert Installment data : " . json_encode($params));
|
||||
}
|
||||
|
||||
return ['status' => "Success", 'message' => "Policy transaction entry created successfully", 'data' => ['params' => $params, 'insert_id' => $insert_id]];
|
||||
} catch (\Throwable $e) {
|
||||
$this->myLogger->logme("error", "Exception occurred in makeEntryForBDSPolicyTransaction(): " . json_encode([
|
||||
'error' => $e->getMessage(),
|
||||
'trace' => $e->getTraceAsString()
|
||||
]));
|
||||
|
||||
return ['status' => "Error", 'message' => "An unexpected error occurred", 'data' => ['error' => $e]];
|
||||
}
|
||||
}
|
||||
|
||||
private function constructBDSData($policy_data, $lead_data, $params)
|
||||
{
|
||||
|
||||
$policyTransactionData = [
|
||||
|
||||
'issuer' => 2,
|
||||
'client_id' => $policy_data['client_id'] ?? null,
|
||||
'client_branch_id' => $policy_data['client_branch_id'] ?? null,
|
||||
'insurer_id' => $policy_data['insurer_id'] ?? null,
|
||||
'insurer_branch_id' => $policy_data['insurer_branch_id'] ?? null,
|
||||
'tpa_id' => $policy_data['tpa_id'] ?? null,
|
||||
'tpa_branch_id' => $policy_data['tpa_branch_id'] ?? null,
|
||||
'policy_type_id' => $policy_data['policy_type_id'] ?? null,
|
||||
'client_policy_id' => $policy_data['id'] ?? null,
|
||||
'policy_no' => $policy_data['policy_no'] ?? null,
|
||||
'cd_ac_no' => $policy_data['cd_ac_no'] ?? null,
|
||||
'cd_ac_pk' => $policy_data['cd_ac_pk'] ?? null,
|
||||
'policy_issue_date' => $policy_data['policy_start_date'] ?? null,
|
||||
'policy_start_date' => $policy_data['policy_start_date'] ?? null,
|
||||
'policy_end_date' => $policy_data['policy_end_date'] ?? null,
|
||||
'data_received_date' => $policy_data['data_received_date'] ?? null,
|
||||
'closure_date' => $policy_data['closure_date'] ?? null,
|
||||
'emp_count' => $policy_data['emp_count'] ?? null,
|
||||
'dependent_count' => $policy_data['dependent_count'] ?? null,
|
||||
'revenue_type' => ($lead_data['lead_type'] == 1 ? "NA" : ($lead_data['lead_type'] == 2 ? "EA" : "EANR") ) ?? null,
|
||||
'co_share' => $policy_data['co_share'] ?? 0,
|
||||
'pre_payable_by' => $policy_data['pre_payable_by'] ?? 1,
|
||||
'renewal_date' => $policy_data['policy_end_date'] ?? null,
|
||||
'month' => date('Y-m-01', strtotime($policy_data['policy_start_date'])) ?? null,
|
||||
'ct_type' => 1,
|
||||
'is_cd_reduce_from_bds' => 0,
|
||||
'client_type_id' => 0,
|
||||
|
||||
'status' => "completed",
|
||||
'action_type' => $params['action_type'] ?? null,
|
||||
'endorsement_no' => $params['endorsement_no'] ?? null,
|
||||
'issue_type' => $lead_data['lead_type'] ?? null,
|
||||
'source_client_policy_id' => $lead_data['source_policy_id'] ?? null,
|
||||
'tsi' => generate_tsi_code($lead_data['lead_type']) ?? null,
|
||||
'installment' => $lead_data['no_of_installment'] ?? null,
|
||||
];
|
||||
|
||||
$this->myLogger->logme("error", "Constructed policy transaction data: " . json_encode($policyTransactionData));
|
||||
|
||||
return $policyTransactionData;
|
||||
}
|
||||
|
||||
private function ConstructPTShareData($policy_data, $pt_id)
|
||||
{
|
||||
$coShareData = [
|
||||
'pt_id' => $pt_id,
|
||||
'insurer_id' => $policy_data['insurer_id'],
|
||||
'insurer_branch_id' => $policy_data['insurer_branch_id'],
|
||||
'co_share_type' => 1,
|
||||
];
|
||||
|
||||
$this->myLogger->logme("error", "Constructed PT co-share data: " . json_encode($coShareData));
|
||||
|
||||
|
||||
return $coShareData;
|
||||
}
|
||||
|
||||
private function constructInstallmentData($data, $pt_id)
|
||||
{
|
||||
if (!empty($data)) {
|
||||
$installment_ids = [];
|
||||
foreach ($data as $key => &$value) {
|
||||
$value['pt_id'] = $pt_id;
|
||||
$installment_ids[] = $this->BdsPlacementModel->insert($value);
|
||||
}
|
||||
unset($value);
|
||||
|
||||
return $installment_ids;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function retriveBDSPolicyTransactionEntry()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -123,6 +123,10 @@ class JobWorker extends AdminController
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\EmpDataServiceController',
|
||||
],
|
||||
'makeEntryForBDSPolicyTransaction' => [
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\EmpDataServiceController',
|
||||
],
|
||||
'employeesEnrollmentInsert' => [
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\EmployeeServiceController',
|
||||
|
||||
@ -241,8 +241,12 @@ class LeadsController extends BaseController
|
||||
$form_file_name = "file_name_" . $index_plus_one;
|
||||
$form_docs_name = "docs_name_" . $index_plus_one;
|
||||
$leads_file_primary_key = $data['leads_file_id'] ?? [];
|
||||
$files = $this->request->getFileMultiple($form_file_name);
|
||||
$multi_file_data = $this->uploadMultiFiles($files, $data[$form_docs_name], $leads_file_primary_key);
|
||||
|
||||
$multi_file_data = [];
|
||||
if(isset($data[$form_docs_name])){
|
||||
$files = $this->request->getFileMultiple($form_file_name);
|
||||
$multi_file_data = $this->uploadMultiFiles($files, $data[$form_docs_name], $leads_file_primary_key);
|
||||
}
|
||||
|
||||
// Separate the insurer and insurer branch, handle missing or invalid data
|
||||
if (isset($data['insurer']) && strpos($data['insurer'], '-') !== false) {
|
||||
@ -631,10 +635,8 @@ class LeadsController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------RFQ-----------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
public function viewRFQ($id, $type = 1)
|
||||
{
|
||||
|
||||
@ -679,7 +681,9 @@ class LeadsController extends BaseController
|
||||
|
||||
if ($lead_data['lead_type'] != 1) {
|
||||
$client_policy_data = $this->clientPolicyModel->where('is_active', 1)->where('id', $lead_data['source_policy_id'])->first();
|
||||
$data['policy_terms'] = $client_policy_data['policy_terms'];
|
||||
if (isset($client_policy_data)) {
|
||||
$data['policy_terms'] = $client_policy_data['policy_terms'];
|
||||
}
|
||||
}
|
||||
|
||||
$data['question_json'] = $lead_data['question_json'];
|
||||
@ -738,7 +742,10 @@ class LeadsController extends BaseController
|
||||
|
||||
if ($lead_data['lead_type'] != 1 && $data['rfq_count'] == 0) {
|
||||
$client_policy_data = $this->clientPolicyModel->where('is_active', 1)->where('id', $lead_data['source_policy_id'])->first();
|
||||
$data['rfq_data']['json'] = $client_policy_data['placement_json'];
|
||||
if (isset($client_policy_data)) {
|
||||
|
||||
$data['rfq_data']['json'] = $client_policy_data['placement_json'];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($data['question_json'])) {
|
||||
@ -2686,64 +2693,103 @@ class LeadsController extends BaseController
|
||||
|
||||
public function featchLeadDataAndInsertClient($lead_id)
|
||||
{
|
||||
$data = $this->leadsModel->where('leads.id', $lead_id)->where('leads.is_active', 1)->first();
|
||||
try {
|
||||
$data = $this->leadsModel->where('leads.id', $lead_id)->where('leads.is_active', 1)->first();
|
||||
|
||||
if (!$data) {
|
||||
return $this->respond(['status' => false, 'message' => 'Failed to create Client', 'data' => null], 200);
|
||||
if (!$data) {
|
||||
$this->myLogger->logme('featchLeadDataAndInsertClient', "Lead not found or inactive", ['lead_id' => $lead_id]);
|
||||
return $this->respond(['status' => false, 'message' => 'Failed to create Client', 'data' => null], 200);
|
||||
}
|
||||
|
||||
$result = $this->createClientWithLeadData($data);
|
||||
|
||||
if ($result) {
|
||||
$policy_data = $this->clientPolicyModel->where('client_id', $result)->where('is_active', 1)->first();
|
||||
return $this->respond([
|
||||
'status' => true,
|
||||
'message' => 'New Client created successfully',
|
||||
'client_id' => $result,
|
||||
'data' => $data,
|
||||
'client_policy_id' => $policy_data['id'] ?? null,
|
||||
], 200);
|
||||
}
|
||||
|
||||
$this->myLogger->logme('featchLeadDataAndInsertClient', "Client creation failed after processing", ['lead_id' => $lead_id]);
|
||||
return $this->respond(['status' => false, 'message' => 'Failed to create client', 'data' => $data], 200);
|
||||
} catch (\Throwable $e) {
|
||||
$this->myLogger->logme('error', 'featchLeadDataAndInsertClient failed');
|
||||
return $this->respond(['status' => false, 'message' => 'Internal server error', 'error' => $e->getMessage()], 500);
|
||||
}
|
||||
|
||||
$result = $this->createClientWithLeadData($data);
|
||||
|
||||
if ($result) {
|
||||
|
||||
$policy_data = $this->clientPolicyModel->where('client_id', $result)->where('is_active', 1)->first();
|
||||
return $this->respond(['status' => true, 'message' => 'New Client created successfully', 'client_id' => $result, 'data' => $data, 'client_policy_id' => $policy_data['id']], 200);
|
||||
}
|
||||
|
||||
return $this->respond(['status' => false, 'message' => 'Failed to create client', 'data' => $data], 200);
|
||||
}
|
||||
|
||||
public function createClientWithLeadData($data)
|
||||
{
|
||||
$client_data = $this->prepareClientData($data);
|
||||
$client_id = $this->clientModel->insert($client_data);
|
||||
try {
|
||||
$client_data = $this->prepareClientData($data);
|
||||
$client_id = $this->clientModel->insert($client_data);
|
||||
|
||||
if ($client_id) {
|
||||
$this->createClientBranchAndContactWithLeadData($data, $client_id);
|
||||
$this->leadsModel->where('id', $data['id'])->set('is_client_created', $client_id)->update();
|
||||
if ($client_id) {
|
||||
$this->createClientBranchAndContactWithLeadData($data, $client_id);
|
||||
$this->leadsModel->where('id', $data['id'])->set('is_client_created', $client_id)->update();
|
||||
}
|
||||
|
||||
return $client_id;
|
||||
} catch (\Throwable $e) {
|
||||
$this->myLogger->logme('error','createClientWithLeadData failed');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return $client_id;
|
||||
public function createClientBranchAndContactWithLeadData($data, $client_id)
|
||||
{
|
||||
try {
|
||||
$branch_data = $this->prepareClientBranchData($data, $client_id);
|
||||
$branch_id = $this->clientBranchModel->insert($branch_data);
|
||||
|
||||
if ($branch_id) {
|
||||
$this->leadsModel->where('id', $data['id'])->set('is_client_created', $client_id)->update();
|
||||
$contact_data = $this->prepareContactData($data, $branch_id);
|
||||
$this->levelContactModel->insert($contact_data);
|
||||
$this->createClientPolicyWithLeadData($data, $client_id, $branch_id);
|
||||
}
|
||||
|
||||
return $branch_id;
|
||||
} catch (\Throwable $e) {
|
||||
$this->myLogger->logme('error','createClientBranchAndContactWithLeadData failed');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function createClientPolicyWithLeadData($data, $client_id, $branch_id)
|
||||
{
|
||||
try {
|
||||
$client_policy_data = $this->prepareClientPolicyData($data, $client_id, $branch_id);
|
||||
$client_policy_id = $this->clientPolicyModel->insert($client_policy_data);
|
||||
|
||||
if ($client_policy_id) {
|
||||
$this->leadsModel->where('id', $data['id'])->set('is_client_created', $client_id)->update();
|
||||
$this->leadsModel->where('id', $data['id'])->set('is_policy_created', $client_policy_id)->update();
|
||||
}
|
||||
|
||||
return $client_policy_id;
|
||||
} catch (\Throwable $e) {
|
||||
$this->myLogger->logme('error','createClientPolicyWithLeadData failed');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private function prepareClientData($data)
|
||||
{
|
||||
return [
|
||||
'client_type' => $data['client_type'],
|
||||
'entity_type_id' => $data['entity_type_id'],
|
||||
'client_code' => $data['client_code'],
|
||||
'client_name' => $data['client_name'],
|
||||
'short_name' => $data['client_short_name'],
|
||||
'pan' => $data['pan'],
|
||||
'client_type' => $data['client_type'] ?? null,
|
||||
'entity_type_id' => $data['entity_type_id'] ?? null,
|
||||
'client_code' => $data['client_code'] ?? null,
|
||||
'client_name' => $data['client_name'] ?? null,
|
||||
'short_name' => $data['client_short_name'] ?? null,
|
||||
'pan' => $data['pan'] ?? null,
|
||||
];
|
||||
}
|
||||
|
||||
public function createClientBranchAndContactWithLeadData($data, $client_id)
|
||||
{
|
||||
$branch_data = $this->prepareClientBranchData($data, $client_id);
|
||||
$branch_id = $this->clientBranchModel->insert($branch_data);
|
||||
|
||||
if ($branch_id) {
|
||||
$this->leadsModel->where('id', $data['id'])->set('is_client_created', $client_id)->update();
|
||||
$contact_data = $this->prepareContactData($data, $branch_id);
|
||||
$this->levelContactModel->insert($contact_data);
|
||||
|
||||
$this->createClientPolicyWithLeadData($data, $client_id, $branch_id);
|
||||
}
|
||||
|
||||
return $branch_id;
|
||||
}
|
||||
|
||||
private function prepareClientBranchData($data, $client_id)
|
||||
{
|
||||
$default_unit = trim(($data['client_short_name'] ?? '') . '-' . ($data['branch_code'] ?? ''), '-');
|
||||
@ -2768,19 +2814,6 @@ class LeadsController extends BaseController
|
||||
];
|
||||
}
|
||||
|
||||
public function createClientPolicyWithLeadData($data, $client_id, $branch_id)
|
||||
{
|
||||
$client_policy_data = $this->prepareClientPolicyData($data, $client_id, $branch_id);
|
||||
$client_policy_id = $this->clientPolicyModel->insert($client_policy_data);
|
||||
|
||||
|
||||
if ($client_policy_id) {
|
||||
$this->leadsModel->where('id', $data['id'])->set('is_client_created', $client_id)->update();
|
||||
}
|
||||
|
||||
return $client_policy_id;
|
||||
}
|
||||
|
||||
private function prepareClientPolicyData($data, $client_id, $branch_id)
|
||||
{
|
||||
$proposel_data = json_decode($data['proposel_data'], true);
|
||||
@ -2830,17 +2863,46 @@ class LeadsController extends BaseController
|
||||
|
||||
private function preparePolicyTermsFromRFQ($data)
|
||||
{
|
||||
$proposel_data = json_decode($data['proposel_data'], true);
|
||||
try {
|
||||
$proposel_data = json_decode($data['proposel_data'], true);
|
||||
$QCRData = $this->RFQModel->where('is_active', 1)->where('lead_id', $data['id'])->first();
|
||||
|
||||
$QCRData = $this->RFQModel->where('is_active', 1)->where('lead_id', $data['id'])->first();
|
||||
if (!$QCRData) {
|
||||
throw new \Exception('RFQ Data not found');
|
||||
}
|
||||
|
||||
$JSON = json_decode($QCRData['json'], true);
|
||||
$JSON = json_decode($QCRData['json'], true);
|
||||
$converted_json = $this->transformProposelData($JSON, $proposel_data['proposel_name'], $proposel_data['insurer_name']);
|
||||
|
||||
$converted_json = $this->transformProposelData($JSON, $proposel_data['proposel_name'], $proposel_data['insurer_name']);
|
||||
|
||||
return $this->convertQCRJsonToPolicyTerms($converted_json, $data['policy_type_id'], $proposel_data['proposel_name'], $proposel_data['insurer_name']);
|
||||
return $this->convertQCRJsonToPolicyTerms($converted_json, $data['policy_type_id'], $proposel_data['proposel_name'], $proposel_data['insurer_name']);
|
||||
} catch (\Throwable $e) {
|
||||
$this->myLogger->logme('error','preparePolicyTermsFromRFQ');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function featchClientPolicyFromLead($client_id, $branch_id, $lead_id)
|
||||
{
|
||||
$data = $this->leadsModel->where('leads.id', $lead_id)->where('leads.is_active', 1)->first();
|
||||
|
||||
if (!$data) {
|
||||
return $this->respond(['status' => false, 'message' => 'Failed to create policy', 'data' => null], 200);
|
||||
}
|
||||
|
||||
$result = $this->createClientPolicyWithLeadData($data, $client_id, $branch_id);
|
||||
// print_r($result); die;
|
||||
|
||||
if ($result) {
|
||||
|
||||
$policy_data = $this->clientPolicyModel->where('id', $result)->where('is_active', 1)->first();
|
||||
return $this->respond(['status' => true, 'message' => 'New Policy created successfully', 'client_policy_id' => $result, 'data' => $data, 'client_id' => $policy_data['client_id']], 200);
|
||||
}
|
||||
|
||||
return $this->respond(['status' => false, 'message' => 'Failed to create policy', 'data' => $data], 200);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------
|
||||
|
||||
//Function for convert the RFQ and QCR Json to Policy Terms Json
|
||||
public function convertQCRJsonToPolicyTerms($data, $policy_type, $proposel_name, $insurer_name)
|
||||
{
|
||||
@ -2965,26 +3027,6 @@ class LeadsController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
public function featchClientPolicyFromLead($client_id, $branch_id, $lead_id)
|
||||
{
|
||||
$data = $this->leadsModel->where('leads.id', $lead_id)->where('leads.is_active', 1)->first();
|
||||
|
||||
if (!$data) {
|
||||
return $this->respond(['status' => false, 'message' => 'Failed to create policy', 'data' => null], 200);
|
||||
}
|
||||
|
||||
$result = $this->createClientPolicyWithLeadData($data, $client_id, $branch_id);
|
||||
// print_r($result); die;
|
||||
|
||||
if ($result) {
|
||||
|
||||
$policy_data = $this->clientPolicyModel->where('id', $result)->where('is_active', 1)->first();
|
||||
return $this->respond(['status' => true, 'message' => 'New Policy created successfully', 'client_policy_id' => $result, 'data' => $data, 'client_id' => $policy_data['client_id']], 200);
|
||||
}
|
||||
|
||||
return $this->respond(['status' => false, 'message' => 'Failed to create policy', 'data' => $data], 200);
|
||||
}
|
||||
|
||||
public function getPlacementJson(array $data): ?string
|
||||
{
|
||||
$proposel_data = json_decode($data['proposel_data'], true);
|
||||
@ -3082,7 +3124,7 @@ class LeadsController extends BaseController
|
||||
}
|
||||
|
||||
|
||||
function getLastFiveFinancialYears()
|
||||
public function getLastFiveFinancialYears()
|
||||
{
|
||||
$currentYear = date('Y');
|
||||
$currentMonth = date('m');
|
||||
|
||||
@ -94,7 +94,7 @@ class LoginController extends BaseController
|
||||
// setcookie('session_data', '', time() - 3600, $path);
|
||||
$path = getenv('cookie.Path');
|
||||
$domain = getenv('cookie.Domain');
|
||||
$https = getenv('ccokie.secure');
|
||||
$https = getenv('cookie.secure');
|
||||
setcookie('session_data',null, time() -3600, $path, $domain, $https, true);
|
||||
return redirect()->to(base_url('login'));
|
||||
}
|
||||
|
||||
@ -235,8 +235,7 @@ class PolicyTransactionController extends BaseController
|
||||
->where('role', 3) // Assuming `role` is in `user_profiles`
|
||||
->where('is_active', 1)
|
||||
->findAll();
|
||||
|
||||
// echo '<pre>';
|
||||
// echo '<pre>';
|
||||
// print_r($data['ppTeamsData']); die;
|
||||
|
||||
// dd($data);
|
||||
@ -357,7 +356,9 @@ class PolicyTransactionController extends BaseController
|
||||
// print_r($data); die;
|
||||
|
||||
$insert = $this->policyTransactionModel->insert($data);
|
||||
|
||||
if ($insert) {
|
||||
|
||||
$this->insertTransactionStatus($insert, $data, 1);
|
||||
$emp_data = $this->processInsertIndividualMemberInEmpTable($data);
|
||||
|
||||
@ -366,19 +367,15 @@ class PolicyTransactionController extends BaseController
|
||||
$pt_co_share_details = $this->insertOrUpdateCoShareDetails($data, $insert);
|
||||
|
||||
if ($data['ct_type'] == 2) {
|
||||
|
||||
$client_policy_insert_data = $this->prepareClientPolicyInsertData($data);
|
||||
$client_policy_id = $this->clientPolicyModel->insert($client_policy_insert_data);
|
||||
$this->policyTransactionModel->update($insert, ['client_policy_id' => $client_policy_id]);
|
||||
$emp_policy_insert = $this->InsertIndividualEmpPolicyTable($emp_data, $client_policy_id);
|
||||
|
||||
if ($data['client_type'] == 1 && $data['status'] == 'completed' && $data['is_cd_reduce_from_bds'] == 1) {
|
||||
$this->processCompletedStatus($data, $client_policy_id, $data['insurer_id']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$data['pt_co_share_details'] = $this->PTCOShareDetailsModel->where('pt_id', $insert)->where('is_active', 1)->findAll();
|
||||
if ($data['client_type'] == 1 && $data['status'] == 'completed' && $data['is_cd_reduce_from_bds'] == 1) {
|
||||
$this->processCompletedStatus($data, $client_policy_id, $data['insurer_id']);
|
||||
}
|
||||
}
|
||||
|
||||
$client_data = $this->clientModel->where('id', $data['client_id'])->first();
|
||||
@ -387,6 +384,7 @@ class PolicyTransactionController extends BaseController
|
||||
|
||||
return $this->respondSuccess($insert, "Policy transaction created successfully", $data);
|
||||
}
|
||||
|
||||
return $this->respondError("Failed to create policy transaction");
|
||||
}
|
||||
|
||||
@ -2906,4 +2904,52 @@ class PolicyTransactionController extends BaseController
|
||||
$this->myLogger->logme('error', 'Exception: ' . $e->getMessage() . 'Page: ' . $e->getFile() . ' Line: ' . $e->getLine());
|
||||
}
|
||||
}
|
||||
|
||||
public function getMoreInfo() {
|
||||
|
||||
$pt_id = $this->request->getPost("pt_id");
|
||||
$data_to_send['bds_data'] = $this->BdsPlacementModel->where("is_active",1)->where("pt_id",$pt_id)->findAll();
|
||||
|
||||
foreach ($data_to_send['bds_data'] as &$data) {
|
||||
|
||||
$data['payment_date'] = (new \DateTime($data['payment_date']))->format('d-m-Y');
|
||||
}
|
||||
|
||||
if (!empty($data_to_send)) {
|
||||
|
||||
return $this->respond(['status' => true , "data" => $data_to_send],200);
|
||||
}else {
|
||||
|
||||
return $this->respond(['status' => false,"No Data Found For the Policy Transaction"],404);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function saveInstallment() {
|
||||
|
||||
$installments = $this->request->getPost('installments');
|
||||
|
||||
if (!$installments || !is_array($installments)) {
|
||||
return $this->respond(['status' => false, 'message' => 'No data received'], 400);
|
||||
}
|
||||
|
||||
$this->myLogger->logme("error",json_encode($installments));
|
||||
// die();
|
||||
|
||||
foreach ($installments as &$row) {
|
||||
// Convert date from d-m-Y to Y-m-d
|
||||
if (!empty($row['payment_date'])) {
|
||||
$date = \DateTime::createFromFormat('d-m-Y', $row['payment_date']);
|
||||
if ($date) {
|
||||
$row['payment_date'] = $date->format('Y-m-d');
|
||||
}
|
||||
}
|
||||
$this->BdsPlacementModel->save($row);
|
||||
}
|
||||
|
||||
return $this->respond(['status' => true, 'message' => 'Data saved successfully'], 200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -22,6 +22,39 @@ class BdsPlacementModel extends Model
|
||||
'is_active'
|
||||
];
|
||||
|
||||
// Callbacks
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = ["checkAndADDCreatedByValue"];
|
||||
protected $afterInsert = [];
|
||||
protected $beforeUpdate = ["checkAndUpdateUpdatedByValue"];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
|
||||
protected function checkAndADDCreatedByValue(array $data)
|
||||
{
|
||||
// Check if 'updated_by' value is null or empty
|
||||
if (empty($data['data']['created_by'])) {
|
||||
// Set 'updated_by' value to the current session user ID
|
||||
$data['data']['created_by'] = get_session_userid();
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function checkAndUpdateUpdatedByValue(array $data)
|
||||
{
|
||||
// Check if 'updated_by' value is null or empty
|
||||
if (empty($data['data']['updated_by'])) {
|
||||
// Set 'updated_by' value to the current session user ID
|
||||
$data['data']['updated_by'] = get_session_userid();
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
public function getClientInstallmentDetails()
|
||||
{
|
||||
|
||||
@ -96,6 +96,7 @@ class LeadsModel extends Model
|
||||
|
||||
'is_installment',
|
||||
'no_of_installment',
|
||||
'is_policy_created',
|
||||
];
|
||||
|
||||
|
||||
@ -176,7 +177,8 @@ class LeadsModel extends Model
|
||||
->where('leads.is_active', 1)
|
||||
->where('leads.status', 'won')
|
||||
->where("leads.proposel_data IS NOT NULL AND leads.proposel_data <> ''")
|
||||
->where("(leads.is_client_created = '' OR leads.is_client_created IS NULL)");
|
||||
->where("(leads.is_client_created = '' OR leads.is_client_created IS NULL)")
|
||||
->where("(leads.is_policy_created = '' OR leads.is_policy_created IS NULL)");
|
||||
|
||||
|
||||
|
||||
|
||||
@ -17,6 +17,10 @@ table.dataTable thead th {
|
||||
max-width: 98% !important;
|
||||
}
|
||||
|
||||
.btn-filter{
|
||||
margin-left: 20px !important;
|
||||
}
|
||||
|
||||
.custom-dropdown-menu {
|
||||
display: none;
|
||||
position: absolute;
|
||||
@ -53,12 +57,12 @@ table.dataTable thead th {
|
||||
<div class="col-6" style="align-self: center;">
|
||||
<h4 style="position: relative;">Client List</h4>
|
||||
</div>
|
||||
<div class="col-2" style="text-align: right; position: relative;top: 56px; left: 303px;">
|
||||
<!-- <div class="col-2" style="text-align: right; position: relative;top: 56px; left: 303px;">
|
||||
<a class="btn btn-primary waves-effect waves-light" onclick="showModal()">Add From Lead</a>
|
||||
</div>
|
||||
<div class="col-1" style="text-align: right; position: relative;top: 56px; left: 294px;">
|
||||
<a href="<?= base_url("client/create"); ?>" type="button" id="btnAdd" class="btn btn-primary waves-effect waves-light" data-toggle="" data-placement="top" title="Add" data-trigger="hover">Add</a>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
<table class="table table-sm table-hover m-0 table-centered dt-responsive nowrap w-100" cellspacing="0"
|
||||
id="tickets-table">
|
||||
@ -269,18 +273,40 @@ table.dataTable thead th {
|
||||
$(document).ready(function()
|
||||
{
|
||||
$('#tickets-table').DataTable({
|
||||
dom: "<'row'<'col-sm-0'f><'col-sm-7 text-right'B>>" +
|
||||
dom: "<'row'<'col-sm-2'f><'col-sm-10 text-right'B>>" +
|
||||
"<'row'<'col-sm-12'tr>>" +
|
||||
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
|
||||
buttons: [{
|
||||
extend: 'csv',
|
||||
text: 'CSV',
|
||||
title: 'ClientList',
|
||||
className: 'my_class',
|
||||
exportOptions: {
|
||||
columns: ':not(:last-child)'
|
||||
buttons: [
|
||||
{
|
||||
extend: 'csv',
|
||||
text: 'CSV',
|
||||
title: 'ClientList',
|
||||
className: 'my_class',
|
||||
exportOptions: {
|
||||
columns: ':not(:last-child)'
|
||||
},
|
||||
},
|
||||
{
|
||||
text: 'Add From Lead',
|
||||
className: 'btn-filter', // custom class
|
||||
action: function(e, dt, node, config) {
|
||||
showModal();
|
||||
}
|
||||
},
|
||||
}],
|
||||
{
|
||||
text: 'Add',
|
||||
className: 'btn-filter', // custom class
|
||||
action: function(e, dt, node, config) {
|
||||
addClient();
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
initComplete: function() {
|
||||
$('.btn-filter')
|
||||
.removeClass('btn-secondary')
|
||||
.addClass('btn btn-primary');
|
||||
},
|
||||
language: {
|
||||
search: "_INPUT_",
|
||||
searchPlaceholder: "Search..."
|
||||
@ -440,4 +466,9 @@ function featchClient(){
|
||||
});
|
||||
}
|
||||
|
||||
function addClient(){
|
||||
let url = "<?= base_url("client/create"); ?>";
|
||||
window.location.href = url;
|
||||
}
|
||||
|
||||
</script>
|
||||
@ -149,7 +149,7 @@
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="client_branch_id">Branch<span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="client_branch_id" name="client_branch_id"
|
||||
onchange="getBranchData(this)">
|
||||
onchange="getBranchData(this,1)">
|
||||
<option value="">Select Branch</option>
|
||||
</select>
|
||||
</div>
|
||||
@ -207,6 +207,14 @@
|
||||
placeholder="Enter Branch Code" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="contact_person_summary">Contact Person's</label>
|
||||
<select class="form-control" name="contact_person_summary" id="contact_person_summary">
|
||||
<option value="">Select a Person</option>
|
||||
</select>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="client_branch">Contact Person Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="contact_person_name" name="contact_person_name"
|
||||
@ -289,6 +297,8 @@
|
||||
</div>
|
||||
</div><!-- end form row -->
|
||||
|
||||
<?php include("newClientModal.php") ?>
|
||||
|
||||
|
||||
<script>
|
||||
let claimIndex = 1;
|
||||
@ -373,6 +383,58 @@
|
||||
// }
|
||||
}
|
||||
});
|
||||
}else if (lead_type == 3) {
|
||||
|
||||
$('#client_id').prepend($('<option>', {
|
||||
value: 'add_client',
|
||||
text: '+ Add Client'
|
||||
}));
|
||||
$("#source_policy_id").removeAttr("required");
|
||||
$("#source_policy_id").closest("div") .find("label .text-danger").remove();
|
||||
|
||||
$("#source_policy_start_date").removeAttr("required");
|
||||
$("#source_policy_start_date").closest("div") .find("label .text-danger").remove();
|
||||
|
||||
$("#source_policy_end_date").removeAttr("required");
|
||||
$("#source_policy_end_date").closest("div") .find("label .text-danger").remove();
|
||||
|
||||
|
||||
|
||||
} else if (lead_type != 3) {
|
||||
$("#source_policy_id").prop("required",true);
|
||||
$("#source_policy_start_date").prop("required", true);
|
||||
$("#source_policy_end_date").prop("required", true);
|
||||
|
||||
|
||||
// Check if the asterisk doesn't already exist, then add it
|
||||
let $label = $("#source_policy_id")
|
||||
.closest("div")
|
||||
.find("label");
|
||||
|
||||
if ($label.find(".text-danger").length === 0) {
|
||||
$label.append(' <span class="text-danger">*</span>');
|
||||
}
|
||||
let $label2 = $("#source_policy_start_date")
|
||||
.closest("div")
|
||||
.find("label");
|
||||
|
||||
if ($label2.find(".text-danger").length === 0) {
|
||||
$label2.append(' <span class="text-danger">*</span>');
|
||||
}
|
||||
let $label3 = $("#source_policy_end_date")
|
||||
.closest("div")
|
||||
.find("label");
|
||||
|
||||
if ($label3.find(".text-danger").length === 0) {
|
||||
$label3.append(' <span class="text-danger">*</span>');
|
||||
}
|
||||
|
||||
var addOption = $('#client_id option[value="add_client"]');
|
||||
if (addOption.length > 0) {
|
||||
addOption.remove();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
var policy_end_datePicker = flatpickr("#policy_end_date_" + increment, {
|
||||
@ -406,8 +468,9 @@
|
||||
$('#tpa_' + increment).select2();
|
||||
$('#proposed_insurer').select2();
|
||||
$('#proposed_tpa').select2();
|
||||
})
|
||||
|
||||
|
||||
})
|
||||
//------------------------------ GET DATA ( EDIT, BRANCH, POLICY ) ---------------------------------------------------------------------------
|
||||
|
||||
//view and edit Lead data function
|
||||
@ -576,10 +639,15 @@
|
||||
});
|
||||
}
|
||||
|
||||
var allContacts = "";
|
||||
//client branch data
|
||||
function getBranchData(input) {
|
||||
function getBranchData(input, inputType) {
|
||||
|
||||
var client_branch_id = $(input).val();
|
||||
if (inputType == 1 ) {
|
||||
var client_branch_id = $(input).val();
|
||||
} else {
|
||||
client_branch_id = input;
|
||||
}
|
||||
|
||||
if (client_branch_id) {
|
||||
|
||||
@ -600,9 +668,29 @@
|
||||
$('#pan').val(res.data.pan);
|
||||
$('#branch_name').val(res.data.branch_name);
|
||||
$('#branch_code').val(res.data.branch_code);
|
||||
$('#contact_person_name').val(res?.contact?.name || '');
|
||||
$('#contact_person_mobile').val(res?.contact?.mobile || '');
|
||||
$('#contact_person_email').val(res?.contact?.email || '');
|
||||
allContacts = res.contact;
|
||||
$('#contact_person_summary').empty();
|
||||
$('#contact_person_summary').append($('<option>', {
|
||||
value: "",
|
||||
text: "Select a Contact"
|
||||
}));
|
||||
|
||||
res.contact.forEach((value, key) => {
|
||||
|
||||
if (value.name && value.email) {
|
||||
|
||||
let display_value = `${value.name} - ${value.email} - ${value.mobile}`;
|
||||
|
||||
$('#contact_person_summary').append($('<option>', {
|
||||
value: key, // index or key in array/object
|
||||
text: display_value
|
||||
}));
|
||||
}
|
||||
|
||||
});
|
||||
// $('#contact_person_name').val(res?.contact?.name || '');
|
||||
// $('#contact_person_mobile').val(res?.contact?.mobile || '');
|
||||
// $('#contact_person_email').val(res?.contact?.email || '');
|
||||
|
||||
|
||||
$('#pan').prop('readOnly', true);
|
||||
@ -1562,7 +1650,14 @@
|
||||
$('.freshFields').hide();
|
||||
|
||||
$('.renewalFields').show();
|
||||
$('.renewalFields').find('select, input').attr('required', 'required');
|
||||
|
||||
if (value != 3) {
|
||||
$('.renewalFields').find('select, input').attr('required', 'required');
|
||||
$("#source_policy_id").removeAttr("required");
|
||||
$("#source_policy_start_date").removeAttr("required");
|
||||
$("#source_policy_end_date").removeAttr("required");
|
||||
|
||||
}
|
||||
|
||||
// $('.proposed_div').show().find('select, input').attr('required', 'required');
|
||||
|
||||
|
||||
@ -231,6 +231,16 @@ if (isset($selected_lead_type)) {
|
||||
$('#client_id').change(function() {
|
||||
|
||||
let client_id = $(this).val();
|
||||
|
||||
|
||||
if (client_id == 'add_client') {
|
||||
// alert("Hello");
|
||||
var myModal = new bootstrap.Modal(document.getElementById('upload_enrollment_model'));
|
||||
myModal.show();
|
||||
// $('#upload_enrollment_model').modal('toggle');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("client_id", client_id)
|
||||
let client_type = $('#client_id option:selected').data('ct');
|
||||
|
||||
@ -258,6 +268,17 @@ if (isset($selected_lead_type)) {
|
||||
|
||||
})
|
||||
|
||||
$("#contact_person_summary").change(function () {
|
||||
let selectedKey = $(this).val();
|
||||
|
||||
if (allContacts[selectedKey]) {
|
||||
$('#contact_person_name').val(allContacts[selectedKey].name || '');
|
||||
$('#contact_person_mobile').val(allContacts[selectedKey].mobile || '');
|
||||
$('#contact_person_email').val(allContacts[selectedKey].email || '');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$('#client_branch_id').change(function() {
|
||||
|
||||
let client_branch_id = $(this).val();
|
||||
@ -271,6 +292,7 @@ if (isset($selected_lead_type)) {
|
||||
} else {
|
||||
$('#source_policy_id').empty();
|
||||
|
||||
// let lead_type = data.lead_type || null;
|
||||
if (temp_branch_id == 0) {
|
||||
console.log("Step 1: temp_branch_id is 0 - No Policies Found for the selected branch");
|
||||
console.log('second client_branch_id', client_branch_id);
|
||||
@ -280,11 +302,17 @@ if (isset($selected_lead_type)) {
|
||||
} else {
|
||||
console.log("Step 3: v exists - Assigning temp_branch_id = client_branch_id");
|
||||
temp_branch_id = client_id;
|
||||
toastr.warning("No Policies Found for the selected Branch", 'Warning');
|
||||
if (lead_type != 3) {
|
||||
|
||||
toastr.warning("No Policies Found for the selected Branch", 'Warning');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.log("Step 4: temp_branch_id is not 0 - Showing warning");
|
||||
toastr.warning("No Policies Found for the selected Branch", 'Warning');
|
||||
if (lead_type != 3) {
|
||||
|
||||
toastr.warning("No Policies Found for the selected Branch", 'Warning');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -310,24 +338,24 @@ if (isset($selected_lead_type)) {
|
||||
$('#salse_person_id').trigger('change');
|
||||
}
|
||||
|
||||
function validateInput(input, table, field){
|
||||
// function validateInput(input, table, field){
|
||||
|
||||
let value = $(input).val();
|
||||
let label = $(input).closest('.form-group').find('label').text().replace('*', '').trim();
|
||||
// let value = $(input).val();
|
||||
// let label = $(input).closest('.form-group').find('label').text().replace('*', '').trim();
|
||||
|
||||
let message = "Value is duplicate!";
|
||||
if(label){
|
||||
message = label + " already exists!";
|
||||
}
|
||||
// let message = "Value is duplicate!";
|
||||
// if(label){
|
||||
// message = label + " already exists!";
|
||||
// }
|
||||
|
||||
checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) {
|
||||
if (isDuplicate) {
|
||||
toastr.warning(message, 'WARNING');
|
||||
$(input).val('')
|
||||
}
|
||||
});
|
||||
// checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) {
|
||||
// if (isDuplicate) {
|
||||
// toastr.warning(message, 'WARNING');
|
||||
// $(input).val('')
|
||||
// }
|
||||
// });
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------
|
||||
|
||||
@ -464,6 +492,8 @@ if (isset($selected_lead_type)) {
|
||||
<?php if (isset($lead_edit_data)) { ?>
|
||||
<script>
|
||||
|
||||
var lead_type = "";
|
||||
|
||||
$(document).ready(async function () {
|
||||
|
||||
$('.loader').fadeIn();
|
||||
@ -481,6 +511,7 @@ if (isset($selected_lead_type)) {
|
||||
});
|
||||
|
||||
function handleEbAndNonEbEdit(data){
|
||||
lead_type = data.lead_type || null;
|
||||
if(data.lead_form_type == 1){
|
||||
dynamicLeadsDataForEdit(data)
|
||||
}else{
|
||||
@ -589,6 +620,40 @@ if (isset($selected_lead_type)) {
|
||||
}
|
||||
}
|
||||
|
||||
// if (lead_type == 3) {
|
||||
|
||||
// $('#client_id').prepend($('<option>', {
|
||||
// value: 'add_client',
|
||||
// text: '+ Add Client'
|
||||
// }));
|
||||
|
||||
// console.log("trying to remove required ");
|
||||
// $("#source_policy_id").prop("required",false);
|
||||
// $("#source_policy_id").closest("div") .find("label .text-danger").remove();
|
||||
|
||||
|
||||
// } else if (lead_type != 3) {
|
||||
// $("#source_policy_id").prop("required",true);
|
||||
// $("#source_policy_id").prop("required", true);
|
||||
|
||||
// // Check if the asterisk doesn't already exist, then add it
|
||||
// let $label = $("#source_policy_id")
|
||||
// .closest("div")
|
||||
// .find("label");
|
||||
|
||||
// if ($label.find(".text-danger").length === 0) {
|
||||
// $label.append(' <span class="text-danger">*</span>');
|
||||
// }
|
||||
|
||||
// var addOption = $('#client_id option[value="add_client"]');
|
||||
// if (addOption.length > 0) {
|
||||
// addOption.remove();
|
||||
// }
|
||||
|
||||
// console.log("rying to remove required and option removed from client")
|
||||
|
||||
// }
|
||||
|
||||
hide_list_show_add();
|
||||
|
||||
$('#page_title').text('Edit Lead');
|
||||
@ -603,27 +668,33 @@ if (isset($selected_lead_type)) {
|
||||
$('#lead_status').val(data.status || '');
|
||||
$('#notes').val(data.notes || '');
|
||||
|
||||
setTimeout(() => {
|
||||
$('#client_id').val(data.client_id || '').change();
|
||||
setTimeout(() => {
|
||||
$('#client_branch_id').val(data.client_branch_id || '').change();
|
||||
setTimeout(() => {
|
||||
$('#source_policy_id').val(data.source_policy_id || '');
|
||||
$('#source_policy_end_date').val(data.source_policy_end_date || '');
|
||||
$('#source_policy_start_date').val(data.source_policy_start_date || '');
|
||||
$('#pan').val(data.pan || '');
|
||||
$('#gst').val(data.gst || '');
|
||||
$('#branch_name').val(data.branch_name || '');
|
||||
$('#branch_code').val(data.branch_code || '');
|
||||
$('#contact_person_name').val(data.contact_person_name || '');
|
||||
$('#contact_person_mobile').val(data.contact_person_mobile || '');
|
||||
$('#contact_person_email').val(data.contact_person_email || '');
|
||||
$('#policy_type_id_1').val(data.policy_type_id || '').select2();
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
}, 1000);
|
||||
}, 1000);
|
||||
}, 5000);
|
||||
// setTimeout(() => {
|
||||
// $('#client_id').val(data.client_id || '').change();
|
||||
// setTimeout(() => {
|
||||
// $('#client_branch_id').val(data.client_branch_id || '').change();
|
||||
// setTimeout(() => {
|
||||
// $('#source_policy_id').val(data.source_policy_id || '');
|
||||
// $('#source_policy_end_date').val(data.source_policy_end_date || '');
|
||||
// $('#source_policy_start_date').val(data.source_policy_start_date || '');
|
||||
// $('#pan').val(data.pan || '');
|
||||
// $('#gst').val(data.gst || '');
|
||||
// $('#branch_name').val(data.branch_name || '');
|
||||
// $('#branch_code').val(data.branch_code || '');
|
||||
// $('#contact_person_name').val(data.contact_person_name || '');
|
||||
// $('#contact_person_mobile').val(data.contact_person_mobile || '');
|
||||
// $('#contact_person_email').val(data.contact_person_email || '');
|
||||
// $('#policy_type_id_1').val(data.policy_type_id || '').select2();
|
||||
// $('.loader').fadeOut();
|
||||
// $('.loader-mask').delay(350).fadeOut('slow');
|
||||
// }, 1000);
|
||||
// }, 1000);
|
||||
// }, 5000);
|
||||
|
||||
// setTimeout(() => {
|
||||
populateForm(data);
|
||||
|
||||
// },5000);
|
||||
|
||||
|
||||
let insurer = (data.insurer_branch_id && data.insurer_id)
|
||||
? `${data.insurer_branch_id}-${data.insurer_id}`
|
||||
@ -678,10 +749,10 @@ if (isset($selected_lead_type)) {
|
||||
}
|
||||
|
||||
if (data.multi_file_html) {
|
||||
console.log(data.multi_file_html);
|
||||
// console.log(data.multi_file_html);
|
||||
setTimeout(function(){
|
||||
$('#multiFileAppendArea_' + dataIncrement).append(data.multi_file_html);
|
||||
}, 2000)
|
||||
}, 1000)
|
||||
} else {
|
||||
console.warn('MULTI FILE HTML content missing in data.');
|
||||
}
|
||||
@ -710,30 +781,33 @@ if (isset($selected_lead_type)) {
|
||||
$('#lead_status').val(data.status || '');
|
||||
$('#notes').val(data.notes || '');
|
||||
|
||||
setTimeout(() => {
|
||||
$('#client_id').val(data.client_id || '').change();
|
||||
setTimeout(() => {
|
||||
$('#client_branch_id').val(data.client_branch_id || '').change();
|
||||
setTimeout(() => {
|
||||
$('#source_policy_id').val(data.source_policy_id || '');
|
||||
$('#pan').val(data.pan || '');
|
||||
$('#gst').val(data.gst || '');
|
||||
$('#branch_name').val(data.branch_name || '');
|
||||
$('#branch_code').val(data.branch_code || '');
|
||||
$('#contact_person_name').val(data.contact_person_name || '');
|
||||
$('#contact_person_mobile').val(data.contact_person_mobile || '');
|
||||
$('#contact_person_email').val(data.contact_person_email || '');
|
||||
$('#policy_type_id').val(data.policy_type_id || '').select2();
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
$(".loss_date").each(function () {
|
||||
flatpickr(this, {
|
||||
dateFormat: "d-m-Y",
|
||||
});
|
||||
});
|
||||
}, 1000);
|
||||
}, 1000);
|
||||
}, 2000);
|
||||
// setTimeout(() => {
|
||||
// $('#client_id').val(data.client_id || '').change();
|
||||
// setTimeout(() => {
|
||||
// $('#client_branch_id').val(data.client_branch_id || '').change();
|
||||
// setTimeout(() => {
|
||||
// $('#source_policy_id').val(data.source_policy_id || '');
|
||||
// $('#pan').val(data.pan || '');
|
||||
// $('#gst').val(data.gst || '');
|
||||
// $('#branch_name').val(data.branch_name || '');
|
||||
// $('#branch_code').val(data.branch_code || '');
|
||||
// $('#contact_person_name').val(data.contact_person_name || '');
|
||||
// $('#contact_person_mobile').val(data.contact_person_mobile || '');
|
||||
// $('#contact_person_email').val(data.contact_person_email || '');
|
||||
// $('#policy_type_id').val(data.policy_type_id || '').select2();
|
||||
// $('.loader').fadeOut();
|
||||
// $('.loader-mask').delay(350).fadeOut('slow');
|
||||
// $(".loss_date").each(function () {
|
||||
// flatpickr(this, {
|
||||
// dateFormat: "d-m-Y",
|
||||
// });
|
||||
// });
|
||||
// }, 1000);
|
||||
// }, 1000);
|
||||
// }, 2000);
|
||||
|
||||
populateForm(data);
|
||||
|
||||
|
||||
let insurer = (data.insurer_branch_id && data.insurer_id)
|
||||
? `${data.insurer_branch_id}-${data.insurer_id}`
|
||||
@ -763,10 +837,96 @@ if (isset($selected_lead_type)) {
|
||||
referenceDiv.innerHTML = '';
|
||||
referenceDiv.insertAdjacentHTML('beforeend', data.claims_details_html);
|
||||
|
||||
console.log("wdesfgefwregfefwregffeegf",data.lead_type);
|
||||
var lead_type_value = data.lead_type;
|
||||
|
||||
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error in dynamicLeadsDataForEdit function:', error);
|
||||
}
|
||||
}
|
||||
|
||||
function waitForDropdownValue(selector, value, callback, retries = 20) {
|
||||
const trySet = () => {
|
||||
const $el = $(selector);
|
||||
if ($el.find(`option[value="${value}"]`).length > 0) {
|
||||
$el.val(value).trigger('change');
|
||||
callback();
|
||||
} else if (retries > 0) {
|
||||
setTimeout(() => trySet(selector, value, callback, retries - 1), 300);
|
||||
} else {
|
||||
console.warn(`Value ${value} not found for ${selector}`);
|
||||
callback(); // Proceed anyway to avoid hanging
|
||||
}
|
||||
};
|
||||
trySet();
|
||||
}
|
||||
|
||||
function populateForm(data) {
|
||||
|
||||
let lead_type = data.lead_type || null;
|
||||
waitForDropdownValue('#client_id', data.client_id || '', () => {
|
||||
if (lead_type == 3) {
|
||||
|
||||
$('#client_id').prepend($('<option>', {
|
||||
value: 'add_client',
|
||||
text: '+ Add Client'
|
||||
}));
|
||||
|
||||
console.log("trying to remove required ");
|
||||
$("#source_policy_id").prop("required",false);
|
||||
$("#source_policy_id").closest("div") .find("label .text-danger").remove();
|
||||
|
||||
|
||||
} else if (lead_type != 3) {
|
||||
$("#source_policy_id").prop("required",true);
|
||||
$("#source_policy_id").prop("required", true);
|
||||
|
||||
// Check if the asterisk doesn't already exist, then add it
|
||||
let $label = $("#source_policy_id")
|
||||
.closest("div")
|
||||
.find("label");
|
||||
|
||||
if ($label.find(".text-danger").length === 0) {
|
||||
$label.append(' <span class="text-danger">*</span>');
|
||||
}
|
||||
|
||||
var addOption = $('#client_id option[value="add_client"]');
|
||||
if (addOption.length > 0) {
|
||||
addOption.remove();
|
||||
}
|
||||
|
||||
console.log("rying to remove required and option removed from client")
|
||||
|
||||
}
|
||||
waitForDropdownValue('#client_branch_id', data.client_branch_id || '', () => {
|
||||
// Fill other fields once both dropdowns are ready
|
||||
$('#source_policy_id').val(data.source_policy_id || '');
|
||||
$('#source_policy_end_date').val(data.source_policy_end_date || '');
|
||||
$('#source_policy_start_date').val(data.source_policy_start_date || '');
|
||||
$('#pan').val(data.pan || '');
|
||||
$('#gst').val(data.gst || '');
|
||||
$('#branch_name').val(data.branch_name || '');
|
||||
$('#branch_code').val(data.branch_code || '');
|
||||
$('#contact_person_name').val(data.contact_person_name || '');
|
||||
$('#contact_person_mobile').val(data.contact_person_mobile || '');
|
||||
$('#contact_person_email').val(data.contact_person_email || '');
|
||||
$('#policy_type_id').val(data.policy_type_id || '').select2();
|
||||
$('#policy_type_id_1').val(data.policy_type_id || '').select2();
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
$(".loss_date").each(function () {
|
||||
flatpickr(this, {
|
||||
dateFormat: "d-m-Y",
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
<?php } ?>
|
||||
|
||||
@ -150,7 +150,7 @@
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="client_branch_id">Branch<span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="client_branch_id" name="client_branch_id"
|
||||
onchange="getBranchData(this)">
|
||||
onchange="getBranchData(this,1)">
|
||||
<option value="">Select Branch</option>
|
||||
</select>
|
||||
</div>
|
||||
@ -198,6 +198,14 @@
|
||||
placeholder="Enter Branch Code" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="contact_person_summary">Contact Person's</label>
|
||||
<select class="form-control" name="contact_person_summary" id="contact_person_summary">
|
||||
<option value="">Select a Person</option>
|
||||
</select>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="client_branch">Contact Person Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="contact_person_name" name="contact_person_name"
|
||||
@ -359,10 +367,14 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php include("newClientModal.php") ?>
|
||||
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
|
||||
|
||||
|
||||
var today = new Date();
|
||||
|
||||
var policy_start_datePicker = flatpickr("#policy_start_date", {
|
||||
@ -559,6 +571,40 @@
|
||||
|
||||
$('#lead_type').change(function() {
|
||||
let value = $(this).val()
|
||||
// alert(value);
|
||||
if (value == 3) {
|
||||
// alert("Function Called");
|
||||
|
||||
$('#client_id').prepend($('<option>', {
|
||||
value: 'add_client',
|
||||
text: '+ Add Client'
|
||||
}));
|
||||
|
||||
$("#source_policy_id").prop("required",false);
|
||||
$("#source_policy_id").closest("div") .find("label .text-danger").remove();
|
||||
|
||||
|
||||
} else if (value != 3) {
|
||||
$("#source_policy_id").prop("required",true);
|
||||
$("#source_policy_id").prop("required", true);
|
||||
|
||||
// Check if the asterisk doesn't already exist, then add it
|
||||
let $label = $("#source_policy_id")
|
||||
.closest("div")
|
||||
.find("label");
|
||||
|
||||
if ($label.find(".text-danger").length === 0) {
|
||||
$label.append(' <span class="text-danger">*</span>');
|
||||
}
|
||||
|
||||
var addOption = $('#client_id option[value="add_client"]');
|
||||
if (addOption.length > 0) {
|
||||
addOption.remove();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
leadTypeBsedHideAndShow(value, true)
|
||||
})
|
||||
|
||||
@ -615,6 +661,13 @@
|
||||
$('.renewalFields').show();
|
||||
$('.renewalFields').find('select, input').attr('required', 'required');
|
||||
|
||||
if (value == 3) {
|
||||
$("#source_policy_id").removeAttr("required");
|
||||
$("#source_policy_start_date").removeAttr("required");
|
||||
$("#source_policy_end_date").removeAttr("required");
|
||||
|
||||
}
|
||||
|
||||
$('.proposed_div').show().find('select, input').attr('required', 'required');
|
||||
|
||||
$('#policy_end_date').removeAttr('required');
|
||||
@ -636,10 +689,16 @@
|
||||
}
|
||||
|
||||
}
|
||||
var allContacts = "";
|
||||
function getBranchData(input,inputType) {
|
||||
|
||||
function getBranchData(input) {
|
||||
// alert("get branch Function called");
|
||||
|
||||
var client_branch_id = $(input).val();
|
||||
if (inputType == 1 ) {
|
||||
var client_branch_id = $(input).val();
|
||||
} else {
|
||||
client_branch_id = input;
|
||||
}
|
||||
|
||||
if (client_branch_id) {
|
||||
|
||||
@ -660,9 +719,30 @@
|
||||
$('#pan').val(res.data.pan);
|
||||
$('#branch_name').val(res.data.branch_name);
|
||||
$('#branch_code').val(res.data.branch_code);
|
||||
$('#contact_person_name').val(res?.contact?.name || '');
|
||||
$('#contact_person_mobile').val(res?.contact?.mobile || '');
|
||||
$('#contact_person_email').val(res?.contact?.email || '');
|
||||
|
||||
allContacts = res.contact;
|
||||
$('#contact_person_summary').empty();
|
||||
$('#contact_person_summary').append($('<option>', {
|
||||
value: "",
|
||||
text: "Select a Contact"
|
||||
}));
|
||||
|
||||
res.contact.forEach((value, key) => {
|
||||
|
||||
if (value.name && value.email) {
|
||||
|
||||
let display_value = `${value.name} - ${value.email} - ${value.mobile}`;
|
||||
|
||||
$('#contact_person_summary').append($('<option>', {
|
||||
value: key, // index or key in array/object
|
||||
text: display_value
|
||||
}));
|
||||
}
|
||||
|
||||
});
|
||||
// $('#contact_person_name').val(res?.contact?.name || '');
|
||||
// $('#contact_person_mobile').val(res?.contact?.mobile || '');
|
||||
// $('#contact_person_email').val(res?.contact?.email || '');
|
||||
|
||||
|
||||
$('#pan').prop('readOnly', true);
|
||||
|
||||
266
app/Views/newClientModal.php
Normal file
266
app/Views/newClientModal.php
Normal file
@ -0,0 +1,266 @@
|
||||
<!-- Client form content modal-->
|
||||
<div class="modal fade" id="upload_enrollment_model" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" data-backdrop="static">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="myCenterModalLabel">Add New Client</h4>
|
||||
<button type="button" id="close_btn" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
<div class="modal-body" style="overflow-y: auto;height: 90vh;">
|
||||
<form class="parsley-examples" method="post" id="client_form" enctype="multipart/form-data">
|
||||
<div class="form-group">
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="client_name">Client Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="client_name" name="client_name" required>
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label for="short_name">Client Short name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="short_name" name="short_name" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
<label for="cost_center">PAN</label>
|
||||
<input type="text" class="form-control" id="pan" placeholder="Enter PAN No" name="pan" onchange="validateInputForClient(this, 'clients', 'pan')">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<!-- Client Type -->
|
||||
<div class="form-row clienttypediv" style="display: none;">
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="dob">Date of Birth<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="dob" placeholder="DD/MM/YYYY" name="dob" >
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="cost_center">Mobile<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="phone" placeholder="Enter Mobile Number" maxlength="10" name="phone"
|
||||
onkeypress="return onlyNumbers(event)" onchange="validateInputForClient(this, 'clients', 'phone')">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
<label for="email2">Email<span class="text-danger">*</span></label>
|
||||
<input type="email" class="form-control" id="email2" placeholder="Enter Email" name="email2">
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label for="aadhar">Aadhar</label>
|
||||
<input type="text" class="form-control" id="aadhar" placeholder="Enter Aadher No" name="aadhar" maxlength="12" onchange="validateInputForClient(this, 'clients', 'aadhar')">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- branch -->
|
||||
<div class="form-row branchdiv">
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
<label for="short_name">Entity Type<span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="entity_type_id_for_client" name="entity_type_id">
|
||||
<option value="" selected>Select Entity</option>
|
||||
<?php
|
||||
if (isset($entity) && count($entity)) {
|
||||
foreach ($entity as $key => $value) {
|
||||
echo "<option value=" . $value['id'] . ">" . $value['name'] . "</option>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="client_name">Branch Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="branch_name" name="branch_name">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="branch_code">Branch Code<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="branch_code" name="branch_code">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="branch_code">Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="name" name="name">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="branch_code">Mobile<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="mobile" maxlength="10" name="mobile" onkeypress="return onlyNumbers(event)">
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label for="email">Email<span class="text-danger">*</span></label>
|
||||
<input type="email" class="form-control" id="email" placeholder="Enter Email" name="email" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
<label for="gst">GST<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="gst" placeholder="Enter GST Number" oninput="validateInputForClient(this, 'client_branch', 'gst')"
|
||||
data-parsley-error-message="Invalid GST Number. Example: 12ABCDE1234F5Z6" name="gst" data-parsley-trigger="change" data-parsley-pattern="^\d{2}[A-Z]{5}\d{4}[A-Z]{1}[A-Z\d]{1}[Z]{1}[A-Z\d]{1}$" required>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="form-group text-right m-b-0" id="hide_smbt_btn">
|
||||
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div>
|
||||
|
||||
<script>
|
||||
let isGSTValidating = false;
|
||||
let isGSTValid = false;
|
||||
|
||||
function validateInputForClient(input, table, field) {
|
||||
let value = $(input).val();
|
||||
if (!value) return;
|
||||
|
||||
let label = $(input).closest('.form-group').find('label').text().replace('*', '').trim();
|
||||
let message = label ? label + " already exists!" : "Value is duplicate!";
|
||||
|
||||
// Set validating state
|
||||
isGSTValidating = true;
|
||||
isGSTValid = false;
|
||||
$('#hide_smbt_btn button').prop('disabled', true);
|
||||
|
||||
checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) {
|
||||
isGSTValidating = false;
|
||||
if (isDuplicate) {
|
||||
toastr.warning(message, 'WARNING');
|
||||
$(input).val('');
|
||||
isGSTValid = false;
|
||||
} else {
|
||||
isGSTValid = true;
|
||||
}
|
||||
});
|
||||
$('#hide_smbt_btn button').prop('disabled', false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$("#client_form").submit(function(event) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
// If GST is currently validating, wait for it to complete
|
||||
if (isGSTValidating) {
|
||||
toastr.info('Please wait while we validate your GST number...', 'Validating');
|
||||
return;
|
||||
}
|
||||
|
||||
// If GST validation failed, prevent submission
|
||||
if ($('#gst').val() && !isGSTValid) {
|
||||
toastr.warning('Please fix the GST number before submitting', 'Validation Error');
|
||||
return;
|
||||
}
|
||||
|
||||
let form_type = $(this).data('id') || 0;
|
||||
|
||||
console.log('onsubmit event', this)
|
||||
console.log('onsubmit event get data value',form_type)
|
||||
console.log('client_type', $('#client_type').val());
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
|
||||
$('#aadhar').attr('data-parsley-required', 'false');
|
||||
$('#aadhar').removeAttr('required');
|
||||
|
||||
|
||||
isClientFormSubmitting = true;
|
||||
var isValid = $('#client_form').parsley().validate();
|
||||
if (!isValid) {
|
||||
console.log('Form is Empty', 'Warning');
|
||||
return ;
|
||||
}
|
||||
|
||||
form_action = '<?= base_url("util/createClientWithMinimalData"); ?>';
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
var client_type = $('#client_type').val() || $('#Owner_type').val() || 1;
|
||||
console.log('client_type:', client_type);
|
||||
|
||||
//FORM Data
|
||||
var formData = new FormData($('#client_form')[0]);
|
||||
formData.append('client_type', client_type);
|
||||
console.log("formData : ",formData);
|
||||
// return
|
||||
$.ajax({
|
||||
data:formData,
|
||||
url: form_action,
|
||||
type: "POST",
|
||||
dataType: 'json',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(res) {
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
console.log('create_Client_With_Minimal_Data', res)
|
||||
|
||||
if(res.status == true){
|
||||
getClientAndBranchAndPolicy(res.client_id, res.branch_id);
|
||||
|
||||
if(form_type != 1){
|
||||
|
||||
setTimeout(function(){
|
||||
$('#client_id').val(res.client_id).change();
|
||||
$('#client_id').prepend($('<option>', {
|
||||
value: 'add_client',
|
||||
text: '+ Add Client'
|
||||
}));
|
||||
setTimeout(function(){
|
||||
$('#client_branch_id').val(res.branch_id).change();
|
||||
// try {
|
||||
// setTimeout(function () {(res.branch_id)},1000);
|
||||
// }catch (e) {
|
||||
// console.error('Error calling getBranchData:', e); // optional logging
|
||||
// }
|
||||
}, 1000)
|
||||
}, 2000)
|
||||
|
||||
}else{
|
||||
|
||||
toastr.error("Couldn't Add Client","Error");
|
||||
}
|
||||
|
||||
toastr.success(res.message, 'Success');
|
||||
|
||||
}else{
|
||||
toastr.error(res.message, 'Error');
|
||||
}
|
||||
|
||||
$('#client_form')[0].reset();
|
||||
$('.close').click();
|
||||
|
||||
if(form_type == 1){
|
||||
|
||||
var myModal = new bootstrap.Modal(document.getElementById('vehicle_modal'));
|
||||
myModal.show();
|
||||
|
||||
$('#client_form').removeAttr('data-id');
|
||||
|
||||
// Load form data into #vehicle_form from localStorage
|
||||
setFormDataFromLocalStorage("#vehicle_form", "vehicleFormData");
|
||||
}
|
||||
|
||||
isClientFormSubmitting = false;
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
@ -129,6 +129,18 @@
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.info-icon {
|
||||
color: #007bff;
|
||||
font-size: 15px;
|
||||
transition: 0.3s ease;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.info-icon:hover {
|
||||
color: #0056b3;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<div class="tab-pane fade active show" id="form">
|
||||
@ -434,7 +446,7 @@
|
||||
<span class="slider round" style="height: 27px;"></span>
|
||||
</label>
|
||||
|
||||
<label for="is_cd_reduce_from_bds" style="position: relative;top: 33px;left: 25px;"> Make Entry in CD <i class="fa fa-info-circle" data-toggle="tooltip" title="Enabling this will affect ( Credit/Debit ) the CD transaction. ( GMC, GPA, EDLI and GTLI, CD transaction from CRM )"></i>
|
||||
<label for="is_cd_reduce_from_bds" style="position: relative;top: 33px;left: 25px;"> Make Entry in CD <i class="fa fa-info-circle info-icon" data-toggle="tooltip" title="Enabling this will affect ( Credit/Debit ) the CD transaction. ( GMC, GPA, EDLI and GTLI, CD transaction from CRM )"></i>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
@ -520,12 +532,14 @@
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="installment">Installment</label>
|
||||
<label for="installment">Installment <i id="infoIcon" class="fas fa-info-circle info-icon" data-toggle="tooltip" title="Click for Installment details" style="margin-left: 5px;"></i></label>
|
||||
<input id="installment" value="" type="text" class="form-control" name="installment">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="installment_data">Installment Data</label>
|
||||
<label for="installment_data">
|
||||
Installment Data
|
||||
</label>
|
||||
<input id="installment_data" class="form-control" name="installment_data">
|
||||
</div>
|
||||
|
||||
@ -795,115 +809,7 @@
|
||||
</div>
|
||||
<!-- end form row -->
|
||||
|
||||
<!-- Client form content modal-->
|
||||
<div class="modal fade" id="upload_enrollment_model" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" data-backdrop="static">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="myCenterModalLabel">Add New Client</h4>
|
||||
<button type="button" id="close_btn" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
<div class="modal-body" style="overflow-y: auto;height: 90vh;">
|
||||
<form class="parsley-examples" method="post" id="client_form" enctype="multipart/form-data">
|
||||
<div class="form-group">
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="client_name">Client Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="client_name" name="client_name" required>
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label for="short_name">Client Short name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="short_name" name="short_name" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
<label for="cost_center">PAN</label>
|
||||
<input type="text" class="form-control" id="pan" placeholder="Enter PAN No" name="pan" onchange="validateInput(this, 'clients', 'pan')">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<!-- Client Type -->
|
||||
<div class="form-row clienttypediv" style="display: none;">
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="dob">Date of Birth<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="dob" placeholder="DD/MM/YYYY" name="dob" >
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="cost_center">Mobile<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="phone" placeholder="Enter Mobile Number" maxlength="10" name="phone"
|
||||
onkeypress="return onlyNumbers(event)" onchange="validateInput(this, 'clients', 'phone')">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
<label for="cost_center">Email<span class="text-danger">*</span></label>
|
||||
<input type="email" class="form-control" id="email" placeholder="Enter Email" name="email">
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label for="aadhar">Aadhar</label>
|
||||
<input type="text" class="form-control" id="aadhar" placeholder="Enter Aadher No" name="aadhar" maxlength="12" onchange="validateInput(this, 'clients', 'aadhar')">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- branch -->
|
||||
<div class="form-row branchdiv">
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
<label for="short_name">Entity Type<span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="entity_type_id_for_client" name="entity_type_id">
|
||||
<option value="" selected>Select Entity</option>
|
||||
<?php
|
||||
if (isset($entity) && count($entity)) {
|
||||
foreach ($entity as $key => $value) {
|
||||
echo "<option value=" . $value['id'] . ">" . $value['name'] . "</option>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="client_name">Branch Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="branch_name" name="branch_name">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="branch_code">Branch Code<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="branch_code" name="branch_code">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="branch_code">Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="name" name="name">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="branch_code">Mobile<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="mobile" maxlength="10" name="mobile" onkeypress="return onlyNumbers(event)">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
<label for="gst">GST<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="gst" placeholder="Enter GST Number" onchange="validateInput(this, 'client_branch', 'gst')"
|
||||
data-parsley-error-message="Invalid GST Number. Example: 12ABCDE1234F5Z6" name="gst" data-parsley-trigger="change" data-parsley-pattern="^\d{2}[A-Z]{5}\d{4}[A-Z]{1}[A-Z\d]{1}[Z]{1}[A-Z\d]{1}$" required>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="form-group text-right m-b-0" id="hide_smbt_btn">
|
||||
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div>
|
||||
<?php include("newClientModal.php") ?>
|
||||
|
||||
<!-- Vehicle form content modal-->
|
||||
<div class="modal fade" id="vehicle_modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" data-backdrop="static">
|
||||
@ -1041,8 +947,220 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Info Modal -->
|
||||
<div class="modal fade" id="moreInfoModal" tabindex="-1" role="dialog" aria-labelledby="fullWidthModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-xl" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="fullWidthModalLabel">More Information</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="installmentForm">
|
||||
<div id="dynamicDivFillInfo"></div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
|
||||
$("#infoIcon").click(function() {
|
||||
var policyTransactionPK = $('#policy_tranction_primarykey').val();
|
||||
getDataForInfo(policyTransactionPK, function(data) {
|
||||
console.log("data: ", data);
|
||||
if (data && Object.keys(data).length) {
|
||||
// openModal();
|
||||
var myModal = new bootstrap.Modal(document.getElementById('moreInfoModal'));
|
||||
myModal.show();
|
||||
|
||||
appendHtmlToModal(data.bds_data);
|
||||
} else {
|
||||
// toastr.warning("Data not Found");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function getDataForInfo (policyTransactionPK,callback) {
|
||||
// alert(policyTransactionPK)
|
||||
$.ajax({
|
||||
url: "<?= base_url('policy_tranction/getMoreInfo') ?>",
|
||||
type: "POST",
|
||||
data: {
|
||||
pt_id: policyTransactionPK
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.status) {
|
||||
console.log("Info Response: ", response);
|
||||
callback(response.data); // pass data to the callback
|
||||
} else {
|
||||
toastr.warning("No Data Found");
|
||||
callback(null);
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
callback(null);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function appendHtmlToModal(data) {
|
||||
|
||||
const items = Array.isArray(data) ? data : data?.bds_data || [];
|
||||
|
||||
const container = document.getElementById('dynamicDivFillInfo');
|
||||
container.innerHTML = '';
|
||||
|
||||
if (!Array.isArray(items) || items.length === 0) {
|
||||
container.innerHTML = '<p>No data available.</p>';
|
||||
return;
|
||||
}
|
||||
|
||||
items.forEach(function(item, index) {
|
||||
// Create .row container
|
||||
const row = document.createElement('div');
|
||||
row.className = 'row mb-3';
|
||||
|
||||
// Hidden input for ID
|
||||
const hiddenId = document.createElement('input');
|
||||
hiddenId.type = 'hidden';
|
||||
hiddenId.name = `installments[${index}][id]`;
|
||||
hiddenId.value = item.id;
|
||||
row.appendChild(hiddenId);
|
||||
|
||||
// Payment Date
|
||||
const paymentCol = document.createElement('div');
|
||||
paymentCol.className = 'col-md-3';
|
||||
|
||||
// Use type="text" for flatpickr
|
||||
const paymentGroup = createEditableInputGroup('Payment Date', 'payment_date', index, '', 'text');
|
||||
paymentCol.appendChild(paymentGroup);
|
||||
row.appendChild(paymentCol);
|
||||
|
||||
// Flatpickr target
|
||||
const paymentInput = paymentGroup.querySelector('input');
|
||||
|
||||
// Convert DB date to d-m-Y (Flatpickr display format)
|
||||
if (item.payment_date) {
|
||||
|
||||
flatpickr(paymentInput, {
|
||||
dateFormat: "d-m-Y",
|
||||
defaultDate: item.payment_date,
|
||||
allowInput: true
|
||||
});
|
||||
}
|
||||
|
||||
// Installment Amount
|
||||
const amountCol = document.createElement('div');
|
||||
amountCol.className = 'col-md-3';
|
||||
amountCol.appendChild(createEditableInputGroup('Installment Amount', 'installment_amount', index, item.installment_amount, 'number'));
|
||||
row.appendChild(amountCol);
|
||||
|
||||
// UTR Number
|
||||
const utrCol = document.createElement('div');
|
||||
utrCol.className = 'col-md-3';
|
||||
utrCol.appendChild(createEditableInputGroup('UTR Number', 'utr_no', index, item.utr_no, 'text'));
|
||||
row.appendChild(utrCol);
|
||||
|
||||
container.appendChild(row);
|
||||
});
|
||||
|
||||
// Add submit button at the end
|
||||
const submitRow = document.createElement('div');
|
||||
submitRow.className = 'row';
|
||||
|
||||
const submitCol = document.createElement('div');
|
||||
submitCol.className = 'col-md-12 text-end d-flex align-items-center justify-content-end';
|
||||
|
||||
const submitBtn = document.createElement('button');
|
||||
submitBtn.type = 'submit';
|
||||
submitBtn.id = 'submitInstallments';
|
||||
submitBtn.className = 'btn btn-primary';
|
||||
submitBtn.innerText = 'Save Installments';
|
||||
|
||||
submitCol.appendChild(submitBtn);
|
||||
submitRow.appendChild(submitCol);
|
||||
container.appendChild(submitRow);
|
||||
}
|
||||
|
||||
$(document).on('click', '#submitInstallments', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
const installments = [];
|
||||
|
||||
$('#dynamicDivFillInfo .row').each(function () {
|
||||
const row = $(this);
|
||||
const installment = {};
|
||||
|
||||
const id = row.find('input[name*="[id]"]').val();
|
||||
const payment_date = row.find('input[name*="[payment_date]"]').val();
|
||||
const installment_amount = row.find('input[name*="[installment_amount]"]').val();
|
||||
const utr_no = row.find('input[name*="[utr_no]"]').val();
|
||||
|
||||
// Ignore empty rows
|
||||
if (payment_date && installment_amount && utr_no) {
|
||||
installment.id = id;
|
||||
installment.payment_date = payment_date;
|
||||
installment.installment_amount = installment_amount;
|
||||
installment.utr_no = utr_no;
|
||||
installments.push(installment);
|
||||
}
|
||||
});
|
||||
|
||||
if (installments.length === 0) {
|
||||
toastr.warning("No valid installment data to save.");
|
||||
return;
|
||||
}
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
$.ajax({
|
||||
url: "<?= base_url('policy_tranction/saveInstallment') ?>",
|
||||
type: "POST",
|
||||
data: { installments },
|
||||
success: function (response) {
|
||||
if (response.status) {
|
||||
toastr.success("Installments saved successfully!");
|
||||
$('#moreInfoModal').modal('hide');
|
||||
} else {
|
||||
toastr.error(response.message || "Save failed.");
|
||||
}
|
||||
},
|
||||
error: function (xhr) {
|
||||
console.error(xhr.responseText);
|
||||
toastr.error("Server error.");
|
||||
}
|
||||
});
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
});
|
||||
|
||||
function createEditableInputGroup(labelText, fieldName, index, value, type) {
|
||||
var group = document.createElement('div');
|
||||
group.className = 'form-group mb-2';
|
||||
|
||||
var label = document.createElement('label');
|
||||
label.innerText = labelText;
|
||||
|
||||
var input = document.createElement('input');
|
||||
input.type = type;
|
||||
input.className = 'form-control';
|
||||
input.name = `installments[${index}][${fieldName}]`;
|
||||
input.value = value;
|
||||
|
||||
group.appendChild(label);
|
||||
group.appendChild(input);
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
|
||||
var team_id = [];
|
||||
let isClientFormSubmitting = false;
|
||||
var insurer_count_array = [];
|
||||
@ -3155,108 +3273,108 @@ $("#inception_form_id").submit(function(event) {
|
||||
});
|
||||
});
|
||||
|
||||
$("#client_form").submit(function(event) {
|
||||
// $("#client_form").submit(function(event) {
|
||||
|
||||
let form_type = $(this).data('id') || 0;
|
||||
// let form_type = $(this).data('id') || 0;
|
||||
|
||||
console.log('onsubmit event', this)
|
||||
console.log('onsubmit event get data value',form_type)
|
||||
console.log('client_type', $('#client_type').val());
|
||||
// console.log('onsubmit event', this)
|
||||
// console.log('onsubmit event get data value',form_type)
|
||||
// console.log('client_type', $('#client_type').val());
|
||||
|
||||
event.preventDefault();
|
||||
// event.preventDefault();
|
||||
|
||||
|
||||
$('#aadhar').attr('data-parsley-required', 'false');
|
||||
$('#aadhar').removeAttr('required');
|
||||
// $('#aadhar').attr('data-parsley-required', 'false');
|
||||
// $('#aadhar').removeAttr('required');
|
||||
|
||||
|
||||
isClientFormSubmitting = true;
|
||||
var isValid = $('#client_form').parsley().validate();
|
||||
if (!isValid) {
|
||||
console.log('Form is Empty', 'Warning');
|
||||
return ;
|
||||
}
|
||||
// isClientFormSubmitting = true;
|
||||
// var isValid = $('#client_form').parsley().validate();
|
||||
// if (!isValid) {
|
||||
// console.log('Form is Empty', 'Warning');
|
||||
// return ;
|
||||
// }
|
||||
|
||||
form_action = '<?= base_url("util/createClientWithMinimalData"); ?>';
|
||||
// form_action = '<?= base_url("util/createClientWithMinimalData"); ?>';
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
// $('.loader').fadeIn();
|
||||
// $('.loader-mask').fadeIn();
|
||||
|
||||
var client_type = $('#client_type').val() || $('#Owner_type').val();
|
||||
console.log('client_type:', client_type);
|
||||
// var client_type = $('#client_type').val() || $('#Owner_type').val();
|
||||
// console.log('client_type:', client_type);
|
||||
|
||||
//FORM Data
|
||||
var formData = new FormData($('#client_form')[0]);
|
||||
formData.append('client_type', client_type);
|
||||
// //FORM Data
|
||||
// var formData = new FormData($('#client_form')[0]);
|
||||
// formData.append('client_type', client_type);
|
||||
|
||||
$.ajax({
|
||||
data:formData,
|
||||
url: form_action,
|
||||
type: "POST",
|
||||
dataType: 'json',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(res) {
|
||||
// $.ajax({
|
||||
// data:formData,
|
||||
// url: form_action,
|
||||
// type: "POST",
|
||||
// dataType: 'json',
|
||||
// processData: false,
|
||||
// contentType: false,
|
||||
// success: function(res) {
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
// $('.loader').fadeOut();
|
||||
// $('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
console.log('create_Client_With_Minimal_Data', res)
|
||||
// console.log('create_Client_With_Minimal_Data', res)
|
||||
|
||||
if(res.status == true){
|
||||
getClientAndBranchAndPolicy(res.client_id, res.branch_id);
|
||||
// if(res.status == true){
|
||||
// getClientAndBranchAndPolicy(res.client_id, res.branch_id);
|
||||
|
||||
if(form_type != 1){
|
||||
// if(form_type != 1){
|
||||
|
||||
setTimeout(function(){
|
||||
$('#client_id').val(res.client_id).change();
|
||||
setTimeout(function(){
|
||||
$('#client_branch_id').val(res.branch_id).change();
|
||||
}, 1000)
|
||||
}, 2000)
|
||||
// setTimeout(function(){
|
||||
// $('#client_id').val(res.client_id).change();
|
||||
// setTimeout(function(){
|
||||
// $('#client_branch_id').val(res.branch_id).change();
|
||||
// }, 1000)
|
||||
// }, 2000)
|
||||
|
||||
}else{
|
||||
// }else{
|
||||
|
||||
setTimeout(function(){
|
||||
$('#owner').val(res.client_id).change();
|
||||
$('#owner_branch').val(res.branch_id).change();
|
||||
// setTimeout(function(){
|
||||
// $('#owner').val(res.client_id).change();
|
||||
// $('#owner_branch').val(res.branch_id).change();
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
// $('.loader').fadeOut();
|
||||
// $('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
}, 2000)
|
||||
}
|
||||
// }, 2000)
|
||||
// }
|
||||
|
||||
toastr.success(res.message, 'Success');
|
||||
// toastr.success(res.message, 'Success');
|
||||
|
||||
}else{
|
||||
toastr.error(res.message, 'Error');
|
||||
}
|
||||
// }else{
|
||||
// toastr.error(res.message, 'Error');
|
||||
// }
|
||||
|
||||
$('#client_form')[0].reset();
|
||||
$('.close').click();
|
||||
// $('#client_form')[0].reset();
|
||||
// $('.close').click();
|
||||
|
||||
if(form_type == 1){
|
||||
// if(form_type == 1){
|
||||
|
||||
var myModal = new bootstrap.Modal(document.getElementById('vehicle_modal'));
|
||||
myModal.show();
|
||||
// var myModal = new bootstrap.Modal(document.getElementById('vehicle_modal'));
|
||||
// myModal.show();
|
||||
|
||||
$('#client_form').removeAttr('data-id');
|
||||
// $('#client_form').removeAttr('data-id');
|
||||
|
||||
// Load form data into #vehicle_form from localStorage
|
||||
setFormDataFromLocalStorage("#vehicle_form", "vehicleFormData");
|
||||
}
|
||||
// // Load form data into #vehicle_form from localStorage
|
||||
// setFormDataFromLocalStorage("#vehicle_form", "vehicleFormData");
|
||||
// }
|
||||
|
||||
isClientFormSubmitting = false;
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
}
|
||||
});
|
||||
});
|
||||
// isClientFormSubmitting = false;
|
||||
// },
|
||||
// error: function (xhr, status, error) {
|
||||
// console.error(xhr.responseText);
|
||||
// console.error(status, error);
|
||||
// $('.loader').fadeOut();
|
||||
// $('.loader-mask').delay(350).fadeOut('slow');
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
|
||||
$("#vehicle_form").submit(function(event) {
|
||||
|
||||
|
||||
@ -1,50 +1,67 @@
|
||||
<?php
|
||||
$fileIndex = 1; // Initialize index
|
||||
$increment = 1; // Example increment value
|
||||
$fileIndex = 1;
|
||||
$increment = 1;
|
||||
?>
|
||||
|
||||
<?php if (isset($lead_edit_data) && isset($lead_edit_data["multi_file_data"]) && !empty($lead_edit_data["multi_file_data"])) {
|
||||
<?php if (isset($lead_edit_data) && isset($lead_edit_data["multi_file_data"]) && !empty($lead_edit_data["multi_file_data"])) {
|
||||
foreach ($lead_edit_data["multi_file_data"] as $index => $value) {
|
||||
$isFirstField = ($index === 0); // First file must be Demography
|
||||
$isFirstField = ($index === 0);
|
||||
$placeholder = $isFirstField ? 'First file must be Demography.' : '';
|
||||
$accept = $isFirstField ? '.xls,.xlsx' : '';
|
||||
$index = $index + 1;
|
||||
$displayIndex = $index + 1;
|
||||
?>
|
||||
|
||||
<div class="form-row d-flex align-items-end" id="fileField_<?= $index ?>">
|
||||
<div class="form-row d-flex align-items-end" id="fileField_<?= $displayIndex ?>">
|
||||
<input type="hidden" name="leads_file_id[]" value="<?= htmlspecialchars($value['id']) ?>" id="file_id_<?= $displayIndex ?>">
|
||||
|
||||
<input type="hidden" name="leads_file_id[]"
|
||||
value="<?= htmlspecialchars($value['id']) ?>" id="file_id_<?= $index ?>">
|
||||
|
||||
<!-- Document Name Input -->
|
||||
<div class="form-group col-md-5">
|
||||
<label>Document Name<span class="text-danger"></span></label>
|
||||
<label>Document Name</label>
|
||||
<input type="text" class="form-control" name="docs_name_<?= $increment ?>[]"
|
||||
placeholder="<?= $placeholder ?>"
|
||||
value="<?= htmlspecialchars($value['docs_name']) ?>" id="docs_name_<?= $index ?>">
|
||||
value="<?= htmlspecialchars($value['docs_name']) ?>" id="docs_name_<?= $displayIndex ?>">
|
||||
</div>
|
||||
|
||||
<!-- File Upload Input -->
|
||||
<div class="form-group col-md-5">
|
||||
<label>
|
||||
File Upload
|
||||
<span class="text-danger"></span><br>
|
||||
<small id="file_name_display_<?= $index ?>" class="text-muted">
|
||||
File Upload<br>
|
||||
<small id="file_name_display_<?= $displayIndex ?>" class="text-muted">
|
||||
<?= !empty($value['file_name']) ? htmlspecialchars($value['file_name']) : 'No file chosen' ?>
|
||||
</small>
|
||||
</label>
|
||||
|
||||
<input type="file" class="form-control" id="file_name_<?= $index ?>"
|
||||
<input type="file" class="form-control" id="file_name_<?= $displayIndex ?>"
|
||||
name="file_name_<?= $increment ?>[]" accept="<?= $accept ?>"
|
||||
onchange="showFileName(this, <?= $index ?>)">
|
||||
onchange="showFileName(this, <?= $displayIndex ?>)">
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Add/Remove Buttons -->
|
||||
<div class="col-md-2" style="position: relative; bottom: 16px;">
|
||||
<button type="button" class="btn btn-danger" onclick="removeFileField(<?= $index ?>, <?= htmlspecialchars($value['id']) ?>)">x</button>
|
||||
<button type="button" class="btn btn-danger" onclick="removeFileField(<?= $displayIndex ?>, <?= htmlspecialchars($value['id']) ?>)">x</button>
|
||||
<button type="button" class="btn btn-primary" onclick="addFileField(<?= $increment ?>)">+</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php } } ?>
|
||||
<?php } } else { ?>
|
||||
<!-- Default field if no file data exists -->
|
||||
<div class="form-row d-flex align-items-end" id="fileField_1">
|
||||
<input type="hidden" name="leads_file_id[]" value="">
|
||||
|
||||
<div class="form-group col-md-5">
|
||||
<label>Document Name</label>
|
||||
<input type="text" class="form-control" name="docs_name_1[]"
|
||||
placeholder="First file must be Demography." id="docs_name_1">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-5">
|
||||
<label>
|
||||
File Upload<br>
|
||||
<small id="file_name_display_1" class="text-muted">No file chosen</small>
|
||||
</label>
|
||||
<input type="file" class="form-control" id="file_name_1"
|
||||
name="file_name_1[]" accept=".xls,.xlsx" onchange="showFileName(this, 1)">
|
||||
</div>
|
||||
|
||||
<div class="col-md-2" style="position: relative; bottom: 16px;">
|
||||
<button type="button" class="btn btn-danger" onclick="removeFileField(1, '')">x</button>
|
||||
<button type="button" class="btn btn-primary" onclick="addFileField(1)">+</button>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user