<?php
/* @var $this SubController */
/* @var $model Sub */

$this->breadcrumbs=array(
	'Subs'=>array('index'),
	$model->name,
);

$this->pageTitle='Klaster ' . $model->Cluster->name;
?>
<H4 class="alert well">

	<div class="row">
		<div class="col-md-11">

			<B><?php echo $model->name; ?></B><BR>
			<!-- Ukuran : <BR><?php echo $model->measure; ?><BR><BR> -->
			Nilai Maksimal : <?php echo $model->max_point; ?><BR>

		</div>
		<div class="col-md-1">

			<button a href="<?php echo $model->link; ?>" class="btn btn-info btn-round label label-primary pull-right"> ? </button>

		</div>

	</div>

</H4>

<div class="panel-group" id="accordion">
	<?php foreach (Question::getQuestions($model->id_sub) as $question) { ?>


		<div class="panel panel-default">
			<div class="panel-heading" data-toggle="collapse" data-parent="#accordion<?php echo $question['id_question']; ?>" href="#collapse-<?php echo $question['id_question']; ?>" aria-expanded="false" class="collapsed">
				<h4 class="panel-title">

					<a data-toggle="collapse" data-parent="#accordion<?php echo $question['id_question']; ?>" href="#collapse-<?php echo $question['id_question']; ?>" aria-expanded="false" class="collapsed"><i class="icon mdi mdi-chevron-down"></i>



						<?php
						$str = $question['question'];
						$headline = substr($str, 0, strpos($str, ':'));
						echo CHtml::encode($headline);
						?>

						<span class="pull-right">
							<span class="label label-danger">Point Minimal <b><?php echo QuestionAnswer::model()->getPointMin($question['id_question']); ?></b></span>
							<span class="label label-info">Point Maksimal <b><?php echo QuestionAnswer::model()->getPointMax($question['id_question'],$question['type']); ?></b></span>
						</span>

					</a>




				</h4>
			</div>
			<div id="collapse-<?php echo $question['id_question']; ?>" class="panel-collapse collapse" aria-expanded="false" style="">
				<div class="panel-body">

					<?php echo CHtml::link('<i class="mdi mdi-edit"></i> Edit Pertanyaan',
						array('master/question/update', 'id'=>$question['id_question'],
					), array('class' => 'btn btn-warning pull-right btn-flat','title'=>'Edit Pertanyaan'));
					?>

					<p>
						<h4>

							<?php echo $question['question']; ?>
							<?php echo $question['attachment']==1 ? "<span class='text-info'><b>( Lampirkan dokumen Pendukung )</b></span>" : ""; ?>
						</h4>
					</p>


					<?php if($question['type']==1){ ?>

						<div class="form-group">
							<div class="col-sm-12 be-radio be-radio-color inline">
								<?php echo CHtml::radioButtonList($question['id_question'],$question['id_question'],CHtml::listData(QuestionAnswer::model()->findAll(array('condition'=>'question_id='.$question['id_question'],'order'=>'name ASC')),
									'id_question_asnwer', 'name'
								),
								array(
									'id'=>$question['id_question'],
									'template'=>'{input}{label}',
									'separator'=>'',
									'labelOptions'=>array(
										'style'=>'padding-right:50px;'),

								)
							); ?>
						</div>
					</div>

				<?php }else if($question['type']==2){ ?>

					<div class="form-group">
						<div class="col-sm-12 be-checkbox be-checkbox-color inline">
							<div class="checkbox checkbox-success checkbox-circle">
								<?php echo Chtml::checkBoxlist($question['id_question'],$question['id_question'],CHtml::listData(QuestionAnswer::model()->findAll(array('condition'=>'question_id='.$question['id_question'],'order'=>'name ASC')),
									'id_question_asnwer', 'name'
								),	array(
									'id'=>$question['id_question'],
									'template'=>'{input}{label}',
									'separator'=>'',
									'labelOptions'=>array(
										'style'=>'padding-bottom:5px;padding-right:200px;'),

									) ); ?>
								</div>
							</div>
						</div>

					<?php }else{ ?>


						<div class="col-sm-12 no-padding">


							<div class="col-md-6">
								<?php echo Chtml::textField($question['id_question'],'',array('class'=>'form-control','placeHolder'=>'Sebelum')); ?>
							</div>


							<div class="col-md-6">
								<?php echo Chtml::textField($question['id_question'],'',array('class'=>'form-control','placeHolder'=>'Sesudah')); ?>
							</div>


						</div>



					<?php } ?>







				</div>
			</div>
		</div>
	<?php } ?>
</div>


<?php if(YII::app()->user->record->level==0): ?>

	<span class="hidden-xs">


		<?php echo CHtml::link('Kembali',
			array('master/sub/admin'),
			array('class' => 'btn btn-info btn-flat', 'title'=>'Kembali'));
			?>

			<?php echo CHtml::link('Tambah Pertanyaan',
				array('master/question/add', 'id'=>$model->id_sub,
			), array('class' => 'btn btn-success pull-right btn-flat', 'title'=>'Tambah Pertanyaan Baru'));
			?>

		</span>

	<?php endif; ?>





	<STYLE>
		th{width:150px;}
		.question{width: 10px;color:#000;}
		.answer{font-weight: 700;font-size: 14px;color:#31708f;}
	</style>

