<?php $this->load->view('includes/head') ?>
<?php $this->load->view('includes/topbar') ?>
<?php $this->load->view('includes/header') ?>
<link rel="stylesheet" type="text/css" href="<?= base_url('assets/css/services_checkout.css'); ?>">
<style>
  .servicesTr {
    border-bottom: 1px solid #c8c8c8 !important;
  }

  .servicesTr td {
    padding-bottom: 5px !important;
  }

  .row {
    margin-left: 0px !important;
    margin-right: 0px !important;
  }

  .padding-5 {
    padding: 3rem;
  }

  @media only screen and (max-width:767px) {
    .padding-5 {
      padding: 1rem;
    }
  }
</style>
<?php
$current_user = getUserDetails()->data[0];
$fgh = getFullPaymentSettings();


$dsbj = $fgh['result']['data'][0]['paymentGatewayoffon'];

foreach ($dsbj as $key => $dd) {
  if ($dd['source'] == 'WEBSITE') {
    $paymentSeverOn = $dd['isenable'];
    $paymentSeverText = $dd['desc'];
  }
}
$paymentSetting = @getPaymentGatewaySettings();

$getclientInfoById = @getclientInfoById()['data'][0];

$CAW_MerchantId = @$getclientInfoById['ChargeAnywhereMerchantId'];
$CAW_TerminalId = @$getclientInfoById['ChargeAnywhereTerminalId'];

$membershipDetails = membershipStatusCheck();
if ($membershipDetails['membershipStatus'] == "ACTIVE") {
  $setting =  SettingsApi();
  $membershipDiscount = $setting['result']['data'][0]['membershipSettings']['membershipDiscount'];
  $discountType = $setting['result']['data'][0]['membershipSettings']['discountType'];
}
// $discountType = 'SERVICE LEVEL';

