<?php
/* @var $this UsersController */
/* @var $model Users */
/* @var $form CActiveForm */
?>



<div class="form-normal form-horizontal clearfix">
	<div class="col-lg-11">

		<?php $form = $this->beginWidget('CActiveForm', array(
			'id' => 'users-form',
			'enableAjaxValidation' => FALSE,
			'enableClientValidation' => true,
			'clientOptions' => array(
				'validateOnSubmit' => true,
				'afterValidate' => 'js:notificationForm',
			),
			'errorMessageCssClass' => 'label label-danger',
			'htmlOptions' => array('class' => 'form-horizontal', 'role' => 'form')
		)); ?>

		<?php echo $form->errorSummary($model, null, null, array('class' => 'alert alert-warning')); ?>

		<div class="form-group">

			<div class="col-sm-3 control-label">
				<?php echo $form->labelEx($model, 'username'); ?>
			</div>

			<div class="col-sm-9">
				<?php echo $form->error($model, 'username'); ?>
				<?php
				if (YII::app()->user->record->level == 1) {

					echo $form->textField($model, 'username', array('class' => 'form-control', 'placeholder' => 'Username'));
				} else {

					echo $form->textField($model, 'username', array('class' => 'form-control', 'placeholder' => 'Username', 'readonly' => true));
				}

				?>
			</div>

		</div>


		<div class="form-group">

			<div class="col-sm-3 control-label">
				<?php echo $form->labelEx($model, 'email'); ?>
			</div>

			<div class="col-sm-9">
				<?php echo $form->error($model, 'email'); ?>
				<?php echo $form->textField($model, 'email', array('class' => 'form-control', 'placeholder' => 'Alamat Email Aktif')); ?>
			</div>

		</div>


		<div class="form-group">

			<div class="col-sm-3 control-label">
				<?php echo $form->labelEx($model, 'fullname'); ?>
			</div>

			<div class="col-sm-9">
				<?php echo $form->error($model, 'fullname'); ?>
				<?php echo $form->textField($model, 'fullname', array('class' => 'form-control', 'placeholder' => 'Nama Depan')); ?>
			</div>

		</div>




		<div class="form-group">

			<div class="col-sm-3 control-label">
				<?php echo $form->labelEx($model, 'phone'); ?>
			</div>

			<div class="col-sm-9">
				<?php echo $form->error($model, 'phone'); ?>
				<?php echo $form->textField($model, 'phone', array('class' => 'form-control', 'placeholder' => 'No. HP')); ?>
			</div>

		</div>



		<div class="form-group">

			<div class="col-sm-3 control-label">
				<?php echo $form->labelEx($model, 'password'); ?>
			</div>

			<div class="col-sm-9">
				<?php echo $form->error($model, 'password'); ?>
				<?php echo $form->passwordField($model, 'password', array('class' => 'form-control')); ?>
			</div>

		</div>

		<div class="form-group">

			<div class="col-sm-3 control-label">
				<?php echo $form->labelEx($model, 'repeat_password'); ?>
			</div>

			<div class="col-sm-9">
				<?php echo $form->error($model, 'repeat_password'); ?>
				<?php echo $form->passwordField($model, 'repeat_password', array('class' => 'form-control')); ?>
			</div>

		</div>


		<div class=" form-group">

			<div class="col-sm-3 control-label">
				<?php echo $form->labelEx($model, 'level'); ?>
			</div>

			<div class="col-sm-9 be-radio">
				<?php echo $form->error($model, 'level'); ?>
				<?php
				echo $form->radioButtonList(
					$model,
					'level',
					array('1' => 'Superadmin', '2' => 'Penilai', '3' => 'Peserta'),
					array(
						'template' => '{input}{label}',
						'separator' => '',
						'labelOptions' => array(
							'style' => 'padding-right:20px;margin-left:15px'
						),

					)
				);
				?>
			</div>

		</div>


		<div class=" form-group" id="penilai">

			<div class="col-sm-3 control-label">
				<?php echo $form->labelEx($model, 'Jenis Penilai'); ?>
			</div>

			<div class="col-sm-9 be-radio">
				<?php echo $form->error($model, 'division'); ?>
				<?php
				echo $form->radioButtonList(
					$model,
					'division',
					array('1' => 'Kategori Umum', '2' => 'Kategori Khusus'),
					array(
						'template' => '{input}{label}',
						'separator' => '',
						'labelOptions' => array(
							'style' => 'padding-right:20px;margin-left:15px'
						),

					)
				);
				?>
			</div>

		</div>


		<div class=" form-group" id="peserta">

			<div class="col-sm-3 control-label">
				<?php echo $form->labelEx($model, 'type'); ?>
			</div>

			<div class="col-sm-9 be-radio">
				<?php echo $form->error($model, 'type'); ?>
				<?php
				echo $form->radioButtonList(
					$model,
					'type',
					array('1' => 'Analis Kebijakan', '2' => 'Non Analis Kebijakan'),
					array(
						'template' => '{input}{label}',
						'separator' => '',
						'labelOptions' => array(
							'style' => 'padding-right:20px;margin-left:15px'
						),

					)
				);
				?>
			</div>

		</div>


	</div>
</div><!-- form -->

<div class=" text-right">
	<?php echo CHtml::submitButton($model->isNewRecord ? 'Submit' : 'Edit Profil', array('class' => 'btn btn-info btn-flat pull-right')); ?>
	<BR><BR>
</div>

<?php $this->endWidget(); ?>


<script>
	$(document).ready(function () {
		$("#penilai").hide();
		$("#peserta").hide();
		$('input[name="Users[level]"]').change(function () {
			var selectedValue = $(this).val();
			if (selectedValue === "2") {
				$("#penilai").show();
				$("#peserta").hide();
			} else if (selectedValue === "3") {
				$("#penilai").hide();
				$("#peserta").show();
			}else{
				$("#penilai").hide();
				$("#peserta").hide();
			}
		});
	});
</script>
