<?php

use app\base\Common;
use yii\helpers\Html;
use yii\helpers\ArrayHelper;
use yii\widgets\ActiveForm;
use kartik\select2\Select2;
use kartik\widgets\DepDrop;
use yii\helpers\Url;

/* @var $this yii\web\View */
/* @var $model app\models\demographics */
/* @var $form yii\widgets\ActiveForm */

$Surveys = Common::getSurvey();
$Locs = Common::getLocations();

$JS = "
	
	$('.datepicker').datepicker({autoclose: true, startDate: '01-01-1900', endDate: '0', format: '".strtolower(Yii::$app->formatter->dateFormat)."'});	 

";
$this->registerJs($JS);

?>

<div class="demographics-form">
	<div class="panel panel-default">
		<div class="panel-heading">
		
		</div>
		<div class="panel-body">
			<div class="row">
				<div class="col-lg-12">
					<?php
						$form = ActiveForm::begin(['options' => ['class' => 'form-horizontal']]);
						$template = [
							'labelOptions' => ['class' => 'form-label'],
							'template' => '<div class="col-sm-5">{label}{hint}</div><div class="col-sm-4">{input}{error}</div>',
						];
						$htemplate = [
							'options' => ['tag' => false],
							'template' => '{input}'
						];
						$fmt = str_replace("dd", "d", strtolower(Yii::$app->formatter->dateFormat));
						$fmt = str_replace("mm", "m", $fmt);
						$fmt = str_replace("yyyy", "Y", $fmt);
					?>
					<?php //  echo $form->errorSummary($model); ?>
								
					
                    <?php if($model->isNewRecord): ?>
						<?= $form->field($model, 'Survey', $template)->dropDownList($Surveys) ?>	
                    <?= $form->field($model, 'Location', $template)->dropDownList($Locs,['prompt' => "Select Location"]) ?>	
					<?= $form->field($model, 'ReportDate', $template)->textInput(['class' => 'form-control datepicker', 'value' => app\base\Converter::toDisplay(date($fmt)), 'readonly' => true]) ?>
					<?php else: ?>
						<?= $form->field($model, 'Survey', $template)->textInput(['disabled' => true, 'readonly' => true]) ?>
						<?= $form->field($model, 'Location', $template)->textInput(['disabled' => true, 'readonly' => true]) ?>						
						<?= $form->field($model, 'ReportDate', $template)->textInput(['class' => 'form-control datepicker', 'value' => $model->ReportDate,'disabled' => true]) ?>
					<?php endif; ?>
					        			
					
					<?= $form->field($model, 'InitiatedOn', $template)->textInput(['class' => 'form-control datepicker']) ?>				
					
					<?= $form->field($model, 'Enrollment', $template)->textInput(['maxlength' => true]) ?>
					<?= $form->field($model, 'HIVPos', $template)->textInput(['maxlength' => true]) ?>
					<?= $form->field($model, 'HIVPosStar', $template)->textInput(['maxlength' => true]) ?>
					<?= $form->field($model, 'HIVNeg', $template)->textInput(['maxlength' => true]) ?>
					<?= $form->field($model, 'HIVInd', $template)->textInput(['maxlength' => true]) ?>
					
                    <?= $form->field($model, 'HIVLinkage', $template)->textarea(['rows' => '2']) ?>	
					<?= $form->field($model, 'HCV', $template)->textarea(['rows' => '2']) ?>	
					<?= $form->field($model, 'Contact', $template)->textarea(['rows' => '2']) ?>	
					<?= $form->field($model, 'HIVPostTestCounseling', $template)->textarea(['rows' => '2']) ?>	
					<?= $form->field($model, 'HCVPostTestCounseling', $template)->textarea(['rows' => '2']) ?>	
					<?= $form->field($model, 'AttendanceOut', $template)->textarea(['rows' => '2']) ?>	
					<?= $form->field($model, 'STI', $template)->textarea(['rows' => '2']) ?>	
					<?= $form->field($model, 'TB', $template)->textarea(['rows' => '2']) ?>	
					<?= $form->field($model, 'Condoms', $template)->textarea(['rows' => '2']) ?>	
					<?= $form->field($model, 'NeedleSyringe', $template)->textarea(['rows' => '2']) ?>	
					<?= $form->field($model, 'HIVVisit', $template)->textarea(['rows' => '2']) ?>	
					<?= $form->field($model, 'CD4Visit', $template)->textarea(['rows' => '2']) ?>	
					<?= $form->field($model, 'ARTBookScan', $template)->textarea(['rows' => '2']) ?>	
					<?= $form->field($model, 'Registration', $template)->textarea(['rows' => '2']) ?>	
					<?= $form->field($model, 'Lab', $template)->textarea(['rows' => '2']) ?>	
					<?= $form->field($model, 'CohortScreening', $template)->textarea(['rows' => '2']) ?>	
					<?= $form->field($model, 'CohortDemographics', $template)->textarea(['rows' => '2']) ?>	
					<?= $form->field($model, 'CohortQoL', $template)->textarea(['rows' => '2']) ?>	
					<?= $form->field($model, 'CohortHIVConstinumofCare', $template)->textarea(['rows' => '2']) ?>	
					<?= $form->field($model, 'CohortPreARTBelief', $template)->textarea(['rows' => '2']) ?>	
					<?= $form->field($model, 'CohotPostARTBelief', $template)->textarea(['rows' => '2']) ?>	
					<?= $form->field($model, 'CohortSubstanceUse', $template)->textarea(['rows' => '2']) ?>	
					<?= $form->field($model, 'CohortRiskbehavior', $template)->textarea(['rows' => '2']) ?>						
					<?= $form->field($model, 'CohortDepression', $template)->textarea(['rows' => '2']) ?>	
					<?= $form->field($model, 'CohortHealthCareUtilisation', $template)->textarea(['rows' => '2']) ?>	
					<?= $form->field($model, 'Remarks', $template)->textarea(['rows' => '4']) ?>	
				
					<?= $form->field($model, 'status', $htemplate)->hiddenInput(['value' => 1])->label() ?>
					<?= $form->field($model, $model->isNewRecord ? 'create_user' : 'update_user', $htemplate)->hiddenInput(['value' => yii::$app->user->identity->id])->label("") ?>
					<div class="form-group">
						<div class="col-sm-offset-5 col-sm-7">
							<?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
							<?= Html::a('Cancel', ['/'.Yii::$app->controller->id], ['class' => 'btn btn-default']) ?>
						</div>
					</div>
					<?php ActiveForm::end(); ?>
				</div>
				<!-- /.col-lg-6 (nested) -->
			</div>
			<!-- /.row (nested) -->
		</div>
		<!-- /.panel-body -->
	</div>
	<!-- /.panel -->
</div>