Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
564dcc642d
@ -48,6 +48,7 @@ $routes->get("frontend_content", "AppContentManagementController::frontend_conte
|
||||
$routes->get('/test', 'Home::index');
|
||||
$routes->get('/check_gemini', 'Home::check_Gemini');
|
||||
$routes->get('/check_gemini2', 'Home::check_gemini_2');
|
||||
$routes->get('/checkPolicyDoc', 'Home::checkPolicyDoc');
|
||||
$routes->get('/login', 'LoginController::index'); ///auth/google
|
||||
$routes->get('/loginPos', 'LoginController::loginPos'); //login POS team
|
||||
$routes->post('/getVerifyPosMobileNo', 'LoginController::getVerifyPosMobileNo'); //Verify POS team mobile no
|
||||
@ -398,8 +399,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->match(['get', 'post', 'delete'], 'nhanceBranchMaster', 'MasterController::nhanceBranchMaster');
|
||||
$routes->match(['get', 'post', 'delete'], 'vehicleTypeMaster', 'MasterController::vehicleTypeMaster');
|
||||
$routes->match(['get', 'post', 'delete'], 'rtoMaster', 'MasterController::rtoMaster');
|
||||
|
||||
|
||||
$routes->get('checkDuplicateCdAccount', 'MasterController::checkDuplicateCdAccount');
|
||||
});
|
||||
|
||||
$routes->post("policy_tranction/sendInstallmentRemainderMail","PolicyTransactionController::sendInstallmentRemainderMail");
|
||||
|
||||
@ -1193,7 +1193,7 @@ class EmployeeController extends AdminController
|
||||
|
||||
// --------------- For E-Card Download -----------------------------------------------------------------------------------------------------
|
||||
|
||||
//E-CARD DOWNLOAD FUNCTION USING HTML PRINT
|
||||
//E-CARD DOWNLOAD FUNCTION USING HTML PRINT ( Not in use ) do not delete
|
||||
public function generateIDCardForEmployeeUsingHtml($rand_string, $people = 0)
|
||||
{
|
||||
// dd($rand_string, $people);
|
||||
@ -1418,7 +1418,7 @@ class EmployeeController extends AdminController
|
||||
echo $htmlContent;
|
||||
}
|
||||
|
||||
//E-CARD DOWNLOAD FUNCTION USING DOM PDF ( CURRENTLY USING THIS )
|
||||
//E-CARD DOWNLOAD FUNCTION USING DOM PDF ( CURRENTLY USING THIS ) Dompdf
|
||||
public function generateIDCardForEmployee($rand_string, $people = 0, $mode = 0)
|
||||
{
|
||||
// dd($rand_string, $people);
|
||||
@ -1470,8 +1470,8 @@ class EmployeeController extends AdminController
|
||||
// Step 3: Prepare template path
|
||||
$template_data_path = WRITEPATH . 'e_card_template/';
|
||||
// $tpa_short_name = strtolower(str_replace(' ', '_', $get_emp_code_and_client_policy_id['short_name'])) . '.html';
|
||||
$tpa_short_name = 'common.html';
|
||||
// $tpa_short_name = 'new_ecard.html';
|
||||
// $tpa_short_name = 'common.html';
|
||||
$tpa_short_name = 'new_ecard.html';
|
||||
$final_path = $template_data_path . $tpa_short_name;
|
||||
|
||||
$this->myLogger->logme('error', 'Checking if template file exists at: ' . $final_path);
|
||||
@ -1495,6 +1495,7 @@ class EmployeeController extends AdminController
|
||||
$value['back_card'] = "Nhance_Ecard_working_1_Back.png";
|
||||
|
||||
$placeholders = [
|
||||
|
||||
'{CLIENT_NAME}' => $value['client_name'],
|
||||
'{TPA_ID}' => $value['tpa_id'],
|
||||
'{NAME}' => $value['name'],
|
||||
@ -1506,9 +1507,6 @@ class EmployeeController extends AdminController
|
||||
'{POLICY_START_DATE}' => date('d-M-Y', strtotime($value['policy_start_date'])),
|
||||
'{POLICY_NO}' => $value['policy_no'],
|
||||
'{INSURER_NAME}' => strtoupper($value['insurer_name']),
|
||||
'{INSURER_LOGO}' => base_url() . 'public/uploads/logo/' . $value['insurer_logo'],
|
||||
'{FRONT_CARD}' => base_url() . 'public/uploads/template_bg/' . $value['front_card'],
|
||||
'{BACK_CARD}' => base_url() . 'public/uploads/template_bg/' . $value['back_card'],
|
||||
'{EMP_ID}' => $value['emp_code'],
|
||||
'{SI_AMT}' => $value['basic_cover_si'],
|
||||
'{CORPORATE_NAME}' => $value['client_name'],
|
||||
@ -1516,15 +1514,33 @@ class EmployeeController extends AdminController
|
||||
'{TPA_NAME}' => $value['tpa_name'],
|
||||
'{INSURER_BRANCH}' => $value['insurer_branch_city'],
|
||||
'{RELATION}' => $value['relationship'],
|
||||
'{TPA_LOGO}' => base_url() . 'public/uploads/logo/' . $value['tpa_logo'],
|
||||
'{MEDI_USER}' => base_url() . 'public/e_card_imgs/medi_uesr.jpg',
|
||||
'{MEDI_INSURER}' => base_url() . 'public/e_card_imgs/Magma.png',
|
||||
'{MEDI_BARCODE}' => base_url() . 'public/e_card_imgs/borcode.jpeg',
|
||||
'{QR_ANDROID}' => base_url() . 'public/e_card_imgs/android.png',
|
||||
'{QR_IOS}' => base_url() . 'public/e_card_imgs/ios.png',
|
||||
'{QR_ANDROID_2}' => base_url() . 'public/e_card_imgs/play_store.png',
|
||||
'{QR_IOS_2}' => base_url() . 'public/e_card_imgs/appstore.png',
|
||||
'{NHANCE_N_LOGO}' => base_url() . 'public/assets/images/Nhance_Favi.png',
|
||||
|
||||
'{TPA_LOGO}' => getFileIfExists('uploads/logo/' . $value['tpa_logo']),
|
||||
'{MEDI_USER}' => getFileIfExists('e_card_imgs/medi_uesr.jpg'),
|
||||
'{MEDI_INSURER}' => getFileIfExists('e_card_imgs/Magma.png'),
|
||||
'{MEDI_BARCODE}' => getFileIfExists('e_card_imgs/borcode.jpeg'),
|
||||
'{QR_ANDROID}' => getFileIfExists('e_card_imgs/android.png'),
|
||||
'{QR_IOS}' => getFileIfExists('e_card_imgs/ios.png'),
|
||||
'{QR_ANDROID_2}' => getFileIfExists('e_card_imgs/play_store.png'),
|
||||
'{QR_IOS_2}' => getFileIfExists('e_card_imgs/appstore.png'),
|
||||
'{NHANCE_N_LOGO}' => getFileIfExists('assets/images/Nhance_Favi.png'),
|
||||
'{INSURER_LOGO}' => getFileIfExists('uploads/logo/' . $value['insurer_logo']),
|
||||
'{FRONT_CARD}' => getFileIfExists('uploads/template_bg/' . $value['front_card']),
|
||||
'{BACK_CARD}' => getFileIfExists('uploads/template_bg/' . $value['back_card']),
|
||||
|
||||
// '{TPA_LOGO}' => base_url() . 'public/uploads/logo/' . $value['tpa_logo'],
|
||||
// '{MEDI_USER}' => base_url() . 'public/e_card_imgs/medi_uesr.jpg',
|
||||
// '{MEDI_INSURER}' => base_url() . 'public/e_card_imgs/Magma.png',
|
||||
// '{MEDI_BARCODE}' => base_url() . 'public/e_card_imgs/borcode.jpeg',
|
||||
// '{QR_ANDROID}' => base_url() . 'public/e_card_imgs/android.png',
|
||||
// '{QR_IOS}' => base_url() . 'public/e_card_imgs/ios.png',
|
||||
// '{QR_ANDROID_2}' => base_url() . 'public/e_card_imgs/play_store.png',
|
||||
// '{QR_IOS_2}' => base_url() . 'public/e_card_imgs/appstore.png',
|
||||
// '{NHANCE_N_LOGO}' => base_url() . 'public/assets/images/Nhance_Favi.png',
|
||||
// '{INSURER_LOGO}' => base_url() . 'public/uploads/logo/' . $value['insurer_logo'],
|
||||
// '{FRONT_CARD}' => base_url() . 'public/uploads/template_bg/' . $value['front_card'],
|
||||
// '{BACK_CARD}' => base_url() . 'public/uploads/template_bg/' . $value['back_card'],
|
||||
|
||||
];
|
||||
|
||||
$placeholders['{LEVELS}'] = $this->generateAcmAndMForEcard($client_id);
|
||||
|
||||
@ -60,6 +60,8 @@ class Home extends PublicController
|
||||
//print_rr($data);
|
||||
}
|
||||
|
||||
|
||||
//for insurer statement upload
|
||||
public function check_gemini_2()
|
||||
{
|
||||
|
||||
@ -158,6 +160,143 @@ class Home extends PublicController
|
||||
|
||||
|
||||
|
||||
// The final JSON payload
|
||||
$data = [
|
||||
"contents" => [
|
||||
$content_parts
|
||||
]
|
||||
];
|
||||
|
||||
// Encode the data to a JSON string
|
||||
$json_data = json_encode($data);
|
||||
|
||||
// Initialize cURL
|
||||
$ch = curl_init($url);
|
||||
|
||||
// Set cURL options
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); // Set the Content-Type header
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data); // Set the JSON payload
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Return the response as a string
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Optional: to bypass SSL verification if needed (not recommended for production)
|
||||
|
||||
// Execute the cURL request and get the response
|
||||
$response = curl_exec($ch);
|
||||
|
||||
// Check for cURL errors
|
||||
if (curl_errno($ch)) {
|
||||
echo 'cURL Error: ' . curl_error($ch);
|
||||
}
|
||||
|
||||
// Close the cURL handle
|
||||
curl_close($ch);
|
||||
|
||||
// Decode the JSON response
|
||||
$responseData = json_decode($response, true);
|
||||
echo '<pre>';
|
||||
print_r($responseData);
|
||||
echo '<pre>';
|
||||
// Check if the response contains generated text
|
||||
if (isset($responseData['candidates'][0]['content']['parts'][0]['text'])) {
|
||||
$generatedText = $responseData['candidates'][0]['content']['parts'][0]['text'];
|
||||
echo "Generated Text: " . $generatedText;
|
||||
} else {
|
||||
echo "Error or no text generated. Response: " . $response;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//for insurer policy doc upload
|
||||
public function checkPolicyDoc()
|
||||
{
|
||||
|
||||
// $this->convertToPdf();die();
|
||||
// Replace with your actual Gemini API key
|
||||
$apiKey = 'AIzaSyBbx-uotRBqkYhqLpmD60420E_a0G0duP8';
|
||||
|
||||
// The model to use and the API endpoint
|
||||
$model = "gemini-pro";
|
||||
$model = "gemini-2.5-flash";
|
||||
// $model = "gemini-1.5-pro";
|
||||
// $model = "gemini-1.5-pro";
|
||||
$url = "https://generativelanguage.googleapis.com/v1beta/models/{$model}:generateContent?key={$apiKey}";
|
||||
|
||||
$filePath = 'C:\Users\Venba\AppData\Local\Programs\Python\pyenv\pdfreader\bike-0904023124P114268957.pdf';
|
||||
$filePath = 'C:\Users\Venba\AppData\Local\Programs\Python\pyenv\pdfreader\car-insurance-0904023124P114213011.pdf';
|
||||
|
||||
// Check if the file exists
|
||||
if (!file_exists($filePath)) {
|
||||
die("Error: File not found at {$filePath}");
|
||||
}
|
||||
|
||||
// Get the file's MIME type using the finfo extension
|
||||
$finfo = finfo_open(FILEINFO_MIME_TYPE);
|
||||
$mimeType = finfo_file($finfo, $filePath);
|
||||
finfo_close($finfo);
|
||||
// print_r($mimeType);die();
|
||||
// Define supported inline MIME types
|
||||
$supportedInlineMimeTypes = ['application/pdf','text/csv'];
|
||||
|
||||
// Read the file content and encode it to Base64
|
||||
$fileContent = file_get_contents($filePath);
|
||||
$base64Content = base64_encode($fileContent);
|
||||
// The prompt you want to send to the model
|
||||
// $prompt = "give me a json with emp data like name,age,dob,mobile and email. only json not any explanations";
|
||||
$prompt = "Read the following motor policy pdf document and convert into JSON format as sample specified. Give me only JSON,not any explanations.";
|
||||
$prompt .= '"{\"policy\":{\"policy_number\":\"\",\"issue_date\":\"\",\"period\":{\"start\":\"\",\"end\":\"\"},\"insurer\":\"\",\"previous_policy_number\":\"\"},\"insured\":{\"name\":\"\",\"father_name\":\"\",\"address\":[\"\"],\"mobile\":\"\",\"id_proofs\":{\"aadhaar\":\"\",\"pan\":\"\"}},\"vehicle\":{\"reg_no\":\"\",\"engine_no\":\"\",\"chassis_no\":\"\",\"make\":\"\",\"model\":\"\",\"year\":\"\",\"cubic_capacity\":\"\",\"vehicle_type\":\"\"},\"rto\":\"\",\"premium\":{\"tp\":0,\"od\":0,\"pa_od\":0,\"taxes\":{},\"total\":0,\"in_words\":\"\"},\"endorsements\":[{\"code\":\"\",\"desc\":\"\"}]}"';
|
||||
|
||||
$payloadPart = null;
|
||||
|
||||
// The text part of the prompt
|
||||
$text_part = [
|
||||
"text" => $prompt
|
||||
];
|
||||
// Conditionally handle the file upload based on MIME type
|
||||
if (in_array($mimeType, $supportedInlineMimeTypes)) {
|
||||
echo "Detected supported format inline MIME type ({$mimeType})";
|
||||
// Handle PDF as inline data
|
||||
$fileContent = file_get_contents($filePath);
|
||||
$base64Content = base64_encode($fileContent);
|
||||
$payloadPart = [
|
||||
"inlineData" => [
|
||||
"mimeType" => $mimeType,
|
||||
"data" => $base64Content
|
||||
]
|
||||
];
|
||||
|
||||
$content_parts = [
|
||||
"parts" => [
|
||||
$text_part,
|
||||
$payloadPart
|
||||
]
|
||||
];
|
||||
} else {
|
||||
// Handle Excel/CSV using the Files API
|
||||
echo "Detected unsupported inline MIME type ({$mimeType}). Uploading via Files API...\n";
|
||||
$fileInfo = $this->uploadFileToGemini($filePath, $apiKey); // Pass apiKey
|
||||
|
||||
print_r($fileInfo);
|
||||
// The file part, using the URI from the Files API upload
|
||||
$file_part = [
|
||||
"fileData" => [
|
||||
"fileUri" => $fileInfo['uri'],
|
||||
"mimeType" => $fileInfo['mimeType']
|
||||
]
|
||||
];
|
||||
|
||||
// The full content array, containing both parts
|
||||
$content_parts = [
|
||||
"parts" => [
|
||||
$text_part,
|
||||
$file_part
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// The final JSON payload
|
||||
$data = [
|
||||
"contents" => [
|
||||
|
||||
@ -1024,14 +1024,7 @@ class LeadsController extends BaseController
|
||||
// 3. Optimize lead data query with specific field selection
|
||||
$lead_data = $this->leadsModel
|
||||
->select('
|
||||
leads.id,
|
||||
leads.policy_type_id,
|
||||
leads.lead_type,
|
||||
leads.source_policy_id,
|
||||
leads.policy_end_date,
|
||||
leads.lead_form_type,
|
||||
leads.created_by,
|
||||
leads.client_name,
|
||||
leads.*,
|
||||
lead_files.status as demography_file_status,
|
||||
policy_type.question_json,
|
||||
policy_type.policy_type,
|
||||
@ -1776,6 +1769,24 @@ class LeadsController extends BaseController
|
||||
|
||||
// dd($rfq_data, $lead_id, $type, $propsal_and_insurer);
|
||||
// print_r($propsal_and_insurer); die;
|
||||
// print_r($is_placement); die;
|
||||
|
||||
$data = json_decode($rfq_data['json'], true);
|
||||
$sheetName = 'Worksheet';
|
||||
if ($type == 2) {
|
||||
$sheetName = 'QCR';
|
||||
// $propsal_and_insurer = "Proposal 1-ICICIPRU-ICICI001";
|
||||
$data = $this->convertJsonForQCR($data, $type);
|
||||
if ($propsal_and_insurer !== null) {
|
||||
list($proposal_key, $insurer_key) = explode('-', $propsal_and_insurer, 2);
|
||||
$data = $this->transformProposelData($data, $proposal_key, $insurer_key);
|
||||
$is_placement = true;
|
||||
$sheetName = 'Placement';
|
||||
}
|
||||
} else if ($type == 1) {
|
||||
$sheetName = 'RFQ';
|
||||
$data = $this->convertJsonForQCR($data, $type);
|
||||
} // dd($data);
|
||||
|
||||
if ($rfq_data['lead_type'] == 1) {
|
||||
|
||||
@ -1808,36 +1819,71 @@ class LeadsController extends BaseController
|
||||
} else {
|
||||
|
||||
if (in_array($rfq_data['policy_type_id'], [2, 3, 4, 5])) {
|
||||
$lead_data = [
|
||||
if($is_placement == true){
|
||||
$lead_data = [
|
||||
|
||||
'Insured' => $rfq_data['client_name'],
|
||||
'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? "",
|
||||
'Insured' => $rfq_data['client_name'],
|
||||
'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? "",
|
||||
|
||||
// 'No of Employees at Inception' => $rfq_data['incept_emp_count'],
|
||||
// 'No of Dependents at Inception' => $rfq_data['incept_dept_count'],
|
||||
// 'Total Lives at Inception ' => $rfq_data['incept_no_of_lives'],
|
||||
// 'No of Employees at Inception' => $rfq_data['incept_emp_count'],
|
||||
// 'No of Dependents at Inception' => $rfq_data['incept_dept_count'],
|
||||
// 'Total Lives at Inception ' => $rfq_data['incept_no_of_lives'],
|
||||
|
||||
// 'No of Employees at Expiry' => $rfq_data['exp_emp_count'],
|
||||
// 'No of Dependents at Expiry' => $rfq_data['exp_dept_count'],
|
||||
// 'Total Lives at Expiry ' => $rfq_data['exp_no_of_lives'],
|
||||
// 'No of Employees at Expiry' => $rfq_data['exp_emp_count'],
|
||||
// 'No of Dependents at Expiry' => $rfq_data['exp_dept_count'],
|
||||
// 'Total Lives at Expiry ' => $rfq_data['exp_no_of_lives'],
|
||||
|
||||
'No of Employees at Renewal' => $rfq_data['renewal_emp_count'],
|
||||
'No of Dependents at Renewal' => $rfq_data['renewal_dept_count'],
|
||||
'Total Lives at Renewal ' => $rfq_data['renewal_no_of_lives'],
|
||||
'No of Employees at Renewal' => $rfq_data['renewal_emp_count'],
|
||||
'No of Dependents at Renewal' => $rfq_data['renewal_dept_count'],
|
||||
'Total Lives at Renewal ' => $rfq_data['renewal_no_of_lives'],
|
||||
|
||||
'Period of Insurance ' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date']) ? date('d-m-Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d-m-Y', strtotime($rfq_data['policy_end_date'])) : "To be decided",
|
||||
'Insurer' => $rfq_data['insurer_name'] ?? " - ",
|
||||
'TPA' => $rfq_data['tpa_name'] ?? " - ",
|
||||
'Period of Insurance ' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date']) ? date('d-m-Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d-m-Y', strtotime($rfq_data['policy_end_date'])) : "To be decided",
|
||||
'Insurer' => $rfq_data['insurer_name'] ?? " - ",
|
||||
'TPA' => $rfq_data['tpa_name'] ?? " - ",
|
||||
|
||||
// 'Policy Run Days' => $rfq_data['policy_run_days'],
|
||||
// 'Inception Premium' => formatIndianCurrency($rfq_data['premium_at_inception']),
|
||||
// 'Premium as on (' . date('d-m-Y', strtotime($rfq_data['incurred_claims_date'])) . ')' => formatIndianCurrency($rfq_data['premium_date']),
|
||||
// 'Earned Premium' => formatIndianCurrency(intval($rfq_data['earned_premium'])),
|
||||
// 'Incurred Claims as on (' . date('d-m-Y', strtotime($rfq_data['incurred_claims_date'])) . ')' => formatIndianCurrency($rfq_data['incurred_claims']),
|
||||
// 'Annualised Claims' => formatIndianCurrency(intval($rfq_data['annualised_claims'])),
|
||||
// 'Incurred Claims Ratio' => $rfq_data['incurred_claims_ratio'] . " %",
|
||||
// 'Earned Claims Ratio' => $rfq_data['earned_claims_ratio'] . " %",
|
||||
];
|
||||
// 'Policy Run Days' => $rfq_data['policy_run_days'],
|
||||
// 'Inception Premium' => formatIndianCurrency($rfq_data['premium_at_inception']),
|
||||
// 'Premium as on (' . date('d-m-Y', strtotime($rfq_data['incurred_claims_date'])) . ')' => formatIndianCurrency($rfq_data['premium_date']),
|
||||
// 'Earned Premium' => formatIndianCurrency(intval($rfq_data['earned_premium'])),
|
||||
// 'Incurred Claims as on (' . date('d-m-Y', strtotime($rfq_data['incurred_claims_date'])) . ')' => formatIndianCurrency($rfq_data['incurred_claims']),
|
||||
// 'Annualised Claims' => formatIndianCurrency(intval($rfq_data['annualised_claims'])),
|
||||
// 'Incurred Claims Ratio' => $rfq_data['incurred_claims_ratio'] . " %",
|
||||
// 'Earned Claims Ratio' => $rfq_data['earned_claims_ratio'] . " %",
|
||||
];
|
||||
}else{
|
||||
$lead_data = [
|
||||
'Insured' => $rfq_data['client_name'],
|
||||
'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? "",
|
||||
|
||||
'No of Employees at Inception' => $is_placement ? '-' : $rfq_data['incept_emp_count'],
|
||||
'No of Dependents at Inception' => $is_placement ? '-' : $rfq_data['incept_dept_count'],
|
||||
'Total Lives at Inception ' => $is_placement ? '-' : $rfq_data['incept_no_of_lives'],
|
||||
|
||||
'No of Employees at Expiry' => $is_placement ? '-' : $rfq_data['exp_emp_count'],
|
||||
'No of Dependents at Expiry' => $is_placement ? '-' : $rfq_data['exp_dept_count'],
|
||||
'Total Lives at Expiry ' => $is_placement ? '-' : $rfq_data['exp_no_of_lives'],
|
||||
|
||||
'No of Employees at Renewal' => $rfq_data['renewal_emp_count'],
|
||||
'No of Dependents at Renewal' => $rfq_data['renewal_dept_count'],
|
||||
'Total Lives at Renewal ' => $rfq_data['renewal_no_of_lives'],
|
||||
|
||||
'Period of Insurance ' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date'])
|
||||
? date('d-m-Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d-m-Y', strtotime($rfq_data['policy_end_date']))
|
||||
: "To be decided",
|
||||
|
||||
'Insurer' => $rfq_data['insurer_name'] ?? " - ",
|
||||
'TPA' => $rfq_data['tpa_name'] ?? " - ",
|
||||
|
||||
'Policy Run Days' => $is_placement ? '-' : $rfq_data['policy_run_days'],
|
||||
'Inception Premium' => $is_placement ? '-' : formatIndianCurrency($rfq_data['premium_at_inception']),
|
||||
'Premium as on (' . date('d-m-Y', strtotime($rfq_data['incurred_claims_date'])) . ')' => $is_placement ? '-' : formatIndianCurrency($rfq_data['premium_date']),
|
||||
'Earned Premium' => $is_placement ? '-' : formatIndianCurrency(intval($rfq_data['earned_premium'])),
|
||||
'Incurred Claims as on (' . date('d-m-Y', strtotime($rfq_data['incurred_claims_date'])) . ')' => $is_placement ? '-' : formatIndianCurrency($rfq_data['incurred_claims']),
|
||||
'Annualised Claims' => $is_placement ? '-' : formatIndianCurrency(intval($rfq_data['annualised_claims'])),
|
||||
'Incurred Claims Ratio' => $is_placement ? '-' : $rfq_data['incurred_claims_ratio'] . " %",
|
||||
'Earned Claims Ratio' => $is_placement ? '-' : $rfq_data['earned_claims_ratio'] . " %",
|
||||
];
|
||||
}
|
||||
} else if (in_array($rfq_data['policy_type_id'], [1, 6, 7])) {
|
||||
|
||||
$lead_data = [
|
||||
@ -1857,27 +1903,8 @@ class LeadsController extends BaseController
|
||||
];
|
||||
}
|
||||
}
|
||||
// print_r($lead_data); die;
|
||||
|
||||
$data = json_decode($rfq_data['json'], true);
|
||||
// dd($data);
|
||||
|
||||
$sheetName = 'Worksheet';
|
||||
if ($type == 2) {
|
||||
$sheetName = 'QCR';
|
||||
// $propsal_and_insurer = "Proposal 1-ICICIPRU-ICICI001";
|
||||
$data = $this->convertJsonForQCR($data, $type);
|
||||
if ($propsal_and_insurer !== null) {
|
||||
list($proposal_key, $insurer_key) = explode('-', $propsal_and_insurer, 2);
|
||||
$data = $this->transformProposelData($data, $proposal_key, $insurer_key);
|
||||
$is_placement = true;
|
||||
$sheetName = 'Placement';
|
||||
}
|
||||
} else if ($type == 1) {
|
||||
$sheetName = 'RFQ';
|
||||
$data = $this->convertJsonForQCR($data, $type);
|
||||
// dd($data);
|
||||
}
|
||||
// dd($data);
|
||||
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
@ -1350,6 +1350,16 @@ class MasterController extends AdminController
|
||||
// === INSERT ===
|
||||
if (empty($id)) {
|
||||
|
||||
$cd_acc_count = $this->CDMasterModel->where('is_active', 1)
|
||||
->where('client_id', $data['client_id'])
|
||||
->where('insurer_id', $data['insurer_id'])
|
||||
->where('insurer_branch_id', $data['insurer_branch_id'])
|
||||
->countAllResults();
|
||||
|
||||
if($cd_acc_count > 0){
|
||||
return $this->respond(['status' => false, 'message' => 'A CD account has already been created for this client, insurer, and insurer branch combination.'], 200);
|
||||
}
|
||||
|
||||
$this->myLogger->logme("error", 'Performing INSERT operation.');
|
||||
$insert = $this->CDMasterModel->insert($data);
|
||||
$this->myLogger->logme("error", 'Insert result: ' . json_encode($insert));
|
||||
@ -1574,6 +1584,15 @@ class MasterController extends AdminController
|
||||
|
||||
$data['insurer_branch_id'] = $insurer_branch_id;
|
||||
|
||||
$cd_acc_count = $this->CDMasterModel->where('is_active', 1)
|
||||
->where('client_id', $data['client_id'])
|
||||
->where('insurer_id', $data['insurer_id'])
|
||||
->where('insurer_branch_id', $data['insurer_branch_id'])
|
||||
->countAllResults();
|
||||
|
||||
if($cd_acc_count > 0){
|
||||
return $this->respond(['status' => false, 'message' => 'A CD account has already been created for this client, insurer, and insurer branch combination.'], 200);
|
||||
}
|
||||
|
||||
// array with data for CD Traction table
|
||||
$cd_tranction_data = [
|
||||
@ -1617,6 +1636,24 @@ class MasterController extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
public function checkDuplicateCdAccount()
|
||||
{
|
||||
$data = $this->request->getGet();
|
||||
|
||||
$cd_acc_count = $this->CDMasterModel
|
||||
->where('is_active', 1)
|
||||
->where('client_id', $data['client_id'])
|
||||
->where('insurer_id', $data['insurer_id'])
|
||||
->where('insurer_branch_id', $data['insurer_branch_id'])
|
||||
->countAllResults();
|
||||
|
||||
if($cd_acc_count > 0){
|
||||
return $this->respond(['status' => false, 'message' => 'A CD account has already been created for this client, insurer, and insurer branch combination.'], 200);
|
||||
}else{
|
||||
return $this->respond(['status' => true], 200);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Vehicle Master data Function
|
||||
|
||||
|
||||
@ -1271,9 +1271,10 @@ class PolicyTransactionController extends BaseController
|
||||
|
||||
$data['tsi'] = generate_tsi_code($issue_type['issue_type'] ?? 1);
|
||||
|
||||
$client_branch_id = $data['client_branch_id'];
|
||||
if ($data['client_branch_id'] == "") {
|
||||
if (!isset($data['client_branch_id']) || $data['client_branch_id'] == "") {
|
||||
$client_branch_id = $issue_type['client_branch_id'];
|
||||
}else{
|
||||
$client_branch_id = $data['client_branch_id'];
|
||||
}
|
||||
|
||||
$data['is_cd_reduce_from_bds'] = (isset($issue_type['policy_type_id']) && $issue_type['policy_type_id'] > 7 && $data['client_type'] == 1) ? 1 : 0;
|
||||
@ -1431,7 +1432,11 @@ class PolicyTransactionController extends BaseController
|
||||
$pt_id = null;
|
||||
|
||||
if(!empty($data)){
|
||||
$inception_data = $this->policyTransactionModel->where('policy_no', $data['policy_no'])->where('client_id', $data['client_id'])->first();
|
||||
$inception_data = $this->policyTransactionModel
|
||||
->where('policy_no', $data['policy_no'])
|
||||
->where('client_id', $data['client_id'])
|
||||
->where('action_type', 'inception')
|
||||
->first();
|
||||
$pt_id = $inception_data['id'];
|
||||
}
|
||||
|
||||
@ -2682,6 +2687,10 @@ class PolicyTransactionController extends BaseController
|
||||
$gst = $gstTotal[$index];
|
||||
$paymentDate = $paymentDates[$index];
|
||||
|
||||
if($utrNo == "" && $tds == "" && $gst == "" && $receivedAmount == "")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// Prepare data for insert/update
|
||||
$childData = [
|
||||
'inv_amt' => $receivedAmount,
|
||||
|
||||
@ -859,3 +859,10 @@ if (!function_exists('expected_amount_calc')) {
|
||||
return round($expectedAmount, 2); // Optional: round to 2 decimal places
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('getFileIfExists')) {
|
||||
function getFileIfExists($path)
|
||||
{
|
||||
return file_exists(FCPATH . $path) ? base_url($path) : '';
|
||||
}
|
||||
}
|
||||
|
||||
@ -1532,8 +1532,15 @@ class EmployeePolicyModel extends Model
|
||||
e.doj,
|
||||
e.band,
|
||||
TIMESTAMPDIFF(YEAR, e.dob, CURDATE()) AS emp_age,
|
||||
(SELECT name FROM employees WHERE relationship = "Self" and emp_code = ' . $this->db->escape($emp_code) . ' and client_id = '.$client_id.' LIMIT 1) AS self,
|
||||
|
||||
(
|
||||
SELECT name FROM employees
|
||||
WHERE relationship = "Self"
|
||||
and emp_code = ' . $this->db->escape($emp_code) . '
|
||||
and client_id = '.$client_id.'
|
||||
and is_active = 1
|
||||
and emp_status = "active"
|
||||
LIMIT 1
|
||||
) AS self,
|
||||
|
||||
ep.tpa_id,
|
||||
ep.uhid,
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="insurer_branch_id">Insurer Branch<span class="text-danger">*</span></label>
|
||||
<select class="form-control <?= !isset($CD_Master_Data) ? 'readonly-select' : '' ?>" id="insurer_branch_id" name="insurer_branch_id" required>
|
||||
<select class="form-control <?= !isset($CD_Master_Data) ? 'readonly-select' : '' ?>" id="insurer_branch_id" name="insurer_branch_id" onchange="checkDuplicateCdAccount(this)" required>
|
||||
<option value="">Select Insurer Branch</option>
|
||||
<?php if(isset($insurer_branch) && !empty($insurer_branch))
|
||||
{ foreach($insurer_branch as $branch) { ?>
|
||||
@ -229,11 +229,11 @@
|
||||
$('#opening_bal').prop("disabled", false);
|
||||
|
||||
if(isCdMasterPage == true){
|
||||
$('#client_id').val('').change();
|
||||
$('#insurer_id_for_cd').val('').change();
|
||||
$('#insurer_branch_id').val('').change();
|
||||
$('#cd_client_id').val('').select2();
|
||||
$('#insurer_id_for_cd').val('').select2();
|
||||
$('#insurer_branch_id').val('').select2();
|
||||
|
||||
$('#client_id').prop("disabled", false);
|
||||
$('#cd_client_id').prop("disabled", false);
|
||||
$('#insurer_id_for_cd').prop("disabled", false);
|
||||
$('#insurer_branch_id').prop("disabled", false);
|
||||
|
||||
@ -266,7 +266,7 @@
|
||||
);
|
||||
});
|
||||
|
||||
$branchSelect.val('').trigger('change.select2');
|
||||
$branchSelect.val('').select2();
|
||||
}
|
||||
|
||||
function showCdMasterAddModal(){
|
||||
@ -301,5 +301,43 @@
|
||||
$('#cd_ac_no_for_cd_master').append(option);
|
||||
}
|
||||
|
||||
function checkDuplicateCdAccount(){
|
||||
|
||||
let url = '<?= base_url('util/checkDuplicateCdAccount') ?>';
|
||||
let client_id = $('#cd_client_id').val();
|
||||
let insurer_id = $('#insurer_id_for_cd').val();
|
||||
let insurer_branch_id = $('#insurer_branch_id').val();
|
||||
console.log({client_id, insurer_id, insurer_branch_id});
|
||||
|
||||
// Data to send in the AJAX request
|
||||
let requestData = {
|
||||
client_id: client_id,
|
||||
insurer_id: insurer_id,
|
||||
insurer_branch_id: insurer_branch_id,
|
||||
};
|
||||
|
||||
if(client_id != "" && insurer_id != "" && insurer_branch_id != ""){
|
||||
// Send AJAX request
|
||||
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
|
||||
|
||||
console.log('Data fetched successfully:', response);
|
||||
|
||||
if (response.status == true) {
|
||||
console.log('No dublicate found');
|
||||
} else {
|
||||
|
||||
$('#cd_client_id').val('').select2();
|
||||
$('#insurer_id_for_cd').val('').select2();
|
||||
$('#insurer_branch_id').val('').select2();
|
||||
toastr.warning(response.message, 'WARNING');
|
||||
}
|
||||
|
||||
}, function(xhr, status, error) {
|
||||
console.error('Error fetching data:', error);
|
||||
console.error(xhr.responseText);
|
||||
toastr.error('An error occurred while checking the CD amount.', 'ERROR');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
@ -323,7 +323,7 @@ table.dataTable thead th {
|
||||
$('#cd_client_id').prop("disabled", true);
|
||||
$('#insurer_id_for_cd').val(res.data.insurer_id).change();
|
||||
$('#insurer_id_for_cd').prop("disabled", true);
|
||||
$('#insurer_branch_id').val(res.data.insurer_id).change();
|
||||
$('#insurer_branch_id').val(res.data.insurer_branch_id).select2();
|
||||
$('#insurer_branch_id').prop("disabled", true);
|
||||
$('#opening_date').val(res.data.opening_date);
|
||||
$('#cd_ac_no_for_cd_master').val(res.data.cd_ac_no);
|
||||
|
||||
@ -842,6 +842,17 @@ input:checked + .slider::before {
|
||||
|
||||
if(response.status == false && response.insurer_id != 'undefined'){
|
||||
toastr.warning('The CD Account Number not found.', 'Warning');
|
||||
|
||||
$('#cd_ac_no').empty();
|
||||
$('#cd_ac_no').append($('<option>', {
|
||||
value: '',
|
||||
text: 'Select CD Account Number'
|
||||
}));
|
||||
$('#cd_ac_no').append($('<option>', {
|
||||
value: 'add_cd',
|
||||
text: '+ Add New CD'
|
||||
}));
|
||||
|
||||
return;
|
||||
}
|
||||
appendCDACNO(response.data)
|
||||
@ -1806,15 +1817,18 @@ input:checked + .slider::before {
|
||||
//console.log('appendCDACNO', select);
|
||||
|
||||
$('#cd_ac_no').empty();
|
||||
|
||||
$('#cd_ac_no').append($('<option>', {
|
||||
value: '',
|
||||
text: 'Select CD Account Number'
|
||||
}));
|
||||
|
||||
$('#cd_ac_no').append($('<option>', {
|
||||
value: 'add_cd',
|
||||
text: '+ Add New CD'
|
||||
}));
|
||||
if(data.length == 0){
|
||||
$('#cd_ac_no').append($('<option>', {
|
||||
value: 'add_cd',
|
||||
text: '+ Add New CD'
|
||||
}));
|
||||
}
|
||||
|
||||
$.each(data, function(index, item) {
|
||||
const option = $('<option>', {
|
||||
@ -2381,140 +2395,135 @@ input:checked + .slider::before {
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$('#chk-show-expired').on('change', function () {
|
||||
|
||||
$('#chk-show-expired').on('change', function () {
|
||||
const showExpired = $(this).is(':checked');
|
||||
|
||||
const showExpired = $(this).is(':checked');
|
||||
let policyTable = '';
|
||||
let data = <?= isset($client_policy) ? json_encode($client_policy) : '[]' ?>;
|
||||
let role = data.role
|
||||
delete data.role;
|
||||
|
||||
let policyTable = '';
|
||||
let data = <?= isset($client_policy) ? json_encode($client_policy) : '[]' ?>;
|
||||
let role = data.role
|
||||
delete data.role;
|
||||
console.log("checkbox working");
|
||||
|
||||
console.log("checkbox working");
|
||||
$.each(data, function(index, item) {
|
||||
// console.log('step 1');
|
||||
let patternGMC = /gmc/i; // Case insensitive pattern for 'gmc'
|
||||
let patternGPA = /gpa/i; // Case insensitive pattern for 'gpa'
|
||||
let subject = item.policy_type_name;
|
||||
|
||||
$.each(data, function(index, item) {
|
||||
// console.log('step 1');
|
||||
let patternGMC = /gmc/i; // Case insensitive pattern for 'gmc'
|
||||
let patternGPA = /gpa/i; // Case insensitive pattern for 'gpa'
|
||||
let subject = item.policy_type_name;
|
||||
//console.log('search terms subject', subject);
|
||||
|
||||
//console.log('search terms subject', subject);
|
||||
if (patternGMC.test(subject)) {
|
||||
search_term = 'GMC';
|
||||
} else if (patternGPA.test(subject)) {
|
||||
search_term = 'GPA';
|
||||
} else {
|
||||
search_term = subject; // Set default value if neither 'GMC' nor 'GPA' exists
|
||||
}
|
||||
|
||||
if (patternGMC.test(subject)) {
|
||||
search_term = 'GMC';
|
||||
} else if (patternGPA.test(subject)) {
|
||||
search_term = 'GPA';
|
||||
} else {
|
||||
search_term = subject; // Set default value if neither 'GMC' nor 'GPA' exists
|
||||
}
|
||||
|
||||
let tpaValue = 'TPA Unavailable';
|
||||
let tpaValue = 'TPA Unavailable';
|
||||
|
||||
if (item.tpa_short && item.tpa_branch_code) {
|
||||
tpaValue = item.tpa_short + '-' + item.tpa_branch_code;
|
||||
if (item.tpa_short && item.tpa_branch_code) {
|
||||
tpaValue = item.tpa_short + '-' + item.tpa_branch_code;
|
||||
}
|
||||
|
||||
let policy_name_data = `${item.policy_type_name ?? ''}` + ' - ' + `${item.policy_no ?? ''}`;
|
||||
|
||||
if(showExpired == true && checkDateStatus(item.policy_end_date) == 'Expired'){
|
||||
|
||||
|
||||
policyTable += `
|
||||
<tr>
|
||||
<td>${item.insurer_short} - ${item.insurer_branch_name}</td>
|
||||
<td>${policy_name_data}</td>
|
||||
<td>${item.branch_name ? item.branch_name : ' - '}</td>
|
||||
<td>${tpaValue}</td>
|
||||
<td>${(item.policy_start_date)} / ${(item.policy_end_date)}</td>
|
||||
|
||||
<td>${checkDateStatus(item.policy_end_date, 1)}</td>
|
||||
<td>
|
||||
<div class="btn-group dropdown">
|
||||
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<a href="#" data-id="${item.id}" id="${item.policy_id}" class="dropdown-item btnPolicyEdit"><i class="mdi mdi-lead-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
|
||||
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item btnPolicyMaster" ><i class="mdi mdi-wrench mr-2 text-muted font-18 vertical-middle"></i>Terms</a>
|
||||
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item btnPolicyModel" data-toggle="modal" data-target="#bs-example-modal-lg"><i class="mdi mdi-book-open mr-2 text-muted font-18 vertical-middle"></i>Rack Rate</a>`;
|
||||
|
||||
// Conditionally render the delete option based on the role
|
||||
if (role != 3 && role != 4) {
|
||||
policyTable += `
|
||||
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item" onclick="removepolicy(this)"><i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete</a>`;
|
||||
}
|
||||
|
||||
policyTable += `
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
|
||||
|
||||
}
|
||||
|
||||
let policy_name_data = `${item.policy_type_name ?? ''}` + ' - ' + `${item.policy_no ?? ''}`;
|
||||
|
||||
if(showExpired == true && checkDateStatus(item.policy_end_date) == 'Expired'){
|
||||
|
||||
|
||||
policyTable += `
|
||||
<tr>
|
||||
<td>${item.insurer_short} - ${item.insurer_branch_name}</td>
|
||||
<td>${policy_name_data}</td>
|
||||
<td>${item.branch_name ? item.branch_name : ' - '}</td>
|
||||
<td>${tpaValue}</td>
|
||||
<td>${(item.policy_start_date)} / ${(item.policy_end_date)}</td>
|
||||
|
||||
<td>${checkDateStatus(item.policy_end_date, 1)}</td>
|
||||
<td>
|
||||
<div class="btn-group dropdown">
|
||||
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<a href="#" data-id="${item.id}" id="${item.policy_id}" class="dropdown-item btnPolicyEdit"><i class="mdi mdi-lead-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
|
||||
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item btnPolicyMaster" ><i class="mdi mdi-wrench mr-2 text-muted font-18 vertical-middle"></i>Terms</a>
|
||||
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item btnPolicyModel" data-toggle="modal" data-target="#bs-example-modal-lg"><i class="mdi mdi-book-open mr-2 text-muted font-18 vertical-middle"></i>Rack Rate</a>`;
|
||||
|
||||
// Conditionally render the delete option based on the role
|
||||
if (role != 3 && role != 4) {
|
||||
policyTable += `
|
||||
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item" onclick="removepolicy(this)"><i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete</a>`;
|
||||
}
|
||||
|
||||
policyTable += `
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
|
||||
if(showExpired == false && checkDateStatus(item.policy_end_date) != 'Expired'){
|
||||
|
||||
}
|
||||
|
||||
if(showExpired == false && checkDateStatus(item.policy_end_date) != 'Expired'){
|
||||
|
||||
policyTable += `
|
||||
<tr>
|
||||
<td>${item.insurer_short} - ${item.insurer_branch_name}</td>
|
||||
<td>${policy_name_data}</td>
|
||||
<td>${item.branch_name ? item.branch_name : ' - '}</td>
|
||||
<td>${tpaValue}</td>
|
||||
<td>${(item.policy_start_date)} / ${(item.policy_end_date)}</td>
|
||||
|
||||
<td>${checkDateStatus(item.policy_end_date, 1)}</td>
|
||||
<td>
|
||||
<div class="btn-group dropdown">
|
||||
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<a href="#" data-id="${item.id}" id="${item.policy_id}" class="dropdown-item btnPolicyEdit"><i class="mdi mdi-lead-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
|
||||
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item btnPolicyMaster" ><i class="mdi mdi-wrench mr-2 text-muted font-18 vertical-middle"></i>Terms</a>
|
||||
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item btnPolicyModel" data-toggle="modal" data-target="#bs-example-modal-lg"><i class="mdi mdi-book-open mr-2 text-muted font-18 vertical-middle"></i>Rack Rate</a>`;
|
||||
|
||||
policyTable += `
|
||||
<tr>
|
||||
<td>${item.insurer_short} - ${item.insurer_branch_name}</td>
|
||||
<td>${policy_name_data}</td>
|
||||
<td>${item.branch_name ? item.branch_name : ' - '}</td>
|
||||
<td>${tpaValue}</td>
|
||||
<td>${(item.policy_start_date)} / ${(item.policy_end_date)}</td>
|
||||
|
||||
<td>${checkDateStatus(item.policy_end_date, 1)}</td>
|
||||
<td>
|
||||
<div class="btn-group dropdown">
|
||||
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<a href="#" data-id="${item.id}" id="${item.policy_id}" class="dropdown-item btnPolicyEdit"><i class="mdi mdi-lead-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
|
||||
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item btnPolicyMaster" ><i class="mdi mdi-wrench mr-2 text-muted font-18 vertical-middle"></i>Terms</a>
|
||||
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item btnPolicyModel" data-toggle="modal" data-target="#bs-example-modal-lg"><i class="mdi mdi-book-open mr-2 text-muted font-18 vertical-middle"></i>Rack Rate</a>`;
|
||||
// Conditionally render the delete option based on the role
|
||||
if (role != 3 && role != 4) {
|
||||
policyTable += `
|
||||
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item" onclick="removepolicy(this)"><i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete</a>`;
|
||||
}
|
||||
|
||||
// Conditionally render the delete option based on the role
|
||||
if (role != 3 && role != 4) {
|
||||
policyTable += `
|
||||
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item" onclick="removepolicy(this)"><i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete</a>`;
|
||||
}
|
||||
|
||||
policyTable += `
|
||||
</div>
|
||||
policyTable += `
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
const table = $('#table-client-policy').DataTable();
|
||||
table.clear().destroy();
|
||||
|
||||
$('#table-client-policy tbody').html(policyTable); // replace tbody content
|
||||
|
||||
$('#table-client-policy').DataTable({
|
||||
paging: true,
|
||||
searching: true,
|
||||
autoWidth: false,
|
||||
responsive: true,
|
||||
});
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
const table = $('#table-client-policy').DataTable();
|
||||
table.clear().destroy();
|
||||
|
||||
$('#table-client-policy tbody').html(policyTable); // replace tbody content
|
||||
|
||||
$('#table-client-policy').DataTable({
|
||||
paging: true,
|
||||
searching: true,
|
||||
autoWidth: false,
|
||||
responsive: true,
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@ -508,7 +508,7 @@
|
||||
</table> -->
|
||||
<!-- <button type="button" id="add_row_btn" class="btn btn-secondary float-right mt-2"><i class="fa fa-plus"></i></button> -->
|
||||
|
||||
<div class="payment-card">
|
||||
<div class="payment-card" id="default_payment_card">
|
||||
<input type="hidden" class="form-control" name="pk[]" placeholder="Enter Amount">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
@ -959,19 +959,54 @@
|
||||
return parts[2] + '/' + parts[1] + '/' + parts[0]; // Rearrange to DD-MM-YYYY
|
||||
}
|
||||
|
||||
function togglePaymentCardRequired(flag) {
|
||||
// Select the default payment card container
|
||||
const card = document.getElementById("default_payment_card");
|
||||
if (!card) return;
|
||||
|
||||
// Select all input elements inside the card
|
||||
const inputs = card.querySelectorAll("input");
|
||||
|
||||
inputs.forEach(input => {
|
||||
if (flag) {
|
||||
input.setAttribute("required", "required");
|
||||
} else {
|
||||
input.removeAttribute("required");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function showInvoiceStatusModal(event) {
|
||||
console.log('############ showInvoiceStatusModal function called ##################');
|
||||
var modal_received_amt_div = document.getElementById('modal_received_amt_div');
|
||||
modal_received_amt_div.style.display = 'none';
|
||||
// alert();
|
||||
// console.log(event.target.data)
|
||||
var dataId = event.target.getAttribute('data-id');
|
||||
// make sure event exists
|
||||
event = event || window.event;
|
||||
|
||||
// the element actually clicked
|
||||
const clicked = event.target;
|
||||
|
||||
// find the nearest ancestor <a> (or element) that has data-id
|
||||
const anchor = clicked.closest('a[data-id], .btnEdit');
|
||||
|
||||
if (!anchor) {
|
||||
console.warn('Could not find element with data-id');
|
||||
return;
|
||||
}
|
||||
|
||||
const dataId = anchor.getAttribute('data-id');
|
||||
const expAmt = anchor.getAttribute('data-exp-amt');
|
||||
const receivedAmt = anchor.getAttribute('data-received-amt');
|
||||
|
||||
console.log('stmt id :', dataId, expAmt, receivedAmt);
|
||||
|
||||
var dataExpAmt = event.target.getAttribute('data-exp-amt');
|
||||
var dataReceivedAmt = event.target.getAttribute('data-received-amt');
|
||||
// Set the value to a hidden input field in the modal
|
||||
document.getElementById('hidden_statement_id').value = dataId;
|
||||
// document.getElementById('modal_exp_amt').value = dataExpAmt;
|
||||
document.getElementById('modal_received_amt').value = dataReceivedAmt;
|
||||
document.getElementById('modal_received_amt').value = receivedAmt;
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
@ -981,10 +1016,78 @@
|
||||
method: 'get',
|
||||
// data: { id: dataId },
|
||||
// dataType: 'json',
|
||||
// success: function(response) {
|
||||
// $('.loader').fadeOut();
|
||||
// $('.loader-mask').delay(10).fadeOut('slow');
|
||||
// console.log(response);
|
||||
// // Assuming response contains the necessary data
|
||||
// if (response.dataStatus === true && response.code === 200) {
|
||||
// // Populate modal fields
|
||||
// if (response.data.invoice_status !== null) {
|
||||
// var inv_status_element = document.getElementById('invoice_status');
|
||||
// inv_status_element.value = response.data.invoice_status;
|
||||
// var event = new Event('change');
|
||||
// inv_status_element.dispatchEvent(event);
|
||||
// }
|
||||
|
||||
// document.getElementById('invoice_no_modal').value = response.data.invoice_no;
|
||||
// document.getElementById('invoice_date_modal').value = response.data.invoice_date === '' ? <?php echo date('d-m-Y') ?> : response.data.invoice_date;
|
||||
// document.getElementById('invoice_amount_no_modal').value = response.data.invoice_amount;
|
||||
|
||||
// document.getElementById('invoice_value_modal').value = response.data.invoice_value;
|
||||
// document.getElementById('gst_per_modal').value = response.data.gst_per;
|
||||
// document.getElementById('gst_value_modal').value = response.data.gst_value;
|
||||
// console.log('response.data.gst_value - ' + response.data.gst_value);
|
||||
// if (response.data.gst_value == 0 || response.data.gst_value == '' || response.data.gst_value == null) {
|
||||
// calcGSTValue();
|
||||
// }
|
||||
|
||||
// if (!$('#invoice_date_modal').val()) {
|
||||
// // alert('nope');
|
||||
// // Set today's date as the default date
|
||||
// $('#invoice_date_modal').datepicker('setDate', new Date());
|
||||
// }
|
||||
// // Clear existing rows in the payment table
|
||||
// var paymentTableBody = document.querySelector('#payment_table_modal tbody');
|
||||
// // var paymentTableBody = document.getElementById('payment_card_container');
|
||||
|
||||
// console.log('response.data.payments.length', response.data.payments.length)
|
||||
// // Populate payment table rows
|
||||
// if (response.data.payments.length) {
|
||||
// paymentTableBody.innerHTML = '';
|
||||
// response.data.payments.forEach(function(payment) {
|
||||
// var row = paymentTableBody.insertRow();
|
||||
|
||||
// row.innerHTML = `
|
||||
// <td style="display: none;"><input type="hidden" class="form-control" name="pk[]" value="${payment.id}"></td>
|
||||
// <td><input type="number" class="form-control" name="received_amount[]" placeholder="Enter Amount" value="${payment.inv_amt}" onchange="checkInvAmont(event)" required step="0.01"></td>
|
||||
// <td><input type="number" class="form-control" name="gst_amount[]" placeholder="Enter Amount" value="${payment.gst}" onchange="checkInvAmont(event)" required step="0.01"></td>
|
||||
// <td><input type="number" class="form-control" name="tds[]" placeholder="Enter Amount" value="${payment.tds}" onchange="checkInvAmont(event)" required></td>
|
||||
// <td><input type="text" class="form-control" name="utr_no[]" placeholder="Enter UTR No" value="${payment.utr_no}" required></td>
|
||||
// <td><input type="text" class="form-control payment_date" name="payment_date[]" value="${formatDateToDMY(payment.received_date)}" required readonly></td>
|
||||
// <td><i class="mdi mdi-delete mr-2 font-18 vertical-middle text-danger remove-row" style="text-align: center;"></i></td>
|
||||
// `;
|
||||
// });
|
||||
// }
|
||||
// $('.payment_date').datepicker({
|
||||
// format: 'dd/mm/yyyy',
|
||||
// autoclose: true
|
||||
// });
|
||||
// // Show the modal
|
||||
// var myModal = new bootstrap.Modal(document.getElementById('invoice_modal'));
|
||||
// myModal.show();
|
||||
// } else {
|
||||
// // Handle error if the response is not successful
|
||||
// console.error('Failed to fetch data:', response);
|
||||
// alert("Something went wrong! Couldn't get data");
|
||||
// }
|
||||
// },
|
||||
|
||||
success: function(response) {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(10).fadeOut('slow');
|
||||
console.log(response);
|
||||
|
||||
// Assuming response contains the necessary data
|
||||
if (response.dataStatus === true && response.code === 200) {
|
||||
// Populate modal fields
|
||||
@ -996,46 +1099,84 @@
|
||||
}
|
||||
|
||||
document.getElementById('invoice_no_modal').value = response.data.invoice_no;
|
||||
document.getElementById('invoice_date_modal').value = response.data.invoice_date === '' ? <?php echo date('d-m-Y') ?> : response.data.invoice_date;
|
||||
document.getElementById('invoice_date_modal').value = response.data.invoice_date === '' ? '<?php echo date('d-m-Y') ?>' : response.data.invoice_date;
|
||||
document.getElementById('invoice_amount_no_modal').value = response.data.invoice_amount;
|
||||
|
||||
document.getElementById('invoice_value_modal').value = response.data.invoice_value;
|
||||
document.getElementById('gst_per_modal').value = response.data.gst_per;
|
||||
document.getElementById('gst_value_modal').value = response.data.gst_value;
|
||||
console.log('response.data.gst_value - ' + response.data.gst_value);
|
||||
|
||||
if (response.data.gst_value == 0 || response.data.gst_value == '' || response.data.gst_value == null) {
|
||||
calcGSTValue();
|
||||
}
|
||||
|
||||
if (!$('#invoice_date_modal').val()) {
|
||||
// alert('nope');
|
||||
// Set today's date as the default date
|
||||
$('#invoice_date_modal').datepicker('setDate', new Date());
|
||||
}
|
||||
// Clear existing rows in the payment table
|
||||
var paymentTableBody = document.querySelector('#payment_table_modal tbody');
|
||||
|
||||
// Clear existing payment cards in the container
|
||||
var defaultPaymentCardContainer = document.getElementById('default_payment_card');
|
||||
defaultPaymentCardContainer.style.display = 'block';
|
||||
togglePaymentCardRequired(true);
|
||||
var paymentCardContainer = document.getElementById('payment_card_container');
|
||||
paymentCardContainer.innerHTML = '';
|
||||
|
||||
console.log('response.data.payments.length', response.data.payments.length)
|
||||
// Populate payment table rows
|
||||
console.log('response.data.payments.length', response.data.payments.length);
|
||||
|
||||
// Populate payment cards
|
||||
if (response.data.payments.length) {
|
||||
paymentTableBody.innerHTML = '';
|
||||
response.data.payments.forEach(function(payment) {
|
||||
var row = paymentTableBody.insertRow();
|
||||
row.innerHTML = `
|
||||
<td style="display: none;"><input type="hidden" class="form-control" name="pk[]" value="${payment.id}"></td>
|
||||
<td><input type="number" class="form-control" name="received_amount[]" placeholder="Enter Amount" value="${payment.inv_amt}" onchange="checkInvAmont(event)" required step="0.01"></td>
|
||||
<td><input type="number" class="form-control" name="gst_amount[]" placeholder="Enter Amount" value="${payment.gst}" onchange="checkInvAmont(event)" required step="0.01"></td>
|
||||
<td><input type="number" class="form-control" name="tds[]" placeholder="Enter Amount" value="${payment.tds}" onchange="checkInvAmont(event)" required></td>
|
||||
<td><input type="text" class="form-control" name="utr_no[]" placeholder="Enter UTR No" value="${payment.utr_no}" required></td>
|
||||
<td><input type="text" class="form-control payment_date" name="payment_date[]" value="${formatDateToDMY(payment.received_date)}" required readonly></td>
|
||||
<td><i class="mdi mdi-delete mr-2 font-18 vertical-middle text-danger remove-row" style="text-align: center;"></i></td>
|
||||
defaultPaymentCardContainer.style.display = 'none';
|
||||
togglePaymentCardRequired(false);
|
||||
// if (defaultPaymentCardContainer) {
|
||||
// defaultPaymentCardContainer.remove();
|
||||
// }
|
||||
response.data.payments.forEach(function(payment, index) {
|
||||
var paymentCard = document.createElement('div');
|
||||
paymentCard.className = 'payment-card';
|
||||
|
||||
paymentCard.innerHTML = `
|
||||
<input type="hidden" class="form-control" name="pk[]" value="${payment.id}">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<label>Invoice value</label>
|
||||
<input type="number" class="form-control" name="received_amount[]" placeholder="Enter Amount" value="${payment.inv_amt}" required step="0.01" onchange="checkInvAmont(event)">
|
||||
</div>
|
||||
<div class="col">
|
||||
<label>GST</label>
|
||||
<input type="number" class="form-control" name="gst_amount[]" placeholder="Enter GST" value="${payment.gst}" required step="0.01" onchange="checkInvAmont(event)">
|
||||
</div>
|
||||
<div class="col">
|
||||
<label>TDS</label>
|
||||
<input type="number" class="form-control" name="tds[]" placeholder="Enter TDS" value="${payment.tds}" onchange="checkInvAmont(event)" required>
|
||||
</div>
|
||||
<div class="col">
|
||||
<label>UTR Number</label>
|
||||
<input type="text" class="form-control" name="utr_no[]" placeholder="Enter UTR No" value="${payment.utr_no}" required>
|
||||
</div>
|
||||
<div class="col">
|
||||
<label>Date</label>
|
||||
<input type="text" class="form-control payment_date" name="payment_date[]" value="${formatDateToDMY(payment.received_date)}" placeholder="dd/mm/yyyy" required readonly>
|
||||
</div>
|
||||
<div class="col-auto d-flex align-items-end">
|
||||
<button type="button" class="btn btn-danger btn-sm remove-row">
|
||||
<i class="mdi mdi-delete"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
paymentCardContainer.appendChild(paymentCard);
|
||||
});
|
||||
}
|
||||
|
||||
// Initialize datepicker for all payment date fields
|
||||
$('.payment_date').datepicker({
|
||||
format: 'dd/mm/yyyy',
|
||||
autoclose: true
|
||||
});
|
||||
|
||||
// Show the modal
|
||||
var myModal = new bootstrap.Modal(document.getElementById('invoice_modal'));
|
||||
myModal.show();
|
||||
|
||||
@ -300,126 +300,123 @@ table.dataTable tbody td {
|
||||
|
||||
<script>
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
const table = document.getElementById("tickets-table");
|
||||
|
||||
function createCustomDropdown(row) {
|
||||
const originalDropdown = row.querySelector('.dropdown-menu');
|
||||
if (!originalDropdown) return null;
|
||||
// New menu
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
const table = document.getElementById("tickets-table");
|
||||
|
||||
const customDropdown = document.createElement('div');
|
||||
customDropdown.className = 'custom-dropdown-menu';
|
||||
|
||||
// Clone the items but remove their original click handlers
|
||||
const items = originalDropdown.querySelectorAll('.dropdown-item');
|
||||
items.forEach(item => {
|
||||
const newItem = item.cloneNode(true);
|
||||
// Preserve the attributes but remove the onclick
|
||||
newItem.removeAttribute('onclick');
|
||||
customDropdown.appendChild(newItem);
|
||||
});
|
||||
|
||||
return customDropdown;
|
||||
}
|
||||
|
||||
let activeDropdown = null;
|
||||
|
||||
table.querySelectorAll("tbody tr").forEach(row => {
|
||||
const customDropdown = createCustomDropdown(row);
|
||||
if (!customDropdown) return;
|
||||
|
||||
document.body.appendChild(customDropdown);
|
||||
|
||||
row.addEventListener("click", function(event) {
|
||||
// Ignore clicks on the action column
|
||||
if (event.target.closest('td:last-child')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeDropdown) {
|
||||
activeDropdown.style.display = 'none';
|
||||
}
|
||||
|
||||
const rect = event.target.getBoundingClientRect();
|
||||
function createCustomDropdown(row) {
|
||||
const originalDropdown = row.querySelector('.dropdown-menu');
|
||||
if (!originalDropdown) return null;
|
||||
|
||||
customDropdown.style.display = 'block';
|
||||
customDropdown.style.position = 'fixed';
|
||||
customDropdown.style.left = `${rect.left}px`;
|
||||
customDropdown.style.top = `${rect.bottom + 5}px`;
|
||||
const customDropdown = document.createElement('div');
|
||||
customDropdown.className = 'custom-dropdown-menu';
|
||||
|
||||
activeDropdown = customDropdown;
|
||||
event.stopPropagation();
|
||||
});
|
||||
// Clone the items but remove their original click handlers
|
||||
const items = originalDropdown.querySelectorAll('.dropdown-item');
|
||||
items.forEach(item => {
|
||||
const newItem = item.cloneNode(true);
|
||||
// Preserve the attributes but remove the onclick
|
||||
newItem.removeAttribute('onclick');
|
||||
customDropdown.appendChild(newItem);
|
||||
});
|
||||
|
||||
return customDropdown;
|
||||
}
|
||||
|
||||
// Handle clicks on dropdown items
|
||||
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
|
||||
item.addEventListener('click', function(e) {
|
||||
console.log("##############");
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
let activeDropdown = null;
|
||||
|
||||
// Get the data-id and other attributes from the original button
|
||||
const originalItem = row.querySelector(`.dropdown-item[data-id="${this.getAttribute('data-id')}"]`);
|
||||
|
||||
// For edit functionality
|
||||
if (this.classList.contains('btnEdit')) {
|
||||
const id = this.getAttribute('data-id');
|
||||
const lead_form_type = this.getAttribute('data-ft');
|
||||
console.log('second drop lead_form_type', lead_form_type)
|
||||
if (id) {
|
||||
getLeadsDataForEdit(id, lead_form_type);
|
||||
}
|
||||
}else if (this.classList.contains('btnHistory')) {
|
||||
let lead_id = this.getAttribute('data-id');
|
||||
if(lead_id){ console.log("******** Clicked from td lead_id-", lead_id); getLeadsDataForMailHistory(lead_id); }
|
||||
else{ console.log("******** Clicked from td but i don`t have lead_id"); }
|
||||
|
||||
}
|
||||
else{
|
||||
const onclickAttr = this.getAttribute('onclick');
|
||||
if (onclickAttr) {
|
||||
eval(onclickAttr);
|
||||
}
|
||||
}
|
||||
|
||||
// For RFQ links
|
||||
const href = this.getAttribute('href');
|
||||
if (href && href !== '#' && !this.classList.contains('btnEdit')) {
|
||||
window.location.href = href;
|
||||
table.querySelectorAll("tbody tr").forEach(row => {
|
||||
const customDropdown = createCustomDropdown(row);
|
||||
if (!customDropdown) return;
|
||||
|
||||
document.body.appendChild(customDropdown);
|
||||
|
||||
row.addEventListener("click", function(event) {
|
||||
// Ignore clicks on the action column
|
||||
if (event.target.closest('td:last-child')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Close the dropdown
|
||||
if (activeDropdown) {
|
||||
activeDropdown.style.display = 'none';
|
||||
activeDropdown = null;
|
||||
}
|
||||
|
||||
const rect = event.target.getBoundingClientRect();
|
||||
|
||||
customDropdown.style.display = 'block';
|
||||
customDropdown.style.position = 'fixed';
|
||||
customDropdown.style.left = `${rect.left}px`;
|
||||
customDropdown.style.top = `${rect.bottom + 5}px`;
|
||||
|
||||
activeDropdown = customDropdown;
|
||||
event.stopPropagation();
|
||||
});
|
||||
|
||||
// Handle clicks on dropdown items
|
||||
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
|
||||
item.addEventListener('click', function(e) {
|
||||
console.log("##############");
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
// Get the data-id and other attributes from the original button
|
||||
const originalItem = row.querySelector(`.dropdown-item[data-id="${this.getAttribute('data-id')}"]`);
|
||||
|
||||
// For edit functionality
|
||||
if (this.classList.contains('btnEdit')) {
|
||||
const id = this.getAttribute('data-id');
|
||||
const lead_form_type = this.getAttribute('data-ft');
|
||||
console.log('second drop lead_form_type', lead_form_type)
|
||||
if (id) {
|
||||
getLeadsDataForEdit(id, lead_form_type);
|
||||
}
|
||||
}else if (this.classList.contains('btnHistory')) {
|
||||
let lead_id = this.getAttribute('data-id');
|
||||
if(lead_id){ console.log("******** Clicked from td lead_id-", lead_id); getLeadsDataForMailHistory(lead_id); }
|
||||
else{ console.log("******** Clicked from td but i don`t have lead_id"); }
|
||||
|
||||
}
|
||||
else{
|
||||
const onclickAttr = this.getAttribute('onclick');
|
||||
if (onclickAttr) {
|
||||
eval(onclickAttr);
|
||||
}
|
||||
}
|
||||
|
||||
// For RFQ links
|
||||
const href = this.getAttribute('href');
|
||||
if (href && href !== '#' && !this.classList.contains('btnEdit')) {
|
||||
window.location.href = href;
|
||||
}
|
||||
|
||||
// Close the dropdown
|
||||
if (activeDropdown) {
|
||||
activeDropdown.style.display = 'none';
|
||||
activeDropdown = null;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Close dropdown when clicking outside
|
||||
document.addEventListener("click", function() {
|
||||
if (activeDropdown) {
|
||||
activeDropdown.style.display = 'none';
|
||||
activeDropdown = null;
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener("click", function(e) {
|
||||
if (e.target.closest(".btnHistory")) {
|
||||
let lead_id = e.target.closest(".btnHistory").dataset.id;
|
||||
console.log("******** in triple dot id available - " + lead_id);
|
||||
getLeadsDataForMailHistory(lead_id);
|
||||
}
|
||||
else{ console.log("******** in triple dot but id not available"); }
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// Close dropdown when clicking outside
|
||||
document.addEventListener("click", function() {
|
||||
if (activeDropdown) {
|
||||
activeDropdown.style.display = 'none';
|
||||
activeDropdown = null;
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener("click", function(e) {
|
||||
if (e.target.closest(".btnHistory")) {
|
||||
let lead_id = e.target.closest(".btnHistory").dataset.id;
|
||||
console.log("******** in triple dot id available - " + lead_id);
|
||||
getLeadsDataForMailHistory(lead_id);
|
||||
}
|
||||
else{ console.log("******** in triple dot but id not available"); }
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
|
||||
// Datatable document ready
|
||||
$(document).ready(function() {
|
||||
|
||||
@ -504,141 +501,143 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
|
||||
function getLeadsDataForMailHistory(lead_id){
|
||||
|
||||
console.log("******** Inside Fnz :", lead_id);
|
||||
let url = '<?= base_url('/util/getLeadEmailHistory/') ?>' + lead_id;
|
||||
console.log("******** Fetching:", url);
|
||||
console.log("******** Inside Fnz :", lead_id);
|
||||
let url = '<?= base_url('/util/getLeadEmailHistory/') ?>' + lead_id;
|
||||
console.log("******** Fetching:", url);
|
||||
|
||||
fetch(url, {
|
||||
method: "GET",
|
||||
headers: { "Accept": "application/json" }
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(response => {
|
||||
let container = document.querySelector(".history-container");
|
||||
container.innerHTML = "";
|
||||
if (response.status === "success" && response.data.length > 0) {
|
||||
console.log("******** 1" + response.status);
|
||||
let table = `
|
||||
<div class="table-responsive">
|
||||
<table data-custom-table-css="table" id="historytable" class="table table-striped mb-0 nowrap" cellspacing="0" id="tickets-table">
|
||||
fetch(url, {
|
||||
method: "GET",
|
||||
headers: { "Accept": "application/json" }
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(response => {
|
||||
let container = document.querySelector(".history-container");
|
||||
container.innerHTML = "";
|
||||
if (response.status === "success" && response.data.length > 0) {
|
||||
console.log("******** 1" + response.status);
|
||||
let table = `
|
||||
<div class="table-responsive">
|
||||
<table data-custom-table-css="table" id="historytable" class="table table-striped mb-0 nowrap" cellspacing="0" id="tickets-table">
|
||||
|
||||
<thead class="bg-light">
|
||||
<tr>
|
||||
<th><div class="column-header">S.No </div></th>
|
||||
<th><div class="column-header">From Mail </div></th>
|
||||
<th><div class="column-header">To Mail </div></th>
|
||||
<th><div class="column-header">BCC </div></th>
|
||||
<th><div class="column-header">CC </div></th>
|
||||
<th><div class="column-header">Type </div></th>
|
||||
<th><div class="column-header">Status </div></th>
|
||||
<th><div class="column-header">Date/Time </div></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
`;
|
||||
<thead class="bg-light">
|
||||
<tr>
|
||||
<th><div class="column-header">S.No </div></th>
|
||||
<th><div class="column-header">From Mail </div></th>
|
||||
<th><div class="column-header">To Mail </div></th>
|
||||
<th><div class="column-header">BCC </div></th>
|
||||
<th><div class="column-header">CC </div></th>
|
||||
<th><div class="column-header">Type </div></th>
|
||||
<th><div class="column-header">Status </div></th>
|
||||
<th><div class="column-header">Date/Time </div></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
`;
|
||||
|
||||
response.data.forEach((row, index) => {
|
||||
let formattedDate = "-";
|
||||
let statusValue = "-";
|
||||
if (row.received_message) {
|
||||
if (row.received_message.toLowerCase().includes("error")) {
|
||||
statusValue = "Failed";
|
||||
} else {
|
||||
statusValue = "Success";
|
||||
}
|
||||
}
|
||||
if (row.created_at) {
|
||||
let dt = new Date(row.created_at);
|
||||
let dateStr = dt.toLocaleDateString("en-GB", {
|
||||
day: "2-digit",
|
||||
month: "long",
|
||||
year: "numeric"
|
||||
});
|
||||
let timeStr = dt.toLocaleTimeString("en-US", {
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
hour12: true
|
||||
}).toLowerCase();
|
||||
formattedDate = `${dateStr} ${timeStr}`;
|
||||
}
|
||||
let fromMails = "-";
|
||||
if (row.from_mail) {
|
||||
fromMails = row.from_mail
|
||||
.split(",") // split by comma
|
||||
.map(m => m.trim().replace(/^"|"$/g, "")) // trim + remove quotes at start/end
|
||||
.filter(m => m !== "") // remo
|
||||
.join("<br>"); // join with line break
|
||||
}
|
||||
let toMails = "-";
|
||||
if (row.mail) {
|
||||
toMails = row.mail
|
||||
.split(",")
|
||||
.map(m => m.trim().replace(/^"|"$/g, ""))
|
||||
.filter(m => m !== "")
|
||||
.join("<br>");
|
||||
}
|
||||
let ccMails = "-";
|
||||
if (row.cc && row.cc.trim() !== "") {
|
||||
ccMails = row.cc
|
||||
.split(",")
|
||||
.map(m => m.trim().replace(/^"|"$/g, ""))
|
||||
.filter(m => m !== "")
|
||||
.join("<br>");
|
||||
}
|
||||
let bccMails = "-";
|
||||
if (row.bcc && row.bcc.trim() !== "") {
|
||||
bccMails = row.bcc
|
||||
.split(",")
|
||||
.map(m => m.trim().replace(/^"|"$/g, ""))
|
||||
.filter(m => m !== "")
|
||||
.join("<br>");
|
||||
}
|
||||
response.data.forEach((row, index) => {
|
||||
let formattedDate = "-";
|
||||
let statusValue = "-";
|
||||
if (row.received_message) {
|
||||
if (row.received_message.toLowerCase().includes("error")) {
|
||||
statusValue = "Failed";
|
||||
} else {
|
||||
statusValue = "Success";
|
||||
}
|
||||
}
|
||||
if (row.created_at) {
|
||||
let dt = new Date(row.created_at);
|
||||
let dateStr = dt.toLocaleDateString("en-GB", {
|
||||
day: "2-digit",
|
||||
month: "long",
|
||||
year: "numeric"
|
||||
});
|
||||
let timeStr = dt.toLocaleTimeString("en-US", {
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
hour12: true
|
||||
}).toLowerCase();
|
||||
formattedDate = `${dateStr} ${timeStr}`;
|
||||
}
|
||||
let fromMails = "-";
|
||||
if (row.from_mail) {
|
||||
fromMails = row.from_mail
|
||||
.split(",") // split by comma
|
||||
.map(m => m.trim().replace(/^"|"$/g, "")) // trim + remove quotes at start/end
|
||||
.filter(m => m !== "") // remo
|
||||
.join("<br>"); // join with line break
|
||||
}
|
||||
let toMails = "-";
|
||||
if (row.mail) {
|
||||
toMails = row.mail
|
||||
.split(",")
|
||||
.map(m => m.trim().replace(/^"|"$/g, ""))
|
||||
.filter(m => m !== "")
|
||||
.join("<br>");
|
||||
}
|
||||
let ccMails = "-";
|
||||
if (row.cc && row.cc.trim() !== "") {
|
||||
ccMails = row.cc
|
||||
.split(",")
|
||||
.map(m => m.trim().replace(/^"|"$/g, ""))
|
||||
.filter(m => m !== "")
|
||||
.join("<br>");
|
||||
}
|
||||
let bccMails = "-";
|
||||
if (row.bcc && row.bcc.trim() !== "") {
|
||||
bccMails = row.bcc
|
||||
.split(",")
|
||||
.map(m => m.trim().replace(/^"|"$/g, ""))
|
||||
.filter(m => m !== "")
|
||||
.join("<br>");
|
||||
}
|
||||
|
||||
|
||||
table += `
|
||||
<tr>
|
||||
<td style="white-space: nowrap !important;">${index + 1}</td>
|
||||
<td style="white-space: nowrap !important;">${fromMails}</td>
|
||||
<td style="white-space: nowrap !important;">${toMails}</td>
|
||||
<td style="white-space: nowrap !important;">${bccMails ? bccMails : '-'}</td>
|
||||
<td style="white-space: nowrap !important;">${ccMails ? ccMails : '-'}</td>
|
||||
<td style="white-space: nowrap !important;">${row.mail_type ? row.mail_type.toUpperCase() : '-'}</td>
|
||||
<td style="white-space: nowrap !important;">${statusValue ? statusValue.toUpperCase() : '-'}</td>
|
||||
<td style="white-space: nowrap !important;">${formattedDate}</td>
|
||||
</tr>
|
||||
`;
|
||||
});
|
||||
|
||||
table += `</tbody></table>`;
|
||||
container.innerHTML = table;
|
||||
// show modal (if using Bootstrap 5)
|
||||
} else {
|
||||
|
||||
container.innerHTML = `
|
||||
<div class="d-flex justify-content-center align-items-center" style="height: 50vh; width:100%;">
|
||||
<p class="text-center font-color-black"><i>${response.message ?? "No History Available"}</i></p>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
// Show modal always
|
||||
new bootstrap.Modal(document.getElementById("EmailModal")).show();
|
||||
|
||||
})
|
||||
.catch(error => {
|
||||
console.log("******** 3" + error);
|
||||
document.querySelector(".history-container").innerHTML = `
|
||||
<div class="d-flex justify-content-center align-items-center" style="height: 50vh; width:100%;">
|
||||
<p class="text-center font-color-black"><i>No Data Found</i></p>
|
||||
</div>
|
||||
`;
|
||||
let EmailModal = new bootstrap.Modal(document.getElementById("EmailModal"));
|
||||
EmailModal.show();
|
||||
console.error(error);
|
||||
table += `
|
||||
<tr>
|
||||
<td style="white-space: nowrap !important;">${index + 1}</td>
|
||||
<td style="white-space: nowrap !important;">${fromMails}</td>
|
||||
<td style="white-space: nowrap !important;">${toMails}</td>
|
||||
<td style="white-space: nowrap !important;">${bccMails ? bccMails : '-'}</td>
|
||||
<td style="white-space: nowrap !important;">${ccMails ? ccMails : '-'}</td>
|
||||
<td style="white-space: nowrap !important;">${row.mail_type ? row.mail_type.toUpperCase() : '-'}</td>
|
||||
<td style="white-space: nowrap !important;">${statusValue ? statusValue.toUpperCase() : '-'}</td>
|
||||
<td style="white-space: nowrap !important;">${formattedDate}</td>
|
||||
</tr>
|
||||
`;
|
||||
});
|
||||
}
|
||||
|
||||
table += `</tbody></table>`;
|
||||
container.innerHTML = table;
|
||||
// show modal (if using Bootstrap 5)
|
||||
} else {
|
||||
|
||||
container.innerHTML = `
|
||||
<div class="d-flex justify-content-center align-items-center" style="height: 50vh; width:100%;">
|
||||
<p class="text-center font-color-black"><i>${response.message ?? "No History Available"}</i></p>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
// Show modal always
|
||||
new bootstrap.Modal(document.getElementById("EmailModal")).show();
|
||||
|
||||
})
|
||||
.catch(error => {
|
||||
console.log("******** 3" + error);
|
||||
document.querySelector(".history-container").innerHTML = `
|
||||
<div class="d-flex justify-content-center align-items-center" style="height: 50vh; width:100%;">
|
||||
<p class="text-center font-color-black"><i>No Data Found</i></p>
|
||||
</div>
|
||||
`;
|
||||
let EmailModal = new bootstrap.Modal(document.getElementById("EmailModal"));
|
||||
EmailModal.show();
|
||||
console.error(error);
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
|
||||
function selectOption(element, radioId) {
|
||||
// Remove selected class from all options
|
||||
document.querySelectorAll('.radio-option').forEach(option => {
|
||||
|
||||
@ -868,7 +868,6 @@
|
||||
$('.branchdiv').show();
|
||||
$('#table_tr_34').show();
|
||||
$('#table_tr_37').show();
|
||||
|
||||
}
|
||||
|
||||
console.log('selectedClientType', selectedClientType);
|
||||
@ -895,10 +894,12 @@
|
||||
|
||||
}
|
||||
|
||||
$('#client_policy_id').empty().append($('<option>', {
|
||||
value: '',
|
||||
text: 'Select Policy'
|
||||
}))
|
||||
if(selectedClientType == 1){
|
||||
$('#client_policy_id').empty().append($('<option>', {
|
||||
value: '',
|
||||
text: 'Select Policy'
|
||||
}));
|
||||
}
|
||||
|
||||
// Initialize or refresh Select2 for both dropdowns
|
||||
$('#client_id').select2();
|
||||
@ -975,8 +976,8 @@
|
||||
}
|
||||
|
||||
$('#policy_tranction_primarykey').val(res.data.id);
|
||||
$('#client_type').val(res.data.client_type).trigger('change');
|
||||
$('#client_id').val(res.data.client_id).change();
|
||||
$('#client_type').val(res.data.client_type);
|
||||
$('#base_cd_amount').val(res.data.base_cd_amount);
|
||||
|
||||
var tpaValue = '';
|
||||
@ -985,13 +986,22 @@
|
||||
}
|
||||
$('#tpa').val(tpaValue).change();
|
||||
|
||||
|
||||
setTimeout(function(){
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
$('#client_branch_id').val(res.data.client_branch_id).change();
|
||||
$('#client_policy_id').val(res.pt_id).select2();
|
||||
$('#client_branch_id').val(res.data.client_branch_id).select2();
|
||||
// $('#client_policy_id').val(res.pt_id).select2();
|
||||
}, 1000)
|
||||
|
||||
if(res.data.client_type == 2){
|
||||
let data1 = policyListByClient[res.data.client_id];
|
||||
appendPolicies(data1, res.pt_id);
|
||||
}else{
|
||||
let data2 = policy_list[res.data.client_branch_id];
|
||||
appendPolicies(data2, res.pt_id);
|
||||
}
|
||||
|
||||
setTimeout(function(){
|
||||
$('#policy_start_date').val(res.data.policy_start_date);
|
||||
$('#policy_end_date').val(res.data.policy_end_date);
|
||||
@ -1042,6 +1052,16 @@
|
||||
addInsurerColumn();
|
||||
}
|
||||
|
||||
if (res.data.client_type == 2) {
|
||||
$('.branchdiv').hide();
|
||||
$('#table_tr_34').hide();
|
||||
$('#table_tr_37').hide();
|
||||
} else {
|
||||
$('.branchdiv').show();
|
||||
$('#table_tr_34').show();
|
||||
$('#table_tr_37').show();
|
||||
}
|
||||
|
||||
// if(res.data.policy_type_id == 1 || res.data.policy_type_id == 2 || res.data.policy_type_id == 3 || res.data.policy_type_id == 4 || res.data.policy_type_id == 5 || res.data.policy_type_id == 6 || res.data.policy_type_id == 7){
|
||||
// $('#is_cd_reduce_from_bds').prop('disabled',true).prop('checked', false);
|
||||
// }else{
|
||||
|
||||
@ -692,7 +692,7 @@ table.dataTable thead th {
|
||||
});
|
||||
}
|
||||
|
||||
function appendPolicies(data) {
|
||||
function appendPolicies(data, policy_id=null) {
|
||||
if (!data) {
|
||||
|
||||
toastr.warning("There are no policies in Inception for the selected client and branch.");
|
||||
@ -724,6 +724,11 @@ table.dataTable thead th {
|
||||
'data-tpa': item.tpa_branch_id + '-' + item.tpa_id,
|
||||
'data-ptid': item.policy_type_id,
|
||||
});
|
||||
|
||||
if (policy_id == item.id) {
|
||||
option.attr('selected', true);
|
||||
}
|
||||
|
||||
$('#client_policy_id').append(option);
|
||||
});
|
||||
}
|
||||
|
||||
@ -3398,10 +3398,12 @@
|
||||
text: 'Select CD No',
|
||||
}));
|
||||
|
||||
$('#cd_ac_no_'+unique_id).append($('<option>', {
|
||||
value: 'add_cd',
|
||||
text: '+ Add CD'
|
||||
}));
|
||||
if(data.length == 0){
|
||||
$('#cd_ac_no_'+unique_id).append($('<option>', {
|
||||
value: 'add_cd',
|
||||
text: '+ Add CD'
|
||||
}));
|
||||
}
|
||||
|
||||
$.each(data, function(index, item) {
|
||||
var option = $('<option>', {
|
||||
@ -5634,7 +5636,6 @@
|
||||
<div class="form-group col-md-4">
|
||||
<label for="modal_vehicle_no">
|
||||
Vehicle No
|
||||
<span class="text-danger">*</span>
|
||||
<small style="font-size: x-small;">( Normal: AA##AA#### | Bharat: ##BH####AA )</small>
|
||||
</label>
|
||||
<div class="vehicle-input-wrapper">
|
||||
|
||||
@ -807,9 +807,11 @@ function appendVehicles(data, vehicle_id = null)
|
||||
}));
|
||||
|
||||
$.each(data, function(index, item) {
|
||||
var displayValue = item.vehicle_no ? item.vehicle_no : item.rc;
|
||||
var dbValue = item.id
|
||||
var option = $('<option>', {
|
||||
value: item.id,
|
||||
text: item.vehicle_no ?? item.rc,
|
||||
value: dbValue,
|
||||
text: displayValue,
|
||||
'data-cid': item.owner,
|
||||
'data-bid': item.branch_id,
|
||||
'data-cty': item.client_type,
|
||||
|
||||
@ -24,6 +24,7 @@
|
||||
margin: 0 auto;
|
||||
table-layout: fixed;
|
||||
border-spacing: 5px 0;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.card {
|
||||
@ -49,7 +50,7 @@
|
||||
}
|
||||
|
||||
.logo-left img {
|
||||
width: 32px;
|
||||
width: 48px;
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
@ -61,7 +62,7 @@
|
||||
|
||||
.logo-right img {
|
||||
width: 65px;
|
||||
height: auto;
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
.card-body {
|
||||
@ -159,6 +160,14 @@
|
||||
font-size: 8px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.card-header img[src=""],
|
||||
.card-header img:not([src]) {
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
display: none;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@ -167,16 +176,16 @@
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<div class="logo-left">
|
||||
<img src="{INSURER_LOGO}" alt="Insurer logo">
|
||||
<img src="{INSURER_LOGO}" alt=" " onerror="this.style.visibility='hidden';">
|
||||
</div>
|
||||
<div class="logo-right">
|
||||
<img src="{TPA_LOGO}" alt="TPA logo">
|
||||
<img src="{TPA_LOGO}" alt=" " onerror="this.style.visibility='hidden';">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<div class="n-logo">
|
||||
<img src="{NHANCE_N_LOGO}" alt="N Logo">
|
||||
<img src="{NHANCE_N_LOGO}" alt=" " onerror="this.style.visibility='hidden';">
|
||||
</div>
|
||||
|
||||
<div class="details">
|
||||
@ -185,47 +194,47 @@
|
||||
<tr>
|
||||
<td class="detail-label">Policy Holder</td>
|
||||
<td class="detail-separator">:</td>
|
||||
<td class="detail-value">AMERICAN MEGATRENDS INTERNATIONAL INDIA PVT LTD</td>
|
||||
<td class="detail-value">{CLIENT_NAME}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="detail-label">Insurer</td>
|
||||
<td class="detail-separator">:</td>
|
||||
<td class="detail-value">The New India Assurance</td>
|
||||
<td class="detail-value">{INSURER_NAME}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="detail-label">TPA</td>
|
||||
<td class="detail-separator">:</td>
|
||||
<td class="detail-value">Mediassit</td>
|
||||
<td class="detail-value">{TPA_NAME}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="detail-label">Primary Insured</td>
|
||||
<td class="detail-separator">:</td>
|
||||
<td class="detail-value">Suganya A</td>
|
||||
<td class="detail-value">{SELF_NAME}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="detail-label">Beneficiary Name</td>
|
||||
<td class="detail-separator">:</td>
|
||||
<td class="detail-value">Suganya A</td>
|
||||
<td class="detail-value">{NAME}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="detail-label">Member ID</td>
|
||||
<td class="detail-separator">:</td>
|
||||
<td class="detail-value">4060881280</td>
|
||||
<td class="detail-value">{TPA_ID}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="detail-label">Employee Code</td>
|
||||
<td class="detail-separator">:</td>
|
||||
<td class="detail-value">9332</td>
|
||||
<td class="detail-value">{EMP_ID}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="detail-label">Relation</td>
|
||||
<td class="detail-separator">:</td>
|
||||
<td class="detail-value">Self</td>
|
||||
<td class="detail-value">{RELATION}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="detail-label">Policy Period</td>
|
||||
<td class="detail-separator">:</td>
|
||||
<td class="detail-value">1-Apr-2025 to 31-Mar-2026</td>
|
||||
<td class="detail-value">{POLICY_START_DATE} to {POLICY_DATE}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@ -237,16 +246,16 @@
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<div class="logo-left">
|
||||
<img src="{INSURER_LOGO}" alt="Insurer logo">
|
||||
<img src="{INSURER_LOGO}" alt=" " onerror="this.style.visibility='hidden';">
|
||||
</div>
|
||||
<div class="logo-right">
|
||||
<img src="{TPA_LOGO}" alt="TPA logo">
|
||||
<img src="{TPA_LOGO}" alt=" " onerror="this.style.visibility='hidden';">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<div class="n-logo">
|
||||
<img src="{NHANCE_N_LOGO}" alt="N Logo">
|
||||
<img src="{NHANCE_N_LOGO}" alt=" " onerror="this.style.visibility='hidden';">
|
||||
</div>
|
||||
|
||||
<div class="details">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user