<?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\preartbeliefs */
/* @var $form yii\widgets\ActiveForm */

$Surveys = Common::getSurvey();
$PIDs = Common::getEnrollPIDs("artb");
$Visits = Common::getCohortVisits();


if(Yii::$app->params['SURVEY'] != '') {
	$Locations = Common::getSurlocations(Yii::$app->params['SURVEY']);
}
if(Yii::$app->params['SURVEY'] != '' && Yii::$app->params['LOCATION'] != '') {
	$Locations = Common::getSurlocations(Yii::$app->params['SURVEY']);
	$PIDs = Common::getEnrollPIDs("artb",Yii::$app->params['SURVEY'], Yii::$app->params['LOCATION']);
}
if(!$model->isNewRecord) {
	$Visits = Common::getPIDsVisit($model->post_art_beliefs_survey, $model->post_art_beliefs_loc, $model->post_art_beliefs_part_id);
}

$JS="
$('#postartbeliefs-post_art_beliefs_part_id').on('select2:select', function (evt) {
		var pid = $(this)[0].value;		
		if(pid != '') {
			var link = $('#pid-info').data('link') + pid;			
			$.ajax({
				type: 'post',
				url: 'visit',
				data: 'pid='+$(this)[0].value,
				success: function(response) {	
                    			
					if(response.visit != null) {
						
						$('#postartbeliefs-visit_code').val(response.visit);
						$('#postartbeliefs-visit').val(response.visit);
						
					} else {
						$('#postartbeliefs-visit_code').val('');
						$('#postartbeliefs-visit').val('');
						
					}
					
				}
			});
		}
	});
		
	
	$('#postartbeliefs-post_art_beliefs_part_id').on('select2:unselect', function (evt) {
		$('#postartbeliefs-visit_code').val('');
		$('#postartbeliefs-visit').val('');
	});


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


?>

