<?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" autocomplete="off" value="<?php echo isset($this->view->userData['birthdate']) ? $this->view->userData['birthdate'] : ''; ?>" id="profile_birthdate" name="data[birthdate][value]">
						
						<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>
					
					<div class="form-group col-lg-6">
						
						<div class="form-check">
							<input class="form-check-input" type="checkbox" value="1" id="check-auto-tlc" name="data[autotlc][value]" <?php echo isset($this->view->userData['remote_auto_tlc'])&&(int)$this->view->userData['remote_auto_tlc']==1 ? 'checked' : ''; ?>>
							<label class="form-check-label" for="check-auto-tlc">
								Associa ad una televisita
								<?php if((isset($this->view->userData['remote_auto_tlc'])&&(int)$this->view->userData['remote_auto_tlc']==1) && (isset($this->view->userData['remote_auto_tlc_id'])&&(int)$this->view->userData['remote_auto_tlc_id']==0)): ?>
								<div class="text-muted"><small>L'ID del nuovo teleconsulto sarà associato quando il paziente risponderà alla scheda.</small></div>
								<?php endif; ?>
								
							</label>
						</div>
					</div>
					
					<div class="form-group col-lg-6">
						<div class="auto-tlc-id <?php echo !isset($this->view->userData['remote_auto_tlc'])||(isset($this->view->userData['remote_auto_tlc'])&&(int)$this->view->userData['remote_auto_tlc']==0) ? 'hide-control' : ''; ?>">
							<label class="label-main" for="profile_phone">#ID teleconsulto</label>
							<input type="number" class="form-control " value="<?php echo isset($this->view->userData['remote_auto_tlc_id'])&&(int)$this->view->userData['remote_auto_tlc_id']>0 ? (int)$this->view->userData['remote_auto_tlc_id'] : ''; ?>" id="profile_tlc_number" name="data[tlcid][value]">
							<small class="text-muted">Indicare l'ID di un teleconsulto esistente o lasciare vuoto per crearne uno nuovo.</small>
						</div>
					</div>
					
					<div class="form-group col-lg-12">
						<hr>
					</div>
					
					<div class="form-group col-lg-6">
						<label class="label-main" for="request_delay_date">Data ricezione</label>
						
						<input type="text" class="form-control field-delay_date survey-delay_date" autocomplete="off" value="<?php echo isset($this->view->userData['msg_delay_at']) ? $this->view->userData['msg_delay_at'] : ''; ?>" id="profile_delay_date" name="data[delay_date][value]">
						
						<input type="hidden" name="data[delay_date][required]" value="0">
						<input type="hidden" name="data[delay_date][type]" value="text">
						<input type="hidden" name="data[delay_date][class]" value="field-request_delay_date">
						<input type="hidden" name="data[delay_date][label]" value="Data ricezione">
					</div>
					
					<div class="form-group col-lg-6">
						<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>