<?php

use app\base\Common;
use yii\helpers\Url;
use yii\helpers\Html;
use yii\widgets\ActiveForm;

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

$Surveys = Common::getSurvey();
$Locations = Common::getLocations();
// $PIDs = Common::getClientid();
$PIDs = "";
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::getClientid(Yii::$app->params['SURVEY'], Yii::$app->params['LOCATION']);
}

$JS = "	
	$('#regngoupdate-corfrm_q10').change(function(){
		
		if($(this).val() == 2) {					
			$('div.form-group.field-regngoupdate-corfrm_q11').addClass('required').show();
		} else {			
			$('div.form-group.field-regngoupdate-corfrm_q11').removeClass('required').hide();			
			$('#regngoupdate-corfrm_q11').val('');
		}
	});

		
	$('#regngoupdate-corfrm_q10').trigger('change');
	
";

$this->registerJs($JS);

?>

<div class="registration-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(['enableAjaxValidation' => true, '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}'
						];
					?>
					
					<?php // echo $form->errorSummary($model); ?>
					<?= Common::generateControl($form, $model, $template, 'corfrm_sid', $Surveys, 'survey', 'getAttendanceInPIDs') ?>
					<?= Common::generateControl($form, $model, $template, 'corfrm_loc', $Locations, 'location', '', [Html::getInputId($model, 'corfrm_sid')]) ?>					
									
                    <?= $form->field($model, 'corfrm_pid', $template)->textInput(['value'=>$model->corfrm_pid,'maxlength' => true, 'class' => 'form-control text-uppercase','readonly' => true]) ?>					
					<?= $form->field($model, 'corfrm_q1', $template)->textInput(['maxlength' => true, 'class' => 'form-control text-uppercase','readonly' => true]) ?>										
					<?= $form->field($model, 'corfrm_q4', $template)->textInput(['maxlength' => true, 'readonly' => true]) ?>
					<?= $form->field($model, 'corfrm_q10', $template)->dropDownList($model->q10, ['prompt'=>'Select']); ?>
					<?= $form->field($model, 'corfrm_q11', $template)->dropDownList($model->q11, ['prompt'=>'Select']); ?>
					<?= $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(Yii::t('app', 'Update'), ['class' =>'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>