<?php $this->load->view('admin/includes/head'); ?>
<link href="<?= base_url('admin_assets/css/select2.min.css') ?>" rel="stylesheet" />

<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;
		}

		.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;
		}
	</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">
				<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<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" value="<?= set_value('fname', @$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<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', @$lastname) ?>" placeholder="Last Name" 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 <span class="text-danger fw-bold text-white" style="font-size: 20px;">*</span></legend>
										<div class="input-group">
											<labe class="fa fa-calendar" for="dob"></labe>
											<input type="text" name="dob" id="dob" class="form-control datepicker" value="<?= set_value('dob', @$userDetails->dob) ?>" placeholder="MM/DD/YYYY" aria-label="dob" aria-describedby="basic-addon1">


										</div>
									</fieldset>

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

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

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

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


													<option value="<?= @replaceSingleQuotesWithBackticks($item['refDataName']); ?>" <?= @replaceSingleQuotesWithBackticks($item['refDataName']) == @replaceSingleQuotesWithBackticks($userDetails->gotraName) ? 'selected' : '' ?>><?= @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) && @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>
										</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) && @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">
								<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<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>
										</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<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>
								</div>
							</div>



							<div class="row">
								<div class="col-md-12">
									<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>
							<div class="row">
								<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">
									<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="<?= @replaceSingleQuotesWithBackticks($state->refDataName) ?>" <?= @replaceSingleQuotesWithBackticks($state->refDataName) == @replaceSingleQuotesWithBackticks($userDetails->stateTypes) ? 'selected' : ''; ?>><?= @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</legend>
										<div class="input-group">
											<i class="fa fa-file"></i>
											<input type="number" class="form-control" onKeyPress="if(this.value.length==6) return false;" name="zipcode" id="zipcode" value="<?= set_value('zipcode', @$userDetails->zip) ?>" 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" placeholder="MM/DD/YYYY" 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) && @replaceSingleQuotesWithBackticks($userDetails->spouseNakshtra) !== replaceSingleQuotesWithBackticks("DON'T KNOW")) {
													$selected_option = '<option value="'. @replaceSingleQuotesWithBackticks($userDetails->spouseNakshtra).'" selected>' . @replaceSingleQuotesWithBackticks($userDetails->spouseNakshtra) . '</option>';
												}

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

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


													<option value="<?= @replaceSingleQuotesWithBackticks($item['refDataName']); ?>" <?= @replaceSingleQuotesWithBackticks($item['refDataName']) == @replaceSingleQuotesWithBackticks($userDetails->spouseNakshtra) ? 'selected' : '' ?>><?= @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) && @replaceSingleQuotesWithBackticks($userDetails->spouseRashi) !== replaceSingleQuotesWithBackticks("DON'T KNOW")) {
													$selected_option = '<option value="'. @replaceSingleQuotesWithBackticks($userDetails->spouseRashi) .'" selected>' . @replaceSingleQuotesWithBackticks($userDetails->spouseRashi) . '</option>';
												}

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

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


													<option value="<?= @replaceSingleQuotesWithBackticks($item['refDataName']); ?>" <?= @replaceSingleQuotesWithBackticks($item['refDataName']) == @replaceSingleQuotesWithBackticks($userDetails->spouseRashi) ? 'selected' : '' ?>><?= @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">
										</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" id="inlineCheckbox2" name="household_indicator[]" <?= @$userDetails->householdInd == 'YES' ? 'checked' : '' ?>>
											<label class="form-check-label m-auto pt-2" for="inlineCheckbox2">Yes</label>
										</div>

										<div class="form-check form-check-inline mx-5" style="padding-bottom: 5px;">
											<input class="form-check-input" type="checkbox" id="inlineCheckbox1" name="household_indicator[]" <?= @$userDetails->householdInd == 'YES' ? '' : 'checked' ?>>
											<label class="form-check-label m-auto pt-2" 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">
											</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, Rashi & Star</legend>

									<div class="row">

										<?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" placeholder="MM/DD/YYYY" 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) && @replaceSingleQuotesWithBackticks($userDetails->nakshatra) !== replaceSingleQuotesWithBackticks("DON'T KNOW")) {
																	$selected_option = '<option value="'. @replaceSingleQuotesWithBackticks($userDetails->nakshatra) .'" selected>' . @replaceSingleQuotesWithBackticks($userDetails->nakshatra) . '</option>';
																}

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

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


																	<option value="<?= @replaceSingleQuotesWithBackticks($item['refDataName']); ?>" <?= @replaceSingleQuotesWithBackticks($item['refDataName']) == @replaceSingleQuotesWithBackticks($userDetails->nakshatra) ? 'selected' : '' ?>><?= @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">
													<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" placeholder="MM/DD/YYYY" aria-label="anniversary" aria-describedby="basic-addon1" value="<?= set_value('anniversary', @$userDetails->memberDetail[0]->anniversaryDate); ?>">
														</div>
													</fieldset>
												</div>
												<div class="col-md-4">
													<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" 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" for="inlineCheckboxYes1">Yes</label>

													</div>



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

														<input class="form-check-input" type="checkbox" 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" 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>
														</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" placeholder="MM/DD/YYYY" aria-label="dateofbirth" aria-describedby="basic-addon1" value="<?= set_value('dateofbirth', @$val->dob); ?>">
															</div>
														</fieldset>

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

													</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) && @replaceSingleQuotesWithBackticks($val->nakshatra) !== replaceSingleQuotesWithBackticks("DON'T KNOW")) {

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

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

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


																		<option value="<?= @replaceSingleQuotesWithBackticks($item['refDataName']); ?>" <?= @replaceSingleQuotesWithBackticks($item['refDataName']) == @replaceSingleQuotesWithBackticks($val->nakshatra) ? 'selected' : '' ?>><?= @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">
														<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" placeholder="MM/DD/YYYY" 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/yy",
																		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">
														<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>
															</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>
		<!-- 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);
					});



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

					if (LastValue === '') {
						alert("Member name is required");
						return false;
					}else{

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


						var newCustomerFields = '<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" placeholder="MM/DD/YYYY" 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="<?=replaceSingleQuotesWithBackticks($item['refDataName']); ?>"><?=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">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">FATHER</option> <option value="MOTHER">MOTHER</option> <option value="SPOUSE">SPOUSE</option> <option value="SON">SON</option> <option value="DAUGHTER">DAUGHTER</option> </select> </div> </fieldset> </div>';

						newCustomerFields += '<div class="col-md-4"> <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"> <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">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" 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> </div> </fieldset> </div>';

						newCustomerFields += '<div class="col-md-4" 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);


						$('.datepicker').datepicker({
							format: 'mm/dd/yyyy',
							autoclose: true
						});

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

						$("#total_member_row").val(count);
					}

				});
});



$(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/yy",
			changeMonth: true,
			changeYear: true,
			yearRange: "-70:+0",
			maxDate: new Date(),
			onSelect: function(dateText) {
				console.log("Selected date:", dateText);
				console.log(dateText);
				$(this).val(dateText);
			}
		});
	});
});






$(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>
	$(document).ready(function(){
		$(".eyeIcon").click(function(){
			$("#message").toggleClass("d-none");
		});
	});
</script> -->





</body>

</html>