?>
<main id="main">
  <section style="background-size: auto;">


    <h2 class="text-center mb-0" style="font-weight:bold!important;font-size: 25px!important;"> CHECKOUT<br><img src="<?= base_url('assets/img/border.png'); ?>" class="img-fluid" style="width: 15%;max-width: 15%;"></h2>

    <!-- <button onclick="window.history.back()">Go Back</button> -->
    <br>
    <div class="h-100 responsive-container">
      <div class="row d-flex justify-content-center align-items-center h-100">
        <div class="col-12">
          <div class="card card-registration card-registration-2 mb-4" style="border-radius: 15px;">
            <div class="card-body p-3">
              <div class="card-header text-end px-3" style="font-size: 18px!important;background-color:var(--main-color-new-theme);">
                <a href="javaScript:void(0)" class="btn" onclick="window.history.back()" style="background-color:var(--main-color-new-theme);color: white!important;border-radius: 1px!important;display:none;">← Back</a>
                <?php
                $redirectURL = '';
                $redirectURL2 = 'services';
                $redirectURL3 = 'Services';
                if (@$session_data == 'sponsor_cart' || @$this->uri->segment('2') == 'sponsorship') {
                  $redirectURL = 'sponsor-now';
                  $redirectURL2 = 'sponsor';
                  $redirectURL3 = 'Sponsorships';
                } else if (@$session_data == 'service_cart' || @$this->uri->segment('2') == 'service') {
                  $redirectURL = 'services';
                  $redirectURL2 = 'services';
                  $redirectURL3 = 'Services';
                } else if (@$session_data == 'child_events'  || (@$this->uri->segment('1') == 'events' && @$this->uri->segment('2') == 'checkout')) {
                  $redirectURL = 'all-upcoming-events';
                  $redirectURL2 = 'event';
                  $redirectURL3 = 'Events';
                } else if (@$session_data == 'donations_cart' || (@$this->uri->segment('1') == 'donations' && @$this->uri->segment('2') == 'checkout')) {
                  $redirectURL = 'donations';
                  $redirectURL2 = 'donations';
                  $redirectURL3 = 'Donations';
                }
                ?>
                <a href="<?= base_url($redirectURL) ?>" class="btn" style=";background-color:#e78b00;color: var(--main-color-new-theme)!important;border-radius: 1px!important;">Close X</a>
              </div>
              <?php $service_cart_items = @$this->session->userdata('service_cart');
              $sponser_cart_items = @$this->session->userdata('sponsorship_cart');
              $event_cart_items = @$this->session->userdata('events_cart');
              $donation_cart_items = @$this->session->userdata('donations_cart');
              $books_cart_items = @$this->session->userdata('books_cart');

              //  $sponser_cart_items = $this->session->userdata($session_data);
              // var_dump(@$service_cart_items);
              $totalItemsCount = 0;

              $totalItemsCount += !empty($service_cart_items) && isset($service_cart_items['ids']) ? count($service_cart_items['ids']) : 0;
              $totalItemsCount += !empty($sponser_cart_items) && isset($sponser_cart_items['ids']) ? count($sponser_cart_items['ids']) : 0;
              $totalItemsCount += !empty($event_cart_items) && isset($event_cart_items['ids']) ? count($event_cart_items['ids']) : 0;
              $totalItemsCount += !empty($donation_cart_items) && isset($donation_cart_items['ids']) ? count($donation_cart_items['ids']) : 0;
              $totalItemsCount += !empty($books_cart_items) && isset($books_cart_items['ids']) ? count($books_cart_items['ids']) : 0;

              $phone_html = '';
              $payNowTotalAmount = 0;
              $s_total = 0;
              ?>
              <?php
              // var_dump($event_cart_items);
              $currencySymbol = isset($GeneralSettings['currencySymbol']) ? (CheckEmptyNullVar($GeneralSettings['currencySymbol']) != '' ? $GeneralSettings['currencySymbol'] : '$') : '$';

              if ((isset($this->session->userdata('service_cart')['ids']) || isset($this->session->userdata('sponsorship_cart')['ids']) || isset($this->session->userdata('events_cart')['ids']) || isset($this->session->userdata('donations_cart')['ids']) || isset($this->session->userdata('books_cart')['ids'])) && $totalItemsCount > 0) { ?>


                <div class="row g-0">
                  <div class="col-lg-7" style="background-color:#f5f5f5">
                    <div class="padding-5">

                      <div class="d-flex justify-content-between align-items-center mb-4">
                        <h3 class="fw-bold mb-0 text-black">Order Summary</h3>

                        <h6 class="mb-0 text-muted d-none d-md-block"><?= $totalItemsCount; ?> items</h6>
                      </div>
                      <hr class="my-4">
                      <!-- ============================================= -->
                      <div class="d-none d-md-block">
                        <div class="table-responsive">
                          <table style="width:100%">
                            <thead>
                              <tr>
                                <th style="width:60%" class="text-start">Service Name</th>
                                <!-- <th style="width:10%" class="text-start">Ctg.</th> -->
                                <!-- <th style="width:25%" class="text-center">Date</th> -->
                                <th style="width:5%" class="text-center">Qty.</th>
                                <th style="width:15%" class="text-end">Total.</th>
                                <th></th>
                              </tr>
                            </thead>
                            <tbody>

                              <?php



                              //Services========================================
                              if (!empty($service_cart_items) && isset($service_cart_items['ids'])) {
                                foreach ($service_cart_items['ids'] as $key => $value) {
                                  $is_membership_discount = @$service_cart_items['is_membership_discount'][$key];
                                  $diacountHtml = '';
                                  // if ($service_cart_items['serviceAmount'][$key] > 0) {
                                  //    $payNowTotalAmount = ($service_cart_items['serviceAmount'][$key] * $service_cart_items['qty'][$key]) + $payNowTotalAmount;
                                  // }
                                  $selectedCartDats = array();
                                  if (!empty($service_cart_items['startDate'][$key])) {

                                    $selectedCartDats = explode(',', $service_cart_items['startDate'][$key]);
                                    if ($service_cart_items['serviceOccurrencesNo'][$key]) {

                                      $discounted_price = '';

                                      if ($membershipDetails['membershipStatus'] == "ACTIVE" && $is_membership_discount == 'YES') {
                                        if ($discountType == 'FLAT') {

                                          if ($service_cart_items['serviceAmount'][$key] > $membershipDiscount) {
                                            $diacountHtml = '<small style="color:green;">( ' . $currencySymbol . ' ' . $membershipDiscount . ' OFF )</small>';
                                            $discounted_price = $service_cart_items['serviceAmount'][$key] - $membershipDiscount;
                                          }
                                        } else if ($discountType == 'SERVICE LEVEL') {
                                          $membershipDiscount = (float)$service_cart_items['membership_discount_amt'][$key];
                                          if ($membershipDiscount > 0) {
                                            $diacountHtml = '<small style="color:green;">( ' . $currencySymbol . ' ' . $membershipDiscount . ' OFF )</small>';
                                          }
                                          // $discounted_price = $service_cart_items['serviceAmount'][$key] - $membershipDiscount;
                                          $discounted_price = $membershipDiscount > 0 ? $membershipDiscount : $service_cart_items['serviceAmount'][$key];
                                        } else {
                                          $diacountHtml = '<small style="color:green;">( ' . $membershipDiscount . ' %OFF )</small>';
                                          $discounted_price = $service_cart_items['serviceAmount'][$key] - ($service_cart_items['serviceAmount'][$key] * $membershipDiscount) / 100;
                                        }
                                      }
                                      // $alldates = implode(",", $selectedCartDats);
                                      $alldates = '<b>From:</b> ' . $selectedCartDats[0] . ' - <b>To: </b>' . end($selectedCartDats);
                              ?>
                                      <tr class="servicesTr">
                                        <td class="text-start">

                                          <p class="mb-0 fontSize fontweight" style="line-height: normal;">
                                            <?php
                                            // $service_cart_items['serviceName'][$key];
                                            echo $service_cart_items['serviceName'][$key];
                                            if (!empty($service_cart_items['service_desc'][$key]) && @$service_cart_items['isTextinputBox'][$key] == 'YES' && $service_cart_items['service_desc'][$key] != $service_cart_items['serviceName'][$key]) {
                                              echo " (" . $service_cart_items['service_desc'][$key] . ")";
                                            }

                                            //  $service_cart_items['serviceName'][$key] . ' (' . $currencySymbol . ' ' . price_format($service_cart_items['serviceAmount'][$key], 2) . ')'; 
                                            ?>
                                          </p>
                                          <span style="color: var(--main-color-new-theme);"><?= $service_cart_items['serviceTypes'][$key] ?></span><br>
                                          <?= $alldates; ?>&nbsp;( <?= count($selectedCartDats) ?> Bookings )
                                        </td>

                                        <!-- <td class="text-center"><?= $alldates; ?><br />(<?= count($selectedCartDats) ?> bookings)</td> -->
                                        <td class="text-center fontSize"><?= $service_cart_items['qty'][$key]; ?></td>
                                        <td class="text-end fontSize" id="amount_<?= $service_cart_items['ids'][$key]; ?>">


                                          <?php
                                          if (isset($service_cart_items['serviceOccurrencesNo'][$key]) && !empty($service_cart_items['serviceOccurrencesNo'][$key])) {

                                            // $final_price = $discounted_price ? $discounted_price : ($service_cart_items['serviceAmount'][$key] * $service_cart_items['qty'][$key]) / $service_cart_items['serviceOccurrencesNo'][$key];
                                            $final_price = $discounted_price ? $discounted_price : ((float)$service_cart_items['serviceAmount'][$key] * (float)$service_cart_items['qty'][$key] * (float)$service_cart_items['serviceOccurrencesNo'][$key]);
                                            $payNowTotalAmount += ((float)$service_cart_items['serviceAmount'][$key] * (float)$service_cart_items['qty'][$key] * (float)$service_cart_items['serviceOccurrencesNo'][$key]);


                                            $s_total += $final_price;


                                            // $serviceAmount = price_format(($service_cart_items['serviceAmount'][$key] * $service_cart_items['qty'][$key]) / $service_cart_items['serviceOccurrencesNo'][$key], 2);
                                            $serviceAmount = price_format(((float)$service_cart_items['serviceAmount'][$key] * (float)$service_cart_items['qty'][$key] * (float)$service_cart_items['serviceOccurrencesNo'][$key]), 2);
                                            if ($discounted_price != '') {

                                          ?>

                                              <!-- <?= $service_cart_items['bookingtype'][$key] == 'PAY LATER' ? '$ 0.00' : '<span style="text-decoration: line-through;">' . $currencySymbol . '&nbsp;' . $serviceAmount . '</span>'; ?>
                            
                                          <?= $service_cart_items['bookingtype'][$key] == 'PAY LATER' ? '$ 0.00' : '<span style="font-weight: bold;font-size: larger;color: #b00000;">' . $currencySymbol . '&nbsp;' . price_format($final_price, 2) . '</span>'; ?> -->

                                              <!-- <img src="<?= base_url('assets/img/crown-solid.gif') ?>" alt="gifimg" height="15"> -->
                                              <?= $service_cart_items['bookingtype'][$key] == 'PAY LATER' ? '$ 0.00' : '<i class="fa-solid fa-crown blinkingText" style="color: #FFC107;"></i><span style="font-weight: bold;font-size: larger;color: #00000;">' . $currencySymbol . '&nbsp;' . price_format($final_price, 2) . '</span>'; ?>
                                              <!-- <br> -->

                                              <!-- <?= $diacountHtml != '' ? $diacountHtml . '<br>' : '' ?>
                                          <?= $service_cart_items['bookingtype'][$key] == 'PAY LATER' ? '$ 0.00' : '<span style="">- ' . $currencySymbol . '&nbsp;' . price_format(((float)$service_cart_items['serviceAmount'][$key] - (float)$discounted_price) * $service_cart_items['qty'][$key], 2) . '</span>'; ?> -->
                                            <?php
                                              $service_cart_items['discountedAmount'][$key] = (float)$service_cart_items['serviceAmount'][$key] - (float)$discounted_price;
                                              $service_cart_items['oldServiceAmount'][$key] = (float)$service_cart_items['serviceAmount'][$key];
                                              $service_cart_items['serviceAmount'][$key] = $discounted_price;
                                            } else { ?>

                                              <?= $service_cart_items['bookingtype'][$key] == 'PAY LATER' ? '$ 0.00' : '<span class="fontSize">' . $currencySymbol . '&nbsp;' . $serviceAmount . '</span>'; ?>

                                            <?php
                                              $service_cart_items['discountedAmount'][$key] = '';
                                              $service_cart_items['oldServiceAmount'][$key] = '';
                                            }
                                          } else {
                                            $final_price = $discounted_price ? $discounted_price : $service_cart_items['serviceAmount'][$key] * $service_cart_items['qty'][$key];
                                            $payNowTotalAmount += ((float)$service_cart_items['serviceAmount'][$key] * (float)$service_cart_items['qty'][$key]);


                                            $s_total += $final_price;

                                            if ($discounted_price != '') { ?>

                                              <!-- <?= $service_cart_items['bookingtype'][$key] == 'PAY LATER' ? '$ 0.00' : '<span style="text-decoration: line-through;">' . $currencySymbol . '&nbsp;' . price_format($service_cart_items['serviceAmount'][$key] * $service_cart_items['qty'][$key], 2) . '</span>'; ?>
                            
                                          <?= $service_cart_items['bookingtype'][$key] == 'PAY LATER' ? '$ 0.00' : '<span style="font-weight: bold;font-size: larger;color: #b00000;">' . $currencySymbol . '&nbsp;' . price_format($final_price, 2) . '</span>'; ?> -->


                                              <!-- <img src="<?= base_url('assets/img/crown-solid.gif') ?>" alt="gifimg" height="15"> -->
                                              <!-- <?= $service_cart_items['bookingtype'][$key] == 'PAY LATER' ? '$ 0.00' : '<i class="fa-solid fa-crown blinkingText" style="color: #FFC107;"></i><span style="font-weight: bold;font-size: larger;color: #b00000;">' . $currencySymbol . '&nbsp;' . price_format($final_price, 2) . '</span>'; ?> -->
                                              <?= $service_cart_items['bookingtype'][$key] == 'PAY LATER' ? '$ 0.00' : '<i class="fa-solid fa-crown blinkingText" style="color: #FFC107;"></i><span style="font-weight: bold;font-size: larger;color: #00000;">' . $currencySymbol . '&nbsp;' . price_format($final_price, 2) . '</span>'; ?>
                                              <!-- <br>
                            
                                          <?= $diacountHtml != '' ? $diacountHtml . '<br>' : '' ?>
                                          <?= $service_cart_items['bookingtype'][$key] == 'PAY LATER' ? '$ 0.00' : '<span style="">- ' . $currencySymbol . '&nbsp;' . number_format(((float)$service_cart_items['serviceAmount'][$key] - (float)$discounted_price) * $service_cart_items['qty'][$key], 2) . '</span>'; ?> -->

                                            <?php
                                              $service_cart_items['discountedAmount'][$key] = (float)$service_cart_items['serviceAmount'][$key] - (float)$discounted_price;
                                              $service_cart_items['oldServiceAmount'][$key] = (float)$service_cart_items['serviceAmount'][$key];
                                              $service_cart_items['serviceAmount'][$key] = $discounted_price;
                                            } else { ?>

                                              <?= $service_cart_items['bookingtype'][$key] == 'PAY LATER' ? '$ 0.00' : '<span>' . $currencySymbol . '&nbsp;' . number_format($service_cart_items['serviceAmount'][$key] * $service_cart_items['qty'][$key], 2) . '</span>'; ?>

                                          <?php
                                              $service_cart_items['discountedAmount'][$key] = '';
                                              $service_cart_items['oldServiceAmount'][$key] = '';
                                            }
                                          }

                                          ?>


                                        </td>

                                        <td style="width:5%;text-align: center;" class="actions" data-th="">
                                          <a href="javaScript:void(0)" class="text-danger btn-sm service-delete-row" data-row-id="<?= $service_cart_items['ids'][$key]; ?>" style="font-size:17px"><i class="fa fa-trash-o"></i></a>
                                        </td>
                                      </tr>
                                      <?php
                                      $phone_html .= '<div style="border-bottom: 1px dashed #ccc; padding-bottom: 10px; margin-bottom: 10px;">
                              <strong><' . $service_cart_items['serviceName'][$key] . '</strong><br>';
                                      if (!empty(trim($service_cart_items['dietyName'][$key]))) {
                                        $phone_html .= '<span><b>Deity:</b>' . $service_cart_items['dietyName'][$key] . '</span><br>';
                                      }

                                      if (!empty($selectedCartDats)) {
                                        $phone_html .= '<span><b>From:</b> ' . $selectedCartDats[0] . ' - <b>To:</b> ' . end($selectedCartDats) . '</span><br>';
                                      }
                                      $phone_html .= ' <span><b>Qty:</b> ' . $service_cart_items['qty'][$key] . '</span><br>
                              <span><b>Amount:</b> ' . $currencySymbol . '&nbsp;' . number_format($service_cart_items['serviceAmount'][$key] * $service_cart_items['qty'][$key], 2) . '</span><br>';
                                      if (!empty(trim($service_cart_items['disclaimerText'][$key]))) {
                                        $phone_html .= '<span style="color: red;"><b>' . $service_cart_items['disclaimerText'][$key] . '</b></span><br>';
                                      }
                                      $phone_html .= '<a href="javascript:void(0)" class="text-danger btn-sm service-delete-row" data-row-id="' . $service_cart_items['ids'][$key] . '"><i class="fa fa-trash-o"></i> Delete</a></div>';
                                    } else {


                                      foreach ($selectedCartDats as $dateKey => $selectedCatVal) {
                                        // if ($service_cart_items['serviceAmount'][$key] > 0) {
                                        //   $payNowTotalAmount = ($service_cart_items['serviceAmount'][$key] * $service_cart_items['qty'][$key]) + $payNowTotalAmount;
                                        // }

                                        $discounted_price = '';
                                        if ($membershipDetails['membershipStatus'] == "ACTIVE" && $is_membership_discount == 'YES') {
                                          if ($discountType == 'FLAT') {

                                            if ($service_cart_items['serviceAmount'][$key] > $membershipDiscount) {

                                              $discounted_price = $service_cart_items['serviceAmount'][$key] - $membershipDiscount;
                                              $diacountHtml = '<small style="color:green;">( ' . $currencySymbol . ' ' . $membershipDiscount . ' OFF )</small>';
                                            }
                                          } else if ($discountType == 'SERVICE LEVEL') {
                                            $membership_discount_amt = (float)$service_cart_items['membership_discount_amt'][$key];
                                            if ($membership_discount_amt > 0) {
                                              $diacountHtml = '<small style="color:green;">( ' . $currencySymbol . ' ' . $membership_discount_amt . ' OFF )</small>';
                                            }
                                            // $discounted_price = $service_cart_items['serviceAmount'][$key] - $membershipDiscount;
                                            // $discounted_price = $membershipDiscount;
                                            $discounted_price = $membership_discount_amt > 0 ? $membership_discount_amt : $service_cart_items['serviceAmount'][$key];
                                          } else {

                                            $diacountHtml = '<small style="color:green;">( ' . $membershipDiscount . ' %OFF )</small>';
                                            $discounted_price = $service_cart_items['serviceAmount'][$key] - ($service_cart_items['serviceAmount'][$key] * $membershipDiscount) / 100;
                                          }
                                        }

                                        // echo $discounted_price;


                                      ?>
                                        <tr class="servicesTr">
                                          <td class="text-start">

                                            <p class="mb-0 fontSize fontweight" style="line-height: normal;">
                                              <?php
                                              // $service_cart_items['serviceName'][$key];
                                              echo $service_cart_items['serviceName'][$key];
                                              // if (!empty($service_cart_items['service_desc'][$key])) {
                                              //   echo " (" . $service_cart_items['service_desc'][$key] . ")";
                                              // }
                                              //  $service_cart_items['serviceName'][$key] . ' (' . $currencySymbol . ' ' . price_format($service_cart_items['serviceAmount'][$key], 2) . ')'; 
                                              ?>
                                            </p>
                                            <span style="color: var(--main-color-new-theme);"><?= $service_cart_items['serviceTypes'][$key] ?></span><br>
                                            <?php
                                            if (!empty(trim($service_cart_items['dietyName'][$key]))) {
                                            ?>
                                              <span style="color: black;font-size:13px!important;"><b>Deity:</b> <?= $service_cart_items['dietyName'][$key] ?></span><br>
                                            <?php
                                            }
                                            if (!empty(trim($service_cart_items['disclaimerText'][$key]))) {
                                            ?>
                                              <span style="color: #ff0000;font-size:12px!important;"><b><?= $service_cart_items['disclaimerText'][$key] ?></b></span>
                                            <?php
                                            }
                                            ?>
                                            <?= !empty($selectedCatVal) ? ' Service Date: ' . $selectedCatVal : ""; ?>
                                          </td>

                                          <!-- <td class="text-center"><?= $selectedCatVal; ?></td> -->
                                          <td class="text-center fontSize"><?= $service_cart_items['qty'][$key]; ?></td>
                                          <td class="text-end fontSize" id="amount_<?= $service_cart_items['ids'][$key]; ?>">


                                            <?php
                                            if (isset($service_cart_items['serviceOccurrencesNo'][$key]) && !empty($service_cart_items['serviceOccurrencesNo'][$key])) {
                                              // $final_price = $discounted_price ? $discounted_price : ($service_cart_items['serviceAmount'][$key] * $service_cart_items['qty'][$key]) / $service_cart_items['serviceOccurrencesNo'][$key];
                                              $final_price = $discounted_price ? $discounted_price * $service_cart_items['qty'][$key] : ($service_cart_items['serviceAmount'][$key] * $service_cart_items['qty'][$key]);
                                              $payNowTotalAmount += ($service_cart_items['serviceAmount'][$key] * $service_cart_items['qty'][$key]);


                                              $s_total += $final_price;


                                              // $serviceAmount = price_format(($service_cart_items['serviceAmount'][$key] * $service_cart_items['qty'][$key]) / $service_cart_items['serviceOccurrencesNo'][$key], 2);
                                              $serviceAmount = price_format(($service_cart_items['serviceAmount'][$key] * $service_cart_items['qty'][$key]), 2);
                                              if ($discounted_price != '') {

                                            ?>

                                                <!-- <?= $service_cart_items['bookingtype'][$key] == 'PAY LATER' ? '$ 0.00' : '<span style="text-decoration: line-through;">' . $currencySymbol . '&nbsp;' . $serviceAmount . '</span>'; ?>
                            
                                            <?= $service_cart_items['bookingtype'][$key] == 'PAY LATER' ? '$ 0.00' : '<span style="font-weight: bold;font-size: larger;color: #b00000;">' . $currencySymbol . '&nbsp;' . price_format($final_price, 2) . '</span>'; ?> -->


                                                <!-- <img src="<?= base_url('assets/img/crown-solid.gif') ?>" alt="gifimg" height="15"> -->
                                                <?= $service_cart_items['bookingtype'][$key] == 'PAY LATER' ? '$ 0.00' : '<i class="fa-solid fa-crown blinkingText" style="color: #FFC107;"></i><span style="font-weight: bold;font-size: larger;color: #00000;">' . $currencySymbol . '&nbsp;' . number_format($final_price, 2) . '</span>'; ?>
                                                <!-- <br>
                            
                                            <?= $diacountHtml != '' ? $diacountHtml . '<br>' : '' ?>
                                            <?= $service_cart_items['bookingtype'][$key] == 'PAY LATER' ? '$ 0.00' : '<span style="">- ' . $currencySymbol . '&nbsp;' . number_format(((float)$service_cart_items['serviceAmount'][$key] - (float)$discounted_price) * $service_cart_items['qty'][$key], 2) . '</span>'; ?> -->
                                              <?php
                                                $service_cart_items['discountedAmount'][$key] = (float)$service_cart_items['serviceAmount'][$key] - (float)$discounted_price;
                                                $service_cart_items['oldServiceAmount'][$key] = (float)$service_cart_items['serviceAmount'][$key];
                                                $service_cart_items['serviceAmount'][$key] = $discounted_price;
                                              } else { ?>

                                                <?= $service_cart_items['bookingtype'][$key] == 'PAY LATER' ? '$ 0.00' : '<span>' . $currencySymbol . '&nbsp;' . $serviceAmount . '</span>'; ?>

                                              <?php
                                                $service_cart_items['discountedAmount'][$key] = '';
                                                $service_cart_items['oldServiceAmount'][$key] = '';
                                              }
                                            } else {
                                              $final_price = $discounted_price ? $discounted_price * $service_cart_items['qty'][$key] : $service_cart_items['serviceAmount'][$key] * $service_cart_items['qty'][$key];
                                              $payNowTotalAmount += $service_cart_items['serviceAmount'][$key] * $service_cart_items['qty'][$key];

                                              $s_total += $final_price;

                                              if ($discounted_price != '') {


                                              ?>

                                                <?= $service_cart_items['bookingtype'][$key] == 'PAY LATER' ? '$ 0.00' : '<i class="fa-solid fa-crown blinkingText" style="color: #FFC107;"></i><span style="font-weight: bold;font-size: larger;color: #00000;">' . $currencySymbol . '&nbsp;' . number_format($service_cart_items['serviceAmount'][$key] * $service_cart_items['qty'][$key], 2) . '</span>'; ?>


                                              <?php
                                                $service_cart_items['discountedAmount'][$key] = (float)$service_cart_items['serviceAmount'][$key] - (float)$discounted_price;
                                                $service_cart_items['oldServiceAmount'][$key] = (float)$service_cart_items['serviceAmount'][$key];
                                                $service_cart_items['serviceAmount'][$key] = $discounted_price;
                                              } else { ?>

                                                <?= $service_cart_items['bookingtype'][$key] == 'PAY LATER' ? '$ 0.00' : '<span class="fontSize">' . $currencySymbol . '&nbsp;' . number_format($service_cart_items['serviceAmount'][$key] * $service_cart_items['qty'][$key], 2) . '</span>'; ?>

                                            <?php

                                                $service_cart_items['discountedAmount'][$key] = '';
                                                $service_cart_items['oldServiceAmount'][$key] = '';
                                              }
                                            }

                                            ?>


                                          </td>

                                          <td style="width:5%;text-align: center;" class="actions" data-th="">
                                            <a href="javaScript:void(0)" class="text-danger btn-sm service-delete-row" data-row-id="<?= $service_cart_items['ids'][$key]; ?>" style="font-size:17px"><i class="fa fa-trash-o"></i></a>
                                          </td>
                                        </tr>
                                    <?php
                                        $phone_html .= '<div style="border-bottom: 1px dashed #ccc; padding-bottom: 10px; margin-bottom: 10px;">
                                      <strong>' . htmlspecialchars($service_cart_items['serviceName'][$key]) . '</strong><br>';

                                        if (!empty(trim($service_cart_items['dietyName'][$key]))) {
                                          $phone_html .= '<span><b>Deity:</b> ' . htmlspecialchars($service_cart_items['dietyName'][$key]) . '</span><br>';
                                        }

                                        if (!empty($selectedCatVal)) {
                                          $phone_html .= '<b>Service Date:</b> ' . htmlspecialchars($selectedCatVal) . '<br>';
                                        }

                                        $qty = $service_cart_items['qty'][$key]; // Ensure $qty is defined
                                        $amount = $service_cart_items['serviceAmount'][$key] * $qty;

                                        $phone_html .= '<span><b>Qty:</b> ' . $qty . '</span><br><span><b>Amount:</b> ' . $currencySymbol . '&nbsp;' . number_format($amount, 2) . '</span><br>';

                                        if (!empty(trim($service_cart_items['disclaimerText'][$key]))) {
                                          $phone_html .= '<span style="color: red;"><b>' . htmlspecialchars($service_cart_items['disclaimerText'][$key]) . '</b></span><br>';
                                        }

                                        $phone_html .= '<a href="javascript:void(0)" class="text-danger btn-sm service-delete-row" data-row-id="' . $service_cart_items['ids'][$key] . '"><i class="fa fa-trash-o"></i> Delete</a></div>';
                                      }
                                    }
                                  } else {
                                    // if ($service_cart_items['serviceAmount'][$key] > 0) {
                                    //   $payNowTotalAmount = ($service_cart_items['serviceAmount'][$key] * $service_cart_items['qty'][$key]) + $payNowTotalAmount;
                                    // }

                                    $diacountHtml = '';
                                    $discounted_price = '';
                                    if ($membershipDetails['membershipStatus'] == "ACTIVE" && $is_membership_discount == 'YES') {
                                      if ($discountType == 'FLAT') {

                                        if ($service_cart_items['serviceAmount'][$key] > $membershipDiscount) {
                                          $diacountHtml = '<small style="color:green;">( ' . $currencySymbol . ' ' . $membershipDiscount . ' OFF )</small>';
                                          $discounted_price = $service_cart_items['serviceAmount'][$key] - $membershipDiscount;
                                        }
                                      } else if ($discountType == 'SERVICE LEVEL') {
                                        $membership_discount_amt = (float)$service_cart_items['membership_discount_amt'][$key];
                                        $membershipDiscount = $membership_discount_amt;
                                        if ($membershipDiscount > 0) {
                                          $diacountHtml = '<small style="color:green;">( ' . $currencySymbol . ' ' . $membershipDiscount . ' OFF )</small>';
                                        }
                                        // $discounted_price = $service_cart_items['serviceAmount'][$key] - $membershipDiscount;
                                        // $discounted_price = $membership_discount_amt;
                                        $discounted_price = $membershipDiscount > 0 ? $membershipDiscount : $service_cart_items['serviceAmount'][$key];
                                      } else {
                                        $diacountHtml = '<small style="color:green;">( ' . $membershipDiscount . ' %OFF )</small>';
                                        $discounted_price = $service_cart_items['serviceAmount'][$key] - ($service_cart_items['serviceAmount'][$key] * $membershipDiscount) / 100;
                                      }
                                    }

                                    if (isset($service_cart_items['serviceOccurrencesNo'][$key]) && !empty($service_cart_items['serviceOccurrencesNo'][$key])) {
                                      // $serviceAmount = price_format(($service_cart_items['serviceAmount'][$key] * $service_cart_items['qty'][$key]) / $service_cart_items['serviceOccurrencesNo'][$key], 2);
                                      $serviceAmount = $discounted_price != '' ? $discounted_price * $service_cart_items['qty'][$key] : price_format(($service_cart_items['serviceAmount'][$key] * $service_cart_items['qty'][$key]), 2);
                                      $payNowTotalAmount += ($service_cart_items['serviceAmount'][$key] * $service_cart_items['qty'][$key]);

                                      $s_total +=  $serviceAmount;
                                    } else {
                                      $serviceAmount = $discounted_price != '' ? $discounted_price * $service_cart_items['qty'][$key] : price_format($service_cart_items['serviceAmount'][$key] * $service_cart_items['qty'][$key], 2);
                                      $payNowTotalAmount += ($service_cart_items['serviceAmount'][$key] * $service_cart_items['qty'][$key]);

                                      $s_total += $serviceAmount;
                                    }
                                    if ($discounted_price != '') {
                                      $service_cart_items['discountedAmount'][$key] = (float)$service_cart_items['serviceAmount'][$key] - (float)$discounted_price;
                                      $service_cart_items['oldServiceAmount'][$key] = (float)$service_cart_items['serviceAmount'][$key];
                                      $service_cart_items['serviceAmount'][$key] = $discounted_price;
                                    } else {
                                      $service_cart_items['discountedAmount'][$key] = '';
                                      $service_cart_items['oldServiceAmount'][$key] = '';
                                    }

                                    ?>
                                    <tr class="servicesTr">
                                      <!-- <td class="text-start"><?= $service_cart_items['serviceName'][$key]; ?></td> -->
                                      <td class="text-start">
                                        <p class="mb-0 fontSize fontweight" style="line-height: normal;">
                                          <?php
                                          // $service_cart_items['serviceName'][$key];
                                          echo $service_cart_items['serviceName'][$key];
                                          // if (!empty($service_cart_items['service_desc'][$key])) {
                                          //   echo " (" . $service_cart_items['service_desc'][$key] . ")";
                                          // }
                                          //  $service_cart_items['serviceName'][$key] . ' (' . $currencySymbol . ' ' . price_format($service_cart_items['serviceAmount'][$key], 2) . ')'; 
                                          ?>
                                          <span style="color: var(--main-color-new-theme);"><?= $service_cart_items['serviceTypes'][$key] ?></span><br>
                                          <?php
                                          if (!empty(trim($service_cart_items['dietyName'][$key]))) {
                                          ?>
                                            <span style="color: black;font-size:13px!important;"><b>Deity:</b> <?= $service_cart_items['dietyName'][$key] ?></span><br>
                                          <?php
                                          }
                                          if (!empty(trim($service_cart_items['disclaimerText'][$key]))) {
                                          ?>
                                            <span style="color: #ff0000;font-size:12px!important;"><b><?= $service_cart_items['disclaimerText'][$key] ?></b></span>
                                          <?php
                                          }
                                          ?>
                                        </p>
                                      </td>

                                      <td class="text-center fontSize"><?= $service_cart_items['qty'][$key]; ?></td>
                                      <!-- <td class="text-end" id="amount_<?= $service_cart_items['ids'][$key]; ?>"><?= $currencySymbol . '&nbsp;' .  $serviceAmount ?></td> -->
                                      <td class="text-end fontSize" id="amount_<?= $service_cart_items['ids'][$key]; ?>">
                                        <?php if ($discounted_price != '') {


                                        ?>
                                          <?= $service_cart_items['bookingtype'][$key] == 'PAY LATER' ? '$ 0.00' : '<i class="fa-solid fa-crown blinkingText" style="color: #FFC107;"></i><span style="font-weight: bold;font-size: larger;color: #00000;">' . $currencySymbol . '&nbsp;' . number_format($service_cart_items['serviceAmount'][$key] * $service_cart_items['qty'][$key], 2) . '</span>'; ?>

                                        <?php
                                          $service_cart_items['discountedAmount'][$key] = (float)$service_cart_items['serviceAmount'][$key] - (float)$discounted_price;
                                          $service_cart_items['oldServiceAmount'][$key] = (float)$service_cart_items['serviceAmount'][$key];
                                          $service_cart_items['serviceAmount'][$key] = $discounted_price;
                                        } else { ?>

                                          <?= $service_cart_items['bookingtype'][$key] == 'PAY LATER' ? '$ 0.00' : '<span>' . $currencySymbol . '&nbsp;' . number_format($service_cart_items['serviceAmount'][$key] * $service_cart_items['qty'][$key], 2) . '</span>'; ?>

                                        <?php

                                          $service_cart_items['discountedAmount'][$key] = '';
                                          $service_cart_items['oldServiceAmount'][$key] = '';
                                        }
                                        ?>
                                      </td>


                                      <td style="width:5%;text-align: center;" class="actions" data-th="">
                                        <a href="javaScript:void(0)" class="text-danger btn-sm service-delete-row" data-row-id="<?= $service_cart_items['ids'][$key]; ?>" style="font-size:17px"><i class="fa fa-trash-o"></i></a>
                                      </td>

                                    </tr>

                                    <?php
                                    $phone_html .= '<div style="border-bottom: 1px dashed #ccc; padding-bottom: 10px; margin-bottom: 10px;">
                              <strong><' . $service_cart_items['serviceName'][$key] . '</strong><br>';
                                    if (!empty(trim($service_cart_items['dietyName'][$key]))) {
                                      $phone_html .= '<span><b>Deity:</b>' . $service_cart_items['dietyName'][$key] . '</span><br>';
                                    }

                                    $phone_html .= ' <span><b>Qty:</b> ' . $service_cart_items['qty'][$key] . '</span><br>
                              <span><b>Amount:</b> ' . $currencySymbol . '&nbsp;' . number_format($service_cart_items['serviceAmount'][$key] * $service_cart_items['qty'][$key], 2) . '</span><br>';
                                    if (!empty(trim($service_cart_items['disclaimerText'][$key]))) {
                                      $phone_html .= '<span style="color: red;"><b>' . $service_cart_items['disclaimerText'][$key] . '</b></span><br>';
                                    }
                                    $phone_html .= '<a href="javascript:void(0)" class="text-danger btn-sm service-delete-row" data-row-id="' . $service_cart_items['ids'][$key] . '"><i class="fa fa-trash-o"></i> Delete</a>
                            </div>';
                                  }
                                }
                              }

                              //SponserShip====================================================
                              if (!empty($sponser_cart_items) && isset($sponser_cart_items['ids'])) {
                                foreach ($sponser_cart_items['ids'] as $key => $value) {
                                  $is_membership_discount = @$sponser_cart_items['is_membership_discount'][$key];
                                  // $payNowTotalAmount += ($sponser_cart_items['serviceAmount'][$key] * $sponser_cart_items['qty'][$key]);

                                  $selectedCartDats = array();
                                  if (!empty($sponser_cart_items['startDate'][$key])) {
                                    $selectedCartDats = explode(',', $sponser_cart_items['startDate'][$key]);
                                    if ($sponser_cart_items['serviceOccurrencesNo'][$key]) {
                                      $discounted_price = '';


                                      if ($membershipDetails['membershipStatus'] == "ACTIVE" && $is_membership_discount == 'YES') {
                                        if ($discountType == 'FLAT') {

                                          if ($sponser_cart_items['serviceAmount'][$key] > $membershipDiscount) {
                                            $diacountHtml = '<small style="color:green;">( ' . $currencySymbol . ' ' . $membershipDiscount . ' OFF )</small>';
                                            $discounted_price = $sponser_cart_items['serviceAmount'][$key] - $membershipDiscount;
                                          }
                                        } else if ($discountType == 'SERVICE LEVEL') {
                                          $membershipDiscount = (float)$sponser_cart_items['membership_discount_amt'][$key];
                                          if ($membershipDiscount > 0) {
                                            $diacountHtml = '<small style="color:green;">( ' . $currencySymbol . ' ' . $membershipDiscount . ' OFF )</small>';
                                          }
                                          // $discounted_price = $sponser_cart_items['serviceAmount'][$key] - $membershipDiscount;
                                          $discounted_price = $membershipDiscount > 0 ? $membershipDiscount : $sponser_cart_items['serviceAmount'][$key];
                                        } else {
                                          $diacountHtml = '<small style="color:green;">( ' . $membershipDiscount . ' %OFF )</small>';
                                          $discounted_price = $sponser_cart_items['serviceAmount'][$key] - ($sponser_cart_items['serviceAmount'][$key] * $membershipDiscount) / 100;
                                        }
                                      }

                                      // $alldates = implode(",", $selectedCartDats);	
                                      // $alldates = $selectedCartDats[0].' - '.end($selectedCartDats);	
                                      $alldates = '<b>From:</b> ' . $selectedCartDats[0] . ' - <b>To: </b>' . end($selectedCartDats);
                                      $serviceAmount = $sponser_cart_items['serviceOccurrencesNo'][$key] * $sponser_cart_items['serviceAmount'][$key];

                                    ?>
                                      <tr class="servicesTr">
                                        <td class="text-start">
                                          <p class="mb-0"><?= $sponser_cart_items['serviceName'][$key]; ?> </p>
                                          <span style="color: var(--main-color-new-theme);"><?= $sponser_cart_items['serviceTypes'][$key] ?></span><br>
                                          <?php
                                          if (!empty(trim($sponser_cart_items['dietyName'][$key]))) {
                                          ?>
                                            <span style="color: black;font-size:13px!important;"><b>Deity:</b> <?= $sponser_cart_items['dietyName'][$key] ?></span><br>
                                          <?php
                                          }
                                          if (!empty(trim($sponser_cart_items['disclaimerText'][$key]))) {
                                          ?>
                                            <span style="color: #ff0000;font-size:12px!important;"><b><?= $sponser_cart_items['disclaimerText'][$key] ?></b></span>
                                          <?php
                                          }
                                          ?>
                                          <?= $alldates; ?>&nbsp;( <?= count($selectedCartDats) ?> Bookings )
                                        </td>
                                        <td class="text-center"><?= $sponser_cart_items['qty'][$key]; ?></td>
                                        <td class="text-end" id="amount_<?= $sponser_cart_items['ids'][$key]; ?>">


                                          <?php
                                          if (isset($sponser_cart_items['serviceOccurrencesNo'][$key]) && !empty($sponser_cart_items['serviceOccurrencesNo'][$key])) {
                                            // $final_price = $discounted_price ? $discounted_price : ($sponser_cart_items['serviceAmount'][$key] * $sponser_cart_items['qty'][$key]) / $sponser_cart_items['serviceOccurrencesNo'][$key];
                                            $final_price = $discounted_price ? $discounted_price * (float)$sponser_cart_items['qty'][$key] * (float)$sponser_cart_items['serviceOccurrencesNo'][$key] : ((float)$sponser_cart_items['serviceAmount'][$key] * (float)$sponser_cart_items['qty'][$key] * (float)$sponser_cart_items['serviceOccurrencesNo'][$key]);
                                            $payNowTotalAmount += ((float)$sponser_cart_items['serviceAmount'][$key] * (float)$sponser_cart_items['qty'][$key] * (float)$sponser_cart_items['serviceOccurrencesNo'][$key]);


                                            $s_total += $final_price;


                                            // $serviceAmount = price_format(($sponser_cart_items['serviceAmount'][$key] * $sponser_cart_items['qty'][$key]) / $sponser_cart_items['serviceOccurrencesNo'][$key], 2);
                                            $serviceAmount = price_format(((float)$sponser_cart_items['serviceAmount'][$key] * (float)$sponser_cart_items['qty'][$key] * (float)$sponser_cart_items['serviceOccurrencesNo'][$key]), 2);
                                            if ($discounted_price != '') {

                                          ?>
                                              <?= '<span style="font-size: larger;">' . $currencySymbol . '&nbsp;' . number_format($serviceAmount, 2) . '</span>'; ?>

                                            <?php
                                              $sponser_cart_items['discountedAmount'][$key] = (float)$sponser_cart_items['serviceAmount'][$key] - (float)$discounted_price;
                                              $sponser_cart_items['oldServiceAmount'][$key] = (float)$sponser_cart_items['serviceAmount'][$key];
                                              $sponser_cart_items['serviceAmount'][$key] = $discounted_price;
                                            } else { ?>

                                              <?= '<span>' . $currencySymbol . '&nbsp;' . $serviceAmount . '</span>'; ?>

                                            <?php
                                              $sponser_cart_items['discountedAmount'][$key] = '';
                                              $sponser_cart_items['oldServiceAmount'][$key] = '';
                                            }
                                          } else {
                                            $final_price = $discounted_price ? $discounted_price * $sponser_cart_items['qty'][$key] : $sponser_cart_items['serviceAmount'][$key] * $sponser_cart_items['qty'][$key];
                                            $payNowTotalAmount += $sponser_cart_items['serviceAmount'][$key] * $sponser_cart_items['qty'][$key];

                                            $s_total += $final_price;

                                            if ($discounted_price != '') { ?>

                                              <?= '<span style="font-size: larger;">' . $currencySymbol . '&nbsp;' . number_format($sponser_cart_items['serviceAmount'][$key] * $sponser_cart_items['qty'][$key], 2) . '</span>'; ?>

                                            <?php
                                              $sponser_cart_items['discountedAmount'][$key] = (float)$sponser_cart_items['serviceAmount'][$key] - (float)$discounted_price;
                                              $sponser_cart_items['oldServiceAmount'][$key] = (float)$sponser_cart_items['serviceAmount'][$key];
                                              $sponser_cart_items['serviceAmount'][$key] = $discounted_price;
                                            } else { ?>

                                              <?= '<span>' . $currencySymbol . '&nbsp;' . number_format($sponser_cart_items['serviceAmount'][$key] * $sponser_cart_items['qty'][$key], 2) . '</span>'; ?>

                                          <?php
                                              $sponser_cart_items['discountedAmount'][$key] = '';
                                              $sponser_cart_items['oldServiceAmount'][$key] = '';
                                            }
                                          }

                                          ?>


                                        </td>
                                        <td style="width:5%;text-align: center;" class="actions" data-th="">
                                          <a href="javaScript:void(0)" class="text-danger btn-sm sponser-delete-row" data-row-id="<?= $sponser_cart_items['ids'][$key]; ?>" style="font-size:17px"><i class="fa fa-trash-o"></i></a>
                                        </td>
                                      </tr>


                                      <?php
                                      $phone_html .= '<div style="border-bottom: 1px dashed #ccc; padding-bottom: 10px; margin-bottom: 10px;"><strong>' . htmlspecialchars($sponser_cart_items['serviceName'][$key]) . '</strong><br>';

                                      if (isset($sponser_cart_items['dietyName'][$key])) {
                                        $phone_html .= '<span><b>Deity:</b> ' . htmlspecialchars($sponser_cart_items['dietyName'][$key]) . '</span><br>';
                                      }


                                      $phone_html .= $alldates;



                                      $phone_html .= '<span><b>Qty:</b> ' . $sponser_cart_items['qty'][$key] . '</span><br><span><b>Amount:</b> ' . $currencySymbol . '&nbsp;' . number_format($serviceAmount, 2)  . '</span><br>';

                                      if (!empty(trim($sponser_cart_items['disclaimerText'][$key]))) {
                                        $phone_html .= '<span style="color: red;"><b>' . htmlspecialchars($sponser_cart_items['disclaimerText'][$key]) . '</b></span><br>';
                                      }

                                      $phone_html .= '<a href="javascript:void(0)" class="text-danger btn-sm sponser-delete-row" data-row-id="' . $sponser_cart_items['ids'][$key] . '"><i class="fa fa-trash-o"></i> Delete</a></div>';
                                    } else {


                                      foreach ($selectedCartDats as $dateKey => $selectedCatVal) {
                                        $discounted_price = '';

                                        if ($membershipDetails['membershipStatus'] == "ACTIVE" && $is_membership_discount == 'YES') {
                                          if ($discountType == 'FLAT') {

                                            if ($sponser_cart_items['serviceAmount'][$key] > $membershipDiscount) {
                                              $diacountHtml = '<small style="color:green;">( ' . $currencySymbol . ' ' . $membershipDiscount . ' OFF )</small>';
                                              $discounted_price = $sponser_cart_items['serviceAmount'][$key] - $membershipDiscount;
                                            }
                                          } else if ($discountType == 'SERVICE LEVEL') {
                                            $membershipDiscount = (float)$sponser_cart_items['membership_discount_amt'][$key];
                                            if ($membershipDiscount > 0) {
                                              $diacountHtml = '<small style="color:green;">( ' . $currencySymbol . ' ' . $membershipDiscount . ' OFF )</small>';
                                            }
                                            // $discounted_price = $sponser_cart_items['serviceAmount'][$key] - $membershipDiscount;
                                            $discounted_price = $membershipDiscount > 0 ? $membershipDiscount : $sponser_cart_items['serviceAmount'][$key];
                                          } else {
                                            $diacountHtml = '<small style="color:green;">( ' . $membershipDiscount . ' %OFF )</small>';
                                            $discounted_price = $sponser_cart_items['serviceAmount'][$key] - ($sponser_cart_items['serviceAmount'][$key] * $membershipDiscount) / 100;
                                          }
                                        }
                                      ?>
                                        <tr class="servicesTr">
                                          <td class="text-start">
                                            <p class="mb-0"><?= $sponser_cart_items['serviceName'][$key]; ?> </p>
                                            <span style="color: var(--main-color-new-theme);"><?= $sponser_cart_items['serviceTypes'][$key] ?></span><br>
                                            <?php
                                            if (!empty(trim($sponser_cart_items['dietyName'][$key]))) {
                                            ?>
                                              <span style="color: black;font-size:13px!important;"><b>Deity:</b> <?= $sponser_cart_items['dietyName'][$key] ?></span><br>
                                            <?php
                                            }
                                            if (!empty(trim($sponser_cart_items['disclaimerText'][$key]))) {
                                            ?>
                                              <span style="color: #ff0000;font-size:12px!important;"><b><?= $sponser_cart_items['disclaimerText'][$key] ?></b></span>
                                              <?php
                                            }
                                              ?><?= @$selectedCatVal; ?>


                                          </td>
                                          <td class="text-center"><?= $sponser_cart_items['qty'][$key]; ?></td>
                                          <td class="text-end" id="amount_<?= $sponser_cart_items['ids'][$key]; ?>">


                                            <?php
                                            if (isset($sponser_cart_items['serviceOccurrencesNo'][$key]) && !empty($sponser_cart_items['serviceOccurrencesNo'][$key])) {
                                              // $final_price = $discounted_price ? $discounted_price : ($sponser_cart_items['serviceAmount'][$key] * $sponser_cart_items['qty'][$key]) / $sponser_cart_items['serviceOccurrencesNo'][$key];
                                              $final_price = $discounted_price ? $discounted_price * (float)$sponser_cart_items['qty'][$key] * (float)$sponser_cart_items['serviceOccurrencesNo'][$key] : ((float)$sponser_cart_items['serviceAmount'][$key] * (float)$sponser_cart_items['qty'][$key] * (float)$sponser_cart_items['serviceOccurrencesNo'][$key]);
                                              $payNowTotalAmount += ((float)$sponser_cart_items['serviceAmount'][$key] * (float)$sponser_cart_items['qty'][$key] * (float)$sponser_cart_items['serviceOccurrencesNo'][$key]);

                                              $s_total += $final_price;


                                              // $serviceAmount = price_format(($sponser_cart_items['serviceAmount'][$key] * $sponser_cart_items['qty'][$key]) / $sponser_cart_items['serviceOccurrencesNo'][$key], 2);
                                              $serviceAmount = price_format(((float)$sponser_cart_items['serviceAmount'][$key] * (float)$sponser_cart_items['qty'][$key] * (float)$sponser_cart_items['serviceOccurrencesNo'][$key]), 2);
                                              if ($discounted_price != '') {

                                            ?>
                                                <?= '<span style="font-size: larger;">' . $currencySymbol . '&nbsp;' . number_format($serviceAmount, 2) . '</span>'; ?>

                                              <?php

                                                $sponser_cart_items['discountedAmount'][$key] = (float)$sponser_cart_items['serviceAmount'][$key] - (float)$discounted_price;
                                                $sponser_cart_items['oldServiceAmount'][$key] = (float)$sponser_cart_items['serviceAmount'][$key];
                                                $sponser_cart_items['serviceAmount'][$key] = $discounted_price;
                                              } else { ?>

                                                <?= '<span>' . $currencySymbol . '&nbsp;' . number_format($serviceAmount, 2) . '</span>'; ?>

                                              <?php
                                                $sponser_cart_items['discountedAmount'][$key] = '';
                                                $sponser_cart_items['oldServiceAmount'][$key] = '';
                                              }
                                            } else {
                                              $final_price = $discounted_price ? $discounted_price * $sponser_cart_items['qty'][$key] : $sponser_cart_items['serviceAmount'][$key] * $sponser_cart_items['qty'][$key];

                                              $payNowTotalAmount += $sponser_cart_items['serviceAmount'][$key] * $sponser_cart_items['qty'][$key];
                                              $s_total += $final_price;

                                              if ($discounted_price != '') { ?>

                                                <?= '<span style="font-size: larger;">' . $currencySymbol . '&nbsp;' . number_format($sponser_cart_items['serviceAmount'][$key] * $sponser_cart_items['qty'][$key], 2) . '</span>'; ?>

                                              <?php
                                                $serviceAmount = price_format(((float)$sponser_cart_items['serviceAmount'][$key] * (float)$sponser_cart_items['qty'][$key]), 2);
                                                $sponser_cart_items['discountedAmount'][$key] = (float)$sponser_cart_items['serviceAmount'][$key] - (float)$discounted_price;
                                                $sponser_cart_items['oldServiceAmount'][$key] = (float)$sponser_cart_items['serviceAmount'][$key];
                                                $sponser_cart_items['serviceAmount'][$key] = $discounted_price;
                                              } else { ?>

                                                <?= '<span>' . $currencySymbol . '&nbsp;' . number_format($sponser_cart_items['serviceAmount'][$key] * $sponser_cart_items['qty'][$key], 2) . '</span>'; ?>

                                            <?php
                                                $serviceAmount = price_format(((float)$sponser_cart_items['serviceAmount'][$key] * (float)$sponser_cart_items['qty'][$key]), 2);
                                                $sponser_cart_items['discountedAmount'][$key] = '';
                                                $sponser_cart_items['oldServiceAmount'][$key] = '';
                                              }
                                            }

                                            ?>


                                          </td>
                                          <td style="width:5%;text-align: center;" class="actions" data-th="">
                                            <a href="javaScript:void(0)" class="text-danger btn-sm sponser-delete-row" data-row-id="<?= $sponser_cart_items['ids'][$key]; ?>" style="font-size:17px"><i class="fa fa-trash-o"></i></a>
                                          </td>
                                        </tr>


                                    <?php

                                        $phone_html .= '<div style="border-bottom: 1px dashed #ccc; padding-bottom: 10px; margin-bottom: 10px;"><strong>' . htmlspecialchars($sponser_cart_items['serviceName'][$key]) . '</strong><br>';

                                        if (isset($sponser_cart_items['dietyName'][$key])) {
                                          $phone_html .= '<span><b>Deity:</b> ' . htmlspecialchars($sponser_cart_items['dietyName'][$key]) . '</span><br>';
                                        }

                                        if (!empty($selectedCatVal)) {
                                          $phone_html .= '<b>Service Date:</b> ' . htmlspecialchars($selectedCatVal) . '<br>';
                                        }


                                        $phone_html .= '<span><b>Qty:</b> ' . $sponser_cart_items['qty'][$key] . '</span><br><span><b>Amount:</b> ' . $currencySymbol . '&nbsp;' . $serviceAmount . '</span><br>';

                                        if (!empty(trim($sponser_cart_items['disclaimerText'][$key]))) {
                                          $phone_html .= '<span style="color: red;"><b>' . htmlspecialchars($sponser_cart_items['disclaimerText'][$key]) . '</b></span><br>';
                                        }

                                        $phone_html .= '<a href="javascript:void(0)" class="text-danger btn-sm sponser-delete-row" data-row-id="' . $sponser_cart_items['ids'][$key] . '"><i class="fa fa-trash-o"></i> Delete</a></div>';
                                      }
                                    }
                                  } else {

                                    $discounted_price = '';
                                    if ($membershipDetails['membershipStatus'] == "ACTIVE" && $is_membership_discount == 'YES') {
                                      if ($discountType == 'FLAT') {

                                        if ($sponser_cart_items['serviceAmount'][$key] > $membershipDiscount) {
                                          $diacountHtml = '<small style="color:green;">( ' . $currencySymbol . ' ' . $membershipDiscount . ' OFF )</small>';
                                          $discounted_price = $sponser_cart_items['serviceAmount'][$key] - $membershipDiscount;
                                        }
                                      } else if ($discountType == 'SERVICE LEVEL') {
                                        $membershipDiscount = (float)$sponser_cart_items['membership_discount_amt'][$key];
                                        if ($membershipDiscount > 0) {
                                          $diacountHtml = '<small style="color:green;">( ' . $currencySymbol . ' ' . $membershipDiscount . ' OFF )</small>';
                                        }
                                        // $discounted_price = $sponser_cart_items['serviceAmount'][$key] - $membershipDiscount;
                                        $discounted_price = $membershipDiscount > 0 ? $membershipDiscount : $sponser_cart_items['serviceAmount'][$key];
                                      } else {
                                        $diacountHtml = '<small style="color:green;">( ' . $membershipDiscount . ' %OFF )</small>';
                                        $discounted_price = $sponser_cart_items['serviceAmount'][$key] - ($sponser_cart_items['serviceAmount'][$key] * $membershipDiscount) / 100;
                                      }
                                    }
                                    ?>

                                    <tr class="servicesTr">
                                      <td class="text-start">
                                        <p class="mb-0"><?= $sponser_cart_items['serviceName'][$key]; ?></p>
                                        <span style="color: var(--main-color-new-theme);"><?= $sponser_cart_items['serviceTypes'][$key] ?></span><br>
                                        <?php
                                        if (!empty(trim($sponser_cart_items['dietyName'][$key]))) {
                                        ?>
                                          <span style="color: black;font-size:13px!important;"><b>Deity:</b> <?= $sponser_cart_items['dietyName'][$key] ?></span><br>
                                        <?php
                                        }
                                        if (!empty(trim($sponser_cart_items['disclaimerText'][$key]))) {
                                        ?>
                                          <span style="color: #ff0000;font-size:12px!important;"><b><?= $sponser_cart_items['disclaimerText'][$key] ?></b></span>
                                        <?php
                                        }
                                        ?>
                                      </td>
                                      <td class="text-center"><?= $sponser_cart_items['qty'][$key]; ?></td>
                                      <td class="text-end" id="amount_<?= $sponser_cart_items['ids'][$key]; ?>">


                                        <?php
                                        if (isset($sponser_cart_items['serviceOccurrencesNo'][$key]) && !empty($sponser_cart_items['serviceOccurrencesNo'][$key])) {
                                          // $final_price = $discounted_price ? $discounted_price : ($sponser_cart_items['serviceAmount'][$key] * $sponser_cart_items['qty'][$key]) / $sponser_cart_items['serviceOccurrencesNo'][$key];
                                          $final_price = $discounted_price ? $discounted_price * (float)$sponser_cart_items['qty'][$key] * (float)$sponser_cart_items['serviceOccurrencesNo'][$key] : ((float)$sponser_cart_items['serviceAmount'][$key] * (float)$sponser_cart_items['qty'][$key] * (float)$sponser_cart_items['serviceOccurrencesNo'][$key]);
                                          $payNowTotalAmount += ((float)$sponser_cart_items['serviceAmount'][$key] * (float)$sponser_cart_items['qty'][$key] * (float)$sponser_cart_items['serviceOccurrencesNo'][$key]);

                                          $s_total += $final_price;


                                          // $serviceAmount = price_format(($sponser_cart_items['serviceAmount'][$key] * $sponser_cart_items['qty'][$key]) / $sponser_cart_items['serviceOccurrencesNo'][$key], 2);
                                          $serviceAmount = price_format(((float)$sponser_cart_items['serviceAmount'][$key] * (float)$sponser_cart_items['qty'][$key] * (float)$sponser_cart_items['serviceOccurrencesNo'][$key]), 2);
                                          if ($discounted_price != '') {

                                        ?>
                                            <?= '<span style="font-size: larger;">' . $currencySymbol . '&nbsp;' . number_format($serviceAmount, 2) . '</span>'; ?>

                                          <?php
                                            $sponser_cart_items['discountedAmount'][$key] = (float)$sponser_cart_items['serviceAmount'][$key] - (float)$discounted_price;
                                            $sponser_cart_items['oldServiceAmount'][$key] = (float)$sponser_cart_items['serviceAmount'][$key];
                                            $sponser_cart_items['serviceAmount'][$key] = $discounted_price;
                                          } else { ?>

                                            <?= '<span>' . $currencySymbol . '&nbsp;' . $serviceAmount . '</span>'; ?>

                                          <?php
                                            $sponser_cart_items['discountedAmount'][$key] = '';
                                            $sponser_cart_items['oldServiceAmount'][$key] = '';
                                          }
                                        } else {
                                          $final_price = $discounted_price ? $discounted_price * $sponser_cart_items['qty'][$key] : $sponser_cart_items['serviceAmount'][$key] * $sponser_cart_items['qty'][$key];

                                          $payNowTotalAmount += $sponser_cart_items['serviceAmount'][$key] * $sponser_cart_items['qty'][$key];
                                          $s_total += $final_price;

                                          if ($discounted_price != '') { ?>
                                            <?= '<span style="font-size: larger;">' . $currencySymbol . '&nbsp;' . number_format($sponser_cart_items['serviceAmount'][$key] * $sponser_cart_items['qty'][$key], 2) . '</span>'; ?>

                                          <?php
                                            $sponser_cart_items['discountedAmount'][$key] = (float)$sponser_cart_items['serviceAmount'][$key] - (float)$discounted_price;
                                            $sponser_cart_items['oldServiceAmount'][$key] = (float)$sponser_cart_items['serviceAmount'][$key];
                                            $sponser_cart_items['serviceAmount'][$key] = $discounted_price;
                                          } else { ?>

                                            <?= '<span>' . $currencySymbol . '&nbsp;' . number_format($sponser_cart_items['serviceAmount'][$key] * $sponser_cart_items['qty'][$key], 2) . '</span>'; ?>

                                        <?php
                                            $sponser_cart_items['discountedAmount'][$key] = '';
                                            $sponser_cart_items['oldServiceAmount'][$key] = '';
                                          }
                                        }

                                        ?>


                                      </td>
                                      <td style="width:5%;text-align: center;" class="actions" data-th="">
                                        <a href="javaScript:void(0)" class="text-danger btn-sm sponser-delete-row" data-row-id="<?= $sponser_cart_items['ids'][$key]; ?>" style="font-size:17px"><i class="fa fa-trash-o"></i></a>
                                      </td>
                                    </tr>
                                  <?php

                                    $phone_html .= '<div style="border-bottom: 1px dashed #ccc; padding-bottom: 10px; margin-bottom: 10px;"><strong>' . htmlspecialchars($sponser_cart_items['serviceName'][$key]) . '</strong><br>';

                                    if (isset($sponser_cart_items['dietyName'][$key])) {
                                      $phone_html .= '<span><b>Deity:</b> ' . htmlspecialchars($sponser_cart_items['dietyName'][$key]) . '</span><br>';
                                    }

                                    $phone_html .= '<span><b>Qty:</b> ' . $sponser_cart_items['qty'][$key] . '</span><br><span><b>Amount:</b> ' . $currencySymbol . '&nbsp;' . number_format($sponser_cart_items['serviceAmount'][$key] * $sponser_cart_items['qty'][$key], 2) . '</span><br>';

                                    if (!empty(trim($sponser_cart_items['disclaimerText'][$key]))) {
                                      $phone_html .= '<span style="color: red;"><b>' . htmlspecialchars($sponser_cart_items['disclaimerText'][$key]) . '</b></span><br>';
                                    }

                                    $phone_html .= '<a href="javascript:void(0)" class="text-danger btn-sm sponser-delete-row" data-row-id="' . $sponser_cart_items['ids'][$key] . '"><i class="fa fa-trash-o"></i> Delete</a></div>';
                                  }
                                }
                              }

                              //Events====================================================
                              if (!empty($event_cart_items) && isset($event_cart_items['ids'])) {
                                foreach ($event_cart_items['ids'] as $key => $value) {
                                  if ($event_cart_items['serviceAmount'][$key] > 0) {
                                    $payNowTotalAmount += ($event_cart_items['serviceAmount'][$key] * $event_cart_items['qty'][$key]);
                                  }
                                  $discounted_price = '';
                                  $is_membership_discount = @$event_cart_items['is_membership_discount'][$key];
                                  if ($membershipDetails['membershipStatus'] == "ACTIVE" && $is_membership_discount == 'YES') {
                                    if ($discountType == 'FLAT') {

                                      if ($event_cart_items['serviceAmount'][$key] > $membershipDiscount) {
                                        $diacountHtml = '<small style="color:green;">( ' . $currencySymbol . ' ' . $membershipDiscount . ' OFF )</small>';
                                        $discounted_price = $event_cart_items['serviceAmount'][$key] - $membershipDiscount;
                                      }
                                    } else if ($discountType == 'SERVICE LEVEL') {
                                      $membershipDiscount = (float)$event_cart_items['membership_discount_amt'][$key];
                                      if ($membershipDiscount > 0) {
                                        $diacountHtml = '<small style="color:green;">( ' . $currencySymbol . ' ' . $membershipDiscount . ' OFF )</small>';
                                      }
                                      // $discounted_price = $event_cart_items['serviceAmount'][$key] - $membershipDiscount;
                                      $discounted_price = $membershipDiscount > 0 ? $membershipDiscount : $event_cart_items['serviceAmount'][$key];
                                    } else {
                                      $diacountHtml = '<small style="color:green;">( ' . $membershipDiscount . ' %OFF )</small>';
                                      $discounted_price = $event_cart_items['serviceAmount'][$key] - ($event_cart_items['serviceAmount'][$key] * $membershipDiscount) / 100;
                                    }
                                  }

                                  $final_price = $discounted_price ? $discounted_price : ($event_cart_items['serviceAmount'][$key] * $event_cart_items['qty'][$key]);


                                  $s_total += $final_price;
                                  ?>
                                  <tr class="servicesTr">
                                    <td class="text-start">
                                      <p class="mb-0"><?= $event_cart_items['serviceName'][$key]; ?><?= isset($event_cart_items['serviceDesc'][$key]) && !empty($event_cart_items['serviceDesc'][$key]) ? '(' . $event_cart_items['serviceDesc'][$key] . ')' : '' ?> </p>
                                      <span style="color: var(--main-color-new-theme);"><?= $event_cart_items['serviceTypes'][$key] ?></span><br>
                                      <?php
                                        if (!empty(trim($event_cart_items['dietyName'][$key]))) {
                                        ?>
                                            <span style="color: black; font-size: 13px !important;">
                                                <b>Deity:</b> <?= htmlspecialchars($event_cart_items['dietyName'][$key]) ?>
                                            </span><br>
                                        <?php
                                        }
                                      ?>
                                      <?= @$event_cart_items['startDate'][$key] ? 'Service Date: '.date('n/j/Y', strtotime($event_cart_items['startDate'][$key])) : 'Not Selected' ?>
                                    </td>

                                    <td class="text-center"><?= $event_cart_items['qty'][$key]; ?></td>
                                    <td class="text-end" id="amount_<?= $event_cart_items['ids'][$key]; ?>">


                                      <?php

                                      if ($discounted_price != '') { ?>
                                        <?= '<span style="font-weight: bold;font-size: larger;color: #b00000;">' . $currencySymbol . '&nbsp;' . number_format($event_cart_items['serviceAmount'][$key] * $event_cart_items['qty'][$key], 2) . '</span>'; ?>

                                      <?php
                                        $event_cart_items['discountedAmount'][$key] = (float)$event_cart_items['serviceAmount'][$key] - (float)$discounted_price;
                                        $event_cart_items['oldServiceAmount'][$key] = (float)$event_cart_items['serviceAmount'][$key];
                                        $event_cart_items['serviceAmount'][$key] = $discounted_price;
                                      } else { ?>

                                        <?= '<span>' . $currencySymbol . '&nbsp;' . number_format($event_cart_items['serviceAmount'][$key] * $event_cart_items['qty'][$key], 2) . '</span>'; ?>

                                      <?php
                                        $event_cart_items['discountedAmount'][$key] = '';
                                        $event_cart_items['oldServiceAmount'][$key] = '';
                                      }
                                      ?>
                                    </td>
                                    <td style="width:5%;text-align: center;" class="actions" data-th="">
                                      <a href="javaScript:void(0)" class="text-danger btn-sm event-delete-row" data-row-id="<?= $event_cart_items['ids'][$key]; ?>" style="font-size:17px"><i class="fa fa-trash-o"></i></a>
                                    </td>
                                  </tr>
                                  <?php
                                  $phone_html .= '<div style="border-bottom: 1px dashed #ccc; padding-bottom: 10px; margin-bottom: 10px;"><strong>' . htmlspecialchars($event_cart_items['serviceName'][$key]) . '</strong><br>';

                                  if (isset($event_cart_items['dietyName'][$key])) {
                                    $phone_html .= '<span><b>Deity:</b> ' . htmlspecialchars($event_cart_items['dietyName'][$key]) . '</span><br>';
                                  }

                                  if (isset($event_cart_items['startDate'][$key])) {
                                    $phone_html .= '<b>Service Date:</b> ' . date('n/j/Y', strtotime($event_cart_items['startDate'][$key])) . '<br>';
                                  }


                                  $phone_html .= '<span><b>Qty:</b> ' . $event_cart_items['qty'][$key] . '</span><br><span><b>Amount:</b> ' . $currencySymbol . '&nbsp;' . number_format($event_cart_items['serviceAmount'][$key] * $event_cart_items['qty'][$key], 2) . '</span><br>';


                                  $phone_html .= '<a href="javascript:void(0)" class="text-danger btn-sm event-delete-row" data-row-id="' . $event_cart_items['ids'][$key] . '"><i class="fa fa-trash-o"></i> Delete</a></div>';
                                }
                              }
                              // var_dump($donation_cart_items);
                              //DOnation======================================
                              if (!empty($donation_cart_items) && isset($donation_cart_items['ids'])) {
                                foreach ($donation_cart_items['ids'] as $key => $value) {
                                  $payNowTotalAmount += (float)$donation_cart_items['qty'][$key] * (float)$donation_cart_items['serviceAmount'][$key];
                                  $s_total += (float)$donation_cart_items['qty'][$key] * (float)$donation_cart_items['serviceAmount'][$key];
                                  ?>
                                  <tr class="servicesTr">
                                    <!-- <td class="text-start"><?= $donation_cart_items['serviceName'][$key]; ?></td> -->
                                    <td class="text-start">
                                      <p class="mb-0"><?= $donation_cart_items['serviceName'][$key]; ?>
                                        <?=
                                        !empty($donation_cart_items['service_desc'][$key]) && @$donation_cart_items['isTextinputBox'][$key] == 'YES' && $donation_cart_items['service_desc'][$key] != $donation_cart_items['serviceName'][$key] ? '(' . $donation_cart_items['service_desc'][$key] . ')' : '' ?>
                                      </p>
                                      <span style="color: var(--main-color-new-theme);"><?= $donation_cart_items['serviceTypes'][$key] ?></span><br>
                                      <?= @$donation_cart_items['startDate'][$key] ? date('n/j/Y', strtotime($donation_cart_items['startDate'][$key])) : '' ?>
                                    </td>
                                    <!-- <td class="text-center"><?= $donation_cart_items['ctg'][$key]; ?></td> -->
                                    <td class="text-center"><?= $donation_cart_items['qty'][$key]; ?></td>
                                    <td class="text-end"><?= $currencySymbol . ' ' . price_format($donation_cart_items['serviceAmount'][$key], 2); ?></td>
                                    <td style="width:5%;text-align: center;" class="actions" data-th="">
                                      <a href="javascript:void(0)" class="text-danger btn-sm donation-delete-row" data-row-id="<?= $donation_cart_items['ids'][$key]; ?>" style="font-size:17px"><i class="fa fa-trash-o"></i></a>
                                    </td>
                                  </tr>
                                  <?php
                                  $phone_html .= '<div style="border-bottom: 1px dashed #ccc; padding-bottom: 10px; margin-bottom: 10px;">
    <strong>' . htmlspecialchars($donation_cart_items['serviceName'][$key]) . '</strong><br>';

                                  if (isset($donation_cart_items['dietyName'][$key])) {
                                    $phone_html .= '<span><b>Deity:</b> ' . htmlspecialchars($donation_cart_items['dietyName'][$key]) . '</span><br>';
                                  }




                                  $phone_html .= '<span><b>Qty:</b> ' . $donation_cart_items['qty'][$key] . '</span><br>
                                                  <span><b>Amount:</b> ' . $currencySymbol . ' ' . number_format($donation_cart_items['serviceAmount'][$key], 2) . '</span><br>';


                                  $phone_html .= '<a href="javascript:void(0)" class="text-danger btn-sm donation-delete-row" data-row-id="' . $donation_cart_items['ids'][$key] . '">
                                                  <i class="fa fa-trash-o"></i> Delete</a>
                                                  </div>';
                                }
                              }
                              //Books======================================
                              if (!empty($books_cart_items) && isset($books_cart_items['ids'])) {
                                foreach ($books_cart_items['ids'] as $key => $value) {
                                  $payNowTotalAmount += (float)$books_cart_items['qty'][$key] * (float)$books_cart_items['serviceAmount'][$key];
                                  $s_total += (float)$books_cart_items['qty'][$key] * (float)$books_cart_items['serviceAmount'][$key];
                                  ?>
                                  <tr class="servicesTr">
                                    <!-- <td class="text-start"><?= $books_cart_items['serviceName'][$key]; ?></td> -->
                                    <td class="text-start">
                                      <p class="mb-0"><?= $books_cart_items['serviceName'][$key]; ?><?= isset($books_cart_items['serviceDesc'][$key]) && !empty($books_cart_items['serviceDesc'][$key]) ? '(' . $books_cart_items['serviceDesc'][$key] . ')' : '' ?> </p>
                                      <span style="color: var(--main-color-new-theme);"><?= $books_cart_items['serviceType'][$key] ?></span><br>
                                      <?= @$books_cart_items['startDate'][$key] ? date('n/j/Y', strtotime($books_cart_items['startDate'][$key])) : '' ?>
                                    </td>
                                    <!-- <td class="text-center"><?= $books_cart_items['ctg'][$key]; ?></td> -->
                                    <td class="text-center"><?= $books_cart_items['qty'][$key]; ?></td>
                                    <td class="text-end"><?= $currencySymbol . ' ' . number_format((float)$books_cart_items['serviceAmount'][$key] * (float)$books_cart_items['qty'][$key], 2); ?></td>
                                    <td style="width:5%;text-align: center;" class="actions" data-th="">
                                      <a href="javaScript:void(0)" class="text-danger btn-sm books-delete-row" data-row-id="<?= $books_cart_items['ids'][$key]; ?>" style="font-size:17px"><i class="fa fa-trash-o"></i></a>
                                    </td>
                                  </tr>
                              <?php

                                  $phone_html .= '<div style="border-bottom: 1px dashed #ccc; padding-bottom: 10px; margin-bottom: 10px;"><strong>' . htmlspecialchars($books_cart_items['serviceName'][$key]) . '</strong><br>';

                                  $phone_html .= '<span><b>Qty:</b> ' . $books_cart_items['qty'][$key] . '</span><br>
                                                  <span><b>Amount:</b> ' . $currencySymbol . ' ' . number_format((float)$books_cart_items['serviceAmount'][$key] * (float)$books_cart_items['qty'][$key], 2) . '</span><br>';


                                  $phone_html .= '<a href="javascript:void(0)" class="text-danger btn-sm books-delete-row" data-row-id="' . $books_cart_items['ids'][$key] . '">
                                                  <i class="fa fa-trash-o"></i> Delete</a>
                                                  </div>';
                                }
                              }
                              ?>

                            </tbody>
                          </table>
                        </div>
                      </div>
                      <!--phone view-->
                      <div class="d-block d-md-none">


                        <?= $phone_html ?>

                      </div>

                      <!-- ============================================= -->

                      <hr class="my-4">
                      <?php if (@CheckEmptyNullVar($GeneralSettings['TaxPercent']) != '' && @$GeneralSettings['TaxPercent'] > 0) { ?>

                        <div class="row mt-3">
                          <div class="col-md-10">
                            <h5 class="mb-0" style="font-weight:bold!important;">Tax (<?= @$GeneralSettings['TaxPercent'] != '' || @$GeneralSettings['TaxPercent'] != 0 ?  @$GeneralSettings['TaxPercent'] : 0 ?>%)</h5>
                          </div>
                          <div class="col-md-2 text-end"><span style="font-weight:bold!important;"><?= $currencySymbol ?> <?= number_format((price_format($sponser_cart_items['totalPrice'], 2) * price_format(@$GeneralSettings['TaxPercent'], 2)) / 100, 2); ?></span></div>

                          <?php $taxAmt = (price_format($sponser_cart_items['totalPrice'], 2) * price_format(@$GeneralSettings['TaxPercent'], 2)) / 100; ?>
                        </div>

                        <hr class="my-4">
                      <?php } else {
                        $taxAmt = 0;
                      } ?>

                      <div class="row mt-3">
                        <div class="col-12 col-md-6 text-start">
                          <h5 class="mb-0" style="font-weight:bold!important;">Subtotal</h5>
                        </div>

                        <div class="col-12 col-md-6 text-start text-md-end">

                          <span style="font-weight:bold!important;" id="subtle"><?= $currencySymbol ?>&nbsp;<?= number_format($payNowTotalAmount, 2); ?></span>


                        </div>

                      </div>



                      <?php
                      if ($payNowTotalAmount > $s_total) {
                      ?>
                        <div class="row mt-3">
                          <div class="col-md-6">
                            <h5 class="mb-0" style="font-weight:bold!important;font-size: 16px;color:#b00000;"> Membership Discount Applied (
                              <?php
                              if ($discountType == 'SERVICE LEVEL' || $discountType == 'FLAT') {
                                echo $currencySymbol . ' ' . number_format($payNowTotalAmount - $s_total, 2);
                              } else {
                                echo $membershipDiscount . '%';
                              }
                              ?>
                              )</h5>
                          </div>

                          <div class="col-md-6 text-end">


                            <span style="font-weight:bold!important;color:#b00000;" id=""><?= $currencySymbol ?>&nbsp;<?= price_format($payNowTotalAmount - $s_total, 2); ?></span>

                          </div>

                        </div>

                      <?php
                      }

                      ?>


                      <hr class="my-4">

                      <div class="row pt-3 pb-3" style="background-color:#dbdbdb">
                        <div class="col-12 col-md-8 text-start">
                          <h4 class="text-dark" style="margin-top:auto;margin-bottom:auto;font-weight: bold!important;">Sale Total</h4>
                        </div>
                        <div class="col-12 col-md-4 text-start text-md-end">

                          <h4 class="text-dark  text-start text-md-end" style="margin-top:auto;margin-bottom:auto;font-weight: bold!important;" id="saletle"><?= $currencySymbol ?>&nbsp;<?= number_format(($s_total + @$taxAmt), 2); ?>
                          </h4>
                        </div>
                      </div>


                    </div>
                  </div>
                  <div class="col-lg-5">
                    <div class="padding-5">
                      <div class="row">
                        <!-- <div class="col-md-7 fw-bold text-start">
                          <h5 class="mb-2" style="color:var(--main-color-new-theme-light)!important"><?= @$this->session->userdata('refDataName'); ?></h5><span><?= @base64_decode($this->session->userdata('email')); ?></span>
                        </div>
                        <div class="col-md-5 fw-bold text-end" style="word-wrap:none ;color:var(--main-color-new-theme)!important">

                          <?= formatPhoneNumber(@base64_decode($this->session->userdata('phone'))); ?>

                        </div> -->
                        <div class="col-md-12 fw-bold text-start">
                          <h5 class="mb-2" style="color:var(--main-color-new-theme)!important">
                            <div class="row p-0">
                              <div class="col-sm-7 p-0">
                                <?php

                                if ($membershipDetails['membershipStatus'] == "ACTIVE") {

                                ?>
                                  <img src="<?= base_url('admin_assets/img/membership.png') ?>" alt="Membership Icon" height="20"> <?php
                                                                                                                                  }
                                                                                                                                    ?> <span class="fw-bold" style="word-wrap:none ;color:var(--main-color-new-theme)!important"><?= @$this->session->userdata('refDataName'); ?></span>
                              </div>
                              <div class="col-sm-5 p-0">
                                <span class="fw-bold" style="word-wrap:none ;color:var(--main-color-new-theme)!important">

                                  <?= formatPhoneNumber(@base64_decode($this->session->userdata('phone'))); ?>

                                </span>
                              </div>
                              <div class="col-sm-12 p-0"> <span><?= @base64_decode($this->session->userdata('email')); ?></span></div>
                            </div>

                          </h5>

                        </div>
                        <?php
                        if ($membershipDetails['membershipStatus'] == "ACTIVE") {
                        ?>

                          <div class="col-md-12 fw-bold text-start">
                            <h5 class="mb-2" style="color:var(--main-color-new-theme)!important">
                              <div class="row p-0">

                                <div class="col-sm-7 p-0">
                                  <span class="fw-bold" style="word-wrap:none ;color: #b00000;">Membership Type: </span>
                                </div>
                                <div class="col-sm-5 p-0">
                                  <span class="fw-bold" style="word-wrap:none ;color: #b00000;">

                                    <?= $membershipDetails['membershipType']; ?>

                                  </span>
                                </div>
                              </div>

                            </h5>
                          </div>
                        <?php
                        }
                        ?>
                      </div>
                      <!-- <hr class="my-4"> -->

                      <hr class="my-2">
                      <?php
                      // var_dump(@$CheckoutDonationSettings);
                      // $CheckoutDonationSettings['acharyasanbhavana'] = 1;
                      if (@$CheckoutDonationSettings['acharyasanbhavana'] == 1) { ?>
                        <div class="row p-3" style="background-color:#dbdbdb">
                          <div class="col-md-9">
                            <h6 class="fw-bold fontSize" style="margin-top:7px!important;margin-bottom:auto;"><?= @$CheckoutDonationSettings['AsDisplayTitle'] ?> (<?= $currencySymbol ?>)</h6>
                          </div>
                          <div class="col-md-3 text-end">
                            <input type="number" name="acharya_sambhavana" placeholder="<?= $currencySymbol ?> 0.00" class="form-control form-control-sm fontSize" id="acharya-sambhavana-input" onchange="AcharyaSambhavanaPriceFormate(this)">
                          </div>

                        </div>
                      <?php } ?>

                      <?php if (@$CheckoutDonationSettings['generalDonation'] == 1) { ?>
                        <div class="row p-3" style="background-color:#dbdbdb">
                          <div class="col-md-9">
                            <h6 class="fw-bold fontSize" style="margin-top:7px!important;margin-bottom:auto;"><?= @$CheckoutDonationSettings['DonationDisplayTitle'] ?> (<?= $currencySymbol ?>)</h6>
                          </div>
                          <div class="col-md-3 text-end">
                            <input type="number" name="general_donation" placeholder="<?= $currencySymbol ?> 0.00" class="form-control form-control-sm fontSize" id="general-donation-input" onchange="AcharyaSambhavanaPriceFormate(this)">
                          </div>

                        </div>
                        <hr class="my-4">
                      <?php } ?>


                      <div class="row p-3" style="background-color:#dbdbdb">
                        <div class="col-md-12">
                          <!-- <h6 class="fw-bold fontSize" style="margin-top:7px!important;margin-bottom:auto;">Notes</h6> -->


                          <textarea name="creditCardRemark" placeholder="Enter notes here....." class="form-control form-control-sm fontSize" id="creditCardRemark"></textarea>
                        </div>

                      </div>
                      <hr class="my-4">

                      <!-- <?php
                            $subTotal =  price_format(((($sponser_cart_items['totalPrice'] * @($GeneralSettings['TaxPercent'] ? $GeneralSettings['TaxPercent'] : 0)) / 100) +  $sponser_cart_items['totalPrice']), 2);
                            $this->session->set_userdata('totalPrice', $subTotal);
                            $newSubTotal = $this->session->userdata('totalPrice');
                            ?>
                      <?php if (@CheckEmptyNullVar($GeneralSettings['TaxPercent']) != '' && @$GeneralSettings['TaxPercent'] > 0) {
                        $sponser_cart_items['totalPrice'] = (price_format($sponser_cart_items['totalPrice'], 2) * price_format(@$GeneralSettings['TaxPercent'], 2)) / 100;
                      }

                      ?> -->
                      <?php
                      if (empty($membershipDetails['membershipStatus'])) {

                      ?>
                        <div class="row mt-3">
                          <div class="col-md-12">
                            <h5 class="mb-0 fontSize text-center" style="font-weight:bold!important;font-size: 16px;color:#b00000;">
                              <a href="<?= base_url('membership-form?page=' . $redirectURL2) ?>" class="text-danger">** Become an annual member to avail discounts? Click here **</a>
                            </h5>
                          </div>
                        </div>
                      <?php
                      }
                      ?>
                      <div class="text-center my-3">
                        <div class="d-flex flex-column flex-md-row justify-content-between my-4 text-start text-md-end">
                          <h3 class="fw-bold mb-2 mb-md-0" style="font-size: 25px;">
                            Amount to Pay:
                          </h3>
                          <h3 class="fw-bold" style="font-size: 25px; border: 2px solid #dbdbdb; border-radius: 9px; padding: 3px;" id="total-price">
                            <?= $currencySymbol ?>&nbsp;<?= number_format($s_total, 2); ?>
                          </h3>
                        </div>

                        <?php if ($paymentSeverOn == 1) {



                          if (isset($paymentSetting) && ($paymentSetting == 'MPI' || $paymentSetting == 'MPITEST')) { ?>

                            <style>
                              #amount {
                                width: 75px;
                              }

                              #card {
                                background: #ffffffa3;
                                height: 100px;
                                padding: 10px 12px;
                                border-radius: 5px;
                                border: 1px solid #84a6ae;
                                box-sizing: border-box;
                                line-height: 0;
                                margin: 9px 0px;
                                width: 500px;
                              }

                              .input-style {
                                color: #32a866;
                              }

                              .input-hint {
                                color: #5e95a1;
                                border-color: #9ac0c8;
                              }

                              /* All fields in form */
                              .form-wrapper {
                                width: 400px;
                              }

                              /* Credit Card Number */
                              .input-wrapper {
                                width: 200px;
                              }

                              /* Expiry Date */
                              .sub-wrapper {
                                width: 100px;
                              }

                              .valid-class {
                                color: #217195;
                              }

                              .invalid-class {
                                color: #b05826;
                              }

                              * {
                                box-sizing: border-box;
                              }

                              .row {
                                display: -ms-flexbox;
                                /* IE10 */
                                display: flex;
                                -ms-flex-wrap: wrap;
                                /* IE10 */
                                flex-wrap: wrap;
                                margin: 0 -16px;
                              }

                              .col-25 {
                                -ms-flex: 25%;
                                /* IE10 */
                                flex: 25%;
                              }

                              .col-50 {
                                -ms-flex: 50%;
                                /* IE10 */
                                flex: 50%;
                              }

                              .col-30 {
                                -ms-flex: 30%;
                                /* IE10 */
                                flex: 30%;
                              }

                              .col-75 {
                                -ms-flex: 75%;
                                /* IE10 */
                                flex: 75%;
                              }

                              .col-25,
                              .col-50,
                              .col-75 {
                                padding: 0 16px;
                              }


                              .form-control:focus {
                                color: #495057;
                                background-color: #fff;
                                border-color: #000408;
                                outline: 0;
                                box-shadow: 0 0 0 0.04rem rgb(0 0 0);
                              }


                              .icon-container {
                                margin-bottom: 20px;
                                padding: 7px 0;
                                font-size: 24px;
                              }




                              hr {
                                border: 1px solid lightgrey;
                              }

                              span.price {
                                float: right;
                                color: grey;
                              }
                            </style>
                            <form id="paymentForm" action="https://www.bridgepaynetsecuretx.com/WebSecurity/echo.aspx" method="post" style=" max-width: 500px;margin: auto;">
                              <div class="row px-0">
                                <div class="col-md-12 px-0">
                                  <h6 class="text-center">Card Details</h6>
                                  <div id="card" class="mx-0" style="width: 100%!important;height: 150px;"></div>
                                  <div id="errorMessage" style="margin-bottom: 10px; color: #c0392b;"></div>
                                </div>

                                <div class="col-md-12 px-0">
                                  <h6 class="text-center">Billing Address</h6>
                                  <p for="fname" style="text-align: justify;margin-bottom: 0px;font-weight: 600;">Name on Card <span class="text-danger">*</span></p>

                                  <input type="text" class="form-control fontSize" id="fname" name="firstname" placeholder="Enter Your Full Name*" style="width: 100%; margin-bottom: 20px; padding: 12px; border: 1px solid #ccc; border-radius: 3px;    padding-top: 12px!important;" value="<?= @$current_user->refDataName; ?>" required>
                                  <input type="email" id="email" class="form-control d-none" name="email" placeholder="Enter Your Email Address" style="width: 100%; margin-bottom: 20px; padding: 12px; border: 1px solid #ccc; border-radius: 3px;    padding-top: 12px!important;" value="<?= base64_decode($current_user->email); ?>" oninput="this.value = this.value.toLowerCase();">
                                  <input type="text" class="form-control d-none" id="address" name="address" placeholder="Enter Your Street Address" style="width: 100%; margin-bottom: 20px; padding: 12px; border: 1px solid #ccc; border-radius: 3px;    padding-top: 12px!important;" value="<?= @$current_user->addressLine1 . ' ' . @$current_user->addressLine2; ?>">
                                  <p for="zipcode" style="text-align: justify;margin-bottom: 0px;font-weight: 600;">ZIP Code <span class="text-danger">*</span></p>

                                  <input type="number" class="form-control fontSize" id="zipcode" name="zipcode" placeholder="Enter Your Zipcode" style="width: 100%; margin-bottom: 20px; padding: 12px; border: 1px solid #ccc; border-radius: 3px;    padding-top: 12px!important;" value="<?= @$current_user->zip; ?>" onKeyPress="if(this.value.length==5) return false;" required>

                                  <div class="row m-0 p-0 d-none">
                                    <div class="col-md-12 px-0">
                                      <input type="text" id="state" name="state" placeholder="State*" style="width: 100%; margin-bottom: 20px; padding: 12px; border: 1px solid #ccc; border-radius: 3px;    padding-top: 12px!important;" value="<?= @$current_user->stateTypes; ?>">
                                    </div>
                                    <div class="col-md-12 px-0">
                                      <input type="text" id="city" name="city" placeholder="City*" style="width: 100%; margin-bottom: 20px; padding: 12px; border: 1px solid #ccc; border-radius: 3px;    padding-top: 12px!important;" value="<?= @$current_user->cityTypes; ?>">
                                    </div>
                                  </div>

                                  <center>
                                    <button type="submit" class="btn btn-success" style="max-width: 500px;margin: auto;border-radius: 4px!important;font-weight: 800;padding: 8px 24px;background: #e78b00;border: 0;text-shadow: 1px 1px 0px black;">PAY NOW</button>
                                  </center>
                                </div>
                              </div>

                            </form>

                            </form>
                          <?php } else if (isset($paymentSetting) && $paymentSetting == 'CHARGEANYWHERE') { ?>
                            <iframe id="paymentIframe" title="Payment Page" width="100%" height="600px"></iframe>

                            <div id="paypal-button-container"></div>

                          <?php }
                        } else { ?>

                          <span class="alert mt-5 alert-danger text-center fw-bold"><i class="fa fa-warning fw-bold"></i> <?= $paymentSeverText; ?></span>
                        <?php } ?>
                      </div>
                    </div>
                  </div>
                </div>
                <!-- <input type="hidden" id="totalDonation" value="<?= price_format($sponser_cart_items['totalPrice'], 2); ?>"> -->
                <input type="hidden" id="totalDonation" value="<?= price_format($s_total, 2); ?>">
              <?php } else { ?>

                <div class="text-center  my-5">
                  <h3 class="text-danger text-center fw-bold mb-5">Your Cart is empty!</h3>
                  <a href="<?= base_url($redirectURL) ?>" class='btn text-center btn-primary btn-sm checkoutbtn' style='background: #910301; border: 1px solid yellow;'>Go to <?= $redirectURL3 ?></a>
                </div>

              <?php } ?>
            </div>
          </div>
        </div>
      </div>
    </div>
  </section>
