FIX_BDS_HIDE_AND_SHOW_ISSUE_AND_SENMAIL_NOTIFICATION_FUNCTION_TEST_FUNCTION_AND_OTHRS : RV

This commit is contained in:
VENKATESHWARAN 2024-10-15 14:42:46 +05:30
parent 34402b8568
commit 46278b9f94
5 changed files with 1014 additions and 649 deletions

View File

@ -12,7 +12,8 @@ $routes->get('/swagger', 'SwaggerController::index', ['filter' => 'authMVC']);
// Reminder Mail Notification // Reminder Mail Notification
$routes->get("reminder_mail", "NotificationController::reminder_mail"); $routes->get("reminder_mail", "NotificationController::reminder_mail");
$routes->get("testing", "ClientController::Testing"); // $routes->get("testing", "ClientController::Testing");
$routes->get("testing_for_review_mail/(:any)", "ClientController::testingForReviewMail/$1");
$routes->get("update-policy-terms-for-corrections", "ClientController::updatePolicyTermsForCorrections"); $routes->get("update-policy-terms-for-corrections", "ClientController::updatePolicyTermsForCorrections");
$routes->get("update_rack_rate_json", "ClientController::updateRackRateJson"); $routes->get("update_rack_rate_json", "ClientController::updateRackRateJson");
$routes->get("updatajson", "EmpDataServiceController::updatajson"); $routes->get("updatajson", "EmpDataServiceController::updatajson");

View File

@ -115,23 +115,47 @@ class ClientController extends AdminController
$this->vehicleModel = new VehicleModel(); $this->vehicleModel = new VehicleModel();
} }
public function Testing() //this function for only tsesting some logics not use for business logic 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
{ {
$emp_code = 'MGL-004';
$client_id = 77;
$client_policy_id = 205;
$array_list = [];
$find = $this->employeeModel->getEmpFamilybyEmpCode(client_policy_id: $client_policy_id, emp_code: $emp_code, client_id: $client_id, emp_status: ['draft', 'enrolled'], policy_status: ['draft', 'enrolled']); $client_policy_ids = $this->employeeModel
->select('employee_polices.client_policy_id')
->join('employee_polices', 'employees.id = employee_polices.employee_id')
->where('employees.client_id', $client_id )
->where('employees.emp_code', $emp_code )
->where('employee_polices.is_active', 1 )
->where('employees.is_active', 1 )
->findAll();
$client_policy_ids2 = array_column($client_policy_ids, 'client_policy_id');
$client_policy_id = array_unique($client_policy_ids2);
// echo '<pre>';
// dd($client_policy_id);
// print_r($unique_policy_ids); die;
// sort($client_policy_id);
$wholeData = '';
$mail_send_return = '';
$mail_send_return1 = '';
$mail_send_return2 = '';
if (!is_null($client_policy_id) && is_array($client_policy_id))
{
$array_list = [];
foreach ($client_policy_id as $key => $value)
{
$find = $this->employeeModel->getEmpFamilybyEmpCode(client_policy_id: $value,emp_code: $emp_code,client_id: $client_id,emp_status:['draft','enrolled'],policy_status:['draft','enrolled']);
if(count($find) > 0){ if(count($find) > 0){
$array_list[] = $find; $array_list[] = $find;
} }
}
// dd($array_list); // dd($array_list);
$notification = $this->notificationModel->where('client_id' ,$client_id)->where('template_name', 'member_review_and_summary_mail')->first(); $notification = $this->notificationModel->where('client_id' ,$client_id)->where('template_name', 'member_review_and_summary_mail')->first();
// dd($notification);
if (isset($notification) && $notification['enabled'] == 1) { if (isset($notification) && $notification['enabled'] == 1) {
@ -141,46 +165,71 @@ class ClientController extends AdminController
$params ['client_id'] = $client_id; $params ['client_id'] = $client_id;
$params ['notification'] = $notification; $params ['notification'] = $notification;
// print_r($params);die; // dd($params);
$wholeData =sendMailNotification::sendMailNotification('member_review_and_summary_mail', $params); $wholeData =sendMailNotification::sendMailNotification('member_review_and_summary_mail', $params);
// print_r($wholeData); die; // print_r($wholeData); die;
if($mail_active > 0){
$mail_send_return = MailHelper::send_email($wholeData[0]); $mail_send_return = MailHelper::send_email($wholeData[0]);
$this->myLogger->logme("info", $mail_send_return); $this->myLogger->logme("info", $mail_send_return);
}
if (isset($wholeData[0])) { if (isset($wholeData[0])) {
$account_manager_wholeData =sendMailNotification::sendMailNotification('account_maneger_summary_mail', $params); $account_manager_wholeData =sendMailNotification::sendMailNotification('account_maneger_summary_mail', $params);
// print_r($account_manager_wholeData); die; // print_r($account_manager_wholeData); die;
if ($account_manager_wholeData) { if($account_manager_wholeData != null && $account_manager_wholeData != '' && count($account_manager_wholeData))
{
if($mail_active > 0){
foreach ($account_manager_wholeData as $key => $value) { foreach ($account_manager_wholeData as $key => $value) {
$mail_send_return1 = MailHelper::send_email($value); $mail_send_return1 = MailHelper::send_email($value);
$this->myLogger->logme("info", $mail_send_return1); $this->myLogger->logme("info", $mail_send_return1);
$this->myLogger->logme("info", $mail_send_return1);
} }
}
}else{
$this->myLogger->logme("error", 'Account Manager Mail Configuration not Enable for this client');
} }
$client_hr_wholeData =sendMailNotification::sendMailNotification('client_hr_summary_mail', $params); $client_hr_wholeData =sendMailNotification::sendMailNotification('client_hr_summary_mail', $params);
// print_r($client_hr_wholeData); die; // print_r($client_hr_wholeData); die;
if ($client_hr_wholeData) { if($client_hr_wholeData != null && $client_hr_wholeData != '' &&count($client_hr_wholeData))
{
if($mail_active > 0){
foreach ($client_hr_wholeData as $key => $value) { foreach ($client_hr_wholeData as $key => $value) {
$mail_send_return2 = MailHelper::send_email($value); $mail_send_return2 = MailHelper::send_email($value);
$this->myLogger->logme("info", $mail_send_return2); $this->myLogger->logme("info", $mail_send_return2);
} }
} }
}else{
$this->myLogger->logme("error", 'Client HR Mail Configuration not Enable for this client');
} }
} }
}else{
$this->myLogger->logme("error", 'Member Review Mail Configuration not Enable for this client');
}
return $this->respond(['status' => 'success', 'code' => 200, 'data' => []], 200); }
print_r($wholeData);
echo '<pre>';
echo '<h3>member_review_and_summary_mail</h3> <br><br>';
print_r($mail_send_return);
echo '<h3>account_maneger_summary_mail</h3> <br><br>';
print_r($mail_send_return1);
echo '<h3>client_hr_summary_mail</h3> <br><br>';
print_r($mail_send_return2);
// return $this->respond(['status' => 'success','code' => 200,'data' => [] ], 200);
} }
public function index() public function index()

