<?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>
			<hr>
			
			<?php //debug($this->view->userData); ?>
			
			<form id="survey-form-edit">
				<input type="hidden" name="data[id][value]" value="<?php echo $this->view->id; ?>">
				
				<div class="form-row">
				
					<div class="form-group col-lg-3">
						<label class="label-main" for="profile_name"><?php echo _('Name'); ?>*</label>
						<input type="text" class="form-control field-name" value="<?php echo isset($this->view->userData['name']) ? $this->view->userData['name'] : ''; ?>" id="profile_name" name="data[name][value]">
						
						<input type="hidden" name="data[name][required]" value="1">
						<input type="hidden" name="data[name][type]" value="text">
						<input type="hidden" name="data[name][class]" value="field-name">
						<input type="hidden" name="data[name][label]" value="<?php echo _('Name'); ?>">
					</div>
					
					<div class="form-group col-lg-3">
						<label class="label-main" for="profile_surname"><?php echo _('Surname'); ?>*</label>
						<input type="text" class="form-control field-surname" value="<?php echo isset($this->view->userData['surname']) ? $this->view->userData['surname'] : ''; ?>" id="profile_surname" name="data[surname][value]">
						
						<input type="hidden" name="data[surname][required]" value="1">
						<input type="hidden" name="data[surname][type]" value="text">
						<input type="hidden" name="data[surname][class]" value="field-surname">
						<input type="hidden" name="data[surname][label]" value="<?php echo _('Surname'); ?>">
					</div>
					
					<div class="form-group col-lg-3">
						<label class="label-main" for="profile_birthdate"><?php echo _('Birthdate'); ?>*</label>
						<input type="text" class="form-control field-birthdate survey-birthdate" value="<?php echo isset($this->view->userData['birthdate']) ? $this->view->userData['birthdate'] : ''; ?>" id="profile_birthdate" name="data[birthdate][value]" autocomplete="off">
						
						<input type="hidden" name="data[birthdate][required]" value="1">
						<input type="hidden" name="data[birthdate][type]" value="date">
						<input type="hidden" name="data[birthdate][class]" value="field-birthdate">
						<input type="hidden" name="data[birthdate][label]" value="<?php echo _('Birth date'); ?>">
					</div>
					
					<div class="form-group col-lg-3">
						<label class="label-main" for="profile_sex"><?php echo _('Sex'); ?>*</label>
						
						<select class="form-control field-sex" id="profile_sex" name="data[sex][value]">
							<option value="">...</option>
							<option value="f" <?php echo isset($this->view->userData['sex'])&&$this->view->userData['sex']=='f' ? 'selected' : ''; ?>>F</option>
							<option value="m" <?php echo isset($this->view->userData['sex'])&&$this->view->userData['sex']=='m' ? 'selected' : ''; ?>>M</option>
						</select>
						
						<input type="hidden" name="data[sex][required]" value="1">
						<input type="hidden" name="data[sex][type]" value="date">
						<input type="hidden" name="data[sex][class]" value="field-sex">
						<input type="hidden" name="data[sex][label]" value="<?php echo _('Sex'); ?>">
					</div>
					
					<div class="form-group col-lg-6">
						<label class="label-main" for="profile_email"><?php echo _('E-mail'); ?>*</label>
						<input type="email" class="form-control field-email" value="<?php echo isset($this->view->userData['email']) ? $this->view->userData['email'] : ''; ?>" id="profile_email" name="data[email][value]">
						
						<input type="hidden" name="data[email][required]" value="1">
						<input type="hidden" name="data[email][type]" value="email">
						<input type="hidden" name="data[email][class]" value="field-email">
						<input type="hidden" name="data[email][label]" value="<?php echo _('E-mail'); ?>">
					</div>
					
					<div class="form-group col-lg-6">
						<label class="label-main" for="profile_phone"><?php echo _('Phone'); ?>*</label>
						<input type="tel" class="form-control field-phone" value="<?php echo isset($this->view->userData['phone']) ? $this->view->userData['phone'] : ''; ?>" id="profile_phone" name="data[phone][value]">
						
						<input type="hidden" name="data[phone][required]" value="0">
						<input type="hidden" name="data[phone][type]" value="text">
						<input type="hidden" name="data[phone][class]" value="field-phone">
						<input type="hidden" name="data[phone][label]" value="<?php echo _('Phone'); ?>">
					</div>
					
					<div class="form-group col-lg-12">
						<hr>
					</div>
					
					<?php /*
					<div class="form-group col-lg-6">
								
						<div class="row">
							<div class="col">
								<label class="label-main" for="request-bp-max"><?php echo _('B.P. Max'); ?></label>
								<input type="number" min="0" max="250" class="form-control text-center field-request_bp_max" value="<?php echo isset($this->view->requestData['max_arterial_pressure']) ? $this->view->requestData['max_arterial_pressure'] : ''; ?>" id="request-bp-max" name="data[request_bp_max][value]">
								
								<input type="hidden" name="data[request_bp_max][required]" value="1">
								<input type="hidden" name="data[request_bp_max][type]" value="text">
								<input type="hidden" name="data[request_bp_max][class]" value="field-request-bp-max">
								<input type="hidden" name="data[request_bp_max][label]" value="<?php echo _('B.P. Max'); ?>">
							</div>
							<div class="col">
								<label class="label-main" for="request-bp-min"><?php echo _('B.P. Min'); ?></label>
								<input type="number" min="0" max="250" class="form-control text-center field-request-bp-min" value="<?php echo isset($this->view->requestData['min_arterial_pressure']) ? $this->view->requestData['min_arterial_pressure'] : ''; ?>" id="request-bp-min" name="data[request_bp_min][value]">
								
								<input type="hidden" name="data[request_bp_min][required]" value="1">
								<input type="hidden" name="data[request_bp_min][type]" value="text">
								<input type="hidden" name="data[request_bp_min][class]" value="field-request-bp-min">
								<input type="hidden" name="data[request_bp_min][label]" value="<?php echo _('Blood Pressure Min'); ?>">
							</div>
							<div class="col">
								<label class="label-main" for="request_heart_rate"><?php echo _('H.R.'); ?></label>
								<input type="number" min="0" max="250" class="form-control text-center field-request_heart_rate" value="<?php echo isset($this->view->requestData['heart_rate']) ? $this->view->requestData['heart_rate'] : ''; ?>" id="request_heart_rate" name="data[request_heart_rate][value]">
								
								<input type="hidden" name="data[request_heart_rate][required]" value="1">
								<input type="hidden" name="data[request_heart_rate][type]" value="text">
								<input type="hidden" name="data[request_heart_rate][class]" value="field-request_heart_rate">
								<input type="hidden" name="data[request_heart_rate][label]" value="<?php echo _('Heart Rate'); ?>">
							</div>
							<div class="col">
								<label class="label-main" for="request_oxy_sat"><?php echo _('O.S.'); ?> %</label>
								<input type="number" min="0" max="100" class="form-control text-center field-request_oxy_sat" value="<?php echo isset($this->view->requestData['saturation']) ? $this->view->requestData['saturation'] : ''; ?>" id="request_oxy_sat" name="data[request_oxy_sat][value]">
								
								<input type="hidden" name="data[request_oxy_sat][required]" value="1">
								<input type="hidden" name="data[request_oxy_sat][type]" value="text">
								<input type="hidden" name="data[request_oxy_sat][class]" value="field-request_oxy_sat">
								<input type="hidden" name="data[request_oxy_sat][label]" value="<?php echo _('Oxygen Saturation'); ?> %">
							</div>
						</div>
						
					</div>
					*/ ?>
					
					<div class="form-group col-lg-12">
						<label class="label-main" for="request_medremarks"><?php echo _('Note'); ?></label>
						<textarea class="form-control field-request_medremarks" name="data[request_medremarks][value]" rows="4"><?php echo isset($this->view->userData['notes']) ? strip_tags($this->view->userData['notes']) : ''; ?></textarea>
						
						<input type="hidden" name="data[request_medremarks][required]" value="1">
						<input type="hidden" name="data[request_medremarks][type]" value="text">
						<input type="hidden" name="data[request_medremarks][class]" value="field-request_medremarks">
						<input type="hidden" name="data[request_medremarks][label]" value="<?php echo _('Note'); ?>">
					</div>
					
					<div class="form-group col-lg-12">
						<hr>
					</div>
					
					<div class="form-group col-lg-9">
						<label class="label-main" for="survey_type_list"><?php echo _('Survey types'); ?>*</label>
						
						<select class="form-control field-survey_types" id="survey_type_list" name="data[survey_type][value]">
							<option value="0">...</option>
							<?php foreach($this->view->survey_type_list as $id => $label): ?>
								<?php
									$selected = '';
									if (isset($this->view->userData['type_id'])) {
										$selected = $this->view->userData['type_id']==$id ? 'selected' : '';
									}
								?>
								<option value="<?php echo $id; ?>" <?php echo $selected; ?>><?php echo $label; ?></option>
							<?php endforeach; ?>
						</select>
						<input type="hidden" name="data[survey_type][class]" value="field-survey_types">
					</div>
					
					<div class="form-group col-lg-3">
						<button type="button" class="btn btn-info btn-block btn-edit-survey-preview" style="margin-top:31px;">Anteprima</button>
					</div>
					
				</div>
				
				<hr>
								
				<div class="clearfix">
					<button type="button" class="btn btn-primary btn-edit-survey float-right"><?php echo _('Send'); ?></button>
				</div>
					
			</form>
			
		</div>
	</div>
</div>

<div class="modal" id="dialog-survey-preview" tabindex="-1" role="dialog">
  <div class="modal-dialog modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title"><?php echo _('Survey preview'); ?></h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        	<div class="text-center" id="dialog-loader"><img src="<?php echo $this->layout->getPublicUri(); ?>images/ajaxloader.svg" width="50"></div>
			<div class="modal-body-survey-preview"></div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-primary" data-dismiss="modal"><?php echo _('Close'); ?></button>
      </div>
    </div>
  </div>
</div>