</main>

<!-- Live Client Id -->
<script>
  /*$(document).ready(function() {
		var $totalPrice = $('#total-price');


		<?php if (@$CheckoutDonationSettings['acharyasanbhavana'] == 1) { ?>
			var $acharyaInput = $('#acharya-sambhavana-input');
			$acharyaInput.on('input', updateTotalPrice);

		<?php } ?>

		<?php if (@$CheckoutDonationSettings['generalDonation'] == 1) { ?>
			var $generalInput = $('#general-donation-input');
			$generalInput.on('input', updateTotalPrice);
		<?php } ?>



		// Function to update the total price based on the input values
		function updateTotalPrice() {
			// Get the input values
			var acharyaValue = 0;
			var generalValue = 0;
			<?php if (@$CheckoutDonationSettings['acharyasanbhavana'] == 1) { ?>
				var acharyaValue = parseFloat($acharyaInput.val().replace(/[^\d.-]/g, '')) || 0;
			<?php } ?>
			<?php if (@$CheckoutDonationSettings['generalDonation'] == 1) { ?>
				var generalValue = parseFloat($generalInput.val().replace(/[^\d.-]/g, '')) || 0;
			<?php } ?>



			// Get the initial total price
			// var initialTotalPrice = parseFloat(<?= @$payNowTotalAmount; ?>) || 0;
			var initialTotalPrice = parseFloat(<?= @$s_total; ?>) || 0;

			// Calculate the new total price
			var newTotalPrice = initialTotalPrice + acharyaValue + generalValue;

			// Update the total price element
			$totalPrice.text('<?= $currencySymbol ?> ' + newTotalPrice.toFixed(2));
		}

		// Call updateTotalPrice once to include the initial total price
		updateTotalPrice();


		<?php if (@$CheckoutDonationSettings['acharyasanbhavana'] == 1) { ?>
			// Disable arrow key inputs
			$acharyaInput.on('keydown', function(e) {
				if (e.which === 38 || e.which === 40) {
					e.preventDefault();
				}
			});
			// Add validation to prevent input of negative values
			$acharyaInput.on('keydown', function(e) {
				if (e.key === '-' || e.key === '+') {
					e.preventDefault();
				}
			});

			// Add validation to prevent input of "+" and "e" characters
			$acharyaInput.on('input', function() {
				$acharyaInput.val($acharyaInput.val().replace(/[+e]/gi, ''));
			});
		<?php } ?>
		<?php if (@$CheckoutDonationSettings['generalDonation'] == 1) { ?>
			$generalInput.on('keydown', function(e) {
				if (e.which === 38 || e.which === 40) {
					e.preventDefault();
				}
			});

			$generalInput.on('keydown', function(e) {
				if (e.key === '-' || e.key === '+') {
					e.preventDefault();
				}
			});

			$generalInput.on('input', function() {
				$generalInput.val($generalInput.val().replace(/[+e]/gi, ''));
			});
		<?php } ?>

	});*/

  function AcharyaSambhavanaPriceFormate(element) {
    // Wrap element in jQuery to ensure it has jQuery functions like val()
    let $element = $(element);

    // Parse the input value as a float, apply toFixed(2), and set it back to the input
    let value = parseFloat($element.val());
    console.log(value);
    if (!isNaN(value)) {
      $element.val(value.toFixed(2));
    }
  }