<div class="post_art_beliefs-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>',
						];
						$chklist_template = [
							'labelOptions' => ['class' => 'form-label'],
							'template' => '<div class="col-sm-5">{label}{hint}</div><div class="col-sm-7 checkbox-list">{input}{error}</div>',
						];
						$htemplate = [
							'options' => ['tag' => false],
							'template' => '{input}'
						];
					?>
					
					<?= Common::generateControl($form, $model, $template, 'post_art_beliefs_survey', $Surveys, 'survey', 'getEnrollPIDs','artb') ?>
					<?= Common::generateControl($form, $model, $template, 'post_art_beliefs_loc', $Locations, 'location', '', [Html::getInputId($model, 'post_art_beliefs_survey')]) ?>
					<?= Common::generateControl($form, $model, $template, 'post_art_beliefs_part_id', $PIDs, 'pid', '', [Html::getInputId($model, 'post_art_beliefs_survey'), Html::getInputId($model, 'post_art_beliefs_loc')]) ?>
					
					<?php  if($model->isNewRecord) : ?>					 
                     <?= $form->field($model, 'visit', $template)->dropDownList($Visits,['prompt' => 'Select','disabled' => true]) ?>	
                     <?php  else: ?>	
                      <?= $form->field($model, 'visit_code', $template)->widget(DepDrop::classname(), ['data'=>$Visits, 'options'=>['prompt'=>$model->getAttributeLabel('visit_code')],'disabled' => true, 'pluginOptions'=>['depends'=>[Html::getInputId($model, 'post_art_beliefs_survey'), Html::getInputId($model, 'post_art_beliefs_loc'), Html::getInputId($model, 'post_art_beliefs_part_id')], 'placeholder'=>$model->getAttributeLabel('visit_code'), 'url'=>Url::to(['/dashboard/getids']), 'params'=>['common-method1', Html::getInputId($model, 'post_art_beliefs_part_id')]]]) ?>						 
					 <?php  endif; ?>  					 
					
                     <?= $form->field($model, 'visit_code', $htemplate)->hiddenInput()->label() ?>
					
					<div class="form-group">
					 <div class="col-sm-5">
					 <?= Html::label('INTERVIEWER READ : Next, I will read you some statements about HIV and HIV treatment. Please tell me how much you agree or disagree with each statement using the response options shown here. There are no right or wrong answers, just tell me your opinion.') ?>
					 </div>
					</div>
					
					<?= $form->field($model, 'post_art_beliefs_q1', $chklist_template)->radioList($model->agree)->hint("<strong>INTERVIEWER INSTRUCTION : </strong> Use <strong>Card ARTB1.</strong><br />")?>
					<?= $form->field($model, 'post_art_beliefs_q2', $chklist_template)->radioList($model->agree)->hint("<strong>INTERVIEWER INSTRUCTION : </strong> Use <strong>Card ARTB1.</strong><br />")?>			
					<?= $form->field($model, 'post_art_beliefs_q3', $chklist_template)->radioList($model->agree)->hint("<strong>INTERVIEWER INSTRUCTION : </strong> Use <strong>Card ARTB1.</strong><br />")?>
					<?= $form->field($model, 'post_art_beliefs_q4', $chklist_template)->radioList($model->agree)->hint("<strong>INTERVIEWER INSTRUCTION : </strong> Use <strong>Card ARTB1.</strong><br />")?>	
					<?= $form->field($model, 'post_art_beliefs_q5', $chklist_template)->radioList($model->agree)->hint("<strong>INTERVIEWER INSTRUCTION : </strong> Use <strong>Card ARTB1.</strong><br />")?>
					<?= $form->field($model, 'post_art_beliefs_q6', $chklist_template)->radioList($model->agree)->hint("<strong>INTERVIEWER INSTRUCTION : </strong> Use <strong>Card ARTB1.</strong><br />")?>	
					<?= $form->field($model, 'post_art_beliefs_q7', $chklist_template)->radioList($model->agree)->hint("<strong>INTERVIEWER INSTRUCTION : </strong> Use <strong>Card ARTB1.</strong><br />")?>	
					<?= $form->field($model, 'post_art_beliefs_q8', $chklist_template)->radioList($model->agree)->hint("<strong>INTERVIEWER INSTRUCTION : </strong> Use <strong>Card ARTB1.</strong><br />")?>	
					<?= $form->field($model, 'post_art_beliefs_q9', $chklist_template)->radioList($model->agree)->hint("<strong>INTERVIEWER INSTRUCTION : </strong> Use <strong>Card ARTB1.</strong><br />")?>
					<?= $form->field($model, 'post_art_beliefs_q10', $chklist_template)->radioList($model->agree)->hint("<strong>INTERVIEWER INSTRUCTION : </strong> Use <strong>Card ARTB1.</strong><br />")?>
					<?= $form->field($model, 'post_art_beliefs_q11', $chklist_template)->radioList($model->agree)->hint("<strong>INTERVIEWER INSTRUCTION : </strong> Use <strong>Card ARTB1.</strong><br />")?>
					<?= $form->field($model, 'post_art_beliefs_q12', $chklist_template)->radioList($model->agree)->hint("<strong>INTERVIEWER INSTRUCTION : </strong> Use <strong>Card ARTB1.</strong><br />")?>			
					<?= $form->field($model, 'post_art_beliefs_q13', $chklist_template)->radioList($model->agree)->hint("<strong>INTERVIEWER INSTRUCTION : </strong> Use <strong>Card ARTB1.</strong><br />")?>
					<?= $form->field($model, 'post_art_beliefs_q14', $chklist_template)->radioList($model->agree)->hint("<strong>INTERVIEWER INSTRUCTION : </strong> Use <strong>Card ARTB1.</strong><br />")?>	
					<?= $form->field($model, 'post_art_beliefs_q15', $chklist_template)->radioList($model->agree)->hint("<strong>INTERVIEWER INSTRUCTION : </strong> Use <strong>Card ARTB1.</strong><br />")?>
					<?= $form->field($model, 'post_art_beliefs_q16', $chklist_template)->radioList($model->agree)->hint("<strong>INTERVIEWER INSTRUCTION : </strong> Use <strong>Card ARTB1.</strong><br />")?>	
					<?= $form->field($model, 'post_art_beliefs_q17', $chklist_template)->radioList($model->agree)->hint("<strong>INTERVIEWER INSTRUCTION : </strong> Use <strong>Card ARTB1.</strong><br />")?>	
					<?= $form->field($model, 'post_art_beliefs_q18', $chklist_template)->radioList($model->agree)->hint("<strong>INTERVIEWER INSTRUCTION : </strong> Use <strong>Card ARTB1.</strong><br />")?>	
					<?= $form->field($model, 'post_art_beliefs_q19', $chklist_template)->radioList($model->agree)->hint("<strong>INTERVIEWER INSTRUCTION : </strong> Use <strong>Card ARTB1.</strong><br />")?>
					<div class="form-group">
					 <div class="col-sm-5">
					 <?= Html::label('INTERVIEWER READ: Next, I will ask you some questions about HIV and HIV treatment. Please tell me how hard or easy it is to complete each action using the response options shown here. There are no right or wrong answers.') ?>
					 </div>
					</div>
					<?= $form->field($model, 'post_art_beliefs_q20', $chklist_template)->radioList($model->easy)->hint("<strong>INTERVIEWER INSTRUCTION : </strong> Use <strong>Card ARTB2.</strong><br />")?>
					<?= $form->field($model, 'post_art_beliefs_q21', $chklist_template)->radioList($model->easy)->hint("<strong>INTERVIEWER INSTRUCTION : </strong> Use <strong>Card ARTB2.</strong><br />")?>
					<?= $form->field($model, 'post_art_beliefs_q22', $chklist_template)->radioList($model->easy)->hint("<strong>INTERVIEWER INSTRUCTION : </strong> Use <strong>Card ARTB2.</strong><br />")?>		 	
					<?= $form->field($model, 'post_art_beliefs_q23', $chklist_template)->radioList($model->easy)->hint("<strong>INTERVIEWER INSTRUCTION : </strong> Use <strong>Card ARTB2.</strong><br />")?>
					<?= $form->field($model, 'post_art_beliefs_q24', $chklist_template)->radioList($model->easy)->hint("<strong>INTERVIEWER INSTRUCTION : </strong> Use <strong>Card ARTB2.</strong><br />")?>	
					<?= $form->field($model, 'post_art_beliefs_q25', $chklist_template)->radioList($model->easy)->hint("<strong>INTERVIEWER INSTRUCTION : </strong> Use <strong>Card ARTB2.</strong><br />")?>
					<?= $form->field($model, 'post_art_beliefs_q26', $chklist_template)->radioList($model->easy)->hint("<strong>INTERVIEWER INSTRUCTION : </strong> Use <strong>Card ARTB2.</strong><br />")?>	
					<?= $form->field($model, 'post_art_beliefs_q27', $chklist_template)->radioList($model->easy)->hint("<strong>INTERVIEWER INSTRUCTION : </strong> Use <strong>Card ARTB2.</strong><br />")?>	
					<?= $form->field($model, 'post_art_beliefs_q28', $chklist_template)->radioList($model->easy)->hint("<strong>INTERVIEWER INSTRUCTION : </strong> Use <strong>Card ARTB2.</strong><br />")?>	
					<?= $form->field($model, 'post_art_beliefs_q29', $chklist_template)->radioList($model->easy)->hint("<strong>INTERVIEWER INSTRUCTION : </strong> Use <strong>Card ARTB2.</strong><br />")?>
					<?= $form->field($model, 'post_art_beliefs_q30', $chklist_template)->radioList($model->easy)->hint("<strong>INTERVIEWER INSTRUCTION : </strong> Use <strong>Card ARTB2.</strong><br />")?>
					<?= $form->field($model, 'post_art_beliefs_q31', $chklist_template)->radioList($model->easy)->hint("<strong>INTERVIEWER INSTRUCTION : </strong> Use <strong>Card ARTB2.</strong><br />")?>			
					<?= $form->field($model, 'post_art_beliefs_q32', $chklist_template)->radioList($model->easy)->hint("<strong>INTERVIEWER INSTRUCTION : </strong> Use <strong>Card ARTB2.</strong><br />")?>
					<?= $form->field($model, 'post_art_beliefs_q33', $chklist_template)->radioList($model->easy)->hint("<strong>INTERVIEWER INSTRUCTION : </strong> Use <strong>Card ARTB2.</strong><br />")?>
				    							
					<?= $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>