<?php $this->load->view('admin/includes/head'); ?>
<link href="<?= base_url('admin_assets/css/select2.min.css') ?>" rel="stylesheet" />
<script src="<?= base_url('assets/js/notify.js') ?>"></script>
<script src="<?= base_url('assets/js/notify.min.js') ?>"></script>
<body>
	<?php
	$header_data = getWebSyncsData('Header Settings', 'headerSettings', '');
	?>
	<style type="text/css">
		.select2-container--default .select2-selection--single {
			margin-bottom: 7px;
		}

		.fa2 {
			margin-top: 7px;

		}

		.fa {
			padding-top: 3px;
		}

		input {
			padding-top: 0px !important;
			padding-left: 15px !important;
		}

		.form-check-input:checked[type=checkbox] {
			padding: 12px 12px !important;
		}

		.form-check-label {
			/* padding-left: 24px; */
			padding-left: 7px;
		}

		.form-check-input:focus {
			box-shadow: 0 0 0 0.25rem #ffc107 !important;
		}

		.form-check-input[type=checkbox] {
			padding: 12px 12px !important;
		}

		.select2-selection {
			margin-bottom: 0 !important;
		}

		.select2-search__field {
			padding-left: 30px !important;
			font-size: 18px!important;
		}

		/* .select2-selection__rendered{
			text-transform: uppercase;
		} */
			@media only screen and (max-width:360px) {
		.collapse:not(.show) {
    display: flex!important;
}
	}
		 
	</style>

	<div class="d-flex" id="wrapper">
		<?php $this->load->view('admin/includes/sidebar'); ?>
		<!-- Page content wrapper-->
		<div id="page-content-wrapper">
			<!-- Top navigation-->
			<?php $this->load->view('admin/includes/topbar'); ?>
			<!-- Main content-->
			<div class="container pt-2">
				<div class="row">

					<div class="col-md-12 mx-auto d-block shadow-lg bg-body rounded">
						<?php echo $this->session->flashdata('success'); ?>
						<?= form_open('admin/update/profile', ' method="post" id="UpdateProfileForm"') ?>


						<fieldset class="border-2">
							<legend class="legend-outer  float-none w-auto"> Personal Details </legend>

							<div class="row">

								<div class="col-md-4">
									<?php
									$parts = explode(" ", @$userDetails->refDataName);
									$lastname = array_pop($parts);
									$firstname = implode(" ", $parts);

									if (empty($firstname)) {
										$firstname = $lastname;
										$lastname = "";
									}


									// echo '<pre>';
									// print_r($userDetails);
									?>
									<fieldset class="border">
										<legend class="legend-inner float-none w-auto">First Name - Head of Household<span class="text-danger fw-bold" style="font-size: 20px;">*</span></legend>
										<!-- <div class="input-group"></div> -->

										<div class="input-group">
											<i class="fa fa-user"></i>
											<input type="text" class="form-control" id="fname" name="fname" placeholder="First Name - Head of Household" value="<?= set_value('fname', @$userDetails->firstName) ?>" required aria-label="fname" aria-describedby="basic-addon1">
										</div>
									</fieldset>
								</div>
								<div class="col-md-4">
									<fieldset class="border">
										<legend class="legend-inner float-none w-auto">Last Name - Head of Household<span class="text-danger fw-bold" style="font-size: 20px;">*</span><span class="text-danger fw-bold" style="font-size: 20px;"></span></legend>
										<div class="input-group">
											<i class="fa fa-user"></i>
											<input type="text" class="form-control" id="lname" name="lname" value="<?= set_value('lname', @$userDetails->lastName) ?>" placeholder="Last Name - Head of Household" aria-label="lname" required aria-describedby="basic-addon1">
										</div>
									</fieldset>

								</div>



								<div class="col-md-4">
									<fieldset class="border">

										<legend class="legend-inner float-none w-auto">Date Of Birth - MM/DD</legend>
										<div class="input-group">
											<labe class="fa fa-calendar" for="dob"></labe>
											<input type="text" name="dob" id="dob" class="form-control datepicker_dob" value="<?= set_value('dob', @$userDetails->dob) ?>" placeholder="MM/DD" aria-label="dob" aria-describedby="basic-addon1">


										</div>
									</fieldset>

								</div>
							</div>
							<div class="row">
								<div class="col-md-4">
									<fieldset class="border" style="height: 62px; margin-top: 4px;">
										<legend class="legend-inner float-none w-auto">Gothram </legend>
										<div class="input-group">

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

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

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


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


												<?php } ?>
											</select>


										</div>


									</fieldset>

								</div>
								<div class="col-md-4">
									<fieldset class="border">
										<legend class="legend-inner float-none w-auto">Nakshatra<span class="fw-bold text-white" style="font-size: 20px;">*</span></legend>
										<div class="input-group">

											<select id="stars" name="stars" style="color:black!important;" class="form-control rounded select3 form-select pt-0">
												<option value=" " selected disabled>Select Nakshtra</option>



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

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

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


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


												<?php } ?>
											</select>
										</div>
									</fieldset>
								</div>
								<div class="col-md-4">
									<fieldset class="border">
										<legend class="legend-inner float-none w-auto">Rashi<span class="fw-bold text-white" style="font-size: 20px;">*</span></legend>
										<div class="input-group">
											<select id="rashi" name="rashi" style="color:black!important;" class="form-control rounded select3 form-select pt-0">
												<option value=" " selected disabled>Select Rashi</option>



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

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

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


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


												<?php } ?>


											</select>
										</div>
									</fieldset>
								</div>
							</div>
							<div class="row">
								<div class="col-md-6">
									<?php

									if (isset($userDetails->email) && !empty($userDetails->email)) {
										$fieldset_bg = 'readonly style="background-color: #e7e6e6;"';
									} else {
										$fieldset_bg = '';
									}

									?>
									<fieldset class="border" <?= $fieldset_bg; ?>>
										<legend class="legend-inner float-none w-auto">Email - Head of Household<span class="text-danger fw-bold" style="font-size: 20px;">*</span></legend>
										<div class="input-group">
											<i class="fa fa-envelope"></i>

											<input type="email" class="form-control" id="main_email" name="main_email" placeholder="Email" value="<?= set_value('main_email', base64_decode(@$userDetails->email)) ?>" <?= $fieldset_bg ?> aria-label="main_email" required oninput="this.value = this.value.toLowerCase()">
										</div>
									</fieldset>

								</div>
								<div class="col-md-6">

									<?php

									if (isset($userDetails->phone) && !empty($userDetails->phone)) {
										$fieldset_bg2 = 'readonly style="background-color: #e7e6e6;"';
									} else {
										$fieldset_bg2 = '';
									}

									?>


									<fieldset class="border" <?= $fieldset_bg2; ?>>
										<legend class="legend-inner float-none w-auto">Phone - Head of Household<span class="text-danger fw-bold" style="font-size: 20px;">*</span></legend>
										<div class="input-group">
											<i class="fa fa-phone"></i>
											<input type="text" class="form-control phone" id="main_phone" name="main_phone" placeholder="Phone" value="<?= set_value('main_phone', formatPhoneNumber(base64_decode(@$userDetails->phone))) ?>" aria-label="main_phone" required <?= $fieldset_bg2 ?>>
										</div>
									</fieldset>
									<?php
									if (isset($userDetails->phone) && !empty($userDetails->phone)) {
									?>
										<p class="mb-0 text-end"><a href="javaScript:void(0)" type="button" class="text-decoration-none text-danger" data-bs-toggle="modal" data-bs-target="#updateMobileModal"> <b><i class="fa fa-edit"></i> Update Phone No. </b></a></p>
									<?php
									}
									?>
								</div>
							</div>



							<div class="row">
								<div class="col-md-6">
									<fieldset class="border">
										<legend class="legend-inner float-none w-auto">Address Line 1<span class="fw-bold text-white" style="font-size: 20px;">*</span></legend>
										<div class="input-group">
											<i class="fa fa2 fa-map-marker"></i>
											<input type="text" class="form-control" name="address_line1" id="address_line1" value="<?= set_value('address_line1', @$userDetails->addressLine1) ?>" placeholder="Address Line 1" aria-label="address_line1">
										</div>
									</fieldset>
								</div>
								<div class="col-md-6">
									<fieldset class="border">
										<legend class="legend-inner float-none w-auto">Address Line 2<span class="fw-bold text-white" style="font-size: 20px;">*</span></legend>
										<div class="input-group">
											<i class="fa fa2 fa-map-marker"></i>
											<input type="text" class="form-control" name="address_line2" id="address_line2" value="<?= set_value('address_line2', @$userDetails->addressLine2) ?>" placeholder="Address Line 2" aria-label="address_line2">
										</div>
									</fieldset>
								</div>


								<div class="col-md-6 d-none">
									<fieldset class="border">
										<legend class="legend-inner float-none w-auto">County<span class="text-danger fw-bold" style="font-size: 20px;">&nbsp;</span></legend>
										<div class="input-group">
											<i class="fa fa2 fa-map-marker"></i>
											<input type="text" class="form-control" name="county" id="county" value="<?= set_value('county', @$userDetails->county) ?>" placeholder="County" aria-label="county">
										</div>
									</fieldset>
								</div>

							</div>

							<div class="row">
								<div class="col-md-4">
									<fieldset class="border">
										<legend class="legend-inner float-none w-auto">State<span class="fw-bold text-white" style="font-size: 20px;">*</span></legend>
										<div class="input-group">
											<select class="form-control select2 rounded form-select pt-0" name="state" id="stateSelect">
												<option value="" selected>Select State</option>
												<?php

												// print_r($userDetails);

												$keys = array_column($GetState, 'refDataName'); /// Multidiamensional array sort by key
												array_multisort($keys, SORT_ASC, $GetState);

												foreach ($GetState as $state) { ?>
													<option value="<?= strtoupper(@replaceSingleQuotesWithBackticks($state->refDataName)) ?>" <?= strtoupper(@replaceSingleQuotesWithBackticks($state->refDataName)) == strtoupper(@replaceSingleQuotesWithBackticks($userDetails->stateTypes)) ? 'selected' : ''; ?>><?= strtoupper(@replaceSingleQuotesWithBackticks($state->refDataName)) ?></option>
												<?php } ?>
											</select>
										</div>
									</fieldset>
								</div>
								<div class="col-md-4">
									<fieldset class="border">
										<legend class="legend-inner float-none w-auto">City<span class="fw-bold text-white" style="font-size: 20px;">*</span></legend>
										<div class="input-group">
											<select class="form-control rounded select3 form-select pt-0" name="city" id="city">
												<option value="" selected disabled>Select City</option>
											</select>
										</div>
									</fieldset>
								</div>
								<div class="col-md-4">
									<fieldset class="border">
										<legend class="legend-inner float-none w-auto">Zip Code<span class="fw-bold text-danger" style="font-size: 20px;">*</span></legend>
										<div class="input-group">
											<!-- <i class="fa fa-file"></i> -->
											<input type="number" class="form-control" onKeyPress="if(this.value.length==5) return false;" name="zipcode" id="zipcode" value="<?= set_value('zipcode', @$userDetails->zip) ?>" required placeholder="Zip Code" aria-label="zipcode" aria-describedby="basic-addon1">
										</div>
									</fieldset>
								</div>
							</div>


							<div class="row">
								<div class="col-md-3">
									<fieldset class="border">
										<legend class="legend-inner float-none w-auto">Spouse Name<span class="fw-bold text-white" style="font-size: 20px;">*</span></legend>
										<div class="input-group">
											<input type="text" class="form-control" id="spouseName" name="spouseName" placeholder="Spouse Name" value="<?= set_value('spouseName', @$userDetails->spouseName) ?>" aria-label="spouseName">
										</div>
									</fieldset>

								</div>
								<div class="col-md-3">
									<fieldset class="border">
										<legend class="legend-inner float-none w-auto">Spouse Date Of Birth</legend>
										<div class="input-group">
											<input name="spousedateofbirth" id="spousedateofbirth" type="text" class="form-control datepicker_dob" placeholder="MM/DD" aria-label="spousedateofbirth" aria-describedby="basic-addon1" value="<?= set_value('spousedateofbirth', @$userDetails->spouseDob); ?>">
										</div>
									</fieldset>
								</div>

								<div class="col-md-3">
									<fieldset class="border">
										<legend class="legend-inner float-none w-auto">Spouse Nakshatra<span class="fw-bold text-white" style="font-size: 20px;">*</span></legend>
										<div class="input-group">

											<select id="spouseStars" name="spouseStars" style="color:black!important;" class="form-control rounded select3 form-select pt-0">
												<option value=" " selected disabled>Select Nakshtra</option>

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

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

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


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


												<?php } ?>



											</select>
										</div>
									</fieldset>
								</div>

								<div class="col-md-3">
									<fieldset class="border">
										<legend class="legend-inner float-none w-auto">Spouse Rashi<span class="fw-bold text-white" style="font-size: 20px;">*</span></legend>
										<div class="input-group">
											<select id="spouseRashi" name="spouseRashi" style="color:black!important;" class="form-control rounded select3 form-select pt-0">
												<option value=" " selected disabled>Select Rashi</option>

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

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

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


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


												<?php } ?>

											</select>
										</div>
									</fieldset>
								</div>


							</div>


							<div class="row">


								<div class="col-md-4">
									<fieldset class="border">
										<legend class="legend-inner float-none w-auto">Spouse Email<span class="fw-bold text-white" style="font-size: 20px;">*</span></legend>
										<div class="input-group">
											<input type="email" class="form-control" id="spouseEmail" name="spouseEmail" placeholder="Spouse Email" value="<?= set_value('spouseEmail', base64_decode(@$userDetails->spouseEmail)) ?>" aria-label="spouseEmail" oninput="this.value = this.value.toLowerCase()">
										</div>
									</fieldset>
								</div>
								<div class="col-md-4">
									<fieldset class="border">
										<legend class="legend-inner float-none w-auto">Spouse Phone</legend>
										<div class="input-group">
											<input type="text" class="form-control phone" id="spousePhone" name="spousePhone" placeholder="Spouse Phone" value="<?= set_value('spousePhone',  formatPhoneNumber(base64_decode(@$userDetails->spousePhone))) ?>" aria-label="spousePhone">
										</div>
									</fieldset>
								</div>


								<div class="col-md-4">
									<!-- <fieldset class="border"> -->
									<legend class="legend-inner float-none w-auto fw-bold eyeIcon">Household Indicator <a href="javaScript:void(0)"><i class="fa fa-eye" style="font-size: 18px; padding-left: 10px; vertical-align: middle; color: teal;"></i></a></legend>
									<div id="message" class="message d-none">By selecting 'YES' for the household indicator, this family member will be linked to the primary household member. All transactions made by this family member will be grouped under the primary household member. Selecting 'NO' means this family member will not be linked to the primary household member!</div>


									<div class="form-check form-check-inline" style="padding-bottom: 5px;">
										<input class="form-check-input" type="checkbox"  style="margin-right:0px!important;" id="inlineCheckbox2" name="household_indicator[]" value="YES" <?= @$userDetails->householdInd == 'YES' ? 'checked' : '' ?>>
										<label class="form-check-label m-auto pt-2"  style="padding-left: 4px!important;" for="inlineCheckbox2">Yes</label>
									</div>

									<div class="form-check form-check-inline" style="padding-bottom: 5px;">
										<input class="form-check-input" type="checkbox"  style="margin-right:0px!important;" id="inlineCheckbox1" name="household_indicator[]" value="NO" <?= @$userDetails->householdInd == 'YES' ? '' : 'checked' ?>>
										<label class="form-check-label m-auto pt-2" style="padding-left: 4px!important;"  for="inlineCheckbox1">No</label>
									</div>
									<!-- </fieldset> -->
								</div>


							</div>

							<div class="row d-none">
								<div class="col-md-6">
									<fieldset class="border">
										<legend class="legend-inner float-none w-auto">Company Name<span class="fw-bold text-white" style="font-size: 20px;">*</span></legend>
										<div class="input-group">
											<i class="fa fa-building-o"></i>
											<input type="text" class="form-control" name="company_name" id="company_name" value="<?= set_value('company_name', @$userDetails->companyName) ?>" placeholder="Company Name" aria-label="company_name" aria-describedby="basic-addon1">
										</div>
									</fieldset>
								</div>
								<div class="col-md-6">
									<fieldset class="border">
										<legend class="legend-inner float-none w-auto">Company Email<span class="fw-bold text-white" style="font-size: 20px;">*</span></legend>
										<div class="input-group">
											<i class="fa fa-envelope"></i>
											<input type="email" class="form-control" name="company_email" id="company_email" value="<?= set_value('company_email', base64_decode(@$userDetails->companyEmail)) ?>" placeholder="Company Email" aria-label="company_email" aria-describedby="basic-addon1" oninput="this.value = this.value.toLowerCase()">
										</div>
									</fieldset>
								</div>
							</div>
							<div class="row d-none">
								<div class="col-md-6">
									<fieldset class="border">
										<legend class="legend-inner float-none w-auto">Company Phone Number<span class="fw-bold text-white" style="font-size: 20px;">*</span></legend>
										<div class="input-group">
											<i class="fa fa-phone"></i>
											<input type="text" class="form-control phone" name="company_phone" id="company_phone" value="<?= set_value('company_phone', formatPhoneNumber(base64_decode(@$userDetails->companyPhone))) ?>" placeholder="Company Phone Number" aria-label="company_phone" aria-describedby="basic-addon1">
										</div>
									</fieldset>
								</div>
								<div class="col-md-6">
									<fieldset class="border">
										<legend class="legend-inner float-none w-auto">Company Website<span class="fw-bold text-white" style="font-size: 20px;">*</span></legend>
										<div class="input-group">
											<i class="fa fa-globe"></i>
											<input type="url" class="form-control" name="company_website" id="company_website" value="<?= set_value('company_website', @$userDetails->website) ?>" placeholder="Company Website" aria-label="company_website" aria-describedby="basic-addon1">
										</div>
									</fieldset>
								</div>
							</div>







							<div class="row my-3">

								<div class="col-md-3">
									<fieldset class="border">
										<legend class="legend-inner float-none w-auto">Preferred Language<span class="fw-bold text-white" style="font-size: 20px;">*</span></legend>
										<div class="input-group">
											<select id="preferredLanguage" name="preferredLanguage" style="color:black!important;" class="form-control rounded select2 form-select pt-0">
												<option value=" " selected disabled>Select Preferred Language</option>
												<?php foreach ($preferredLanguage->data as $item) { ?>
													<option value="<?= @$item->refDataName ?>" <?= @$item->refDataName == @$userDetails->languagePreferenceName ? 'selected' : '' ?>><?= @$item->refDataName ?></option>
												<?php } ?>
											</select>
										</div>
									</fieldset>
								</div>

								<div class="col-md-3">
									<fieldset class="border">
										<legend class="legend-inner float-none w-auto">Preferred Priest<span class="fw-bold text-white" style="font-size: 20px;">*</span></legend>
										<div class="input-group">

											<select id="priestName" name="priestName" style="color:black!important;" class="form-control rounded select2  form-select pt-0">
												<?php

												if ($priest_data != "") { ?>
													<option value=" " selected disabled>Select Preferred Priest</option>
													<?php foreach ($priest_data->data as $item) { ?>
														<option value="<?= @$item->refDataName ?>" email="<?= base64_decode(@$item->email) ?>" phone="<?= base64_decode(@$item->phone) ?>" priestID="<?= @$item->_id ?>" <?= $item->refDataName == @$userDetails->requestForPriestName ? 'selected' : ''; ?>><?= @$item->refDataName ?></option>
													<?php }
												} else { ?>
													<option value=" " selected disabled>Priest Not Available.</option>
												<?php	} ?>
											</select>
											<input type="hidden" name="priestPhone" id="priestPhone">
											<input type="hidden" name="priestEmail" id="priestEmail">
											<input type="hidden" name="priestId" id="priestId">
										</div>
									</fieldset>
								</div>
								<div class="col-md-6">
									<!-- <fieldset class="border"> -->
									<legend class="legend-inner float-none w-auto fw-bold">Do you want to receive temple newsletter and communications?<span class="fw-bold text-white" style="font-size: 20px;">*</span></legend>


									<div class="form-check form-check-inline mx-4" style="padding-bottom: 5px;">
										<input class="form-check-input" type="checkbox" id="inlineCheckbox2" name="emailNotification" <?= @$userDetails->emailPref == TRUE ? 'checked' : '' ?>>
										<label class="form-check-label m-auto pt-2" for="inlineCheckbox2">On Email</label>
									</div>

									<!-- <div class="form-check form-check-inline mx-4" style="padding-bottom: 5px;">
												<input class="form-check-input" type="checkbox" id="inlineCheckbox1" name="phoneNotification" <?= @$userDetails->smsPref == TRUE ? 'checked' : '' ?>>
												<label class="form-check-label m-auto pt-2" for="inlineCheckbox1">On SMS</label>
											</div> -->
									<!-- </fieldset> -->
								</div>
							</div>

						</fieldset>



						<fieldset class="border-2">
							<legend class="legend-outer float-none w-auto">Family Members, Nakshatra</legend>

							<div class="row" style="
    text-align: justify;
    justify-content: center;