</script>
<?php if ($paymentSeverOn == 1 && $paymentSetting == 'PAYPAL') { ?>
  <?php $paypalLiveClientId  = getclientInfoById()['data'][0]['paypalClientId']; ?>
  <script src="https://www.paypal.com/sdk/js?client-id=<?= $paypalLiveClientId ?>&enable-funding=venmo&intent=capture" data-sdk-integration-source="integrationbuilder"></script>
<?php } ?>

<?php $this->load->view('includes/footer') ?>
<script type="text/javascript">
  var loader = new ldLoader({
    root: ".ldld.full"
  });
  if (window.performance && window.performance.navigation.type === window.performance.navigation.TYPE_BACK_FORWARD) {
    loader.on();
  }
  document.addEventListener("click", function(event) {
    if (event.target.matches(".navlink, .loader")) {
      loader.on();
    }
  });
  window.onload = function() {
    loader.off();
  };
</script>

<?php if ($paymentSeverOn == 1 && $paymentSetting == 'PAYPAL') { ?>
  <script type="text/javascript">
    $(document).ready(function() {
      var $totalPrice = $('#total-price');


      <?php if (@$CheckoutDonationSettings['acharyasanbhavana'] == 1) { ?>
        var $acharyaInput = $('#acharya-sambhavana-input');
        $acharyaInput.on('input', updateTotalPrice);

      <?php } ?>

      <?php if (@$CheckoutDonationSettings['generalDonation'] == 1) { ?>
        var $generalInput = $('#general-donation-input');
        $generalInput.on('input', updateTotalPrice);
      <?php } ?>



      // Function to update the total price based on the input values
      function updateTotalPrice() {
        // Get the input values
        var acharyaValue = 0;
        var generalValue = 0;
        <?php if (@$CheckoutDonationSettings['acharyasanbhavana'] == 1) { ?>
          var acharyaValue = parseFloat($acharyaInput.val().replace(/[^\d.-]/g, '')) || 0;
        <?php } ?>
        <?php if (@$CheckoutDonationSettings['generalDonation'] == 1) { ?>
          var generalValue = parseFloat($generalInput.val().replace(/[^\d.-]/g, '')) || 0;
        <?php } ?>



        // Get the initial total price
        // var initialTotalPrice = parseFloat(<?= @$payNowTotalAmount; ?>) || 0;
        var initialTotalPrice = parseFloat(<?= @$s_total; ?>) || 0;

        // Calculate the new total price
        var newTotalPrice = initialTotalPrice + acharyaValue + generalValue;

        // Update the total price element
        $totalPrice.text('<?= $currencySymbol ?> ' + newTotalPrice.toFixed(2));
      }

      // Call updateTotalPrice once to include the initial total price
      updateTotalPrice();


      <?php if (@$CheckoutDonationSettings['acharyasanbhavana'] == 1) { ?>
        // Disable arrow key inputs
        $acharyaInput.on('keydown', function(e) {
          if (e.which === 38 || e.which === 40) {
            e.preventDefault();
          }
        });
        // Add validation to prevent input of negative values
        $acharyaInput.on('keydown', function(e) {
          if (e.key === '-' || e.key === '+') {
            e.preventDefault();
          }
        });

        // Add validation to prevent input of "+" and "e" characters
        $acharyaInput.on('input', function() {
          $acharyaInput.val($acharyaInput.val().replace(/[+e]/gi, ''));
        });
      <?php } ?>
      <?php if (@$CheckoutDonationSettings['generalDonation'] == 1) { ?>
        $generalInput.on('keydown', function(e) {
          if (e.which === 38 || e.which === 40) {
            e.preventDefault();
          }
        });

        $generalInput.on('keydown', function(e) {
          if (e.key === '-' || e.key === '+') {
            e.preventDefault();
          }
        });

        $generalInput.on('input', function() {
          $generalInput.val($generalInput.val().replace(/[+e]/gi, ''));
        });
      <?php } ?>

    });

    const paypalButtonsComponent = paypal.Buttons({
      style: {
        shape: 'rect',
        color: 'gold',
        layout: 'vertical',
        label: 'paypal',
      },
      createOrder: (data, actions) => {
        var currency = "USD";

        amt = $("#totalDonation").val();

        var status = 'TEMP';
        var paymentSource = data.paymentSource;

        var totalPrice = amt;
        var acharya_sambhavana = parseFloat($('#acharya-sambhavana-input').val()) || 0;
        var general_donation = parseFloat($('#general-donation-input').val()) || 0;


        var cart_data = '<?php echo json_encode($sponser_cart_items) ?>';

        $.ajax({
          url: "<?= base_url('SponsorNow/AddToCart') ?>",
          type: "POST",
          dataType: "json",
          data: {
            'status': status,
            'paymentSource': paymentSource,
            'acharya_sambhavana': acharya_sambhavana,
            'general_donation': general_donation,
            'totalPrice': totalPrice,
            'cart_data': cart_data,
          },
          success: function(response) {
            loader.off();
            console.log(response);
          }
        });




        const createOrderPayload = {
          purchase_units: [{
            amount: {
              currency_code: currency,
              value: amt
            }
          }]
        };
        return actions.order.create(createOrderPayload);
      },
      onApprove: (data, actions) => {
        const captureOrderHandler = (details) => {

          loader.on();
          var status = 'COMPLETED';

          // var orderid = details.id;
          var status = details.status;

          var transaction_id = details.purchase_units[0].payments.captures[0].id;

          $.ajax({
            url: "<?= base_url('SponsorNow/updateTransactionStatus') ?>",
            type: "POST",
            dataType: "json",
            data: {
              'status': status,
              'transaction_id': transaction_id,
              'paymentDescription': details
            },
            success: function(response) {
              loader.off();
              if (response.statusCode == 1) {
                swal({
                    html: true,
                    title: "Payment Successfully Processed!",
                    text: "<span style='font-weight: 600;margin:5px;padding:5px;font-size: 27px !important;'>Receipt #: " + update_transactionstatus_response.envoiceNo + "</span>",
                    type: "success",
                    confirmButtonText: 'OK',
                    confirmButtonColor: 'var(--main-color-new-theme)',
                  },
                  function() {
                    // window.location.reload();
                    window.location.href = "<?= base_url('sponsor-now') ?>";
                  });
              } else {
                swal({
                    html: true,
                    title: "Failed!",
                    text: "<span>Transaction Failed!<span><br><span style='font-weight: 600;margin:5px;padding:5px;font-size: 27px !important;'>Receipt #: " + update_transactionstatus_response.envoiceNo + "</span>",
                    type: "error",
                    confirmButtonText: 'OK',
                    confirmButtonColor: 'var(--main-color-new-theme)',
                  },
                  function() {
                    window.location.reload();
                  });
              }
            }
          });
        };

        return actions.order.capture().then(captureOrderHandler);
      },

      onError: (err) => {

        console.log(err);
        alert('Transaction Failed');

      }
    });

    paypalButtonsComponent
      .render("#paypal-button-container")
      .catch((err) => {
        console.log('PayPal Buttons failed to render');
      });
  </script>

<?php } ?>






