<?php
/* @var $this QuestionController */
/* @var $data Question */

$jawaban=Answer::model()->findByAttributes(
	array(
		'question_id'=>$data->id_question,
		'created_id'=>$user_id,
		'session_id'=>$sessionid,
	)
);
?>

<div>
	<div class="panel panel-default">
		<div class="panel-heading">
			<h4 class="panel-title">

				<?php echo CHtml::encode($data->question_sort); ?>. <?php echo $data->question; ?>
				<?php
				if($data->attachment==1){
					echo "<span class='text-info'><b>( Lampirkan dokumen Pendukung )</b></span>";
				}else{
				}
				?>


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

				<?php
				if($jawaban->answer_status==0){
					echo "<div class='pull-right label label-danger'><small>( Belum di Jawab )</small></div>";
				}else{

					?>

					<table class="table table-condensed">
						<?php if($data->type!=3){ ?>
							<TR>
								<TD class="question">Jawaban</TD>
								<TD class="answer">
									<?php echo Answer::model()->AnswerStatus($jawaban->answer_status); ?>
								</TD>
							</TR>
						<?php } ?>
						<?php if($jawaban->answer_status==1){ ?>
							<TR>
								<TD class="question"></TD>
								<TD class="answer">
									<?php echo $data->question_extend; ?>
								</TD>
							</TR>
							<TR>
								<TD class="question"></TD>
								<TD class="answer">
									<?php if($data->type==1){ ?>

										<?php echo $jawaban->QuestionAnswer->name; ?>

									<?php }elseif($data->type==2){ ?>

										<?php echo Answer::model()->multipleKu($jawaban->answer_multiple);; ?>

									<?php }elseif($data->type==3){ ?>

										<?php echo $jawaban->male + $jawaban->female; ?>

									<?php }elseif($data->type==4){ ?>

									<?php } ?>
								</TD>
							</TR>
						<?php }else{ ?>
							<TR>
								<TD class="question"></TD>
								<TD class="answer">
									<?php echo $jawaban->answer_status == 0 ? "-" : "Jika Tidak, Alasannya"; ?>
								</TD>
							</TR>
							<TR>
								<TD class="question"></TD>
								<TD class="answer">
									<?php echo $jawaban->reason == NULL ? "-" : $jawaban->reason; ?>
								</TD>
							</TR>
						<?php } ?>

						<?php if($data->attachment==1){ ?>
							<TR>
								<TD class="question">Lampiran</TD>
								<TD class="answer">
									<?php echo Answer::model()->Attachment($jawaban->attachment); ?>
								</TD>
							</TR>
						<?php } ?>
						<?php if($data->total_children==1){ ?>
							<TR>
								<TD class="question">Kondisi Sebelum</TD>
								<TD class="answer">
									<?php echo $jawaban->male; ?>
								</TD>
							</TR>
							<TR>
								<TD class="question">Kondisi Sessudah</TD>
								<TD class="answer">
									<?php echo $jawaban->female; ?>
								</TD>
							</TR>
						<?php } ?>

						<TR>
							<TD class="question">Catatan</TD>
							<TD class="answer">
								<?php echo $jawaban->answer == NULL ? "-" : $jawaban->answer; ?>
							</TD>
						</TR>

						<TR>
							<TD class="question">Nilai</TD>
							<TD class="answer">
								<?php echo $jawaban->point; //echo Question::model()->sumQustionPointMY($data->id_question,$jawaban->created_id); ?>
							</TD>
						</TR>


						<?php if($jawaban->verified_id==NULL): ?>
							<TR>
								<TD class="question">Status Jawaban</TD>
								<TD class="answer">
									<?php echo Answer::model()->AnswerVerified($jawaban->verified_answer); ?>
								</TD>
							</TR>
						<?php endif; ?>


					</table>

					<?php
					if($jawaban->attachment==1):
						$dataAnswerAttachment=new CActiveDataProvider('AnswerAttachment',array('criteria'=>array('condition'=>'question_id='.$data->id_question.' AND session_id='.$jawaban->session_id)));
						$this->widget('zii.widgets.grid.CGridView', array(
							'id'=>'answer-attachment-grid',
							'summaryText'=>'',
							'emptyText'=>'Lampiran tidak diupload',
							'dataProvider'=>$dataAnswerAttachment,
							'itemsCssClass' => 'table-responsive table table-striped table-hover table-vcenter',
							'columns'=>array(

								array(
									'header'=>'Lampiran',
									'type'=>'raw',
									'value'=>'CHtml::link($data->lampiran, array("main/answer/download/id/$data->id_attachment"))',
								),

							),
						));
					endif;
					?>



				<?php } ?>

			</div>
		</div>
	</div>
</div>

