<?php echo $this->partial('Layout/nav'); ?>

<div class="container">
	<div class="container-page-wrapper shodowed bordered">
		<div class="container-page-container">
			<div class="row">
				<div class="col-lg-6">
					<h1><?php echo $this->actionTitle; ?></h1>
				</div>
				<div class="col-lg-6 clearfix">
					<div class="float-right">

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

			<?php
				//if (is_array($this->view->centerData)):
				if(true) :
			?>
				<form id="center-form">
					<input type="hidden" name="data[center_id][value]" value="<?php echo $this->view->centerId; ?>">
					<input type="hidden" name="data[center_id][required]" value="0">

					<div class="form-row">
						<div class="form-group col-lg-12">
							<hr>
							<h4 class="text-center"><?php echo _('Clinical center information'); ?></h4>
							<hr>
						</div>

						<div class="form-group col-lg-8">
							<label class="label-main" for="profile_description"><?php echo _('Clinical center name'); ?></label>
							<input type="text" class="form-control field-description" value="<?php echo isset($this->view->centerData['description']) ? $this->utility->sureHtml($this->view->centerData['description']) : ''; ?>" id="profile_description" name="data[description][value]">

							<input type="hidden" name="data[description][required]" value="1">
							<input type="hidden" name="data[description][type]" value="text">
							<input type="hidden" name="data[description][class]" value="field-description">
							<input type="hidden" name="data[description][label]" value="<?php echo _('Clinical center name'); ?>">
						</div>

						<div class="form-group col-lg-4">
							<label class="label-main"><?php echo _('Anonymize'); ?></label>
							<div>
								<div class="form-check form-check-inline">
									<input type="hidden" name="data[anonymize][value]" value="0">
									<input class="form-check-input" type="checkbox" id="profile-anonymize" value="1" name="data[anonymize][value]"
										<?php echo (int)$this->view->centerData['anonymize'] == 1 ? 'checked' : ''; ?>
									>
									<label class="form-check-label" for="profile-anonymize ?>"><?php echo _('Yes') . '/' . _('No'); ?></label>

									<input type="hidden" name="data[anonymize][required]" value="0">
									<input type="hidden" name="data[anonymize][type]" value="checkbox">
									<input type="hidden" name="data[anonymize][class]" value="field-anonymize">
									<input type="hidden" name="data[anonymize][label]" value="<?php echo _('Anonymize'); ?>">
								</div>
							</div>
						</div>

						<div class="form-group col-lg-6">
							<label class="label-main" for="profile_continent_code"><?php echo _('Continent'); ?></label>
							<select class="form-control field-continent_code" id="profile_continent_code" name="data[continent_code][value]">
								<?php foreach($this->view->continents as $continent): ?>
									<option <?php echo $continent['code'] == $this->view->centerData['continent_code'] ? 'selected' : '' ?> value="<?php echo $continent['code']; ?>"><?php echo $continent['name']; ?></option>
								<?php endforeach; ?>
							</select>
							<input type="hidden" name="data[continent_code][required]" value="1">
							<input type="hidden" name="data[continent_code][type]" value="select">
							<input type="hidden" name="data[continent_code][class]" value="field-continent_code">
							<input type="hidden" name="data[continent_code][label]" value="<?php echo _('Continent'); ?>">
						</div>
						<div class="form-group col-lg-6">
							<label class="label-main" for="profile_country_code"><?php echo _('Country'); ?></label>
							<select class="form-control field-country_code" id="profile_country_code" name="data[country_code][value]" <?php echo !$this->view->isEditing ? 'disabled' : ''; ?>>
								<?php foreach($this->view->countries as $country): ?>
									<option <?php echo $country['code'] == $this->view->centerData['country_code'] ? 'selected' : '' ?> value="<?php echo $country['code']; ?>"><?php echo $country['name']; ?></option>
								<?php endforeach; ?>
							</select>
							<input type="hidden" name="data[country_code][required]" value="1">
							<input type="hidden" name="data[country_code][type]" value="select">
							<input type="hidden" name="data[country_code][class]" value="field-country_code">
							<input type="hidden" name="data[country_code][label]" value="<?php echo _('Country'); ?>">
						</div>

						<div class="form-group col-lg-12">
							<label class="label-main" for="profile_address"><?php echo _('Address'); ?></label> <?php //htmlspecialchars($string, ENT_HTML5, 'UTF-8'); ?>
							<input type="text" class="form-control field-address" value="<?php echo isset($this->view->centerData['address']) ? $this->utility->sureHtml($this->view->centerData['address']) : ''; ?>" id="profile_address" name="data[address][value]">

							<input type="hidden" name="data[address][required]" value="0">
							<input type="hidden" name="data[address][type]" value="text">
							<input type="hidden" name="data[address][class]" value="field-address">
							<input type="hidden" name="data[address][label]" value="<?php echo _('Address'); ?>">
						</div>

						<div class="form-group col-lg-6">
							<label class="label-main" for="profile_lat"><?php echo _('Latitude'); ?></label>
							<input type="text" class="form-control field-lat" value="<?php echo isset($this->view->centerData['lat']) && $this->view->centerData['lat']!=0 ? $this->view->centerData['lat'] : ''; ?>" id="profile_lat" name="data[lat][value]">

							<input type="hidden" name="data[lat][required]" value="0">
							<input type="hidden" name="data[lat][type]" value="text">
							<input type="hidden" name="data[lat][class]" value="field-lat">
							<input type="hidden" name="data[lat][label]" value="<?php echo _('Latitude'); ?>">
						</div>
						<div class="form-group col-lg-6">
							<label class="label-main" for="profile_lng"><?php echo _('Longitude'); ?></label>
							<input type="text" class="form-control field-lng" value="<?php echo isset($this->view->centerData['lng']) && $this->view->centerData['lng']!=0 ? $this->view->centerData['lng'] : ''; ?>" id="profile_lng" name="data[lng][value]">

							<input type="hidden" name="data[lng][required]" value="0">
							<input type="hidden" name="data[lng][type]" value="text">
							<input type="hidden" name="data[lng][class]" value="field-lng">
							<input type="hidden" name="data[lng][label]" value="<?php echo _('Longitude'); ?>">
						</div>

						<div class="form-group col-lg-12">
							<label class="label-main" for="profile_notes"><?php echo _('Notes'); ?></label>
							<textarea class="form-control field-notes" id="profile_notes" name="data[notes][value]" rows="4"><?php echo isset($this->view->centerData['notes']) ? $this->utility->sureHtml($this->view->centerData['notes']) : ''; ?></textarea>

							<input type="hidden" name="data[notes][required]" value="0">
							<input type="hidden" name="data[notes][type]" value="textarea">
							<input type="hidden" name="data[notes][class]" value="field-notes">
							<input type="hidden" name="data[notes][label]" value="<?php echo _('Notes'); ?>">
						</div>

						<div class="form-group col-lg-12">
							<hr>
							<h4 class="text-center"><?php echo _('Medical specialties association'); ?></h4>
							<hr>
						</div>

						<div class="col-lg">
							<label class="label-main" for="profile_medical_specialties"><?php echo _('Medical specialties'); ?></label>
						</div>
						<div class="col-lg-auto clearfix">
							<div class="float-right">
								<div class="btn-group" role="group">
									<button type="button" class="btn btn-outline-primary btn-sm font-weight-bold btn-all-medical_specialties" data-action="select"><?php echo _('Select all') ?></button>
									<button type="button" class="btn btn-outline-primary btn-sm font-weight-bold btn-all-medical_specialties" data-action="deselect"><?php echo _('Deselect all') ?></button>
								</div>
							</div>
						</div>
						<div class="form-group col-lg-12">
							<select multiple class="form-control field-medical_specialties chosen-select" id="profile_medical_specialties" name="data[medical_specialties][value][]">
								<?php $inactive_specilties_msg = ''; ?>
								<?php foreach ($this->view->allSpecialties as $specialty) : ?>
									<?php if((int)$specialty['status'] == 1): ?>
										<option class="medical_specialty" value="<?php echo $specialty['id']; ?>"
											<?php
												if(isset($this->view->centerData['medical_specialties']) && is_array($this->view->centerData['medical_specialties']))
													echo in_array($specialty['id'], $this->view->centerData['medical_specialties']) ? 'selected' : '';
											?>
										><?php echo _($specialty['description']); ?></option>
									<?php endif; ?>
									<?php if(isset($this->view->centerData['medical_specialties']) && is_array($this->view->centerData['medical_specialties'])) : ?>
										<?php if((int)$specialty['status'] == 0 && in_array($specialty['id'], $this->view->centerData['medical_specialties'])) : ?>
											<?php $inactive_specilties_msg .= ' ' . _($specialty['description']) . ','; ?>
											<option class="medical_specialty" value="<?php echo $specialty['id']; ?>" selected><?php echo _($specialty['description']); ?></option>
										<?php endif; ?>
									<?php endif; ?>
								<?php endforeach; ?>
							</select>
							<!-- <?php if($inactive_specilties_msg != ''): ?> -->
								<div class="small font-weight-bold text-danger">
									<?php echo _('No more active medical specialties are assigned:') . substr($inactive_specilties_msg, 0, -1) . ('.'); ?>
								</div>
							<!-- <?php endif; ?> -->
							<input type="hidden" name="data[medical_specialties][required]" value="0">
							<input type="hidden" name="data[medical_specialties][type]" value="multiselect">
							<input type="hidden" name="data[medical_specialties][class]" value="field-medical_specialties">
							<input type="hidden" name="data[medical_specialties][label]" value="<?php echo _('Medical specialties'); ?>">
						</div>

						<div class="form-group col-lg-12">
							<hr>
							<h4 class="text-center"><?php echo _('Medical devices'); ?></h4>
							<hr>
						</div>
					</div>

					<div class="form-row">
						<?php debug($this->view->DEBUG); ?>
						<hr>
						<?php debug($this->view->centerData); ?>
					</div>

					<hr>
					<div class="clearfix">
						<button type="button" class="btn btn-primary btn-center-save float-right"><?php echo _('Save'); ?></button>
					</div>
				</form>
			<?php else: ?>
				<div class="alert alert-warning" role="alert"><?php echo _("Unable to get user's information right now. Please try in a few minutes."); ?></div>
			<?php endif; ?>

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