<?php if (isset($paymentSetting) && ($paymentSetting == 'MPITEST' || $paymentSetting == 'MPI') && $paymentSeverOn == 1) { ?>

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>



  <!-- <script type="text/javascript" src="https://www.bridgepaynetsecuretx.com/Bridgepay.WebSecurity/TokenPay/js/tokenPay.js"></script> -->
  <!-- <script type="text/javascript" src="https://www.bridgepaynetsecuretest.com/WebSecurity/TokenPay/js/tokenPay.js"></script> -->

  <?php $mpiTokenPayId  = @getclientInfoById()['data'][0]['MPItokenPay'];
  $MpiPayUrl = base_url('MPI_Payments/Paynow');
  if (isset($mpiTokenPayId) && $mpiTokenPayId != '' && $paymentSetting == 'MPI') {
    $TokenPay = $mpiTokenPayId;
  ?>
    <script type="text/javascript" src="https://www.bridgepaynetsecuretx.com/Bridgepay.WebSecurity/TokenPay/js/tokenPay.js"></script>
  <?php
  } else {
    $TokenPay = 'tokenpay10579api20211508121542285';
    $MpiPayUrl = base_url('MPI_Payments/PaynowTest');
  ?>
    <script type="text/javascript" src="https://www.bridgepaynetsecuretest.com/WebSecurity/TokenPay/js/tokenPay.js"></script>
  <?php
  }

  ?>
  <script>
    /*Acharya sambhawana And General Donation  Start*/
    $(document).ready(function() {
      var $totalPrice = $('#total-price');
      var $totalDonation = $('#totalDonation');


      <?php if (@$CheckoutDonationSettings['acharyasanbhavana'] == 1) { ?>
        var $acharyaInput = $('#acharya-sambhavana-input');
        $acharyaInput.on('input', updateTotalPrice);
      <?php } ?>

      <?php if (@$CheckoutDonationSettings['generalDonation'] == 1) { ?>
        var $generalInput = $('#general-donation-input');
        $generalInput.on('input', updateTotalPrice);
      <?php } ?>



      // Function to update the total price based on the input values
      function updateTotalPrice() {
        // Get the input values
        var acharyaValue = 0;
        var generalValue = 0;

        <?php if (@$CheckoutDonationSettings['acharyasanbhavana'] == 1) { ?>
          var acharyaValue = parseFloat($acharyaInput.val().replace(/[^\d.-]/g, '')) || 0;
        <?php } ?>
        <?php if (@$CheckoutDonationSettings['generalDonation'] == 1) { ?>
          var generalValue = parseFloat($generalInput.val().replace(/[^\d.-]/g, '')) || 0;
        <?php } ?>

        // Get the initial total price
        // var initialTotalPrice = parseFloat( price_format($sponser_cart_items['totalPrice'], 2); ?>) || 0;
        var initialTotalPrice = parseFloat(<?= $s_total; ?>) || 0;

        // Calculate the new total price
        var newTotalPrice = initialTotalPrice + acharyaValue + generalValue;

        // Format the new total price with commas
        var formattedTotalPrice = newTotalPrice.toLocaleString('en-US', {
          minimumFractionDigits: 2,
          maximumFractionDigits: 2
        });

        // Update the total price element
        $totalPrice.text('<?= $currencySymbol ?> ' + formattedTotalPrice);

        // Update the total donation input value
        $totalDonation.val(newTotalPrice.toFixed(2)); // Keeping the original value without formatting for internal processing
      }

      // Call updateTotalPrice once to include the initial total price
      updateTotalPrice();



      <?php if (@$CheckoutDonationSettings['acharyasanbhavana'] == 1) { ?>
        // Disable arrow key inputs
        $acharyaInput.on('keydown', function(e) {
          if (e.which === 38 || e.which === 40) {
            e.preventDefault();
          }
        });
        // Add validation to prevent input of negative values
        $acharyaInput.on('keydown', function(e) {
          if (e.key === '-' || e.key === '+') {
            e.preventDefault();
          }
        });

        // Add validation to prevent input of "+" and "e" characters
        $acharyaInput.on('input', function() {
          $acharyaInput.val($acharyaInput.val().replace(/[+e]/gi, ''));
        });
      <?php } ?>
      <?php if (@$CheckoutDonationSettings['generalDonation'] == 1) { ?>
        $generalInput.on('keydown', function(e) {
          if (e.which === 38 || e.which === 40) {
            e.preventDefault();
          }
        });

        $generalInput.on('keydown', function(e) {
          if (e.key === '-' || e.key === '+') {
            e.preventDefault();
          }
        });

        $generalInput.on('input', function() {
          $generalInput.val($generalInput.val().replace(/[+e]/gi, ''));
        });
      <?php } ?>

    });
    /*Acharya sambhawana And General Donation  End*/

    var tokenpay = TokenPay('<?= $TokenPay ?>');
    tokenpay.initialize({
      dataElement: '#card',
      errorElement: '#errorMessage',
      amountElement: '#amount',
      useStyles: false,
      useACH: false,
      disableZip: true,
      disableCvv: false
    });

    var form = document.getElementById('paymentForm');
    form.addEventListener('submit', function(event) {



      event.preventDefault();
      loader.on();
      tokenpay.createToken(function(result) {


        console.log(result);


        var totalPriceText = $("#total-price").text();
        var mpi_zipcode = $("#zipcode").val();
        var mpi_fname = $("#fname").val();
        var mpi_address = $("#address").val();

        var numericValue = totalPriceText.replace(/[^0-9.]/g, '');
        var numericAmount = parseFloat(numericValue);

        var totolAmt = numericAmount;


        if (result.status == 'auth_success') {
          // loader.on();

          $.ajax({
            url: "<?= $MpiPayUrl ?>",
            type: "POST",
            dataType: "json",
            data: {
              'token': result.token,
              'totolAmt': totolAmt,
              // 'totolAmt': 5,
              'name': mpi_fname,
              'address': mpi_address,
              'zipcode': mpi_zipcode
            },
            success: function(mpicardpayment_response) {
              let session_data = '<?= @$session_data ?>';
              console.log(mpicardpayment_response);
              var paymentSource = 'MPI';

              var status = 'TEMP';

              var totalPrice = totolAmt;


              var acharya_sambhavana = parseFloat($('#acharya-sambhavana-input').val()) || 0;
              var general_donation = parseFloat($('#general-donation-input').val()) || 0;
              var creditCardRemark = $('#creditCardRemark').val();



              var sponser_cart_items = '<?= json_encode($sponser_cart_items) ?>';
              var service_cart_items = '<?= json_encode($service_cart_items) ?>';
              var event_cart_items = '<?= json_encode($event_cart_items) ?>';
              var donation_cart_items = '<?= json_encode($donation_cart_items) ?>';
              var books_cart_items = <?= json_encode(is_array($books_cart_items) ? $books_cart_items : json_decode($books_cart_items, true)) ?>;
              if (mpicardpayment_response.data.responseCode == 00000) {


                $.ajax({
                  url: "<?= base_url('Common/AddToCart') ?>",
                  type: "POST",
                  dataType: "json",
                  data: {
                    'status': status,
                    'paymentSource': paymentSource,
                    'acharya_sambhavana': acharya_sambhavana,
                    'general_donation': general_donation,
                    'totalPrice': totalPrice,
                    'mpiInvNumber': mpicardpayment_response.mpiInvNumber,
                    'sponser_cart_items': sponser_cart_items,
                    'service_cart_items': service_cart_items,
                    'event_cart_items': event_cart_items,
                    'donation_cart_items': donation_cart_items,
                    'books_cart_items': books_cart_items,
                    'creditCardRemark': creditCardRemark
                  },
                  success: function(addtocart_response) {
                    if (addtocart_response.statusCode == 1) {

                      var status = 'COMPLETED';
                      var trnxId = "Payment completed~" + mpicardpayment_response.data.ReferenceNumber + "~" + mpicardpayment_response.data.cardType + "~" + mpicardpayment_response.data.maskedAccountNumber;

                      $.ajax({
                        url: "<?= base_url('Common/updateTransactionStatus') ?>",
                        type: "POST",
                        dataType: "json",
                        data: {
                          'status': status,
                          'transaction_id': trnxId,
                          'paymentDescription': mpicardpayment_response
                        },
                        success: function(update_transactionstatus_response) {
                          if (update_transactionstatus_response.statusCode == 1) {


                            swal({
                                html: true,
                                title: "Payment Successfully Processed!",
                                text: "<span style='font-weight: 600;margin:5px;padding:5px;font-size: 27px !important;'>Receipt #: " + update_transactionstatus_response.envoiceNo + "</span>",
                                type: "success",
                                confirmButtonText: 'OK',
                                confirmButtonColor: 'var(--main-color-new-theme)',
                              },
                              function() {
                                // window.location.reload();

                                window.location.href = "<?= base_url($redirectURL) ?>";


                              });

                            loader.off();
                          }

                        }
                      });

                    }
                  }
                });

              } else {

                $.ajax({
                  url: "<?= base_url('Common/AddToCart') ?>",
                  type: "POST",
                  dataType: "json",
                  data: {

                    'status': status,
                    'paymentSource': paymentSource,
                    'acharya_sambhavana': acharya_sambhavana,
                    'general_donation': general_donation,
                    'totalPrice': totalPrice,
                    'mpiInvNumber': mpicardpayment_response.mpiInvNumber,
                    'sponser_cart_items': sponser_cart_items,
                    'service_cart_items': service_cart_items,
                    'event_cart_items': event_cart_items,
                    'donation_cart_items': donation_cart_items,
                    'books_cart_items': books_cart_items,
                    'creditCardRemark': creditCardRemark
                  },
                  success: function(addtocart_response) {

                    if (addtocart_response.statusCode == 1) {

                      var status = 'FAILED';
                      var trnxId = "Payment failed~0~" + mpicardpayment_response.message;

                      $.ajax({
                        url: "<?= base_url('Common/updateTransactionStatus') ?>",
                        type: "POST",
                        dataType: "json",
                        data: {

                          'status': status,
                          'transaction_id': trnxId,
                          'paymentDescription': mpicardpayment_response
                        },
                        success: function(update_transactionstatus_response) {
                          if (update_transactionstatus_response.statusCode == 1) {


                            var original_string = update_transactionstatus_response.message;
                            var substring_to_replace = "Payment failed~0~"

                            var new_string = original_string.replace(substring_to_replace, "");


                            swal({
                                html: true,
                                title: "Failed!",
                                text: "<span>" + new_string + "!<span><br><span style='font-weight: 600;margin:5px;padding:5px;font-size: 27px !important;'>Receipt #: " + update_transactionstatus_response.envoiceNo + "</span>",
                                type: "error",
                                confirmButtonText: 'OK',
                                confirmButtonColor: 'var(--main-color-new-theme)',
                              },
                              function() {
                                window.location.reload();
                              });

                            loader.off();
                          }

                        }
                      });

                    }
                  }
                });
              }

            }
          });
        } else {
          alert('Please enter valid details');
        }

      }, function(result) {
        loader.off();
        console.log("error@@@: " + result.token);
      });
    });
  </script>



<?php } ?>