">
								<div class="family_alert_0"></div>
								<?php if (empty(@$userDetails->memberDetail) || @$userDetails->memberDetail[0]->memberName == '') { ?>
									<hr>
									<div class="row customer_records px-0 familyMemberSection">
										<div class="col-md-4">
											<fieldset class="border">
												<legend class="legend-inner float-none w-auto">Family Member 1<span class="fw-bold text-white" style="font-size: 20px;">*</span></legend>
												<div class="input-group">
													<i class="fa fa-user"></i>
													<input name="family_member_name[]" id="familyMember" value="<?= set_value('family_member_name', @$userDetails->memberDetail[0]->memberName); ?>" type="text" class="form-control" placeholder="Family Member" aria-label="familyMember" aria-describedby="basic-addon1">


													<input name="family_member_gotraName[]" id="family_member_gotraName" value="<?= set_value('family_member_gotraName', @$userDetails->memberDetail[0]->gotraName); ?>" type="text" class="form-control" placeholder="family_member_gotraName" hidden>

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


										<div class="col-md-4">
											<fieldset class="border">
												<legend class="legend-inner float-none w-auto">Date Of Birth<span class="fw-bold text-white" style="font-size: 20px;">*</span></legend>
												<div class="input-group">
													<input name="dateofbirth[]" id="dateofbirth0" type="text" class="form-control datepicker_dob" placeholder="MM/DD" aria-label="dateofbirth" aria-describedby="basic-addon1" value="<?= set_value('dateofbirth', @$userDetails->memberDetail[0]->dob); ?>">
												</div>
											</fieldset>
										</div>


										<div class="col-md-4">
											<fieldset class="border">
												<legend class="legend-inner float-none w-auto">Nakshatra<span class="fw-bold text-white" style="font-size: 20px;">*</span></legend>
												<div class="input-group">

													<select name="family_member_stars[]" style="color:black!important;" class="form-control select3 rounded  form-select  pt-0">
														<option value=" " selected disabled>Select Nakshtra</option>

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

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

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


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


														<?php } ?>

													</select>
												</div>
											</fieldset>
										</div>


										<div class="col-md-4">
											<fieldset class="border">
												<legend class="legend-inner float-none w-auto">Relationship<span class="fw-bold text-white" style="font-size: 20px;">*</span></legend>
												<div class="input-group">
													<select class="form-control select2 rounded form-select pt-0" name="relationship[]">
														<option value=" " selected>Select</option>
														<option value="FATHER" <?= @$userDetails->memberDetail[0]->relationship == 'FATHER' ? 'selected' : '' ?>>FATHER</option>
														<option value="MOTHER" <?= @$userDetails->memberDetail[0]->relationship == 'MOTHER' ? 'selected' : '' ?>>MOTHER</option>
														<option value="SPOUSE" <?= @$userDetails->memberDetail[0]->relationship == 'SPOUSE' ? 'selected' : '' ?>>SPOUSE</option>
														<option value="SON" <?= @$userDetails->memberDetail[0]->relationship == 'SON' ? 'selected' : '' ?>>SON</option>
														<option value="DAUGHTER" <?= @$userDetails->memberDetail[0]->relationship == 'DAUGHTER' ? 'selected' : '' ?>>DAUGHTER</option>
													</select>
												</div>
											</fieldset>
										</div>

										<div class="col-md-4 d-none">
											<fieldset class="border">
												<legend class="legend-inner float-none w-auto">Anniversary<span class="fw-bold text-white" style="font-size: 20px;">*</span></legend>
												<div class="input-group">
													<input name="anniversary[]" id="anniversary0" type="text" class="form-control datepicker_dob" placeholder="MM/DD" aria-label="anniversary" aria-describedby="basic-addon1" value="<?= set_value('anniversary', @$userDetails->memberDetail[0]->anniversaryDate); ?>">
												</div>
											</fieldset>
										</div>
										<div class="col-md-4 d-none">
											<fieldset class="border">
												<legend class="legend-inner float-none w-auto">Status<span class="fw-bold text-white" style="font-size: 20px;">*</span></legend>
												<div class="input-group">

													<select name="family_member_status[]" id="familyMemberStatus" style="color:black!important;" class="form-control rounded  form-select pt-0">
														<option value=" " selected>Select Status</option>

														
														<option value="ACTIVE" <?= @$userDetails->memberDetail[0]->status == 'ACTIVE' ? 'selected' : '' ?>>ACTIVE</option>
														<option value="INACTIVE" <?= @$userDetails->memberDetail[0]->status == 'INACTIVE' ? 'selected' : '' ?>>INACTIVE</option>
													</select>
												</div>
											</fieldset>
										</div>


										<div class="col-md-4">


											<legend class="legend-inner float-none w-auto fw-bold eyeIcon">Household Indicator <a href="javaScript:void(0)"><i class="fa fa-eye" style="font-size: 18px; padding-left: 10px; vertical-align: middle; color: teal;"></i></a></legend>
											<div id="message" class="message d-none">By selecting 'YES' for the household indicator, this family member will be linked to the primary household member. All transactions made by this family member will be grouped under the primary household member. Selecting 'NO' means this family member will not be linked to the primary household member!</div>

											<div class="form-check form-check-inline" style="padding-bottom: 5px;">

												<input class="form-check-input" type="checkbox" style="margin-right:0px!important;"  id="inlineCheckboxYes1" name="member_household_indicator[]" onclick="selectOnlyThis(1, this)" value="YES" <?= @$userDetails->memberDetail[0]->householdInd == 'YES' ? 'checked' : '' ?>>

												<label class="form-check-label m-auto pt-2" style="padding-left: 4px!important;"  for="inlineCheckboxYes1">Yes</label>

											</div>



											<div class="form-check form-check-inline" style="padding-bottom: 5px;">

												<input class="form-check-input" type="checkbox" style="margin-right:0px!important;"  id="inlineCheckboxNo1" name="member_household_indicator[]" onclick="selectOnlyThis(1, this)" value="NO" <?= @$userDetails->memberDetail[0]->householdInd == 'YES' ? '' : 'checked' ?>>

												<label class="form-check-label m-auto pt-2"  style="padding-left: 4px!important;" for="inlineCheckboxNo1">No</label>

											</div>
										</div>

										<div class="col-md-4" id="member_email_section1" <?= @$userDetails->memberDetail[0]->householdInd == 'YES' ? 'style="display:block"' : 'style="display:none"' ?>>

											<fieldset class="border">
												<legend class="legend-inner float-none w-auto">Household Member Email<span class="fw-bold text-white" style="font-size: 20px;">*</span></legend>
												<div class="input-group">
													<input type="email" class="form-control" id="member_email1" name="member_email[]" placeholder="Member Email" required oninput="this.value = this.value.toLowerCase()">
												</div>
											</fieldset>
										</div>
										<div class="col-md-4" id="member_phone_section1" <?= @$userDetails->memberDetail[0]->householdInd == 'YES' ? 'style="display:block"' : 'style="display:none"' ?>>
											<fieldset class="border">
												<legend class="legend-inner float-none w-auto">Household Member Phone<span class="fw-bold text-white" style="font-size: 20px;">*</span></legend>
												<div class="input-group">
													<input type="text" class="form-control phone" id="member_phone1" name="member_phone[]" placeholder="Member Phone">
												</div>
											</fieldset>
										</div>





										<!-- <div class="text-end py-4">
													<a class="extra-fields-customer btn btn-success btn-sm" style="border-radius:5px!important" href="javaScript:void(0)">Add More</a>
												</div> -->
									</div>




									<?php $total_no_member = 0;
								} else {

									foreach (@$userDetails->memberDetail as $key => $val) {

									?>


										<hr>
										<div class="row customer_records px-0 familyMemberSection">
											<div class="col-md-4">
												<fieldset class="border">
													<legend class="legend-inner float-none w-auto">Family Member <?= $key + 1 ?><span class="fw-bold text-white" style="font-size: 20px;">*</span></legend>
													<div class="input-group">
														<i class="fa fa-user"></i>
														<input name="family_member_name[]" id="familyMember" value="<?= set_value('family_member_name', @$val->memberName); ?>" id="family_member_name" type="text" class="form-control" placeholder="Family Member" aria-label="familyMember" aria-describedby="basic-addon1">

														<input name="family_member_gotraName[]" id="family_member_gotraName" value="<?= set_value('family_member_gotraName', @$val->gotraName); ?>" type="text" class="form-control" placeholder="family_member_gotraName" hidden>
													</div>
												</fieldset>
											</div>


											<div class="col-md-4">
												<fieldset class="border">
													<legend class="legend-inner float-none w-auto">Date Of Birth<span class="fw-bold text-white" style="font-size: 20px;">*</span></legend>
													<div class="input-group">
														<input name="dateofbirth[]" id="dateofbirth<?= $key ?>" type="text" class="form-control datepicker_dob" placeholder="MM/DD" aria-label="dateofbirth" aria-describedby="basic-addon1" value="<?= set_value('dateofbirth', @$val->dob); ?>">
													</div>
												</fieldset>

											

											</div>


											<div class="col-md-4">
												<fieldset class="border">
													<legend class="legend-inner float-none w-auto">Nakshatra<span class="fw-bold text-white" style="font-size: 20px;">*</span></legend>
													<div class="input-group">

														<select name="family_member_stars[]" style="color:black!important;" class="form-control select3 rounded form-select pt-0">
															<option value=" " selected disabled>Select Nakshtra</option>



															<?php
															$selected_option = '';
															if (!empty(@$val->nakshatra) && strtoupper(@replaceSingleQuotesWithBackticks($val->nakshatra)) !== replaceSingleQuotesWithBackticks("DON'T KNOW")) {

																$selected_option = '<option value="' . strtoupper(@replaceSingleQuotesWithBackticks($val->nakshatra)) . '" selected>' . strtoupper(@replaceSingleQuotesWithBackticks($val->nakshatra)) . '</option>';
															}

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

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


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


															<?php } ?>


														</select>
													</div>
												</fieldset>
											</div>


											<div class="col-md-4">
												<fieldset class="border">
													<legend class="legend-inner float-none w-auto">Relationship<span class="fw-bold text-white" style="font-size: 20px;">*</span></legend>
													<div class="input-group">
														<select class="form-control select2 rounded form-select pt-0" name="relationship[]">
															<option value=" " selected>Select</option>
															<option value="FATHER" <?= @$val->relationship == 'FATHER' ? 'selected' : '' ?>>FATHER</option>
															<option value="MOTHER" <?= @$val->relationship == 'MOTHER' ? 'selected' : '' ?>>MOTHER</option>
															<option value="SPOUSE" <?= @$val->relationship == 'SPOUSE' ? 'selected' : '' ?>>SPOUSE</option>
															<option value="SON" <?= @$val->relationship == 'SON' ? 'selected' : '' ?>>SON</option>
															<option value="DAUGHTER" <?= @$val->relationship == 'DAUGHTER' ? 'selected' : '' ?>>DAUGHTER</option>
														</select>
													</div>
												</fieldset>
											</div>

											<div class="col-md-4 d-none">
												<fieldset class="border">
													<legend class="legend-inner float-none w-auto">Anniversary<span class="fw-bold text-white" style="font-size: 20px;">*</span></legend>
													<div class="input-group">
														<input name="anniversary[]" id="anniversary<?= $key ?>" type="text" class="form-control datepicker_dob" placeholder="MM/DD" aria-label="anniversary" aria-describedby="basic-addon1" value="<?= set_value('anniversary', @$val->anniversaryDate); ?>">
													</div>


													<script type="text/javascript">
														$(document).ready(function() {
															$('#anniversary<?= $key ?>').datepicker({
																dateFormat: "mm/dd",
																changeMonth: true,
																changeYear: true,
																yearRange: "-70:+0",
																maxDate: new Date(),
																onSelect: function(dateText) {
																	console.log("Selected date:", dateText);
																	console.log(dateText);
																	$('#anniversary<?= $key ?>').val(dateText);
																}
															});
														});
													</script>
												</fieldset>
											</div>

											<div class="col-md-4 d-none">
												<fieldset class="border">
													<legend class="legend-inner float-none w-auto">Status<span class="fw-bold text-white" style="font-size: 20px;">*</span></legend>
													<div class="input-group">

														<select name="family_member_status[]" id="familyMemberStatus" style="color:black!important;" class="form-control rounded  form-select pt-0">
															<option value=" " selected>Select Status</option>

															=
															<option value="ACTIVE" <?= @$val->status == 'ACTIVE' ? 'selected' : '' ?>>ACTIVE</option>
															<option value="INACTIVE" <?= @$val->status == 'INACTIVE' ? 'selected' : '' ?>>INACTIVE</option>
														</select>
													</div>
												</fieldset>
											</div>

											<div class="col-md-4">


												<legend class="legend-inner float-none w-auto fw-bold eyeIcon">Household Indicator <a href="javaScript:void(0)"><i class="fa fa-eye" style="font-size: 18px; padding-left: 10px; vertical-align: middle; color: teal;"></i></a></legend>
												<div id="message" class="message d-none">By selecting 'YES' for the household indicator, this family member will be linked to the primary household member. All transactions made by this family member will be grouped under the primary household member. Selecting 'NO' means this family member will not be linked to the primary household member!</div>

												<div class="form-check form-check-inline" style="padding-bottom: 5px;">

													<input class="form-check-input" type="checkbox" id="inlineCheckboxYes<?= $key + 1 ?>" name="member_household_indicator[]" onclick="selectOnlyThis(<?= $key + 1 ?>, this)" value="YES" <?= @$val->householdInd == 'YES' ? 'checked' : '' ?>>

													<label class="form-check-label m-auto pt-2" for="inlineCheckboxYes<?= $key + 1 ?>">Yes</label>

												</div>



												<div class="form-check form-check-inline mx-5" style="padding-bottom: 5px;">

													<input class="form-check-input" type="checkbox" id="inlineCheckboxNo<?= $key + 1 ?>" name="member_household_indicator[]" onclick="selectOnlyThis(<?= $key + 1 ?>, this)" value="NO" <?= @$val->householdInd == 'YES' ? '' : 'checked' ?>>

													<label class="form-check-label m-auto pt-2" for="inlineCheckboxNo<?= $key + 1 ?>">No</label>

												</div>
											</div>

											<div class="col-md-4" id="member_email_section<?= $key + 1 ?>" <?= @$val->householdInd == 'YES' ? 'style="display:block"' : 'style="display:none"' ?>>

												<fieldset class="border">
													<legend class="legend-inner float-none w-auto">Household Member Email<span class="fw-bold text-white" style="font-size: 20px;">*</span></legend>
													<div class="input-group">
														<input type="email" class="form-control" id="member_email1" name="member_email[]" placeholder="Member Email" value="<?= base64_decode(@$val->member_email); ?>" required oninput="this.value = this.value.toLowerCase()">
													</div>
												</fieldset>
											</div>
											<div class="col-md-4" id="member_phone_section<?= $key + 1 ?>" <?= @$val->householdInd == 'YES' ? 'style="display:block"' : 'style="display:none"' ?>>
												<fieldset class="border">
													<legend class="legend-inner float-none w-auto">Household Member Phone<span class="fw-bold text-white" style="font-size: 20px;">*</span></legend>
													<div class="input-group">
														<input type="text" class="form-control phone" id="member_phone<?= $key + 1 ?>" name="member_phone[]" placeholder="Member Phone" value="<?= formatPhoneNumber(base64_decode(@$val->member_phone)); ?>">
													</div>
												</fieldset>
											</div>


											<!-- <div class="text-end py-4"><a href="#" style="border-radius:5px!important" class="remove-field btn-remove-customer btn btn-danger btn-sm">Remove</a></div> -->

										</div>



								<?php }
									$total_no_member = $key;
								} ?>
								<div class="customer_records_dynamic px-0"></div>

								<div class="text-end py-4">
									<a class="extra-fields-customer btn btn-success btn-sm" style="border-radius:5px!important" href="javaScript:void(0)">Add More</a>
								</div>

							</div>


							<input type="hidden" id="total_member_row" value="<?= $total_no_member + 1 ?>">
							<script type="text/javascript" id="newjs"></script>

						</fieldset>
						</form>
					</div>
				</div>
			</div>
			<!-- End Main content-->
		</div>
	</div>


	<div class="modal fade" id="updateMobileModal" tabindex="-1" aria-labelledby="updateMobileModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<h5 class="modal-title" id="updateMobileModalLabel">Update Phone No.</h5>
					<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
				</div>
				<form action="<?= base_url('Admin/Dashboard/UpdateMobileNumber') ?>" method="post" id="MobileNumberForm">
					<div class="modal-body">
						<div class="row">
							<div class="col-sm-12">
								<fieldset class="border mb-0">
									<legend class="legend-inner float-none w-auto">New Phone No.<span class="text-danger fw-bold" style="font-size: 20px;">*</span></legend>
									<div class="input-group">
										<i class="fa fa-phone"></i>
										<input type="text" class="form-control phone" id="new_phone" name="new_phone" placeholder="Phone" aria-label="new_phone" required>
									</div>

								</fieldset>

							</div>
							<div class="col-sm-12" id="MobileAlreadyExistDiv">

							</div>
						</div>
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-danger mt-0" data-bs-dismiss="modal">Close</button>
						<button type="submit" class="btn btn-success">Save</button>
					</div>
				</form>
			</div>
		</div>
	</div>


	<!-- Bootstrap core JS-->
	<script src="<?= base_url('admin_assets/js/bootstrap.bundle.min.js') ?>"></script>
	<!-- Core theme JS-->
	<script src="<?= base_url('admin_assets/js/theme.js') ?>"></script>
	<script src="<?= base_url('assets/js/jquery-ui.min.js'); ?>"></script>

	<script src="<?= base_url('admin_assets/js/select2.min.js') ?>"></script>
	<script type="text/javascript">
		$('#UpdateProfileForm').keypress(function(e) {
			if (e.which == 13) {
				$('#UpdateProfileBtn').click();
				return false;
			}
		});


		$('#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);

		});


		$(document).ready(function() {

			$(document).on("click", ".eyeIcon", function() {
				$(this).siblings('.message').toggleClass("d-none");
			});


			$(document).on('click', '.extra-fields-customer', function() {

				let family_member_names = [];
				$('input[name="family_member_name[]"]').each(function() {
					let nameValue = $(this).val().trim();
					family_member_names.push(nameValue);
				});

				if (family_member_names.length < 6) {

					let LastValue = family_member_names[family_member_names.length - 1];

					if (LastValue === '') {
						// alert("Member name is required");
						// $.notify("Member name is required");
						let l = family_member_names.length - 1;
						console.log(l);
						$(".family_alert_" + l).notify("Member name is required");

						return false;
					} else {

						var count = parseInt($("#total_member_row").val()) + 1;

						var countLength = count - 1;
						var newCustomerFields = '<div class="family_alert_' + countLength + '"></div><hr><div class="row customer_records">';

						newCustomerFields += '<div class="col-md-4"> <fieldset class="border"> <legend  class="legend-inner float-none w-auto">Family Member ' + count + '<span class="fw-bold text-white" style="font-size: 20px;">*</span></legend> <div class="input-group"> <i class="fa fa-user"></i> <input name="family_member_name[]" value="" type="text" class="form-control" placeholder="Family Member" aria-label="familyMember" aria-describedby="basic-addon1"> </div> </fieldset> </div>';

						newCustomerFields += '<div class="col-md-4"> <fieldset class="border"> <legend  class="legend-inner float-none w-auto">Date Of Birth<span class="fw-bold text-white" style="font-size: 20px;">*</span></legend> <div class="input-group"> <input  name="dateofbirth[]" class="form-control datepicker_dob" placeholder="MM/DD" aria-label="dateofbirth" aria-describedby="basic-addon1"  value="" autocomplete="off"> </div> </fieldset> </div>';

						newCustomerFields += '<div class="col-md-4"> <fieldset class="border"> <legend  class="legend-inner float-none w-auto">Nakshatra<span class="fw-bold text-white" style="font-size: 20px;">*</span></legend> <div class="input-group"> <select name="family_member_stars[]"  style="color:black!important;" class="form-control rounded select3 form-select pt-0"> <option value=" " selected disabled>Select Nakshtra</option> <?php foreach ($nakshtra_data as $item) { ?> <option value="<?= strtoupper(replaceSingleQuotesWithBackticks($item['refDataName'])); ?>"><?= strtoupper(replaceSingleQuotesWithBackticks($item['refDataName'])); ?></option> <?php } ?> </select> </div> </fieldset> </div>';
						// newCustomerFields += '<div class="col-md-4"> <fieldset class="border"> <legend  class="legend-inner float-none w-auto">Nakshatra<span class="fw-bold text-white" style="font-size: 20px;">*</span></legend> <div class="input-group"> <select id="family_member_stars' + count + '" name="family_member_stars[]"  style="color:black!important;" class="form-control rounded select3 form-select pt-0"> <option value=" " selected disabled>Select Nakshtra</option> </select> </div> </fieldset> </div>';

						newCustomerFields += '<div class="col-md-6"> <fieldset class="border"> <legend  class="legend-inner float-none w-auto">Relationship to Head of Household<span class="fw-bold text-white" style="font-size: 20px;">*</span></legend> <div class="input-group"> <select class="form-control select2 rounded form-select pt-0" name="relationship[]"> <option value=" " selected>Select</option> <option value="FATHER">FATHER</option> <option value="MOTHER">MOTHER</option> <option value="SPOUSE">SPOUSE</option> <option value="SON">SON</option> <option value="DAUGHTER">DAUGHTER</option><option value="FATHER-IN-LAW">FATHER-IN-LAW</option><option value="MOTHER-IN-LAW">MOTHER-IN-LAW</option> </select> </div> </fieldset> </div>';

						newCustomerFields += '<div class="col-md-4  d-none"> <fieldset class="border"> <legend  class="legend-inner float-none w-auto">Anniversary<span class="fw-bold text-white" style="font-size: 20px;">*</span></legend> <div class="input-group"> <input name="anniversary[]" class="form-control datepicker" placeholder="MM/DD/YYYY" aria-label="anniversary" aria-describedby="basic-addon1" value=""> </div> </fieldset> </div>';

						newCustomerFields += '<div class="col-md-4 d-none"> <fieldset class="border"> <legend  class="legend-inner float-none w-auto">Status<span class="fw-bold text-white" style="font-size: 20px;">*</span></legend> <div class="input-group"> <select name="family_member_status[]" id="familyMemberStatus' + count + '"  style="color:black!important;" class="form-control rounded  form-select pt-0"> <option value=" " selected>Select Status</option> <option value="ACTIVE">ACTIVE</option><option value="INACTIVE">INACTIVE</option></select> </div> </fieldset> </div>';

						newCustomerFields += '<div class="col-md-4"> <legend  class="legend-inner float-none w-auto fw-bold"><legend class="legend-inner float-none w-auto fw-bold eyeIcon">Household Indicator <a href="javaScript:void(0)"><i class="fa fa-eye" style="font-size: 18px; padding-left: 10px; vertical-align: middle; color: teal;"></i></a></legend><div id="message" class="message d-none text-dark">By selecting `YES` for the household indicator, this family member will be linked to the primary household member. All transactions made by this family member will be grouped under the primary household member. Selecting `NO` means this family member will not be linked to the primary household member!</div> <div class="form-check form-check-inline" style="padding-bottom: 5px;"> <input class="form-check-input" type="checkbox" id="inlineCheckboxYes' + count + '" name="member_household_indicator[]" onclick="selectOnlyThis(' + count + ', this)" value="YES"> <label class="form-check-label m-auto pt-2" for="inlineCheckboxYes' + count + '">Yes</label> </div> <div class="form-check form-check-inline mx-5" style="padding-bottom: 5px;"> <input class="form-check-input" type="checkbox" id="inlineCheckboxNo' + count + '" name="member_household_indicator[]" onclick="selectOnlyThis(' + count + ', this)" value="NO" checked> <label class="form-check-label m-auto pt-2" for="inlineCheckboxNo' + count + '">No</label></div></div>';

						newCustomerFields += '<div class="col-md-4 d-none" id="member_email_section' + count + '" style="display:none"> <fieldset class="border"> <legend  class="legend-inner float-none w-auto">Household Member Email<span class="fw-bold text-white" style="font-size: 20px;">*</span></legend> <div class="input-group"><input type="email" class="form-control" id="member_email' + count + '" name="member_email[]" placeholder="Member Email" required oninput="this.value = this.value.toLowerCase()"> </div> </fieldset> </div>';

						newCustomerFields += '<div class="col-md-4 d-none" id="member_phone_section' + count + '" style="display:none"> <fieldset class="border"> <legend  class="legend-inner float-none w-auto">Household Member Phone<span class="fw-bold text-white" style="font-size: 20px;">*</span></legend> <div class="input-group"><input type="text" class="form-control phone" id="member_phone' + count + '" name="member_phone[]" placeholder="Member Phone"> </div> </fieldset> </div>';

						// newCustomerFields += '<div class="col-md-4 py-4"><a href="#" style="border-radius:5px!important" class="remove-field btn-remove-customer btn btn-danger btn-sm">Remove</a></div><hr>';

						newCustomerFields += '</div>';

						$('.customer_records_dynamic').append(newCustomerFields);
						var lang = $("#preferredLanguage").val();
						// FamilyGotraNakshatraRashi(count, lang);

						$('.datepicker').datepicker({
							format: 'mm/dd/yyyy',
							autoclose: true
						});
						$(".datepicker_dob").datepicker({
							dateFormat: 'mm/dd', // Month/Day format
							changeMonth: true,
							changeYear: false, // Disable year change
							showButtonPanel: true,
							onClose: function(dateText, inst) {
								// Retrieve the selected date from the input field
								var date = $(this).datepicker('getDate');

								if (date) {
									var day = ("0" + date.getDate()).slice(-2); // Get day and format it
									var month = ("0" + (date.getMonth() + 1)).slice(-2); // Get month and format it

									// Set the formatted date in the input field
									$(this).val(month + '/' + day);
								} else {
									// Default to 01/01 if no date is selected
									$(this).val('01/01');
								}
							}
						}).focus(function() {
							$(".ui-datepicker-year").hide(); // Hide the year dropdown
						});

						$(".select3").select2({
							tags: true
						});

						$("#total_member_row").val(count);
					}
				} else {
					$("#add_more_error").text('MAX ALLOWED 6 FAMILY MEMBERS.');
					// alert("Max allowed 6 family members.");
				}

			});
		});



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


		function selectOnlyThis(id, clicked) {



			var clicked_checkbox = $(clicked).val();


			if (clicked_checkbox == 'YES') {

				$('#inlineCheckboxYes' + id).prop('checked', true);
				$('#inlineCheckboxNo' + id).prop('checked', false);




				$("#member_email_section" + id).css('display', 'block');
				$("#member_phone_section" + id).css('display', 'block');



			} else {

				$('#inlineCheckboxNo' + id).prop('checked', true);
				$('#inlineCheckboxYes' + id).prop('checked', false);




				$("#member_email_section" + id).css('display', 'none');
				$("#member_phone_section" + id).css('display', 'none');

			}
		}



		$(document).ready(function() {
			// Trigger focus on the date input field when the page loads
			// $('.datepicker').focus();

			$(document).on('focus', '.datepicker', function() {
				console.log("Datepicker focused on:", this);
				$(this).datepicker({
					dateFormat: "mm/dd",
					changeMonth: true,
					changeYear: true,
					yearRange: "-70:+0",
					maxDate: new Date(),
					onSelect: function(dateText) {
						console.log("Selected date:", dateText);
						console.log(dateText);
						$(this).val(dateText);
					}
				});
			});

			$(".datepicker_dob").datepicker({
				dateFormat: 'mm/dd', // Month/Day format
				changeMonth: true,
				changeYear: false, // Disable year change
				showButtonPanel: true,
				onClose: function(dateText, inst) {
					// Retrieve the selected date from the input field
					var date = $(this).datepicker('getDate');

					if (date) {
						var day = ("0" + date.getDate()).slice(-2); // Get day and format it
						var month = ("0" + (date.getMonth() + 1)).slice(-2); // Get month and format it

						// Set the formatted date in the input field
						$(this).val(month + '/' + day);
					} else {
						// Default to 01/01 if no date is selected
						$(this).val('01/01');
					}
				}
			}).focus(function() {
				$(".ui-datepicker-year").hide(); // Hide the year dropdown
			});

		});






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

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

			});
		});




		function submitForm() {
			$("#UpdateProfileForm").validate({

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

			});


			Swal.fire({
				title: 'Do you want to save the changes?',
				showDenyButton: false,
				showCancelButton: true,
				confirmButtonText: 'Save',
				denyButtonText: `Don't save`,
			}).then((result) => {

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




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

			var stateCode = $(this).val();
			$.ajax({
				url: "<?= base_url('admin/getCityByState') ?>",
				type: "POST",
				// dataType: "json",
				data: {
					'stateCode': stateCode
				},
				success: function(data) {
					$("#city").html(data);
				}
			});

		});

		$(document).ready(function() {
			$('#stateSelect').change();
			$('#heading').text('Update Profile');


			setTimeout(function() {
				$("select[name='city'] option[value='<?= @$userDetails->cityTypes; ?>']").attr('selected', 'selected');
			}, 1500);


		});

		function closeForm() {

			Swal.fire({
				title: 'Do you want to cancel the changes?',
				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-profile') ?>";
				}
			})
		}



		$(".select2").select2({
			tags: false
		});

		$(".select3").select2({
			tags: true
		});



		$(document).ready(function() {
			$('input[name="household_indicator[]"]').click(function() {
				$('input[name="household_indicator[]"]').prop('checked', false);
				$(this).prop('checked', true);
			});
		});


		$('.phone').on('input', function(e) {
			var x = e.target.value.replace(/\D/g, '').match(/(\d{0,3})(\d{0,3})(\d{0,4})/);
			e.target.value = !x[2] ? x[1] : '' + x[1] + '-' + x[2] + (x[3] ? '-' + x[3] : '');
		});
	</script>



	<!-- <script type="text/javascript">
		$(document).on('input', '.select2-search__field', function() {
			var words = $(this).val().split(' ');
			for (var i = 0; i < words.length; i++) {
				words[i] = words[i].toUpperCase();
			}
			$(this).val(words.join(' '));
		});
		$(document).ready(function() {
			$('.select2-selection__rendered').on('DOMNodeInserted', function(event) {
				var $target = $(event.target);
				if ($target.is('span')) {
					var text = $target.text().toUpperCase();
					$target.text(text);
				}
			});
		});
	</script> -->
	<!-- <script type="text/javascript">
		$(document).on('input', '.select2-search__field', function() {
			var ariaControls = $(this).attr('aria-controls');
			
			
		
		
			
		

			if (ariaControls != "select2-rashi-results" && ariaControls != "select2-stars-results" && ariaControls != "select2-spouseStars-results" && ariaControls != "select2-spouseStars-result-3vpu-PUSHYA" && ariaControls != "select2-family_member_stars-fk-result-cvgp-PURVA" && ariaControls != "select2-family_member_stars-4a-results" && ariaControls != "select2-family_member_stars-vl-results" && ariaControls != "select2-family_member_stars-u2-results" && ariaControls != "select2-family_member_stars-lp-results" && ariaControls != "select2-family_member_stars-u3-results") {
				console.log("ariaControls");
				console.log(ariaControls == "select2-rashi-results");
				var words = $(this).val().split(' ');
				for (var i = 0; i < words.length; i++) {
					words[i] = words[i].toUpperCase();
				}
				$(this).val(words.join(' '));
				$(".select2-results__option").text(words.join(' '));
			} else {
				$(".select2-results__option--highlighted").addClass('d-none');
				$('.select2-results__option--highlighted').remove();
			}
		});
		$(document).ready(function() {
			$('.select2-selection__rendered').on('DOMNodeInserted', function(event) {
				var $target = $(event.target);
				if ($target.is('span')) {
					var text = $target.text().toUpperCase();
					$target.text(text);
				}
			});
		});

		$('#MobileNumberForm').submit(function(event) {
			event.preventDefault(); // Prevent the default form submission
			$('#MobileAlreadyExistDiv').html('');
			var formData = new FormData($('#MobileNumberForm')[0]);
			var formAction = $('#MobileNumberForm').attr('action'); // Get form action URL

			$.ajax({
				url: formAction,
				type: 'POST',
				data: formData,
				contentType: false,
				processData: false,
				success: function(response) {
					// Handle success response
					console.log(response.user.statusCode);
					if (response.user.statusCode == -1) {
						if (response.user.data) {
							let content = `<p class="mt-1 text-danger"><b>` + response.user.message + `</b></p><p class="mb-0"><b>Name: </b> ` + response.user.data.refDataName + `</p><p class=""><b>Email: </b> ` + response.user.data.email + `</p>`;
							$('#MobileAlreadyExistDiv').html(content);
						} else {
							Swal.fire(response.user.message, '', 'error');
						}
					} else {
						Swal.fire(response.user.message, '', 'success');
						setTimeout(function() {
							location.reload();
						}, 2000);
					}
				},
				error: function(xhr, status, error) {
					// Handle error response
					console.error('Error:', error);
					Swal.fire('Error saving changes', '', 'error');
				}
			});
		});
	</script> -->
	<!-- <script>
	$(document).ready(function(){
		$(".eyeIcon").click(function(){
			$("#message").toggleClass("d-none");
		});
	});
</script> -->





</body>

</html>