<?php $this->load->view('includes/head') ?>
<?php $this->load->view('includes/topbar') ?>
<?php $this->load->view('includes/header') ?>
<script type="text/javascript" src="<?= base_url('admin_assets/js/sweetalert2.all.min.js') ?>"></script>
<link href="<?=base_url('assets/css/lightbox.min.css');?>" rel="stylesheet" />
<script src="<?=base_url('assets/js/lightbox-plus-jquery.min.js');?>"></script>


<link href="<?= base_url('admin_assets/css/sweetalert2.min.css') ?>" rel="stylesheet">
<?php $currencySymbol = getCurrencySymbol(); ?>

<link rel="stylesheet" type="text/css" href="<?= base_url('assets/css/services-cart.css') ?>">
<main id="main">
	<!-- ======= Coming Soon ======= -->
	<?php

	if (@$this->uri->segment(3) == 'outside-temple' && $this->session->userdata('logged_in') == 1 && $this->session->userdata('userType') == 'Devotee') {
		$parts = explode(" ", @$userDetails->refDataName);
		$lastname = array_pop($parts);
		$firstname = implode(" ", $parts);

		$enable_service_request_form = true;
	} else if (@$this->uri->segment(3) == 'aparakarya' && $this->session->userdata('logged_in') == 1 && $this->session->userdata('userType') == 'Devotee') {

		$parts = explode(" ", @$userDetails->refDataName);
		$lastname = array_pop($parts);
		$firstname = implode(" ", $parts);

		$enable_service_request_form = true;
	} else {
		$enable_service_request_form = false;
	}


	if ($this->session->userdata('logged_in') == 1 && $this->session->userdata('userType') == 'Devotee') {
		$enable_service_request_btnlink = true;
	} else {
		$enable_service_request_btnlink = false;
	}


	?>
	<section class="temple-services" style="background-image: url(<?= base_url('assets/img/elegant-background-with-mandala.png'); ?>);background-size: auto;">

		<div class="row">


			<?php if ($enable_service_request_form == false) { ?>

				<?php
				$cartList = $this->session->userdata('service_cart');
				if (isset($cartList['includeSankalpam'])) {
					$includeSankalpam = checkForYesValue($cartList['includeSankalpam']);
				} else {

					$includeSankalpam = 'NO';
				}

				$cart_count = isset($cartList['ids']) && $cartList['ids'] ? count($cartList['ids']) : 0;
				$cart_count = $cart_count != '' ? $cart_count : 0;
				if (empty($cartList['ids'])) {
					$cartList = array('totalPrice' => 0.00, 'ids' => array());
				} else {
					if ($cartList['is_date_required'] == 'YES') {
						// code...
						$cartDetelists = array();
						$cartDetelistsCount = 0;

						foreach ($cartList['startDate'] as $key => $value) {
							$cartDetelistsCount =  $cartDetelistsCount + (count(explode(',', $value)) * $cartList['qty'][$key]);
						}
						$cart_count = $cartDetelistsCount;
					} else {
						$cart_count = $cart_count != '' ? $cart_count : 0;
					}
				}


				$GeneralSettings = GeneralSettings();

				$serivce_Types = getServiceTypes();

				$serivce_Types = sortBySequenceId($serivce_Types);

				// echo '<pre>';
				// print_r($cartList);


				// $serivce_Types = ArrReverse($serivce_Types);
				?>
			</div>

			<div class="bg-image shadow-1-strong">
				<div class="row">
					<div class="col-md-12 mx-auto">
						<div class="row m-0 p-0">
							<div class="col-md-12">

								<div class="row" id="searchField">
									<div class="col-md-12 m-0 p-0">

										<div class="px-5">
											<input type="search" name="q" id="search" class="search-text searchKey" placeholder="Search..." autocomplete="off" style="margin-left: 10px;height: 70px;">
										</div>
									</div>
								</div>

								<div class="row mt-5" style="display: flex; flex-direction: row; align-content: flex-end; align-items: flex-end;">



									<div class="col-md-4  px-4" style="display: flex;align-items: flex-end;">
										<div class="row m-0 p-0">
											<div class="col-md-12 m-0 p-0">
											</div>
										</div>
									</div>

									<div class="col-md-3 text-center">

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

									<div class="col-md-5">
										<div class="d-flex justify-content-end align-items-end" style="border-bottom: 20px;" id="RightField">
											<div class="text-white px-4">
												<div class="row">
													<div class="col-md-9 text-start text-dark">
														<span class="fw-bold" style="padding-left: 34px;">Total Amount</span>
													</div>
												</div>



												<div style="display: flex;align-items: flex-end;">
													<span style="padding-right:6px!important">
														<a href="javascript:void(0)" onclick="ViewCart()"> <i class="fa fa-shopping-cart fa-2x" style="color:#000030;"></i>
															<span class="cart-count text-dark" style="font-size: 14px!important;"><?= $cart_count ?></span></a>
														</span>
														<label class="label label-primary price-span"><?= $currencySymbol; ?> <span class="allPrice"><?= sprintf("%.2f", $cartList['totalPrice']); ?></span></label>



														<?php if ((isset($GeneralSettings['isMultipleSelect']) && $GeneralSettings['isMultipleSelect'] == 'YES')) { ?>

															<a href="javascript:void(0)" class="btn btn-success paymentBtn" onclick="CartCheckLogin('services')">

																<?php if ((isset($GeneralSettings['payNowText']) && $GeneralSettings['payNowText'] != ''  && $GeneralSettings['payNowText'] != 'null')) {
																	echo $GeneralSettings['payNowText'];
																} else {
																	echo 'Proceed to Checkout';
																} ?>
															</a>
														<?php } else if (isset($GeneralSettings['isMultipleSelect']) && $GeneralSettings['isMultipleSelect'] == 'NO') { ?>

															<a href="javascript:void(0)" class="btn btn-success paymentBtn" onclick="CartCheckLogin('services')">

																<?php if ((isset($GeneralSettings['payLetterText']) && $GeneralSettings['payLetterText'] != ''  && $GeneralSettings['payLetterText'] != 'null')) {
																	echo $GeneralSettings['payLetterText'];
																} else {
																	echo 'BOOK NOW';
																} ?>
															</a>

														<?php } else { ?>
															<a href="javascript:void(0)" class="btn btn-success paymentBtn" onclick="CartCheckLogin('services')">
																<?php if ((isset($GeneralSettings['payNowText']) && $GeneralSettings['payNowText'] != ''  && $GeneralSettings['payNowText'] != 'null')) {
																	echo $GeneralSettings['payNowText'];
																} else {
																	echo 'Proceed To Checkout';
																} ?>
															</a>
														<?php } ?>

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


								<div class="justify-content-center align-items-center filter-tab px-2" style="overflow:hidden">

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

									<div class="responsive-container">
										<ul class="nav nav-tabs">

											<?php
											$s = 1;
											if (!empty($serivce_Types)) {

												foreach ($serivce_Types as $key => $val) {

													if ($val['refDataName'] == 'IN-TEMPLE') {

												// $displayName = $val['refDataName'] == 'IN-TEMPLE' ? 'IN TEMPLE' : ($val['refDataName'] == 'AWAY-TEMPLE' ? 'OUTSIDE TEMPLE' : '');
														?>


														<li class="nav-item mt-3 rounded" style="padding-right:15px">


															<button class="custom-btn btn-15 <?= ($s == 1) ? 'serviceTypes1 active' : ''; ?>" tab="<?= ($key + 1); ?>" id="home-tab<?= $val['_id']; ?>" data-bs-toggle="tab" data-bs-target="#home-tab-pane<?= $val['_id']; ?>" type="button" role="tab" aria-controls="home-tab-pane<?= $val['_id']; ?>" aria-selected="true" style="font-weight: 700; font-size: 16px;background: url('<?= base_url('assets/img/green-btn-backgroung.jpeg'); ?>');background-size: cover;border-radius: 5px!important;padding: 12px 23px 12px 23px; color: white;"><?= $val['displayName']; ?></button>




														</li>

														<?php $s++;
													}
												}
											} ?>

											<?php if ($enable_service_request_btnlink == true) {  ?>
												<li class="nav-item mt-3 rounded" id="right" style="padding-right:15px">
													<a href="<?php echo base_url('services/request/outside-temple'); ?>" class="custom-btn btn-15 <?= @$this->uri->segment(3) == 'outside-temple' ? 'active-btn' : 'normal-btn'; ?> <?= ($s == 1) ? 'serviceTypes1 active' : ''; ?>" tab="<?= ($key + 1); ?>" id="home-tab<?= $val['_id']; ?>" data-bs-target="#home-tab-pane<?= $val['_id']; ?>" type="button" role="tab" aria-controls="home-tab-pane<?= $val['_id']; ?>" aria-selected="true" style="font-weight: 700; font-size: 16px;background: #03376a;background-size: cover;border-radius: 5px!important;padding: 12px 23px 12px 23px; color: white;">OUTSIDE TEMPLE</a>
												</li>

												<li class="nav-item mt-3 rounded" style="padding-right:15px">
													<a href="<?php echo base_url('services/request/aparakarya'); ?>" class="custom-btn btn-15 <?= @$this->uri->segment(3) == 'aparakarya' ? 'active-btn' : 'normal-btn'; ?> <?= ($s == 1) ? 'serviceTypes1 active' : ''; ?>" tab="<?= ($key + 1); ?>" id="home-tab<?= $val['_id']; ?>" data-bs-target="#home-tab-pane<?= $val['_id']; ?>" type="button" role="tab" aria-controls="home-tab-pane<?= $val['_id']; ?>" aria-selected="true" style="font-weight: 700; font-size: 16px;background: #03376a;background-size: cover;border-radius: 5px!important;padding: 12px 23px 12px 23px; color: white;">APARAKARYA SERVICES</a>
												</li>

											<?php } else { ?>
												<li class="nav-item mt-3 rounded" style="padding-right:15px">


													<a href="javascript:void(0)" id="right" class="custom-btn btn-15 <?= ($s == 1) ? 'serviceTypes1 active' : ''; ?> <?= @$this->uri->segment(2) == 'serviceRequest' ? 'active-btn' : 'normal-btn'; ?>" tab="<?= ($key + 1); ?>" id="home-tab<?= $val['_id']; ?>" data-bs-target="#home-tab-pane<?= $val['_id']; ?>" type="button" role="tab" aria-controls="home-tab-pane<?= $val['_id']; ?>" aria-selected="true" onclick="checkLoginStatus('OUTSIDE')" style="font-weight: 700; font-size: 16px;background: #03376a;background-size: cover;border-radius: 5px!important;padding: 12px 23px 12px 23px; color: white;">OUTSIDE TEMPLE</a>
												</li>


												<li class="nav-item mt-3 rounded" style="padding-right:15px">


													<a href="javascript:void(0)" class="custom-btn btn-15 <?= ($s == 1) ? 'serviceTypes1 active' : ''; ?> <?= @$this->uri->segment(2) == 'serviceRequest' ? 'active-btn' : 'normal-btn'; ?>" tab="<?= ($key + 1); ?>" id="home-tab<?= $val['_id']; ?>" data-bs-target="#home-tab-pane<?= $val['_id']; ?>" type="button" role="tab" aria-controls="home-tab-pane<?= $val['_id']; ?>" aria-selected="true" onclick="checkLoginStatus('APARAKARYA')" style="font-weight: 700; font-size: 16px;background: #03376a;background-size: cover;border-radius: 5px!important;padding: 12px 23px 12px 23px; color: white;">APARAKARYA SERVICES</a>
												</li>

											<?php } ?>

										</ul>
										<div class="tab-content" id="myTabContent">

											<?php $s = 1;
											if (!empty($serivce_Types)) {
												foreach ($serivce_Types as $key => $val) {

													if ($val['refDataName'] == 'IN-TEMPLE') { ?>

														<div class="tab-pane table-responsive fade shadow panettttttttt<?= $val['_id']; ?> show <?= ($s == 1) ? 'active' : ''; ?>" id="home-tab-pane<?= $val['_id']; ?>" role="tabpanel" aria-labelledby="home-tab<?= $val['_id']; ?>" tabindex="0">

															<?php $services = getServicesByServiceType($val['refDataName'], $cartList);
															echo $services;
															?>
															<div id="emptyServices" style="padding: 4px 66px; font-size: 21px; font-weight: 700;"></div>
														</div>
														<?php $s++;
													}
												}
											} ?>

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

			<?php } ?>



			<?php if ($enable_service_request_form == true) { ?>
				<div class="px-5">
					<a href="javascript:void(0)" class="btn" onclick="window.history.back()" style="background-color:#df4a19;color: white!important;border-radius: 1px!important;">← Back</a>
					<style type="text/css">
						.form-control:focus {
							box-shadow: none !important;
						}
					</style>
				</div>
				<div class="container-fluid">
					<div class="row py-4 ">
						<?php echo $this->session->flashdata('success'); ?>
						<div class="col-md-12 mx-auto d-block card shadow-lg p-5 my-2">
							<?= form_open(base_url('admin/service-request'), 'method="post" id="serviceRequestForm"'); ?>

							<fieldset class="border-2">
								<legend class="legend-outer  float-none w-auto"> Request for Puja Service </legend>

								<input type="hidden" name="page_name" value="<?= $this->uri->segment(3); ?>">
								<fieldset class="border-2">
									<div class="row justify-content-between m-0 p-5">
										<div class="col-md-2 customeWidth m-0 p-5">
											<fieldset class="border" style="background-color: #e7e6e6;">
												<legend class="legend-inner float-none w-auto required">First Name<span class="mandate">*</span></legend>
												<div class="input-group">
													<i class="fa fa-user fa2"></i>
													<input type="text" class="form-control form-control2" style="color:black!important;background-color: #e7e6e6;" name="fname" id="fname" placeholder="First Name*" value="<?= set_value('fname', @$firstname) ?>" required readonly>
												</div>
											</fieldset>
										</div>
										<div class="col-md-2 customeWidth m-0 p-5">
											<fieldset class="border" style="background-color: #e7e6e6;">
												<legend class="legend-inner float-none w-auto required">Last Name<span class="mandate">*</span></legend>
												<div class="input-group">
													<i class="fa fa-user fa2"></i>
													<input type="text" class="form-control2 form-control " name="lname" style="background-color: #e7e6e6;" id="lname" placeholder="Last Name" value="<?= set_value('lname', @$lastname) ?>" required readonly>
												</div>
											</fieldset>
										</div>

										<?php

										$gotra_data = getGotra()['data'];
										$rashi_data = getRashi()['data'];
										$nakshtra_data = getNakshtra()['data'];

										?>

										<div class="col-md-2 customeWidth m-0 p-5">
											<fieldset class="border">
												<legend class="legend-inner float-none w-auto required">Gotra<span class="text-danger fw-bold" style="font-size: 20px;"></span></legend>
												<div class="input-group">
													<i class="fa fa-user fa2"></i>
													<input type="text" class="form-control2 form-control " style="color:black!important;border: 0;" id="gotra" name="gotra" placeholder="Gotra" value="<?= set_value('gotra', @$userDetails->gotraName) ?>">
												</div>
											</fieldset>
										</div>
										<div class="col-md-2 customeWidth m-0 p-5">
											<fieldset class="border">
												<legend class="legend-inner float-none w-auto required">Nakshatra<span class="text-danger fw-bold" style="font-size: 20px;"></span></legend>
												<div class="input-group">
													<!-- <i class="fa fa-user fa2"></i> -->

													<select id="stars" name="stars" style="color:black!important;border: 0;" class="form-control rounded  form-select" >
														<option value=" " selected disabled>Select Nakshtra</option>
														<?php
														$selected_option = '';
														if (!empty(@$userDetails->Nakshtra) && @replaceSingleQuotesWithBackticks($userDetails->Nakshtra) !== replaceSingleQuotesWithBackticks("DON'T KNOW")) {
															$selected_option = '<option value="'. @replaceSingleQuotesWithBackticks($userDetails->Nakshtra) .'" selected>' . @replaceSingleQuotesWithBackticks($userDetails->Nakshtra) . '</option>';
														}

														foreach ($nakshtra_data as $key => $item) { ?>

															<?= $key == 0 ? $selected_option : ''; ?>


															<option value="<?= @replaceSingleQuotesWithBackticks($item['refDataName']); ?>" <?= @replaceSingleQuotesWithBackticks($item['refDataName']) == @replaceSingleQuotesWithBackticks($userDetails->Nakshtra) ? 'selected' : '' ?>><?= @replaceSingleQuotesWithBackticks($item['refDataName']); ?></option>


															<?php } ?>>
														</select>

														<!-- <input type="text" class="form-control2 form-control " name="stars" placeholder="Nakshatra" value="<?= set_value('stars', @$userDetails->Nakshtra); ?>" style="color:black!important;background-color: #e7e6e6;" readonly required> -->
													</div>
												</fieldset>
											</div>
											<div class="col-md-2 customeWidth m-0 p-5">
												<fieldset class="border">
													<legend class="legend-inner float-none w-auto required">Rashi<span class="text-danger fw-bold" style="font-size: 20px;"></span></legend>
													<div class="input-group">
														<!-- <i class="fa fa-user fa2"></i> -->

														<select id="rashi" name="rashi" style="color:black!important;border: 0;" class="form-control rounded  form-select" >
															<option value=" " selected disabled>Select Rashi</option>

															<?php
															$selected_option = '';
															if (!empty(@$userDetails->rashi) && @replaceSingleQuotesWithBackticks($userDetails->rashi) !== replaceSingleQuotesWithBackticks("DON'T KNOW")) {
																$selected_option = '<option value="'. @replaceSingleQuotesWithBackticks($userDetails->rashi) .'" selected>' . @replaceSingleQuotesWithBackticks($userDetails->rashi) . '</option>';
															}

															foreach ($rashi_data as $key => $item) { ?>

																<?= $key == 0 ? $selected_option : ''; ?>


																<option value="<?= @replaceSingleQuotesWithBackticks($item['refDataName']); ?>" <?= @replaceSingleQuotesWithBackticks($item['refDataName']) == @replaceSingleQuotesWithBackticks($userDetails->rashi) ? 'selected' : '' ?>><?= @replaceSingleQuotesWithBackticks($item['refDataName']); ?></option>


															<?php } ?>
														</select>
													</div>
												</fieldset>
											</div>
										</div>




										<div class="row m-0 p-5">
											<div class="col-md-6 m-0 p-5">
												<fieldset class="border">
													<legend class="legend-inner float-none w-auto required">Street Address<span class="mandate">*</span></legend>
													<div class="input-group">
														<input type="text" class="form-control2 form-control " name="streetAddress" id="streetAddress" placeholder="Street Address*" style="color:black!important;" required value="<?= set_value('streetAddress', @$userDetails->addressLine1); ?>">
													</div>
												</fieldset>
											</div>
											<div class="col-md-3 m-0 p-5">
												<fieldset class="border" style="background-color: #e7e6e6;">
													<legend class="legend-inner float-none w-auto required">Email<span class="mandate">*</span></legend>
													<div class="input-group">
														<i class="fa fa-envelope fa2"></i>
														<input type="email" class="form-control2 form-control " style="color:black!important;background-color: #e7e6e6!important;" id="email" name="email" placeholder="Email ID*" value="<?= set_value('email', base64_decode(@$userDetails->email)) ?>" readonly required>
													</div>
												</fieldset>
											</div>
											<div class="col-md-3 m-0 p-5">
												<fieldset class="border" style="background-color: #e7e6e6;">
													<legend class="legend-inner float-none w-auto required">Phone<span class="mandate">*</span></legend>
													<div class="input-group">
														<i class="fa fa-phone fa2"></i>
														<input type="text" class="form-control2 form-control " name="phoneNumber" placeholder="Phone Number*" value="<?= set_value('phoneNumber', formatPhoneNumber(base64_decode(@$userDetails->phone))) ?>" style="color:black!important;background-color: #e7e6e6!important;" readonly required>
													</div>
												</fieldset>
											</div>
										</div>
									</fieldset>

									<div class="col-md-4 d-none">
										<fieldset class="border">
											<legend class="legend-inner float-none w-auto required">State<span class="mandate">*</span></legend>
											<div class="input-group">
												<input type="text" name="state" id="state" class="form-control2 form-control" placeholder="State" value="<?= set_value('state', @$userDetails->stateTypes); ?>">
											</div>
										</fieldset>
									</div>
									<div class="col-md-4 d-none">
										<fieldset class="border">
											<legend class="legend-inner float-none w-auto required">City<span class="mandate">*</span></legend>
											<div class="input-group">
												<input type="text" name="city" id="city" class="form-control2 form-control" placeholder="City" value="<?= set_value('city', @$userDetails->cityTypes); ?>">
											</div>
										</fieldset>
									</div>

									<div class="col-md-4 d-none">
										<fieldset class="border">
											<legend class="legend-inner float-none w-auto required">Zip Code<span class="mandate">*</span></legend>
											<div class="input-group">
												<input type="text" class="form-control2 form-control" style="color:black!important;" name="zipcode" id="zipcode" placeholder="Zip Code*" value="<?= set_value('zipcode', @$userDetails->zip) ?>" required>
											</div>
										</fieldset>
									</div>

									<fieldset class="border-2">
										<div class="row">
											<div class="col-md-4 m-0 p-5">
												<fieldset class="border">
													<legend class="legend-inner float-none w-auto required">Preferred Location<span class="mandate">*</span></legend>
													<div class="input-group">
														<select id="preferredLocation" name="preferredLocation" style="color:black!important;" class="form-control2 form-control rounded  form-select" required>
															<option value=" " selected disabled style="color:black!important;">Preferred Location</option>
															<?php
															foreach ($preferredLocations as $item) {

																if ($item->refDataName == 'IN-TEMPLE') {
																	$catName = 'IN TEMPLE';
																} else if ($item->refDataName == 'SHRAADHAM') {

																	$catName = 'APARAKARYA';
																} else if ($item->refDataName == 'AWAY-TEMPLE') {
																	$catName = 'OUTSIDE TEMPLE';
																}
																?>
																<option value="<?= @$item->refDataName ?>" <?= ($this->uri->segment(3) == 'outside-temple' &&  $catName == 'OUTSIDE TEMPLE') ? 'selected' : (($this->uri->segment(3) == 'aparakarya' &&  $catName == 'APARAKARYA') ? 'selected' : '') ?>><?= @$catName; ?></option>
															<?php } ?>
														</select>
													</div>
												</fieldset>
											</div>
											<div class="col-md-4 m-0 p-5">
												<fieldset class="border">
													<legend class="legend-inner float-none w-auto required">Service<span class="mandate">*</span></legend>
													<div class="input-group">
														<select name="serviceName" id="serviceName" style="color:black!important;" class="form-control2 form-control rounded  form-select" required>
															<option value=" " selected disabled>Select Service</option>
														</select>
														<input type="hidden" id="serviceType" name="serviceType">
														<input type="hidden" id="serviceAmount" name="serviceAmount">
														<input type="hidden" name="serviceId" id="serviceId">
													</div>
												</fieldset>
											</div>

											<div class="col-md-12 m-0 p-5" style="display: none;" id="serviceDetailsBox">


											</div>
											<div class="col-md-4 m-0 p-5">
												<fieldset class="border" style="background-color: #e7e6e6;">
													<legend class="legend-inner float-none w-auto required">Service Amount<span class="mandate">*</span></legend>
													<div class="input-group">
														<i class="fa fa-location fa2"></i>
														<input type="text" class="form-control2 form-control rounded" id="serviceAmountBox" placeholder="Service Amount*" value="" readonly required style="background-color: #e7e6e6;">
													</div>
												</fieldset>
											</div>


											<div class="col-md-3 m-0 p-5">
												<fieldset class="border">
													<legend class="legend-inner float-none w-auto required">Service Date<span class="mandate">*</span></legend>
													<div class="input-group">
														<i class="fa fa-calendar fa2"></i>
														<input placeholder="MM/DD/YYYY" class="form-control2 form-control rounded " id="serviceDate" name="serviceDate" type="text" readonly required>
													</div>
												</fieldset>
											</div>
											<div class="col-md-3 m-0 p-5">
												<fieldset class="border">
													<legend class="legend-inner float-none w-auto required">Service Time<span class="mandate">*</span></legend>
													<div class="input-group">
														<i class="fa fa-clock-o fa2"></i>

														<input type='text' class='form-control2 form-control' name="serviceTime" id="serviceTime" placeholder='00:00' required>

													</div>
												</fieldset>

											</div>

											<div class="col-md-3 m-0 p-5">
												<fieldset class="border">
													<legend class="legend-inner float-none w-auto required">Priests<span class="mandate">*</span></legend>
													<div class="input-group">
														<select id="priestName" name="priestName" style="color:black!important;" class="form-control2 form-control rounded  form-select" required>
															<option value=" " selected disabled>Select Preferred Priest</option>

															<!-- <option value="Any Priest" email="" phone="" priestId="0">Any Priest</option> -->

														</select>

														<input type="hidden" name="priestPhone" id="priestPhone" value="<?= json_decode(@$userDetails->priestPhone); ?>">
														<input type="hidden" name="priestEmail" id="priestEmail" value="<?= json_decode(@$userDetails->priestEmail); ?>">
														<input type="hidden" name="priestId" id="priestId" value="<?= @$userDetails->requestedPriestId; ?>">
													</div>

												</fieldset>
											</div>
								<!-- <div class="col-md-6 m-0 p-5" style="display: flex; align-items: center; flex-direction: row-reverse;">
																	<div class="form-check form-check-inline mx-4">
																		<input class="form-check-input" type="checkbox" id="inlineCheckbox" name="confirmByPriest">
																		<label class="form-check-label" style="padding-top: 10px !important;  padding-left: 20px;" for="inlineCheckbox">Already Confirmed By Priest</label>
																	</div>
																</div> -->

																

																<div class="col-md-3 m-0 p-5">
																	<fieldset class="border">
																		<legend class="legend-inner float-none w-auto required">Select Venue<span class="mandate">*</span></legend>
																		<div class="input-group">
																			<select name="selectVenue" id="selectVenue" style="color:black!important;" class="form-control2 form-control rounded  form-select" required>
																				<option value=" " selected disabled>Select Venue</option>
																				<option value="Same as Home Address">Same as Home Address</option>
																				<option value="Same as Temple Address">Same as Temple Address</option>
																				<option value="Other">Other</option>
																			</select>

																		</div>
																	</fieldset>

																</div>

																<div class="col-md-12 m-0 p-5">
																	<fieldset class="border" id="serviceAddressBox">
																		<legend class="legend-inner float-none w-auto required">Full Address</legend>
																		<div class="input-group">
																			<i class="fa fa-location fa2"></i>
																			<input type="text" class="form-control2 form-control rounded " name="serviceAddress" id="serviceAddress" placeholder="Please enter your address*" value="">
																		</div>
																	</fieldset>
																</div>

																<div class="col-md-12 m-0 p-5">
																	<fieldset class="border">
																		<legend class="legend-inner float-none w-auto">Additional Info</legend>
																		<div class="input-group">
																			<textarea type="textarea" name="addtionalInfo" class="form-control2 form-control rounded form-text-area" placeholder="Please provide any additional details here."></textarea>

																			<input type="hidden" name="source" value="SERVICES-PAGE">
																		</div>
																	</fieldset>
																</div>
															</div>
														</fieldset>

														<div style="display: flex; justify-content: center;">
															<a href="javascript:void(0)" class="btn btn-primary" id="submitRequestForm" style="border-radius: 3px!important; background: #b02135; border-color: #b02135; box-shadow: 1px 1px 10px black; margin-bottom: 18px;" onclick="submitForm()">Send Request <i class="fa fa-paper-plane"></i></a>
														</div>
													</form>
												</div>

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

									<?php

									$TempleAddress = getclientInfoById()['data'][0];
									$TempleAddress =  $TempleAddress['addressLineOne'] . ' ' . $TempleAddress['addressLinetwo'] . ' ' . $TempleAddress['state'] . ' ' . $TempleAddress['city'] . ' ' . $TempleAddress['zipCode'];
									?>
									<script type="text/javascript" src="<?= base_url('assets/js/time-picker.js') ?>"></script>
									<script src="<?= base_url('assets/js/jquery-ui.min.js'); ?>"></script>
									<link href="<?=base_url('assets/css/select2.min.css');?>" rel="stylesheet" />
									<script src="<?=base_url('assets/js/select2.min.js');?>"></script>
									<script type="text/javascript" src="<?= base_url('admin_assets/js/jquery.validate.js'); ?>"></script>
									<script type="text/javascript">
										$('#serviceRequestForm').keypress(function(e) {
											if (e.which == 13) {
												$('#serviceRequestBtn').click();
												return false;
											}
										});

										$(function() {

											$("#serviceAddressBox").hide();
											$otherField = $("#serviceAddressBox");
											$otherFieldval = $("#serviceAddress");

											$('#preferredLocation').on('change', function() {
					// alert();
												if (this.value == 'AWAY-TEMPLE') {



													$otherFieldval.val("");
													$otherField.show();
												} else if (this.value == 'IN-TEMPLE') {
													var templeAddress = "<?= $TempleAddress ?>";

													$otherField.hide();
													$otherFieldval.val(templeAddress);

												} else {
													$otherFieldval.val("");
													$otherField.show();
												}

											});


											$('#serviceTime').mdtimepicker();
										});




										function checkValue(str, max) {
											if (str.charAt(0) !== '0' || str == '00') {
												var num = parseInt(str);
												if (isNaN(num) || num <= 0 || num > max) num = 1;
												str = num > parseInt(max.toString().charAt(0)) && num.toString().length == 1 ? '0' + num : num.toString();
											};
											return str;
										};

										$('#priestName').change(function() {

											var priestEmail = $(this).children(":selected").attr("email");
											var priestPhone = $(this).children(":selected").attr("phone");
											var priestId = $(this).children(":selected").attr("priestID");

											$("#priestEmail").val(priestEmail);
											$("#priestPhone").val(priestPhone);
											$("#priestId").val(priestId);

										});

										$('#preferredLocation').change(function() {


											var param = $(this).val();

											if (param == 'AWAY-TEMPLE') {
												$("#selectVenue").html('<option value=" " disabled selected>Select Venue</option><option value="Same as Home Address">Same as Home Address</option><option value="Other">Other</option>');

												$('#selectVenue').prop('disabled', false);
											} else if (param == 'SHRAADHAM') {

												$("#selectVenue").html('<option value=" " disabled selected>Select Venue</option><option value="Same as Home Address">Same as Home Address</option><option value="Same as Temple Address">Same as Temple Address</option><option value="Other">Other</option>');

												$('#selectVenue').prop('disabled', false);

											} else {
												$("#selectVenue").html(`
													<option value="Same as Temple Address" selected>Same as Temple Address</option>
													`);

												$('#selectVenue').prop('disabled', true);
											}




											$.ajax({
												url: "<?= base_url('admin/GetServicesByCategory') ?>",
												type: "POST",
												data: {
													'param': param
												},
												success: function(data) {
													if (data == '') {
														$('#serviceName').html('<option value=" " disabled selected>No Service Available On This Location.</option>');
													} else {
														$('#serviceName').html(data);
													}


													$('#serviceName').select2();


												}
											});

										});



										$('#serviceName').change(function() {

											var serviceType = $('option:selected', this).attr('serviceType');

											$("#serviceType").val(serviceType);

											var startDate = $('option:selected', this).attr('startDate');
											if (startDate != '') {

												$("#serviceDate").val(startDate);
												$("#serviceDate").attr('disabled', 'true');

											}


											var startTime = $('option:selected', this).attr('startTime');
											if (startTime != '') {
												$("#serviceTime").val(startTime);
												$("#serviceTime").attr('disabled', 'true');
											}

											var serviceId = $('option:selected', this).attr('serviceId');
											if (serviceId != '') {
												$("#serviceId").val(serviceId);
											}


											if (serviceId == 0) {

												$("#serviceDetailsBox").css('display', 'block');
												$("#serviceDetailsBox").html('<fieldset class="border"><legend  class="legend-inner float-none w-auto required">Service Details<span class="mandate">*</span></legend><div class="input-group"><input type="text"  class="form-control2 form-control" name="serviceDetails" id="serviceDetails" placeholder="Specify Service Details" required></div></fieldset>');

												var serviceAmount = $('option:selected', this).attr('serviceAmount');
												$("#serviceAmountBox").val('TBD By Priest');

											} else {
												$("#serviceDetailsBox").css('display', 'none');
												$("#serviceDetailsBox").html('');
												var serviceAmount = $('option:selected', this).attr('serviceAmount');
												$("#serviceAmountBox").val('$ ' + serviceAmount + '.00');
											}
										});


										$(document).ready(function() {
											$('#preferredLocation option[selected]').parent().change();

										});
										$('#serviceName').change(function() {

											var serviceAmount = $('option:selected', this).attr('serviceAmount');


											var finalPrice = (serviceAmount / 1).toFixed(2);

											$("#serviceAmount").val(finalPrice);

										});


										$(document).ready(function() {
											$("#serviceRequestForm").validate({

												submitHandler: function(form) {
													form.submit();
												}

											});
										});

										$("#serviceDate").datepicker({
											dateFormat: "mm/dd/yy",
											minDate: 0
										});




										$(document).ready(function() {
											$('#inlineCheckbox').change(function() {
												var isChecked = $(this).prop('checked');
												var select = $('#priestName');
												var anyPriestOption = select.find('option[value="Any Priest"]');

												if (isChecked) {
													anyPriestOption.remove();
													$("#serviceTime").attr('required', true);
													$("#serviceDate").attr('required', true);
												} else {
													select.append('<option value="Any Priest" email="" phone="">Any Priest</option>');
													$("#serviceTime").attr('required', false);
													$("#serviceDate").attr('required', false);
												}
											});


											$('#selectVenue').change(function() {
												var selectedOption = $(this).val();
												var addressInput = $('#serviceAddress');

												if (selectedOption === 'Same as Home Address') {
													var homeAddress = "<?= @$userDetails->addressLine1; ?>";
													addressInput.val(homeAddress);
													addressInput.prop('readonly', true);
												} else if (selectedOption === 'Same as Temple Address') {
													var templeAddress = "<?= $TempleAddress ?>";
													addressInput.val(templeAddress);
													addressInput.prop('readonly', true);
												} else if (selectedOption === 'Other') {
													addressInput.val('');
													addressInput.prop('readonly', false);
													// addressInput.prop('disabled', false);
												}
											});
										});


										function submitForm() {

											Swal.fire({
												title: 'Do you want to send request to temple?',
												showDenyButton: false,
												showCancelButton: true,
												confirmButtonText: 'Send',
												denyButtonText: `Cancel`,
											}).then((result) => {

												if (result.isConfirmed) {

													$("#serviceRequestForm").submit();
												} else if (result.isDenied) {
													Swal.fire('Changes are not saved', '', 'info')
												}
											});
										}



										function closeForm() {

											Swal.fire({
												title: 'Do you want to send request to temple?',
												showDenyButton: true,
												showCancelButton: true,
												showConfirmButton: false,
												cancelButtonText: 'No',
												denyButtonText: `Yes`,
											}).then((result) => {
												if (result.isConfirmed) {
													Swal.fire('Saved!', '', 'success')
												} else if (result.isDenied) {

													window.location.href = "<?= base_url('admin/my-service-request') ?>";
												}
											})
										}
									</script>

								<?php } ?>
								<!-- *************************Request Form Section End********************************* -->
							</section>



						</main>
						<input type="hidden" id="includeSankalpamModal" value="<?= @$includeSankalpam ?>">
						<input type="hidden" id="datesArray" value="">

						<?php $this->load->view('includes/footer') ?>

						<script type="text/javascript" src="<?= base_url('assets/js/paging.js'); ?>"></script>

						<script src="https://cdn.jsdelivr.net/gh/dubrox/Multiple-Dates-Picker-for-jQuery-UI@master/jquery-ui.multidatespicker.js"></script>


						<script type="text/javascript">
							function OpenPayLaterPage(pageName) {
								window.location.href = "<?= base_url('services/payLater'); ?>";
							}

							$(document).ready(function() {

								var Page_limit = $("#pageLength").val();
								if (Page_limit > 20) {
									$('.servicesDataTable').paging({
										limit: Page_limit
									});
								}

								$("[data-page='0']").click();

								$('.timepicker-services').mdtimepicker();
							});

							$(document).ready(function() {
								$("#search").on("keyup", function() {
									var value = $(this).val().toLowerCase();
									var $tableRows = $(".serviceSearch");
									var noResults = true;

									$tableRows.filter(function() {
										var rowText = $(this).text().toLowerCase();
										var isMatch = rowText.indexOf(value) > -1;
										$(this).toggle(isMatch);
										if (isMatch) {
											noResults = false;
										}
									});

									if (noResults && value !== "") {
										$("#emptyServices").text("Service not found!").show();
									} else {
										$("#emptyServices").hide();
									}
								}).on("search", function() {
									if ($(this).val() === "") {
										$("#table tr").show();
										$("#emptyServices").hide();
									}
								});
							});




							var tithiDates = [];

							function getDatesOfTithi(tithiVal) {
								$.ajax({
									type: "POST",
									url: "<?= base_url('Services/getThithiNext90Days'); ?>",
									data: {
										tithi: tithiVal
									},
									dataType: 'json',
									success: function(result) {
										tithiDates = result;

										$("#datesArray").val(tithiDates);
									}
								});
							}

							$(document).on('click', '.datepicker-services', function() {
								var dayVal = $(this).attr('daytype');
								var nclickF = $(this);

								$.ajax({
									type: "POST",
									url: "<?= base_url('Services/getThithiNext90Days'); ?>",
									data: {
										tithi: dayVal
									},
									dataType: 'json',
									success: function(result) {
										$("#datesArray").val(result);



										if (dayVal !== '') {
											nclickF.notify(
												"You can select only " + dayVal + " dates!", {
													position: "right",
													className: "success",
												}
												);
										} else {
											nclickF.notify(
												"You can select any date!", {
													position: "right",
													className: "success",
												}
												);
										}


										if (!$(nclickF).hasClass('hasDatepicker')) {
											if (dayVal == '') {
												$(nclickF).multiDatesPicker({
													dateFormat: "mm/dd/yy",
													minDate: 0,
													changeMonth: true,
													changeYear: false,
													onSelect: function(dateText, inst) {
														$(this).datepicker('show');
														addTocart();
													}
												});
											} else {

												$(nclickF).multiDatesPicker({
													dateFormat: "mm/dd/yy",
													minDate: 0,
													changeMonth: true,
													changeYear: false,
													onSelect: function(dateText, inst) {
														$(this).datepicker('show');
														addTocart();
													},


													beforeShowDay: function(date) {
														var dayOfWeek = $.datepicker.formatDate('DD', date);
														var dateInMMDDYYFormat = $.datepicker.formatDate('yy-mm-dd', date);

														var tithis = ["PRATIPADA", "DWITIYA", "TRITIYA", "CHATURTHI", "PANCHAMI", "SHASHDI", "SAPTAMI", "ASHTAMI", "NAVAMI", "DASHAMI", "EKADASHI", "DWADASHI", "TRAYODASHI", "CHATURDASHI", "PURNIMA", "AMAVASYA"];

														if (dayOfWeek.toUpperCase() === dayVal.toUpperCase()) {
															return [true];
														} else if (tithis.includes(dayVal.toUpperCase())) {

															var tithiDates = $("#datesArray").val();




															var startDatearray = tithiDates.split(" ").pop().split(",");
															return [startDatearray.includes(dateInMMDDYYFormat)];



														} else {
															return [false];
														}
													}
												});
											}
										}

										$(nclickF).datepicker('show');

									}
								});

							});


							function clearCart() {

								$('input[name="services_id[]"]:checked').each(function() {
									$("input[name='services_id[]']").prop('checked', false);
								});

								if ($("input[name='allCheck']").is(":checked")) {
									$("input[name='allCheck']").prop('checked', false);
								}
								addTocart();

							}

							function addTocart() {

								var totalPrice = 0;
								var sankalpam_data = [];
								var cart_type = 'SERVICES';
								var ids = [];
								var qty = [];
								var ctg = [];
								var serviceTypes = [];
								var serviceName = [];
								var startDate = [];
								var startTime = [];
								var serviceAmount = [];
								var description = [];
								var image = [];
								var cart_ctg = [];
								var bookingtype = [];
								var includeSankalpam = [];
								var is_date_required = [];
								var isServicePaid = [];
								var is_membership_discount = [];
								var service_desc = [];

								if ($(this).attr('includeSankalpam') == 'YES') {
									$("#includeSankalpamModal").val($(this).attr('includeSankalpam'));
								}


								sankalpam_data.push($("#includeSankalpamModal").val());

								var noDateSelected = 0;
								var addtoCartStatus = true;


								$('input[name="services_id[]"]:checked').each(function() {
									id = $(this).attr('data-id');

									loader.on();

									var init_qty = parseInt($("#quantity-input" + id).val());

									if ($(this).attr('is_date_required') == 'YES') {
										if ($("#datepicker_" + id).val().length == 0) {
											$(this).prop('checked', false);
											$("#datepicker_" + id).focus();
											$("#datepicker_" + id).notify(
												"Please select date!", {
													position: "right"
												}
												);


											addtoCartStatus = false;
											return false;
										}
				// else if($("#timepicker_"+id).val().length == 0)
				// {
				// 	$("#timepicker_"+id).focus();
				// 	$(this).prop('checked', false);

				// 	$("#timepicker_"+id).notify(
				// 		"Please select time!",
				// 		{
				// 			position: "right"
				// 		}
				// 		);


				// 	addtoCartStatus = false;
				// 	return false;
				// }


										startDate.push($("#datepicker_" + id).val());
										var dateArray = startDate[0].split(', ');
										var count = dateArray.length;
										var nDateSelectCount = ($("#datepicker_" + id).val()).split(', ');
										nDateSelectCount = nDateSelectCount.length;

										init_qty = (init_qty ? parseInt(init_qty) : 1);
										noDateSelected = noDateSelected + (nDateSelectCount * init_qty);


										totalPrice = (parseFloat(totalPrice) + ((parseFloat($(this).attr('data-price')) * init_qty) * nDateSelectCount));

										$("#Totalprice_" + $(this).attr('data-id')).html("<?= $currencySymbol; ?>&nbsp;" + (parseFloat($(this).attr('data-price')) * init_qty * nDateSelectCount).toFixed(2));

									} else {
										init_qty = (init_qty ? parseInt(init_qty) : 1);
										totalPrice = (parseFloat(totalPrice) + (parseFloat($(this).attr('data-price')) * init_qty));

										$("#Totalprice_" + $(this).attr('data-id')).html("<?= $currencySymbol; ?>&nbsp;" + (parseFloat($(this).attr('data-price')) * init_qty).toFixed(2));


										startDate.push('');
									}




									if ($(this).attr("booking_type") === 'PAY NOW') {

										isServicePaid.push("YES");

									} else if ($(this).attr("booking_type") === 'PAY LATER') {
										isServicePaid.push($(this).attr("NO"));

									} else {

										isServicePaid.push($(this).attr("YES"));
									}

									startTime.push($("#timepicker_" + id).val());

									ctg.push($(this).attr('data-category'));
									serviceTypes.push($(this).attr('data-service-type'));
									serviceName.push($(this).attr('data-service-name'));
									image.push($(this).attr('data-image'));


									var booking_type = $(this).attr('booking_type');

									bookingtype.push(booking_type);
									description.push($(this).attr('data-description'));
									cart_ctg.push($(this).attr('cart_category'));
									serviceAmount.push($(this).attr('data-price'));
									ids.push($(this).attr('data-id'));
									includeSankalpam.push($(this).attr('includeSankalpam'));
									qty.push(init_qty);
									is_date_required.push($(this).attr('is_date_required'));
									is_membership_discount.push($(this).attr('is_membership_discount'));
									service_desc.push($(this).attr('data-servicedesc'));

								});


								if (addtoCartStatus == false) {
									loader.off();
									return false;
								} else {
									if ($(this).attr('is_date_required') == 'YES') {

										$(".cart-count").text(noDateSelected);
									} else {
										$(".cart-count").text(ids.length);
									}
									$(".allPrice").text((totalPrice / 1).toFixed(2));
								}

								$.ajax({
									type: "POST",
									url: "<?= base_url('Services/addCart'); ?>",
									dataType: 'json',
									data: {
										ids: ids,
										totalPrice: totalPrice,
										qty: qty,
										ctg: ctg,
										serviceTypes: serviceTypes,
										serviceName: serviceName,
										startDate: startDate,
										startTime: startTime,
										serviceAmount: serviceAmount,
										cart_type: cart_type,
										image: image,
										description: description,
										cart_ctg: cart_ctg,
										bookingtype: bookingtype,
										includeSankalpam: includeSankalpam,
										is_date_required: is_date_required,
										is_membership_discount: is_membership_discount,
										service_desc : service_desc
									},
									success: function(result) {
										console.log(result);
										$("#includeSankalpamModal").val(result.includeSankalpam);
										loader.off();
									}
								});


							}



							function quantityMinusFunction(id) {

								var totalPrice = 0;
								var init_qty = parseInt($('#quantity-input' + id).val());
								if (init_qty > 1) {
									init_qty = init_qty ? parseInt(init_qty) - 1 : 0;

									$('#quantity-input' + id).val(init_qty);
								}

								addTocart();
							}

							function quantityPlusFunction(id) {
								var totalPrice = 0;
								var init_qty = parseInt($('#quantity-input' + id).val());

								init_qty = init_qty ? parseInt(init_qty) + 1 : 0;
								$('#quantity-input' + id).val(init_qty);
								addTocart();

							}


							function ViewCart() {
								if ($(".cart-count").text() > 0) {
									window.location.href = "<?= base_url('Services/ViewCart') ?>";

								} else {
									swal({
										title: "Your cart is empty!",
										text: "Please add some items to your cart.",
										icon: "warning",
										confirmButtonText: 'OK',
										confirmButtonColor: '#005D4B',
									});


								}

							}


							function CartCheckLogin(page) {

								if ($(".cart-count").text() > 0) {
									loader.on();

									var page_name = page;
									event.preventDefault();
									$.ajax({
										url: "<?= base_url('check-login-status') ?>",
										type: "POST",
										dataType: "json",
										success: function(data) {
											loader.off();

											if (data == 0) {
												openLoginModal(page_name);
											} else {
												if (page_name == 'services') {
													window.location.href = "<?= base_url('checkout/service') ?>";
												}

											}

										}
									});

								} else {
									swal({
										title: "Your cart is empty!",
										text: "Please add some items to your cart.",
										icon: "warning",
										confirmButtonText: 'OK',
										confirmButtonColor: '#005D4B',
									});


								}
							}

							function changebtnStyles(id) {
								$(".styles").removeClass('active-services');
								$(".styles").addClass('services');
								$("#" + id).addClass('active-services');
								$("#" + id).removeClass('services');
							}


	// ********************************
							$('.extra-fields-customer').click(function() {
								$('.customer_records').clone().appendTo('.customer_records_dynamic');
								$('.customer_records_dynamic .customer_records').addClass('single remove');
								$('.single .extra-fields-customer').remove();
								$('.single').append('<a href="#" class="btn btn-sm btn-danger remove-field btn-remove-customer mx-3 mb-3 mt-0" style="border-radius: 2px!important; margin-top: 8px; margin-right: 5px;">Remove Fields</a>');
								$('.customer_records_dynamic > .single').attr("class", "remove");

								$('.customer_records_dynamic input').each(function() {
									var count = 0;
									var fieldname = $(this).attr("name");
									$(this).attr('name', fieldname + count);
									count++;
								});

							});

							$(document).on('click', '.remove-field', function(e) {
								$(this).parent('.remove').remove();
								e.preventDefault();
							});

							function sendSankalpamToSession() {



								var formData = {};
								$('.form-group input').each(function() {
									var fieldName = $(this).attr('name');
									var fieldValue = $(this).val();
									formData[fieldName] = fieldValue;
								});



								$.ajax({
									url: "<?= base_url('Services/AddSankalpamToSession'); ?>",
									type: "POST",
									data: {
										formData: formData
									},
									dataType: "json",
									success: function(data) {


										if (data.statusCode == 1) {
											window.location.href = "<?= base_url('checkout/service') ?>";
										}

									}
								});


							}





							// For Setting Priest Availibility Dynamically


							// $(document).ready(function(){
							// 	function fetchPriestAvailability() {
							// 		var serviceDate = $('#serviceDate').val();
								
							// 		var serviceTime = $('#serviceTime').val();
									
							// 		if(serviceDate != '' && serviceTime != '') {
							// 			$.ajax({
							// 				url: '<?=base_url('Home/GetPriestAvailibility')?>',
							// 				type: 'POST',
							// 				data: {
							// 					serviceDate: serviceDate,
							// 					serviceTime: serviceTime
							// 				},
							// 				success: function(response) {
							// 					$("#priestName").empty();
							// 					$("#priestName").append(response);
							// 				},
							// 				error: function(xhr, status, error) {
							// 					console.error(xhr.responseText);
							// 				}
							// 			});
							// 		} else {
							// 			console.log('Please fill both service date and service time.');
							// 		}
							// 	}
							// 	$("#serviceDate").on("input change", fetchPriestAvailability);
							// 	$(".mdtp__button").click(function() {
							// 		alert("this is time  section");
							// 		fetchPriestAvailability();
							// 	});
							// });
							$(document).ready(function() {
									function fetchPriestAvailability() {
										var serviceDate = $('#serviceDate').val();
										var serviceTime = $('#serviceTime').val();
										
										if(serviceDate != '' && serviceTime != '') {
											$.ajax({
												url: '<?=base_url('Home/GetPriestAvailibility')?>',
												type: 'POST',
												data: {
													serviceDate: serviceDate,
													serviceTime: serviceTime
												},
												success: function(response) {
													$("#priestName").empty();
													$("#priestName").append(response);
												},
												error: function(xhr, status, error) {
													console.error(xhr.responseText);
												}
											});
										} else {
											console.log('Please fill both service date and service time.');
										}
									}

									$("#serviceDate").on("input change", fetchPriestAvailability);
									// $("#serviceTime").on("input change", fetchPriestAvailability);
									$(".mdtp__button").click(function() {
										fetchPriestAvailability();
									});

								});




							$(document).ready(function(){
								$('.price_types').change(function(){
									var selectedValue = parseFloat($(this).val()).toFixed(2);

									var id = $(this).attr('id');

									var selectedOption = $(this).find('option:selected');

									var key = selectedOption.attr('key');

									var spanId = "Totalprice_" + id;

									var checkboxId = "checkbox_" + id;

									$("#" + spanId).text('$ ' + selectedValue);
									$("#" + checkboxId).attr('data-price',selectedValue);
									$("#" + checkboxId).attr('data-servicedesc',key);

									addTocart();
								});
							});

						</script>

						<?php $this->load->view('includes/script') ?>