<?php

if (isset($paymentSetting) && $paymentSetting == 'CHARGEANYWHERE' && $paymentSeverOn == 1) { ?>

  <script type="text/javascript">
    /*Acharya sambhawana And General Donation  Start*/
    $(document).ready(function() {



      var $totalPrice = $('#total-price');
      var amountString = $('#total-price').text();
      var finalAmtWithoutDollar = amountString.replace("$", "");
      var finalAmt = parseInt(finalAmtWithoutDollar);




      var iframe = document.getElementById('paymentIframe');



      var url = "https://www.chargeanywhere.com/APIs/PayOnline.aspx?Version=2.0&MerchantId=<?= $CAW_MerchantId ?>&TerminalId=<?= $CAW_TerminalId ?>&Amount=" + finalAmt + "&Mode=0";


      // var url = "https://www.chargeanywhere.com/APIs/PayOnline.aspx?Version=2.0&MerchantId=27680&TerminalId=0001&Amount=" + finalAmt + "&Mode=0";



      iframe.src = url;



      <?php if (@$CheckoutDonationSettings['acharyasanbhavana'] == 1) { ?>
        var $acharyaInput = $('#acharya-sambhavana-input');
        $acharyaInput.on('input', updateTotalPrice);
      <?php } ?>

      <?php if (@$CheckoutDonationSettings['generalDonation'] == 1) { ?>
        var $generalInput = $('#general-donation-input');
        $generalInput.on('input', updateTotalPrice);
      <?php } ?>



      // Function to update the total price based on the input values
      function updateTotalPrice() {
        // Get the input values
        var acharyaValue = 0;
        var generalValue = 0;
        <?php if (@$CheckoutDonationSettings['acharyasanbhavana'] == 1) { ?>
          var acharyaValue = parseFloat($acharyaInput.val().replace(/[^\d.-]/g, '')) || 0;
        <?php } ?>
        <?php if (@$CheckoutDonationSettings['generalDonation'] == 1) { ?>
          var generalValue = parseFloat($generalInput.val().replace(/[^\d.-]/g, '')) || 0;
        <?php } ?>



        // Get the initial total price
        var initialTotalPrice = parseFloat(<?= @$s_total; ?>) || 0;

        // Calculate the new total price
        var newTotalPrice = initialTotalPrice + acharyaValue + generalValue;

        // Update the total price element
        $totalPrice.text('<?= $currencySymbol ?> ' + newTotalPrice.toFixed(2));


        var iframe = document.getElementById('paymentIframe');
        var url = "https://www.chargeanywhere.com/APIs/PayOnline.aspx?Version=2.0&MerchantId=<?= $CAW_MerchantId ?>&TerminalId=<?= $CAW_TerminalId ?>&Amount=" + newTotalPrice.toFixed(2) + "&Mode=0";



        iframe.src = url;

      }

      // Call updateTotalPrice once to include the initial total price
      updateTotalPrice();


      <?php if (@$CheckoutDonationSettings['acharyasanbhavana'] == 1) { ?>
        // Disable arrow key inputs
        $acharyaInput.on('keydown', function(e) {
          if (e.which === 38 || e.which === 40) {
            e.preventDefault();
          }
        });
        // Add validation to prevent input of negative values
        $acharyaInput.on('keydown', function(e) {
          if (e.key === '-' || e.key === '+') {
            e.preventDefault();
          }
        });

        // Add validation to prevent input of "+" and "e" characters
        $acharyaInput.on('input', function() {
          $acharyaInput.val($acharyaInput.val().replace(/[+e]/gi, ''));
        });
      <?php } ?>
      <?php if (@$CheckoutDonationSettings['generalDonation'] == 1) { ?>
        $generalInput.on('keydown', function(e) {
          if (e.which === 38 || e.which === 40) {
            e.preventDefault();
          }
        });

        $generalInput.on('keydown', function(e) {
          if (e.key === '-' || e.key === '+') {
            e.preventDefault();
          }
        });

        $generalInput.on('input', function() {
          $generalInput.val($generalInput.val().replace(/[+e]/gi, ''));
        });
      <?php } ?>

    });
    /*Acharya sambhawana And General Donation  End*/



    window.addEventListener('message', handleMessage, false);
    window.addEventListener('message', chargeanywher, false);

    function handleMessage(event) {

      if (event.origin != "https://www.chargeanywhere.com") {
        return;
      }

      var customData = event.data;


    }



    function chargeanywher(event) {

      loader.on();

      if (event.origin != "https://www.chargeanywhere.com") {
        return;
      }


      var customData = event.data;


      console.log(customData);
      var acharya_sambhavana = parseFloat($('#acharya-sambhavana-input').val()) || 0;
      var general_donation = parseFloat($('#general-donation-input').val()) || 0;



      var cart_data = '<?= json_encode($sponser_cart_items) ?>';
      var paymentSource = 'CREDIT CARD';


      var grand_totalPrice = customData.GrandTotal;


      var cleanedPrice = grand_totalPrice.replace(/[,$\s]/g, '');


      var totalPrice = parseFloat(cleanedPrice);




      if (customData.ResponseCode === "000") {

        var status = 'COMPLETED';




        $.ajax({
          url: "<?= base_url('SponsorNow/AddToCart') ?>",
          type: "POST",
          dataType: "json",
          data: {

            'status': status,
            'paymentSource': paymentSource,
            'acharya_sambhavana': acharya_sambhavana,
            'general_donation': general_donation,
            'totalPrice': totalPrice,
            'cart_data': cart_data,
          },
          success: function(addtocart_response) {

            console.log(addtocart_response);



            if (addtocart_response.statusCode == 1) {

              var status = 'COMPLETED';

              var cardTypeCode = customData.CardType;
              var cardTypeName = getCardTypeName(cardTypeCode);
              var trnxId = "Payment completed~" + customData.ReferenceNumber + "~" + cardTypeName + "~" + customData.CardNumber;


              $.ajax({
                url: "<?= base_url('SponsorNow/updateTransactionStatus') ?>",
                type: "POST",
                dataType: "json",
                data: {

                  'status': status,
                  'transaction_id': trnxId,
                  'paymentDescription': customData
                },
                success: function(update_transactionstatus_response) {
                  if (update_transactionstatus_response.statusCode == 1) {


                    swal({
                        html: true,
                        title: "Payment Processed Successfully!",
                        text: "<span style='font-weight: 600;margin:5px;padding:5px;font-size: 27px !important;'>Receipt #: " + update_transactionstatus_response.envoiceNo + "</span>",
                        type: "success",
                        confirmButtonText: 'OK',
                        confirmButtonColor: 'var(--main-color-new-theme)',
                      },
                      function() {
                        window.location.reload();
                      });

                    loader.off();
                  }

                }
              });

            }
          }
        });



      } else {

        $.ajax({
          url: "<?= base_url('SponsorNow/AddToCart') ?>",
          type: "POST",
          dataType: "json",
          data: {

            'status': 'TEMP',
            'paymentSource': paymentSource,
            'acharya_sambhavana': acharya_sambhavana,
            'general_donation': general_donation,
            'totalPrice': totalPrice,
            'cart_data': cart_data,
          },
          success: function(addtocart_response) {

            if (addtocart_response.statusCode == 1) {
              var status = 'FAILED';
              var cardTypeCode = customData.CardType;
              var cardTypeName = getCardTypeName(cardTypeCode);
              var trnxId = "Payment failed~0~" + customData.ResponseText + "~" + cardTypeName + "~" + customData.CardNumber;

              $.ajax({
                url: "<?= base_url('SponsorNow/updateTransactionStatus') ?>",
                type: "POST",
                dataType: "json",
                data: {

                  'status': status,
                  'transaction_id': trnxId,
                  'paymentDescription': customData
                },
                success: function(update_transactionstatus_response) {
                  if (update_transactionstatus_response.statusCode == 1) {

                    var original_string = update_transactionstatus_response.message;
                    var substring_to_replace = "Payment failed~0~"

                    var new_string = original_string.replace(substring_to_replace, "");

                    swal({
                        html: true,
                        title: "Failed!",
                        text: "<span>" + new_string + "!<span><br><span style='font-weight: 600;margin:5px;padding:5px;font-size: 27px !important;'>Receipt #: " + update_transactionstatus_response.envoiceNo + "</span>",
                        type: "error",
                        confirmButtonText: 'OK',
                        confirmButtonColor: 'var(--main-color-new-theme)',
                      },
                      function() {
                        window.location.reload();
                      });

                    loader.off();
                  }

                }
              });

            }
          }
        });
      }

    }
  </script>

<?php } ?>




