diff --git a/app/Config/Routes.php b/app/Config/Routes.php index ede8146b..34478d0c 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -19,7 +19,7 @@ $routes->get("update_rack_rate_json", "ClientController::updateRackRateJson"); $routes->get("updatajson", "EmpDataServiceController::updatajson"); $routes->get("view", "EmployeeController::viewECard/$1"); // $routes->get("exportQCRandRFQ", "LeadsController::exportQCRandRFQ"); - +$routes->get("smapletest", "ClientController::smapletest"); $routes->post("add_advertise_image", "AppContentManagementController::add_advertise_image"); @@ -298,10 +298,10 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) { $routes->get("base_policy_for_policy_inception/(:any)", "PolicyTransactionController::getBasePolicy/$1"); $routes->get("sentTestMail/(:any)", "NotificationController::sentTestMail/$1"); $routes->get("send_manual_reminder/(:any)", "DashboardController::sendManualReminder/$1"); + $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->group("policy_tranction", ["filter" => "authMVC"], function ($routes) { @@ -347,6 +347,7 @@ $routes->group("leads", ["filter" => "authMVC"], function ($routes) { $routes->get("list/(:any)", "LeadsController::getLeadDataForEdit/$1"); $routes->get("sendMail", "LeadsController::sendMailWithAttachement"); $routes->get("exportQCRandRFQ/(:any)", "LeadsController::exportQCRandRFQ/$1"); + $routes->get("featchLeadDataAndInsertClient/(:any)", "LeadsController::featchLeadDataAndInsertClient/$1"); }); $routes->group("rfq", ["filter" => "authMVC"], function ($routes) { @@ -371,12 +372,12 @@ $routes->cli('cli/check_bounce_mail_cli', 'MasterController::testCheckBounceMail $routes->cli('cli/app_check_list', 'MasterController::appCheckList'); $routes->cli('cli/new_gdrive_token', 'GoogleDriveController::generateNewGoogleDriveAccessToken'); - //Employee login api's $routes->post("/employeeRest/verifyEmployeeNumber", "RestAuthenticationController::verifyEmployeeWithMobileNumber"); $routes->post("/employeeRest/getVerifiedUserData", "RestAuthenticationController::getVerifiedUserData"); $routes->post("/employeeRest/verifyMpin", "RestAuthenticationController::verifyMpin"); $routes->post("/employeeRest/checkMpin", "RestAuthenticationController::checkMpin"); + //HR login api's $routes->post("/employeeRest/verifyHrWithMobileNumber", "RestAuthenticationController::verifyHrWithMobileNumber"); $routes->post("/employeeRest/getVerifiedHrData", "RestAuthenticationController::getVerifiedHrData"); @@ -386,9 +387,6 @@ $routes->group("/api", ["filter" => "authJWT"], function ($routes) { $routes->post("getId", "RestAuthenticationController::getUserIdFromToken"); }); - - - $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) { $routes->post("getVerifiedUserData", "RestAuthenticationController::getVerifiedUserData"); @@ -431,17 +429,9 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) { }); $routes->get("sendPushNotification", "EmployeeRestController::sendPushNotification"); - - - - $routes->post("sendEmail", "EmployeeRestController::send_email"); - - - - // Ticketing System // Ticketing System End's diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index c6b3f152..78c8c7a5 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -38,6 +38,7 @@ use App\Models\PolicyTypeModel; use App\Models\PolicyTransactionModel; use App\Models\PolicyTransactionStatusModel; use App\Models\VehicleModel; +use App\Models\LeadsModel; use App\Controllers\EmpDataServiceController; use App\Controllers\GoogleDriveController; @@ -78,6 +79,7 @@ class ClientController extends AdminController protected $policyTransactionModel; protected $policyTransactionStatusModel; protected $vehicleModel; + protected $leadsModel; @@ -113,6 +115,14 @@ class ClientController extends AdminController $this->policyTransactionModel = new PolicyTransactionModel(); $this->policyTransactionStatusModel = new PolicyTransactionStatusModel(); $this->vehicleModel = new VehicleModel(); + $this->leadsModel = new LeadsModel(); + } + + public function smapletest(){ + + $headers = ['S.No','EMP ID','EMP NAME','DOB','GENDER','RELATIONSHIP','SUM INSURED','Date of Leaving','Policy End Date','No Of Days','Premium','Pro Rata Premium','GST','Total','Claim Status','ENDORSEMENT_ID']; + $filePath = generateExcelWithHeader($headers); + echo "Excel file created at: $filePath"; } public function testingForReviewMail($client_id = 77, $emp_code = 'MGL-004', $mail_active = 0) //this function for only tsesting some logics not use for business logic @@ -238,6 +248,7 @@ class ClientController extends AdminController $headerData['page_name'] = 'Client List'; $data['clientList'] = $this->clientModel->getCreatedByUserName(); $data['client_rm'] = $this->clientRMModel->getAllClientRM(); + $data['lead_data'] = $this->leadsModel->getLeadForInsertClientList(); // dd($data); @@ -1705,15 +1716,6 @@ class ClientController extends AdminController } - public function editUploadVehicleFile() {} - - public function listVehicleFiles() {} - - public function deleteVehicleFiles() {} - - - - public function getKycDocsById($id = null) { diff --git a/app/Controllers/DashboardController.php b/app/Controllers/DashboardController.php index bd126144..dfa0841a 100755 --- a/app/Controllers/DashboardController.php +++ b/app/Controllers/DashboardController.php @@ -20,6 +20,7 @@ use App\Models\ClientPolicyModel; use App\Models\NotificationModel; use App\Models\EmployeePolicyModel; use App\Controllers\PendingActionsContrller; +use App\Controllers\EmpDataServiceController; class DashboardController extends AdminController { @@ -544,6 +545,35 @@ class DashboardController extends AdminController } } + public function sendManualEcard($client_id, $client_branch_id, $policy_id) + { + $this->myLogger->logme('error', "sendManualEcard called with client_id: {$client_id}, client_branch_id: {$client_branch_id}, policy id : {$policy_id}"); + + $notification = $this->notificationModel->where('client_id', $client_id)->where('template_name', 'member_ecard_mail')->first(); + // print_r(($notification)); die; + if($notification && $notification['enabled'] == 0 && $notification['mail_content'] == '') + { + return $this->respond(['status' => false, 'code' => 400, 'message' => 'No template found','message2' => 'Failed' ], 200); + } + + $emp_data = $this->employeePolicyModel->getEmployeePolicyForEcard($policy_id); + if(count($emp_data) == 0) + { + return $this->respond(['status' => false, 'code' => 400, 'message' => 'No employees found','message2' => 'Failed' ], 200); + } + $ids = array_column($emp_data, 'id'); + // print_r(($ids)); die; + // print_r($this->clientPolicyModel->getLastQuery()); die; + // $this->myLogger->logme('error', "Policy details fetched: " . json_encode($client_policy_data)); + Jobs::addJob(['job_name' => 'sendMailForDownloadingECard', 'payload' => $ids]); + // $empEmpDataServiceController = new EmpDataServiceController(); + // $empEmpDataServiceController->sendMailForDownloadingECard($ids); + + + return $this->respond(['status' => true, 'code' => 200, 'message' => 'Mail Queued'], 200); + + } + public function data_construct_for_bds($data){ $groupedData = [ diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php index 5cefd249..42fa56e2 100755 --- a/app/Controllers/EmpDataServiceController.php +++ b/app/Controllers/EmpDataServiceController.php @@ -168,19 +168,23 @@ class EmpDataServiceController extends BaseController $cash_balance['balance'] = $balance['opening_bal']; } - - // Calculate the total amount from the objects - $totals = 0; - foreach ($objects as $item) { - $totals = $totals + $item->total; - } - $totals = round($totals, 2); - if (!empty($cash_balance)) { - if ((int) $cash_balance['balance'] < (int) $totals) { - $this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount.'); - $this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount. CASH BALANCE : {balance} and TOTAL AMOUNT : {total}', ['balance' => $cash_balance['balance'], 'total' => $totals]); - return 0; + // Calculate the total amount from the objects + $totals = 0; + foreach ($objects as $item) { + $totals = $totals + $item->total; + } + + $totals = round($totals, 2); + + if($export_data['insurer_or_tpa'] == 'insurer') //check CD amt related issue for only insurer, not tpa + { + if (!empty($cash_balance)) { + if ((int) $cash_balance['balance'] < (int) $totals) { + $this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount.'); + $this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount. CASH BALANCE : {balance} and TOTAL AMOUNT : {total}', ['balance' => $cash_balance['balance'], 'total' => $totals]); + return 0; + } } } @@ -408,7 +412,7 @@ class EmpDataServiceController extends BaseController ], [ 'column_index' => 18, - 'column_name' => 'PR0 RATA PREMIUM', + 'column_name' => 'PRO RATA PREMIUM', 'db_column_name' => 'pro_rata_premium' ], [ @@ -921,18 +925,23 @@ class EmpDataServiceController extends BaseController $cash_balance['balance'] = $balance['opening_bal']; } - // Calculate the total amount from the objects - $totals = 0; - foreach ($inceptionData as $item) { - $totals = $totals + $item->total; - } + - $totals = round($totals, 2); - if (!empty($cash_balance)) { - if ((int) $cash_balance['balance'] < (int) $totals) { - $this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount.'); - $this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount. CASH BALANCE : {balance} and TOTAL AMOUNT : {total}', ['balance' => $cash_balance['balance'], 'total' => $totals]); - return 0; + // Calculate the total amount from the objects + $totals = 0; + foreach ($inceptionData as $item) { + $totals = $totals + $item->total; + } + $totals = round($totals, 2); + + if($export_data['insurer_or_tpa'] != 'tpa')// check overal emp premium amt with cd balance only for insurer export, not tpa export + { + if (!empty($cash_balance)) { + if ((int) $cash_balance['balance'] < (int) $totals) { + $this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount.'); + $this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount. CASH BALANCE : {balance} and TOTAL AMOUNT : {total}', ['balance' => $cash_balance['balance'], 'total' => $totals]); + return 0; + } } } } diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 569f1c65..e5c6a9ab 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -445,28 +445,25 @@ class EmployeeController extends AdminController 'actions' => $actions, 'file_name' => $file_name, ]; - if ($actions == 'export') { - if ($event_type == 'inception' || $event_type == 'addition' || $event_type == 'dependent_addition' || $event_type == 'missed_inception') { + if ($event_type == 'inception' || $event_type == 'addition' || $event_type == 'dependent_addition' || $event_type == 'missed_inception' || ($event_type == 'MultipleEvents' && $insurer_or_tpa == 'tpa')) { $return = $empDataServiceController->generateExcelForAdditionandInception($batch_data); + if ($return === 0) { + session()->setFlashdata('error', "Insufficient deposit amount."); + return redirect()->to(base_url('employee/upload')); - if ($return === 0) { + }else if($return === 5){ - session()->setFlashdata('error', "Insufficient deposit amount."); - return redirect()->to(base_url('employee/upload')); + session()->setFlashdata('error', "The policy does not have a CD account number."); + return redirect()->to(base_url('employee/upload')); + } + else if($return === 6){ - }else if($return === 5){ - - session()->setFlashdata('error', "The policy does not have a CD account number."); - return redirect()->to(base_url('employee/upload')); - } - else if($return === 6){ - - session()->setFlashdata('error', "The Insurer does not have an Excel export template format."); - return redirect()->to(base_url('employee/upload')); - } + session()->setFlashdata('error', "The Insurer does not have an Excel export template format."); + return redirect()->to(base_url('employee/upload')); + } if (!$return) { @@ -1111,6 +1108,7 @@ class EmployeeController extends AdminController $htmlContent = $tmplt_data; $placeholders = [ + '{CLIENT_NAME}' => $value['client_name'], '{TPA_ID}' => $value['tpa_id'], '{NAME}' => $value['name'], '{UHID}' => $value['uhid'], @@ -1417,7 +1415,11 @@ class EmployeeController extends AdminController $excelErrorData['excel_header'] = $excel_data[0]; unset($excel_data[0]); - if($event_type == 'inception' || $event_type == 'deletion'){ + // if($event_type == 'inception' || $event_type == 'deletion'){ + // array_pop($excel_data); + // } + + if($event_type == 'deletion'){ array_pop($excel_data); } diff --git a/app/Controllers/Jobs.php b/app/Controllers/Jobs.php index 56855efd..ad10f86d 100755 --- a/app/Controllers/Jobs.php +++ b/app/Controllers/Jobs.php @@ -49,7 +49,7 @@ class Jobs extends AdminController } $uuid = generate_uuid(); - $jobid = $jobModel->insert(['name' => $payload['job_name'],'uuid' => $uuid,'payload' => json_encode($payload['payload'])]); + $jobid = $jobModel->insert(['name' => $payload['job_name'],'uuid' => $uuid,'payload' => json_encode($payload['payload']), 'status' => isset($payload['status']) ? $payload['status'] : 'queued']); // echo $jobid; $myLogger->logme('error','new job {jobid} added to queue',['jobid' => $jobid]); return ['id' => $jobid,'uuid' => $uuid,'job_name' => $payload['job_name']]; diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index d359c7d9..2d4a68ef 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -215,6 +215,7 @@ class LeadsController extends BaseController 'branch_code' => $data['branch_code'], 'contact_person_name' => $data['contact_person_name'], 'contact_person_mobile' => $data['contact_person_mobile'], + 'contact_person_email' => $data['contact_person_email'], 'client_id' => $data['client_id'] ?? 0, 'client_branch_id' => $data['client_branch_id'] ?? 0, 'source_policy_id' => $data['source_policy_id'] ?? 0, @@ -394,8 +395,10 @@ class LeadsController extends BaseController return $this->respond(['status' => false, 'id' => $result, 'message' => "Failed to create QCR", 'data' =>$data], 200); } + //-----RFQ and QCR EXPORT------------------------------------------------------------------------------------------------ + //export main route function public function exportQCRandRFQ($lead_id, $type, $export_type){ @@ -654,7 +657,8 @@ class LeadsController extends BaseController } - public function getLevelContects(){ + public function getLevelContects() + { $data = $this->levelContactModel->getContectForRFQ(); @@ -667,4 +671,134 @@ class LeadsController extends BaseController } + //----- Featch Lead data and insert Client ------------------------------------------------------------------------------------------- + + + + public function featchLeadDataAndInsertClient($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 Client', 'data' => null], 200); + } + + $result = $this->createClientWithLeadData($data); + + if ($result) { + return $this->respond(['status' => true, 'message' => 'New Client created successfully', 'client_id' => $result, 'data' => $data], 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); + + if ($client_id) { + $this->createClientBranchAndContactWithLeadData($data, $client_id); + } + + return $client_id; + } + + 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'], + ]; + } + + public function createClientBranchAndContactWithLeadData($data, $client_id) + { + $branch_data = $this->prepareClientBranchData($data, $client_id); + $branch_id = $this->clientBranchModel->insert($branch_data); + + if ($branch_id) { + + $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'] ?? ''), '-'); + + return [ + 'client_id' => $client_id, + 'branch_name' => $data['branch_name'], + 'branch_code' => $data['branch_code'], + 'gst' => $data['gst'], + 'units' => json_encode([$default_unit]), + ]; + } + + private function prepareContactData($data, $branch_id) + { + return [ + 'name' => $data['contact_person_name'], + 'mobile' => $data['contact_person_mobile'], + 'email' => $data['contact_person_email'], + 'contact_type' => 'client', + 'ref_id' => $branch_id, + ]; + } + + public function createClientPolicyWithLeadData($data, $client_id, $branch_id) + { + $client_policy_data = $this->prepareClientPolicyData($data, $client_id, $branch_id); + return $this->clientPolicyModel->insert($client_policy_data); + } + + private function prepareClientPolicyData($data, $client_id, $branch_id) + { + $client_policy_data = [ + 'client_id' => $client_id, + 'client_branch_id' => $branch_id, + 'policy_type_id' => $data['policy_type_id'], + 'insurer_id' => $data['insurer_id'], + 'insurer_branch_id' => $data['insurer_branch_id'], + 'tpa_id' => $data['tpa_id'], + 'tpa_branch_id' => $data['tpa_branch_id'], + 'policy_start_date' => $data['policy_start_date'], + 'policy_end_date' => $data['policy_end_date'], + 'policy_status' => 1, + ]; + + $policy_type_id = $data['policy_type_id']; + if (in_array($policy_type_id, [1, 2, 6, 7])) { + $client_policy_data['is_addon'] = 1; // Base Policy + } elseif (in_array($policy_type_id, [4, 5])) { + $client_policy_data['is_addon'] = 2; // SI TOPUP + } elseif ($policy_type_id == 3) { + // if ($base_policy) { + // $data['is_addon'] = 3; // Dependent Addon + // } else { + $data['is_addon'] = 1; + // } + } + + return $client_policy_data; + } + + private function preparePolicyTermsFromRFQ($data) + { + + } + + + } diff --git a/app/Helpers/excel_import_export_helper.php b/app/Helpers/excel_import_export_helper.php index b7eb87c8..3355253e 100755 --- a/app/Helpers/excel_import_export_helper.php +++ b/app/Helpers/excel_import_export_helper.php @@ -972,3 +972,39 @@ if(!function_exists('query_construct_second_stage')){ } } +if (!function_exists('generateExcelWithHeader')) { + /** + * Generate an Excel file with the specified headers + * + * @param array $header The header row for the Excel file + * @param string $filename The name of the Excel file to be created + * @return string Path to the generated Excel file + */ + function generateExcelWithHeader(array $header, string $filename = 'InceptionHeader.xlsx') + { + // Create a new Spreadsheet + $spreadsheet = new Spreadsheet(); + $sheet = $spreadsheet->getActiveSheet(); + + // Set header row + $column = 'A'; + foreach ($header as $headerText) { + $sheet->setCellValue($column . '1', $headerText); + $column++; + } + + // // Style the header row (optional) + // $sheet->getStyle('A1:' . $column . '1')->getFont()->setBold(true); + // $sheet->getStyle('A1:' . $column . '1')->getAlignment()->setHorizontal('center'); + + // Define the file path + $filePath = WRITEPATH . 'uploads/' . $filename; // WRITEPATH is typically for writable directories + + // Save the file + $writer = new Xlsx($spreadsheet); + $writer->save($filePath); + + return $filePath; + } +} + diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php index 18dff3a9..4f265aff 100755 --- a/app/Models/EmployeePolicyModel.php +++ b/app/Models/EmployeePolicyModel.php @@ -157,6 +157,27 @@ class EmployeePolicyModel extends Model return $result->findAll(); } + public function getEmployeePolicyForEcard($policy_id = 0) + { + $result = $this->select([ + 'employee_polices.id' + ]) + ->join('employees emp', 'employee_polices.employee_id = emp.id AND emp.relationship = "Self" '); + if ($policy_id !=0 && !empty($policy_id)) { + $result->where('employee_polices.client_policy_id', $policy_id); + } + // Always check these conditions + $result->where('employee_polices.is_active', 1) + ->where('employee_polices.status', 'active') + ->where('employee_polices.tpa_id is not null') + ->where('emp.relationship','Self'); + + return $result->findAll(); + // $result->findAll(); + // print_r($this->db->getLastQuery());die(); + } + + //for emp onboard do not change public function checkExistingEmpPolicy($arr) { @@ -845,7 +866,7 @@ 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.') AS self, + (SELECT name FROM employees WHERE relationship = "Self" and emp_code = ' . $this->db->escape($emp_code) . ' and client_id = '.$client_id.' LIMIT 1) AS self, ep.tpa_id, @@ -910,7 +931,7 @@ 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.') AS self, + (SELECT name FROM employees WHERE relationship = "Self" and emp_code = ' . $this->db->escape($emp_code) . ' and client_id = '.$client_id.' LIMIT 1) AS self, ep.tpa_id, diff --git a/app/Models/LeadsModel.php b/app/Models/LeadsModel.php index 9de34d05..705f1587 100644 --- a/app/Models/LeadsModel.php +++ b/app/Models/LeadsModel.php @@ -24,6 +24,7 @@ class LeadsModel extends Model 'branch_code', 'contact_person_name', 'contact_person_mobile', + 'contact_person_email', 'client_id', 'client_branch_id', 'source_policy_id', @@ -85,7 +86,8 @@ class LeadsModel extends Model return $data; } - public function getLeadDataForLising(){ + public function getLeadDataForLising() + { return $this->select(' leads.*, @@ -116,6 +118,14 @@ class LeadsModel extends Model ->findAll(); } + + public function getLeadForInsertClientList() + { + return $this + ->where('leads.is_active', 1) + ->where('leads.status', 'won') + ->findAll(); + } } diff --git a/app/Views/client_list.php b/app/Views/client_list.php index 8d015165..e9499095 100755 --- a/app/Views/client_list.php +++ b/app/Views/client_list.php @@ -26,8 +26,11 @@ table.dataTable thead th {

