
<div class="page-header pb-10 page-header-dark bg-gradient-primary-to-secondary">
	<?php echo $this->partial('Layout/header-public'); ?>	
</div>

<style>
	.custom-file-input ~ .custom-file-label::after {
		content: "<?php echo _('Browse'); ?>";
	}
	
	/* Chrome, Safari, Edge, Opera */
	input::-webkit-outer-spin-button,
	input::-webkit-inner-spin-button {
	  -webkit-appearance: none;
	  margin: 0;
	}
	
	/* Firefox */
	input[type=number] {
	  -moz-appearance: textfield;
	}
</style>

<div class="container mt-n10">
    <div class="card card-shadow">
		
		<?php //debug($this->view->debug); ?>
	    
	    <?php if(!is_null($this->view->survey_title)): ?>
	        <div class="card-header card-header-large text-center">
		        <h1><?php echo $this->view->survey_title; ?></h1>
		    </div>
	        <div class="card-body">
				
				<?php if($this->view->is_download): ?>					
					<?php if($this->view->passcode_checked == 0): ?>
						<?php echo $this->partial('Survey/mobile-code-box'); ?>
					<?php else: ?>
					
						<?php if (is_array($this->view->attachList) && !empty($this->view->attachList)): ?>
							<div class="survey-patient-row"><small><?php echo $this->view->survey_patient_string; ?></small></div>
							<hr>
						
							<?php foreach($this->view->attachList as $email_id => $item): ?>
								<h5><i class="fa fa-envelope-o" aria-hidden="true"></i> <?php echo $this->helper->getDateString($item['created_at'], false); ?></h5>
								
								<?php if(is_array($item['data'])): ?>
								
									<div class="download-wrapper">
										<?php foreach($item['data'] as $index_data => $data_item): ?>
											<div <?php echo $index_data == 0 ? 'style="padding: 5px; background-color:#f5f5f5;"' : ''; ?>><?php echo $index_data > 0 ? '<i class="fa fa-file-o" aria-hidden="true"></i>' : ''; ?> <a class="btn-check-passcode-status" data-surveycode="<?php echo $this->view->survey_code; ?>" data-src="<?php echo $this->view->remotePlatformUrl; ?>d6d/?ft=<?php echo $data_item['name']; ?>&fn=<?php echo $data_item['file_name']; ?>" href="#"><?php echo $data_item['name']; ?></a></div>
										<?php endforeach; ?>
									</div>
									
								<?php endif; ?>
								
								<hr>
								
								
							<?php endforeach; ?>
						
						<?php else: ?>
							<div class="alert alert-warning"><?php echo _('There are no files yet for this questionnaire.'); ?></div>
						<?php endif; ?>
						
					<?php endif; ?>
					
				<?php else: ?>
				
					<?php if(!$this->view->survey_delayed): ?>
										
	        			<?php if(!is_null($this->view->structure)): ?>
	        		        			
							<?php if (!$this->view->survey_answered): ?>
							
								<?php if($this->view->passcode_checked == 0): ?>
								
									<?php echo $this->partial('Survey/mobile-code-box'); ?>
									
								<?php else: ?>
									<div><small><?php echo $this->view->survey_patient_string; ?></small></div>
									<hr>
									<div id="survey-form-container">
										<form id="public-survey-send">
											<input type="hidden" name="survey_code" value="<?php echo $this->view->survey_code; ?>">
											<?php echo $this->partial('Survey/form'); ?>
											<!--<hr>-->
											<div class="clearfix">
												<button type="button" class="btn btn-primary btn-public-survey-send float-right"><?php echo _('Send'); ?></button>
											</div>
										</form>
									</div>
									
									<div class="alert alert-success margin-top-20" id="survey-success-msg"><?php echo _('The questionnaire has been completed correctly, you will receive a reply as soon as possible.'); ?></div>
								<?php endif; ?>
								
							
							<?php else: ?>
								<div class="alert alert-warning margin-top-20"><?php echo _('This questionnaire has already been completed and sent on:'); ?> <?php echo $this->helper->getDateString($this->view->survey_date); ?>.</div>
							<?php endif; ?>
		        			
		    			<?php else: ?>
		    				<div class="alert alert-danger"><?php echo _('Invalid questionnaire.'); ?></div>
	        			<?php endif; ?>
					
					<?php else: ?>
						<div class="alert alert-danger"><?php echo _('This questionnaire is not accessible at the moment, you will receive the instructions for completing it in the manner required by your health situation.'); ?></div>
					<?php endif; ?>
				
				<?php endif; ?>
	
	        </div>
	    <?php else: ?>
		    <div class="card-body">
		    	<div class="alert alert-danger"><?php echo _('Information not available for this questionnaire.'); ?></div>
		    </div>
        <?php endif; ?>
    </div>
</div>

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