<!-- ==========Language Translator Code============= -->
<a href="#" class="back-to-top d-flex align-items-center justify-content-center" style="background-color:var(--headerFooter)!important;"><i class="bi bi-arrow-up-short"></i></a>


<!-- Vendor JS Files -->
<script src="<?= base_url('assets/vendor/aos/aos.js'); ?>"></script>
<script src="<?= base_url('assets/vendor/bootstrap/js/bootstrap.bundle.min.js'); ?>"></script>
<script src="<?= base_url('assets/vendor/glightbox/js/glightbox.min.js'); ?>"></script>
<script src="<?= base_url('assets/vendor/swiper/swiper-bundle.min.js'); ?>"></script>

<!-- Template Main JS File -->

<script src="<?= base_url('assets/js/main.js'); ?>"></script>

<div class="ldld full" style="z-index: 9999;"></div>

<?php $this->load->view('includes/script') ?>
<script>
  $(document).on('click', '.donation-delete-row', function(e) {
    e.preventDefault();
    var row_id = $(this).data('row-id');
    var selected_date = $(this).data('selected-date');
    var current_row = $(this).closest('tr');
    var confirmDelete = confirm('Do you want to delete this service from your cart?');

    if (confirmDelete) {
      loader.on();
      $.ajax({
        url: '<?= base_url('Donations/delete_cart_row') ?>',
        method: 'POST',
        data: {
          row_id: row_id,
          selected_date: selected_date
        },
        dataType: 'json',
        success: function(response) {
          if (response.status == 'success') {
            current_row.remove();
            // var updated_amount = response.updated_amount;
            // $('#cart-amount').text(updated_amount);
            location.reload();
          }
        },
        error: function() {
          loader.off();
          alert('Error deleting cart row. Please try again.');
        }
      });
    }
  });

  $(document).on('click', '.event-delete-row', function(e) {
    e.preventDefault();
    var row_id = $(this).data('row-id');
    var selected_date = $(this).data('selected-date');
    var current_row = $(this).closest('tr');
    var confirmDelete = confirm('Do you want to delete this service from your cart?');

    if (confirmDelete) {
      loader.on();
      $.ajax({
        url: '<?= base_url('Events/delete_cart_row') ?>',
        method: 'POST',
        data: {
          row_id: row_id,
          selected_date: selected_date
        },
        dataType: 'json',
        success: function(response) {
          if (response.status == 'success') {
            current_row.remove();
            // var updated_amount = response.updated_amount;
            // $('#cart-amount').text(updated_amount);
            location.reload();
          }
        },
        error: function() {
          loader.off();
          alert('Error deleting cart row. Please try again.');
        }
      });
    }
  });

  $(document).on('click', '.service-delete-row', function(e) {
    e.preventDefault();

    var row_id = $(this).data('row-id');
    var selected_date = $(this).data('selected-date');
    var current_row = $(this).closest('tr');
    var confirmDelete = confirm('Do you want to delete this service from your cart?');

    if (confirmDelete) {
      loader.on();
      $.ajax({
        url: '<?= base_url() ?>Services/delete_cart_row',
        method: 'POST',
        data: {
          row_id: row_id,
          selected_date: selected_date
        },
        dataType: 'json',
        success: function(response) {
          if (response.status == 'success') {
            // remove the deleted row from the DOM
            current_row.remove();
            // update the cart amount
            // var updated_amount = response.updated_amount;
            // $('#cart-amount').text(updated_amount);
            location.reload();
          }
        },
        error: function() {
          loader.off();
          alert('Error deleting cart row. Please try again.');
        }
      });
    }
  });

  $(document).on('click', '.sponser-delete-row', function(e) {
    e.preventDefault();

    var row_id = $(this).data('row-id');
    var selected_date = $(this).data('selected-date');
    var current_row = $(this).closest('tr');

    // Show a confirmation dialog
    var confirmDelete = confirm('Do you want to delete this service from your cart?');

    if (confirmDelete) {
      loader.on();
      $.ajax({
        url: '<?= base_url() ?>SponsorNow/delete_cart_row',
        method: 'POST',
        data: {
          row_id: row_id,
          selected_date: selected_date
        },
        dataType: 'json',
        success: function(response) {
          if (response.status == 'success') {
            current_row.remove();
            // var updated_amount = response.updated_amount;
            // $('#cart-amount').text(updated_amount);
            location.reload();
          }
        },
        error: function() {
          loader.off();
          alert('Error deleting cart row. Please try again.');
        }
      });
    }
  });


  $(document).on('click', '.books-delete-row', function(e) {
    e.preventDefault();

    var row_id = $(this).data('row-id');
    var selected_date = $(this).data('selected-date');
    var current_row = $(this).closest('tr');

    // Show a confirmation dialog
    var confirmDelete = confirm('Do you want to delete this service from your cart?');

    if (confirmDelete) {
      loader.on();
      $.ajax({
        url: '<?= base_url() ?>About_Temple/book_delete_cart_row',
        method: 'POST',
        data: {
          row_id: row_id,
          selected_date: selected_date
        },
        dataType: 'json',
        success: function(response) {
          if (response.status == 'success') {
            current_row.remove();
            // var updated_amount = response.updated_amount;
            // $('#cart-amount').text(updated_amount);
            location.reload();
          }
        },
        error: function() {
          loader.off();
          alert('Error deleting cart row. Please try again.');
        }
      });
    }
  });
</script>