Client List

-
- " type="button" id="btnAdd" class="btn btn-primary waves-effect waves-light" data-toggle="" data-placement="top" title="Add" data-trigger="hover">ADD +
+ Add From Lead +
+
+ " type="button" id="btnAdd" class="btn btn-primary waves-effect waves-light" data-toggle="" data-placement="top" title="Add" data-trigger="hover">Add
+ + + + \ No newline at end of file diff --git a/app/Views/employee_list.php b/app/Views/employee_list.php index d615e7db..fed29d5d 100755 --- a/app/Views/employee_list.php +++ b/app/Views/employee_list.php @@ -70,8 +70,13 @@ table.dataTable tbody td { -
-
+
+
+ + Send Ecard + +
+
" class="btn btn-primary waves-effect waves-light" id="get-emp-list" onclick="fetchEmpolyeeList(event);">Submit @@ -371,4 +376,69 @@ document.getElementById('toggleIcon').addEventListener('click', function() { icon.classList.toggle('mdi-chevron-up'); }); + +function sendManualEcard(input) + { + console.log('sendManualEcard function called'); + + var client_id = $('#clients').val() + var client_branch_id = $('#branch_id').val() + var policy_id = $('#policies').val() + + console.log('input', input); + console.log('client_id', client_id); + console.log('client_branch_id', client_branch_id); + + if(client_id == 0 || client_branch_id == 0 || policy_id == 0) + { + Swal.fire({ + title: "warning!", + text: 'Please select the Client, Client Branch and Policy.', + icon: "warning" + }); + + return false + } + + Swal.fire({ + title: "Do you want to send Ecard Mail?", + showDenyButton: true, + showCancelButton: false, + confirmButtonText: "Yes,Send", + denyButtonText: "Don't Send" + }).then((result) => { + + if (result.isConfirmed) { + + $.ajax({ + url: '' + client_id + '/' + client_branch_id+'/'+policy_id, + type: "GET", + dataType: 'json', + success: function(res) { + + console.log('send_manual_ecard', res) + + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + + if(res.status == false){ + toastr.info(res.message, 'INFO'); + }else{ + toastr.success(res.message, 'SUCCESS'); + } + + }, + error: function(xhr, status, error) { + console.error(xhr.responseText); + console.error(status, error); + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + } + }); + // Swal.fire("Saved!", "", "success"); + } + }); + + } + diff --git a/app/Views/enrollment_list.php b/app/Views/enrollment_list.php index 8459974c..3d37096a 100755 --- a/app/Views/enrollment_list.php +++ b/app/Views/enrollment_list.php @@ -66,7 +66,7 @@
- Search +
@@ -74,17 +74,22 @@ Send Reminder
-
+ -
+ + + + +
+
@@ -713,31 +718,44 @@ return false } - $.ajax({ - url: '' + client_id + '/' + client_branch_id, - type: "GET", - dataType: 'json', - success: function(res) { + Swal.fire({ + title: "Do you want to send reminder mail?", + showDenyButton: true, + showCancelButton: false, + confirmButtonText: "Yes,Send", + denyButtonText: "Don't Send" + }).then((result) => { - console.log('send_manual_reminder', res) + if (result.isConfirmed) { - $('.loader').fadeOut(); - $('.loader-mask').delay(350).fadeOut('slow'); + $.ajax({ + url: '' + client_id + '/' + client_branch_id, + type: "GET", + dataType: 'json', + success: function(res) { - if(res.status == false){ - toastr.info(res.message, 'INFO'); - }else{ - toastr.success(res.message, 'SUCCESS'); + console.log('send_manual_reminder', res) + + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + + if(res.status == false){ + toastr.info(res.message, 'INFO'); + }else{ + toastr.success(res.message, 'SUCCESS'); + } + + }, + error: function(xhr, status, error) { + console.error(xhr.responseText); + console.error(status, error); + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); } - - }, - error: function(xhr, status, error) { - console.error(xhr.responseText); - console.error(status, error); - $('.loader').fadeOut(); - $('.loader-mask').delay(350).fadeOut('slow'); - } - }); + }); + // Swal.fire("Saved!", "", "success"); + } + }); } diff --git a/app/Views/leads_form.php b/app/Views/leads_form.php index 9cb36865..c9caf4c1 100644 --- a/app/Views/leads_form.php +++ b/app/Views/leads_form.php @@ -193,24 +193,30 @@ placeholder="Enter Branch Name" required>
-
+
-
+
-
- +
+
+
+ + +
+
@@ -374,10 +380,9 @@ function getLeadsDataForEdit(input) { $('#gst').val(res.data.gst); $('#branch_name').val(res.data.branch_name); $('#branch_code').val(res.data.branch_code); - $('#contact_person_name').val(res.data - .contact_person_name); - $('#contact_person_mobile').val(res.data - .contact_person_mobile); + $('#contact_person_name').val(res.data.contact_person_name); + $('#contact_person_mobile').val(res.data.contact_person_mobile); + $('#contact_person_email').val(res.data.contact_person_email); $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); @@ -461,6 +466,7 @@ function getBranchData(input) { $('#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); $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); @@ -473,6 +479,7 @@ function getBranchData(input) { $('#branch_code').val(''); $('#contact_person_name').val(''); $('#contact_person_mobile').val(''); + $('#contact_person_email').val(''); console.log(res.message, 'warning'); } @@ -512,6 +519,7 @@ function getPolicyData(input) { $('#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); $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); @@ -524,6 +532,7 @@ function getPolicyData(input) { $('#branch_code').val(''); $('#contact_person_name').val(''); $('#contact_person_mobile').val(''); + $('#contact_person_email').val(''); console.log(res.message, 'warning'); } @@ -827,6 +836,7 @@ $('#lead_type').change(function() { $('#branch_code').val(''); $('#contact_person_name').val(''); $('#contact_person_mobile').val(''); + $('#contact_person_email').val(''); } else { @@ -842,6 +852,7 @@ $('#lead_type').change(function() { $('#branch_code').val(''); $('#contact_person_name').val(''); $('#contact_person_mobile').val(''); + $('#contact_person_email').val(''); $('#client_type').val(''); $('#client_name').val(''); diff --git a/app/Views/view_rfq.php b/app/Views/view_rfq.php index 7c889591..95b5297e 100644 --- a/app/Views/view_rfq.php +++ b/app/Views/view_rfq.php @@ -179,6 +179,17 @@ body { color:red; } +.select2-selection__choice { + background-color: #0a8794 !important; + color: white !important; + font-weight: bold; +} + +.select2-selection__choice__remove { + color: white !important; + margin-right: 5px; +} + @@ -297,13 +308,13 @@ body {
@@ -374,6 +385,7 @@ $(document).ready(function() { $('#submitMail').attr('data-url', mail_url); console.log('RFQ_or_QCR:', RFQ_or_QCR); + }); $(document).ready(function() { @@ -430,13 +442,14 @@ const closeDialogBtn = document.getElementById('closeDialogBtn'); $('.remove-icon').on('click', function() { $('#familyFloaterDialog').css('display', 'none'); }); + var currentThrdottedMenu = ''; var proposal_colum_count = 1; var over_all_column_data = { "Proposal 1": { - "qcr": 0, - "stc": 0, + "qcr": 1, + "stc": 1, 'insurers': [] } }; @@ -468,7 +481,7 @@ function showFamilyFloaterDialogBox(target) { let hiddenInput = target.querySelector('input[type="hidden"]'); // alert(hiddenInput); let inputValue = hiddenInput ? hiddenInput.value : null; - console.log('hidden input value'); + // console.log('hidden input value'); console.log(inputValue); if (inputValue !== null && inputValue !== '') { //get stored familiy composition json if any in hidden input and display it @@ -731,12 +744,23 @@ function addSuggestionsToTable() { // Function to move add row button to last row function moveAddRowButton() { - + + console.log('table', rfqTable) const lastRow = rfqTable.rows[rfqTable.rows.length - 1]; - const actionCell = lastRow.cells[lastRow.cells.length - 1]; - actionCell.innerHTML = - ' QCR Client '; - document.getElementById('addRow').addEventListener('click', addRow); + const actionCell = lastRow.querySelector('.action'); + + if (actionCell && !actionCell.querySelector('#addRow')) { + actionCell.innerHTML += ' '; + document.getElementById('addRow').addEventListener('click', addRow); + } + + // const actionCell = lastRow.cells[lastRow.cells.length - 1]; + // actionCell.innerHTML = + // ' QCR Client '; + // document.getElementById('addRow').addEventListener('click', addRow); + + // const lastRow = rows[rows.length - 1]; + } // Event listener to handle row removal @@ -807,8 +831,8 @@ addQuoteButton.addEventListener('click', function() { //add new proposal in gobal array var new_proposal_array = {} over_all_column_data[new_proposal_name] = { - "ocr": 0, - "stc": 0, + "qcr": 1, + "stc": 1, 'insurers': [] }; console.log(over_all_column_data); @@ -1014,6 +1038,7 @@ function hideSuggestionBox() { } function addRow(e) { + let columnCount = rfqTable.rows[1].cells.length; const newRow = rfqTable.insertRow(); @@ -1254,8 +1279,8 @@ function addInsurer(event) { //add insurer into over all column data pushInsurerInArray(proposal_name, { 'ins_name': (insurerName.split('-')[0]), - 'qcr': 0, - 'stc': 0, + 'qcr': 1, + 'stc': 1, 'display_name': insurerName }); } @@ -1532,6 +1557,9 @@ function checkExistingInsurer(proposal_name, insurer_name) { } function pushInsurerInArray(proposal_name, insurer_arr) { + + console.log('pushInsurerInArray function called'); + proposal_name = proposal_name.trim(); if (over_all_column_data[proposal_name]) { over_all_column_data[proposal_name].insurers.push(insurer_arr); @@ -1646,6 +1674,7 @@ function changeState(event) { console.log(type); if (['qcrProposal', 'sendClientProposal'].includes(type)) { + console.log('Proposal'); const closestTh = event.target.closest('th'); let proposal_name = closestTh.innerText.split('⋮')[0].trim(); @@ -2174,15 +2203,15 @@ function appendInput(data) { const url = '?lead_id=' +lead_id; html = ` -
+
- +
`; if (!data.contact_person_email) { html += ` -
+ `; @@ -2216,7 +2245,13 @@ function appendInput(data) { // Initialize select2 for the dropdown if insurerContact is present if ($('#insurerContact').length) { - $('#insurerContact').select2(); + + $('#insurerContact').select2({ + placeholder: 'Select an insurer', + }); + + $("textarea.select2-search__field").attr('rows', '1'); + $("textarea.select2-search__field").css('resize', 'none'); } } @@ -2274,6 +2309,7 @@ function ajaxRequest(url){ }); } + //-------------------------------------------------------------------------------------------------------------------------------------------- function tableToJson() { @@ -2371,7 +2407,7 @@ function tableToJson() { if (input) { content = input.value; - console.log('hidden input value', content); + // console.log('hidden input value', content); } else { content = cells[dataIndex].innerText; } @@ -2443,10 +2479,12 @@ function tableToJson() { }); localStorage.setItem('data', d); + console.log({ headers, data }); + jsonToTable(JSON.parse(d)); } @@ -2605,7 +2643,7 @@ function jsonToTable(json) { }); }); - console.log('proposel_color_count', proposel_color_count); + // console.log('proposel_color_count', proposel_color_count); thead.appendChild(parentHeaderRow); thead.appendChild(subHeaderRow); @@ -2712,6 +2750,8 @@ function jsonToTable(json) { $(document).ready(function () { $('#submitData').on('click', async function () { + console.log(over_all_column_data); + try { // $('.loader').fadeIn(); @@ -2769,8 +2809,11 @@ function jsonToTable(json) { }); }); - $(document).ready(function () { + $(document).ready(function () { $('#submitQCRData').on('click', async function () { + + console.log(over_all_column_data); + try { $('.loader').fadeIn(); @@ -2829,7 +2872,6 @@ function jsonToTable(json) { async function tableToJsonForFormSubmit() { return new Promise((resolve) => { - const headers = []; const data = []; const table = document.getElementById('rfqTable'); @@ -2870,7 +2912,9 @@ function jsonToTable(json) { header.subHeaders.forEach(subHeader => { const cell = cells[dataIndex]; let content = cells[dataIndex]?.innerText || ''; - const inputType = suggestions[rowId]['type']; + + // Ensure suggestions[rowId] exists + const inputType = suggestions[rowId]?.type; // Handle 'text' input types if (inputType === "text") { @@ -2883,11 +2927,9 @@ function jsonToTable(json) { }; } else { const input = cell.querySelector('input'); - // console.log('input cell', input) - if (input) { content = input.value; - console.log('hidden input value', content); + // console.log('hidden input value', content); } else { content = cells[dataIndex].innerText; } @@ -2945,10 +2987,13 @@ function jsonToTable(json) { const first_json = JSON.parse(JSON.stringify(json)); // Deep copy console.log("Original JSON:", json); + let rowIndexArray = []; + let rowIndexArray2 = []; + // Column-wise Check: Remove headers and relevant data if qcr == 0 Object.entries(json.proposal_data.over_all_column_data).forEach(([proposalKey, proposalData], index) => { - console.log(index); + // console.log('over_all_column_data index', index); if (proposalData.qcr == 0 || proposalData.qcr == false) { @@ -2956,42 +3001,75 @@ function jsonToTable(json) { const headerIndex = first_json.table_data.headers.findIndex(header => header.parentHeader === proposalKey); if (headerIndex !== -1) first_json.table_data.headers.splice(headerIndex, 1); - // Remove data entries with matching parentth - Object.values(first_json.table_data.data).forEach(dataEntry => { - const dataArray = dataEntry.data; - if (dataArray) { - const dataIndex = dataArray.findIndex(dataItem => dataItem.parentth === proposalKey); - if (dataIndex !== -1) dataArray.splice(dataIndex, 1); - } + first_json.table_data.data.forEach(item => { + item.data = item.data.filter(entry => entry.parentth !== proposalKey); }); + // Remove data entries with matching parentth + // Object.values(first_json.table_data.data).forEach(dataEntry => { + // const dataArray = dataEntry.data; + // if (dataArray) { + // const dataIndex = dataArray.findIndex(dataItem => dataItem.parentth === proposalKey); + // if (dataIndex !== -1) dataArray.splice(dataIndex, 1); + // } + // }); + // Remove proposalKey from over_all_column_data - // console.log() // Object.entries(first_json.proposal_data.over_all_column_data).splice(index, 1); + + + const updatedData = Object.keys(first_json.proposal_data.over_all_column_data) + .filter(key => key !== proposalKey) + .reduce((acc, key) => { + acc[key] = first_json.proposal_data.over_all_column_data[key]; + return acc; + }, {}); + + // Assign the updated data back if needed + first_json.proposal_data.over_all_column_data = updatedData; } // Insurer Check: Remove subHeaders and relevant data for insurers with qcr == 0 proposalData.insurers.forEach((insurer, insurerIndex) => { - if (insurer.qcr === 0) { + // console.log('insurer', insurer) + if (insurer.qcr === 0 || insurer.qcr == false) { + + console.log(insurer.qcr) + first_json.table_data.headers.forEach(header => { const subHeaderIndex = header.subHeaders.findIndex(sub => sub === insurer.display_name); if (subHeaderIndex !== -1) header.subHeaders.splice(subHeaderIndex, 1); }); - Object.values(first_json.table_data.data).forEach(dataEntry => { - const dataArray = dataEntry.data; - if (dataArray) { - const dataIndex = dataArray.findIndex(dataItem => dataItem.subth === insurer.display_name); - if (dataIndex !== -1) dataArray.splice(dataIndex, 1); - } + first_json.table_data.data.forEach(item => { + item.data = item.data.filter(entry => entry.subth !== insurer.display_name); }); + // Object.values(first_json.table_data.data).forEach(dataEntry => { + // const dataArray = dataEntry.data; + // if (dataArray) { + // const dataIndex = dataArray.findIndex(dataItem => dataItem.subth === insurer.display_name); + // if (dataIndex !== -1) dataArray.splice(dataIndex, 1); + // } + // }); + // Remove insurer from proposal's insurers array + console.log('insurerIndex', insurerIndex) first_json.proposal_data.over_all_column_data[proposalKey].insurers.splice(insurerIndex, 1); } + }); }); + // rowIndexArray.sort((a, b) => b - a); + + // rowIndexArray2.forEach((index) => { + // rowIndexArray.forEach((index2) => { + // first_json.table_data.data[index].data.splice(index2, 1); + // }) + // }); + + // Row-wise Check: Remove rows if qcr == 0 for actions Object.entries(first_json.table_data.data).forEach(([rowKey, rowData]) => { const actionData = rowData.data.find(data => data.parentth === "Action" && data.input_value.qcr === 0);