View File

@ -180,14 +180,6 @@ class sendMailNotification
$client_data =$clientModel->where('id', $client_id)->first(); $client_data =$clientModel->where('id', $client_id)->first();
$notification_data = $notificationModel->where('client_id' ,$client_id)->where('template_name', $action)->first(); $notification_data = $notificationModel->where('client_id' ,$client_id)->where('template_name', $action)->first();
$client_policy_data = $clientPolicyModel->where('id', $client_policy_id)->first();
if($client_policy_data['policy_type_id'] == 1 || $client_policy_data['policy_type_id'] == 6 || $client_policy_data['policy_type_id'] == 7 ){
$policy_premium_data = $PolicyPremium1Model->where('client_policy_id', $client_policy_id)->first();
}else{
$policy_premium_data = $PolicyPremium2Model->where('client_policy_id', $client_policy_id)->first();
}
// dd($notification_data); // dd($notification_data);
if (isset($notification_data) && $notification_data['enabled'] == 1) { if (isset($notification_data) && $notification_data['enabled'] == 1) {
@ -230,10 +222,20 @@ class sendMailNotification
foreach ($item as $inner_item) { foreach ($item as $inner_item) {
//getting policy premium data
$client_policy_data = $clientPolicyModel->where('id', $inner_item['client_policy_id'])->first();
if($client_policy_data['policy_type_id'] == 1 || $client_policy_data['policy_type_id'] == 6 || $client_policy_data['policy_type_id'] == 7 ){
$policy_premium_data = $PolicyPremium1Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first();
}else{
$policy_premium_data = $PolicyPremium2Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first();
}
//end of getting policy premium data
$policy_name = $inner_item['policy_name']; $policy_name = $inner_item['policy_name'];
if ($inner_item['relationship'] == 'Self') { if ($inner_item['relationship'] == 'Self') {
$emp_code = ' (' . $inner_item['emp_code'] . ')'; $emp_code = ' (' . $inner_item['emp_code'] . ')';
$mail = $inner_item['email_corporate'];
} else { } else {
$emp_code = ''; $emp_code = '';
} }
@ -385,14 +387,6 @@ class sendMailNotification
$client_data =$clientModel->where('id', $client_id)->first(); $client_data =$clientModel->where('id', $client_id)->first();
$notification_data = $notificationModel->where('client_id' ,$client_id)->where('template_name', $action)->first(); $notification_data = $notificationModel->where('client_id' ,$client_id)->where('template_name', $action)->first();
$client_policy_data = $clientPolicyModel->where('id', $client_policy_id)->first();
if($client_policy_data['policy_type_id'] == 1 || $client_policy_data['policy_type_id'] == 6 || $client_policy_data['policy_type_id'] == 7 ){
$policy_premium_data = $PolicyPremium1Model->where('client_policy_id', $client_policy_id)->first();
}else{
$policy_premium_data = $PolicyPremium2Model->where('client_policy_id', $client_policy_id)->first();
}
if (isset($notification_data) && $notification_data['enabled'] == 1) { if (isset($notification_data) && $notification_data['enabled'] == 1) {
$client_rm_data= $clientRMModel->where('client_id', $client_id)->where('is_active',1)->findAll(); $client_rm_data= $clientRMModel->where('client_id', $client_id)->where('is_active',1)->findAll();
@ -436,6 +430,15 @@ class sendMailNotification
foreach ($item as $inner_item) { foreach ($item as $inner_item) {
//getting policy premium data
$client_policy_data = $clientPolicyModel->where('id', $inner_item['client_policy_id'])->first();
if($client_policy_data['policy_type_id'] == 1 || $client_policy_data['policy_type_id'] == 6 || $client_policy_data['policy_type_id'] == 7 ){
$policy_premium_data = $PolicyPremium1Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first();
}else{
$policy_premium_data = $PolicyPremium2Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first();
}
//end of getting policy premium data
$policy_name = $inner_item['policy_name']; $policy_name = $inner_item['policy_name'];
if ($inner_item['relationship'] == 'Self') { if ($inner_item['relationship'] == 'Self') {
@ -588,17 +591,8 @@ class sendMailNotification
$notification_data = $notificationModel->where('client_id' ,$client_id)->where('template_name', $action)->first(); $notification_data = $notificationModel->where('client_id' ,$client_id)->where('template_name', $action)->first();
$clientRMModel =new ClientRMModel(); $clientRMModel =new ClientRMModel();
$client_policy_data = $clientPolicyModel->where('id', $client_policy_id)->first();
if($client_policy_data['policy_type_id'] == 1 || $client_policy_data['policy_type_id'] == 6 || $client_policy_data['policy_type_id'] == 7 ){
$policy_premium_data = $PolicyPremium1Model->where('client_policy_id', $client_policy_id)->first();
}else{
$policy_premium_data = $PolicyPremium2Model->where('client_policy_id', $client_policy_id)->first();
}
if (isset($notification_data['enabled']) && $notification_data['enabled'] == 1) { if (isset($notification_data['enabled']) && $notification_data['enabled'] == 1) {
$client_rm_data= $clientRMModel->where('client_id', $client_id)->where('is_active',1)->findAll(); $client_rm_data= $clientRMModel->where('client_id', $client_id)->where('is_active',1)->findAll();
$user_list= []; $user_list= [];
foreach ($client_rm_data as $key => $value) { foreach ($client_rm_data as $key => $value) {
@ -641,6 +635,16 @@ class sendMailNotification
$is_addon = ''; $is_addon = '';
foreach ($item as $inner_item) { foreach ($item as $inner_item) {
//getting policy premium data
$client_policy_data = $clientPolicyModel->where('id', $inner_item['client_policy_id'])->first();
if($client_policy_data['policy_type_id'] == 1 || $client_policy_data['policy_type_id'] == 6 || $client_policy_data['policy_type_id'] == 7 ){
$policy_premium_data = $PolicyPremium1Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first();
}else{
$policy_premium_data = $PolicyPremium2Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first();
}
//end of getting policy premium data
$policy_name = $inner_item['policy_name']; $policy_name = $inner_item['policy_name'];
if ($inner_item['relationship'] == 'Self') { if ($inner_item['relationship'] == 'Self') {

View File

@ -361,6 +361,9 @@
<tr id="table_tr_13"> <tr id="table_tr_13">
<td>Total</td> <td>Total</td>
</tr> </tr>
<?php if (in_array(FINANCE_TEAM_ID, user_team())) { ?>
<tr id="table_tr_14"> <tr id="table_tr_14">
<td>Agreed BP %</td> <td>Agreed BP %</td>
</tr> </tr>
@ -418,9 +421,14 @@
<tr id="table_tr_32"> <tr id="table_tr_32">
<td>Reward</td> <td>Reward</td>
</tr> </tr>
<?php } ?>
<tr id="table_tr_33" style="display: none;"> <tr id="table_tr_33" style="display: none;">
<td></td> <td></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>
@ -451,9 +459,21 @@
<script> <script>
var team_id = [];
$(document).ready(function(){ $(document).ready(function(){
team_id = <?php echo json_encode(user_team()); ?>;
console.log('team_id', team_id);
if (team_id.includes('4')) {
console.log('Finance Team Logged in.');
} else if (team_id.includes('3')) {
console.log('Business Team Logged in.');
}
getURLParamsForReport() getURLParamsForReport()
hidePermiumDetailsBasedOnTheTeam() // hidePermiumDetailsBasedOnTheTeam()
}) })
$(document).ready(function(){ $(document).ready(function(){
@ -1335,7 +1355,7 @@ $('#setInsurerCount').on('input', function() {
function addInsurerColumn() { function addInsurerColumn() {
insurerCount++; insurerCount++;
hidePermiumDetailsBasedOnTheTeam(); // hidePermiumDetailsBasedOnTheTeam();
// Update header // Update header
$('#insurerTable thead tr').append(` $('#insurerTable thead tr').append(`
@ -1349,6 +1369,7 @@ function addInsurerColumn() {
$('#insurerTable tbody tr').each(function(index) { $('#insurerTable tbody tr').each(function(index) {
let newCell = ''; let newCell = '';
if(team_id.includes('4')){
switch(index) { switch(index) {
case 0: // Insurer selection case 0: // Insurer selection
newCell = `<td> newCell = `<td>
@ -1465,7 +1486,70 @@ function addInsurerColumn() {
newCell = `<td><input type="hidden" name="co_share_id[]" id="co_share_id[]" onkeypress="return onlyNumbers(event)"></td>`; newCell = `<td><input type="hidden" name="co_share_id[]" id="co_share_id[]" onkeypress="return onlyNumbers(event)"></td>`;
break; break;
} }
}else if(team_id.includes('3')){
switch(index) {
case 0: // Insurer selection
newCell = `<td>
<select class="form-control follow_insurer readonly-select" data-count="${insurerCount}" id="follow_insurer_id_${insurerCount}" name="follow_insurer_id[]">
<option value="" selected>Select Insurer</option>
<?php foreach ($insurer_branch as $value) { ?>
<option value="<?= $value['id'] . '-' . $value['insurer_id'] ?>" data-id="<?= $value['insurer_id'] ?>" data-bid="<?= $value['id'] ?>">
<?= $value['insurer_name'] . '-' . $value['branch_code'] ?>
</option>
<?php } ?>
</select>
</td>`;
break;
case 1: // Is Leader?
newCell = `<td>
<label class="switch" style="position: relative; top: 5px; left: 35px;">
<input data-id="${insurerCount}" id="co_share_type_${insurerCount}" type="checkbox" name="co_share_type[]">
<span class="slider round" style="height: 27px;"></span>
</label>
<label for="inception_type" style="position: relative; top: 5px; left: 40px;">Leader Yes</label>
</td>`;
break;
case 2: // Co-Share %
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" name="co_share_per[]" oninput="validateRange(this)" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 3: // Base Premium
newCell = `<td><input type="text" class="right-align-input" id="base_premium_${insurerCount}" name="base_premium[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 4: // TP Premium
newCell = `<td><input type="text" class="right-align-input" id="tp_premium_${insurerCount}" name="tp_premium[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 5: // Ter Premium
newCell = `<td><input type="text" class="right-align-input" id="ter_premium_${insurerCount}" name="ter_premium[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 6: // co Premium
newCell = `<td><input type="text" class="right-align-input" id="co_premium_${insurerCount}" name="co_premium[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 7: // CGST
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="cgst_${insurerCount}" name="cgst[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 8: // SGST
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="sgst_${insurerCount}" name="sgst[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 9: // IGST
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="igst_${insurerCount}" name="igst[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 10: // GST Amount
newCell = `<td><input type="text" class="readonly-color right-align-input" id="gst_amount_${insurerCount}" name="gst_amount[]" oninput="amountCalculation('${insurerCount}')" readonly onkeypress="return onlyNumbers(event)"></td>`;
break;
case 11: // Stamp Duty
newCell = `<td><input type="text" class="right-align-input" id="stamp_duty_${insurerCount}" name="stamp_duty[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 12: // Total
newCell = `<td><input type="text" class="readonly-color right-align-input" id="total_amt_${insurerCount}" name="total[]" readonly onkeypress="return onlyNumbers(event)"></td>`;
break;
case 13: // Agreed BP %
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="agreed_bp_${insurerCount}" name="agreed_bp[]" oninput="amountCalculation('${insurerCount}'); validateRange(this)" onkeypress="return onlyNumbers(event)" ></td>`;
break;
case 14: // ID For Update
newCell = `<td><input type="hidden" name="co_share_id[]" id="co_share_id[]" onkeypress="return onlyNumbers(event)"></td>`;
break;
}
}
// console.log(newCell); // console.log(newCell);
$(this).append(newCell); $(this).append(newCell);
@ -1578,6 +1662,7 @@ function populateTable(dataArray, status = false) {
let insurer = data.insurer_branch_id + '-' + data.insurer_id; let insurer = data.insurer_branch_id + '-' + data.insurer_id;
if(team_id.includes('4')){
switch (rowIndex) { switch (rowIndex) {
case 0: // Insurer selection case 0: // Insurer selection
cell.find('select').val(insurer); cell.find('select').val(insurer);
@ -1679,6 +1764,55 @@ function populateTable(dataArray, status = false) {
cell.find('input[type="hidden"]').val(status ? data.id : ''); cell.find('input[type="hidden"]').val(status ? data.id : '');
break; break;
} }
}else if(team_id.includes('3')){
switch (rowIndex) {
case 0: // Insurer selection
cell.find('select').val(insurer);
break;
case 1: // Is Leader?
cell.find('input[type="checkbox"]').prop('checked', data.co_share_type === '1');
break;
case 2: // Co-Share %
cell.find('input').val(data.co_share_per);
break;
case 3: // Base Premium
cell.find('input').val(status ? data.bp_amt : '');
break;
case 4: // TP Premium
cell.find('input').val(status ? data.tp_amt : '');
break;
case 5: // Ter Premium
cell.find('input').val(status ? data.tep_amt : '');
break;
case 6: // Co Premium
cell.find('input').val(data.cop_amt);
break;
case 7: // CGST
cell.find('input').val(data.bp_cgst);
break;
case 8: // SGST
cell.find('input').val(data.bp_sgst);
break;
case 9: // IGST
cell.find('input').val(data.bp_igst);
break;
case 10: // GST Amount
cell.find('input').val(status ? data.bp_gst_amt : '');
break;
case 11: // Stamp Duty
cell.find('input').val(status ? data.stamp_duty : '');
break;
case 12: // Total
cell.find('input').val(status ? data.amount : '');
break;
case 13: // Agreed BP %
cell.find('input').val(data.agreed_bp_per);
break;
case 14: // Co-share ID (hidden field)
cell.find('input[type="hidden"]').val(status ? data.id : '');
break;
}
}
}); });
}); });
} }

View File

@ -633,6 +633,9 @@
<tr id="table_tr_13"> <tr id="table_tr_13">
<td>Total</td> <td>Total</td>
</tr> </tr>
<?php if (in_array(FINANCE_TEAM_ID, user_team())) { ?>
<tr id="table_tr_14"> <tr id="table_tr_14">
<td>Agreed BP %</td> <td>Agreed BP %</td>
</tr> </tr>
@ -690,6 +693,9 @@
<tr id="table_tr_32"> <tr id="table_tr_32">
<td>Reward</td> <td>Reward</td>
</tr> </tr>
<?php } ?>
<tr id="table_tr_33" style="display: none;"> <tr id="table_tr_33" style="display: none;">
<td></td> <td></td>
</tr> </tr>
@ -971,9 +977,20 @@
<script> <script>
var team_id = [];
$(document).ready(function(){ $(document).ready(function(){
hidePermiumDetailsBasedOnTheTeam() // hidePermiumDetailsBasedOnTheTeam()
team_id = <?php echo json_encode(user_team()); ?>;
console.log('team_id', team_id);
if (team_id.includes('4')) {
console.log('Finance Team Logged in.');
} else if (team_id.includes('3')) {
console.log('Business Team Logged in.');
}
$('#listed_insurers').select2({ $('#listed_insurers').select2({
placeholder: "Select Insurers", // Placeholder for a better UX placeholder: "Select Insurers", // Placeholder for a better UX
@ -1080,7 +1097,7 @@ $(document).ready(function(){
$('#policy_type_id').change(function() { $('#policy_type_id').change(function() {
hidePermiumDetailsBasedOnTheTeam(); // hidePermiumDetailsBasedOnTheTeam();
$('#client_type').val(''); $('#client_type').val('');
$('#client_id').val('').select2(); $('#client_id').val('').select2();
@ -1148,7 +1165,7 @@ $(document).ready(function(){
$('#client_branch_id').removeClass('readonly-select ').select2(); $('#client_branch_id').removeClass('readonly-select ').select2();
} }
hidePermiumDetailsBasedOnTheTeam(); // hidePermiumDetailsBasedOnTheTeam();
}); });
}) })
@ -1439,7 +1456,7 @@ function getPolicyTransactionDataForEdit(input) {
setTimeout(function() { setTimeout(function() {
$('#cd_ac_no').val(res.data.cd_ac_no); $('#cd_ac_no').val(res.data.cd_ac_no);
$('#client_branch_id').val(res.data.client_branch_id).select2(); $('#client_branch_id').val(res.data.client_branch_id).change();
$('#source_client_policy_id').val(res.data.source_client_policy_id).change(); $('#source_client_policy_id').val(res.data.source_client_policy_id).change();
$('#base_policy').val(res.data.base_policy).select2(); $('#base_policy').val(res.data.base_policy).select2();
//console.log('---------------------------------------------------------------') //console.log('---------------------------------------------------------------')
@ -1720,7 +1737,7 @@ function actualAmountCalculation(input, field = null){
console.log('actualAmountCalculation function input', input) console.log('actualAmountCalculation function input', input)
console.log('actualAmountCalculation function field', field) console.log('actualAmountCalculation function field', field)
let selectedOption = $('#client_policy_id').find('option:selected'); let selectedOption = $('#policy_type_id').find('option:selected');
let bap = selectedOption.data('bap'); let bap = selectedOption.data('bap');
console.log('actualAmountCalculation function bap', bap) console.log('actualAmountCalculation function bap', bap)
@ -2141,11 +2158,16 @@ function getCDAccountNumber(input)
$('#cd_ac_no').val(res.data[0].cd_ac_no) $('#cd_ac_no').val(res.data[0].cd_ac_no)
} }
}else{ }else{
var pt_id = $('#policy_tranction_primarykey').val();
if(pt_id == ''){
toastr.warning('The insurer does not has a CD account number'); toastr.warning('The insurer does not has a CD account number');
}
console.log('The insurer does not has a CD account number');
$('#cd_ac_no_'+unique_id).empty(); $('#cd_ac_no_'+unique_id).empty();
$('#cd_ac_no_'+unique_id).append($('<option>', { $('#cd_ac_no_'+unique_id).append($('<option>', {
value: '', value: '',
text: 'Select Policy', text: 'Select CD No',
})); }));
$('#cd_ac_no_'+unique_id).append($('<option>', { $('#cd_ac_no_'+unique_id).append($('<option>', {
value: 'add_cd', value: 'add_cd',
@ -2301,6 +2323,31 @@ function hidePermiumDetailsBasedOnTheTeam(){
} }
} }
function removeAllColumnsExceptFirst(tableId) {
console.log('######################################')
console.log('removeAllColumnsExceptFirst function called');
console.log('######################################');
// Remove all headers except the first one
$('#' + tableId + ' thead tr th').each(function(index) {
if (index > 0) { // Keep the first column (index 0)
$(this).remove();
}
});
// Remove corresponding data cells in each row except the first one
$('#' + tableId + ' tbody tr').each(function() {
$(this).find('td').each(function(index) {
if (index > 0) { // Keep the first column (index 0)
$(this).remove();
}
});
});
insurerCount = 0;
}
//--------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------
function convertToMySQLDate(dateString) { function convertToMySQLDate(dateString) {
@ -2316,7 +2363,6 @@ function convertToMySQLDate(dateString) {
return ''; return '';
} }
function convertMonthYearToMySQLDate(dateString) { function convertMonthYearToMySQLDate(dateString) {
// console.log('convertMonthYearToMySQLDate' + dateString); // console.log('convertMonthYearToMySQLDate' + dateString);
if(dateString !== "" && dateString !== undefined) if(dateString !== "" && dateString !== undefined)
@ -2839,12 +2885,16 @@ $('#Owner_type').on('change', function() {
$('#policy_status').change(function(){ $('#policy_status').change(function(){
var pt_id = $('#policy_tranction_primarykey').val();
var status = $(this).val() var status = $(this).val()
var policy_type_id = $('#policy_type_id').val() var policy_type_id = $('#policy_type_id').val()
var client_id = $('#client_id').val(); var client_id = $('#client_id').val();
var client_branch_id = $('#client_branch_id').val(); var client_branch_id = $('#client_branch_id').val();
if(status == 'completed'){ if(status == 'completed'){
if(pt_id == ''){
removeAllColumnsExceptFirst('insurerTable');
}
addInsurerColumn() ; addInsurerColumn() ;
$('#sales_row').show(); $('#sales_row').show();
$('#policy_no').prop('required', true); $('#policy_no').prop('required', true);
@ -2963,7 +3013,7 @@ $('#setInsurerCount').on('input', function() {
function addInsurerColumn() { function addInsurerColumn() {
insurerCount++; insurerCount++;
hidePermiumDetailsBasedOnTheTeam() // hidePermiumDetailsBasedOnTheTeam()
// Update header // Update header
$('#insurerTable thead tr').append(` $('#insurerTable thead tr').append(`
@ -2977,6 +3027,9 @@ function addInsurerColumn() {
$('#insurerTable tbody tr').each(function(index) { $('#insurerTable tbody tr').each(function(index) {
let newCell = ''; let newCell = '';
if(team_id.includes('4')){
switch(index) { switch(index) {
case 0: // Insurer selection case 0: // Insurer selection
newCell = `<td> newCell = `<td>
@ -3103,6 +3156,78 @@ function addInsurerColumn() {
} }
}else if(team_id.includes('3')){
switch(index) {
case 0: // Insurer selection
newCell = `<td>
<select class="form-control follow_insurer" data-count="${insurerCount}" id="follow_insurer_id_${insurerCount}" name="follow_insurer_id[]" onchange="getCDAccountNumber(this)">
<option value="" selected>Select Insurer</option>
<?php foreach ($insurer_branch as $value) { ?>
<option value="<?= $value['id'] . '-' . $value['insurer_id'] ?>" data-id="<?= $value['insurer_id'] ?>" data-bid="<?= $value['id'] ?>">
<?= $value['insurer_name'] . '-' . $value['branch_code'] ?>
</option>
<?php } ?>
</select>
</td>`;
break;
case 1: // Is Leader?
newCell = `<td>
<label class="switch" style="position: relative; top: 5px; left: 35px;">
<input data-id="${insurerCount}" id="co_share_type_${insurerCount}" type="checkbox" name="co_share_type[]">
<span class="slider round" style="height: 27px;"></span>
</label>
<label for="inception_type" style="position: relative; top: 5px; left: 40px;">Leader Yes</label>
</td>`;
break;
case 2: // CD Account Number selectionclass="std_tp_td"
newCell = `<td>
<select class="form-control follow_insurer_cd" data-count="${insurerCount}" id="cd_ac_no_${insurerCount}" name="cd_ac_no_for_child[]" onchange="addCDAccountNumber(this); restrictCDACNO(this)">
<option value="" selected>Select CD No</option>
<option value="add_cd"> + Add CD No</option>
</select>
</td>`;
break;
case 3: // Co-Share %
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" name="co_share_per[]" oninput="validateRange(this)" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 4: // Base Premium
newCell = `<td><input type="text" class="right-align-input" id="base_premium_${insurerCount}" name="base_premium[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 5: // TP Premium
newCell = `<td><input type="text" class="right-align-input" id="tp_premium_${insurerCount}" name="tp_premium[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 6: // Ter Premium
newCell = `<td><input type="text" class="right-align-input" id="ter_premium_${insurerCount}" name="ter_premium[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 7: // co Premium
newCell = `<td><input type="text" class="right-align-input" id="co_premium_${insurerCount}" name="co_premium[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 8: // CGST
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="cgst_${insurerCount}" name="cgst[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 9: // SGST
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="sgst_${insurerCount}" name="sgst[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 10: // IGST
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="igst_${insurerCount}" name="igst[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 11: // GST Amount
newCell = `<td><input type="text" class="readonly-color right-align-input" id="gst_amount_${insurerCount}" name="gst_amount[]" oninput="amountCalculation('${insurerCount}')" readonly onkeypress="return onlyNumbers(event)"></td>`;
break;
case 12: // Stamp Duty
newCell = `<td><input type="text" class="right-align-input" id="stamp_duty_${insurerCount}" name="stamp_duty[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
break;
case 13: // Total
newCell = `<td><input type="text" class="readonly-color right-align-input" id="total_amt_${insurerCount}" name="total[]" readonly onkeypress="return onlyNumbers(event)"></td>`;
break;
case 14: // ID For Update
newCell = `<td><input type="hidden" name="co_share_id[]" id="co_share_id[]" onkeypress="return onlyNumbers(event)"></td>`;
break;
}
}
$(this).append(newCell); $(this).append(newCell);
$('#follow_insurer_id_' + insurerCount).select2() $('#follow_insurer_id_' + insurerCount).select2()
@ -3169,6 +3294,8 @@ function removeInsurerColumn(index) {
function populateTable(dataArray) { function populateTable(dataArray) {
console.log('populateTable data', dataArray)
dataArray.forEach((data, index) => { dataArray.forEach((data, index) => {
// Add a new insurer column for each entry in the data array // Add a new insurer column for each entry in the data array
addInsurerColumn(); // This will add a new column dynamically addInsurerColumn(); // This will add a new column dynamically
@ -3179,6 +3306,7 @@ function populateTable(dataArray) {
let insurer = data.insurer_branch_id + '-' + data.insurer_id; let insurer = data.insurer_branch_id + '-' + data.insurer_id;
if(team_id.includes('4')){
switch (rowIndex) { switch (rowIndex) {
case 0: // Insurer selection case 0: // Insurer selection
cell.find('select').val(insurer).change(); cell.find('select').val(insurer).change();
@ -3283,6 +3411,55 @@ function populateTable(dataArray) {
cell.find('input[type="hidden"]').val(data.id); cell.find('input[type="hidden"]').val(data.id);
break; break;
} }
}else if(team_id.includes('3')){
switch (rowIndex) {
case 0: // Insurer selection
cell.find('select').val(insurer).change();
break;
case 1: // Is Leader?
cell.find('input[type="checkbox"]').prop('checked', data.co_share_type === '1');
break;
case 2: // CD Account Number selection
cell.find('select').val(data.cd_ac_no);
break;
case 3: // Co-Share %
cell.find('input').val(data.co_share_per);
break;
case 4: // Base Premium
cell.find('input').val(data.bp_amt);
break;
case 5: // TP Premium
cell.find('input').val(data.tp_amt);
break;
case 6: // Ter Premium
cell.find('input').val(data.tep_amt);
break;
case 7: // Co Premium
cell.find('input').val(data.cop_amt);
break;
case 8: // CGST
cell.find('input').val(data.bp_cgst);
break;
case 9: // SGST
cell.find('input').val(data.bp_sgst);
break;
case 10: // IGST
cell.find('input').val(data.bp_igst);
break;
case 11: // GST Amount
cell.find('input').val(data.bp_gst_amt);
break;
case 12: // Stamp Duty
cell.find('input').val(data.stamp_duty);
break;
case 13: // Total
cell.find('input').val(data.amount);
break;
case 14: // Co-share ID (hidden field)
cell.find('input[type="hidden"]').val(data.id);
break;
}
}
}); });
}); });
} }