<?php
/* @var $this PaperController */
/* @var $model Paper */
/* @var $form CActiveForm */
?>

<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id' => 'users-grid',
	'dataProvider' => $dataMember,
	'summaryText' => '',
	'itemsCssClass' => 'table-responsive table table-striped table-hover table-vcenter',
	'columns' => array(
		'code',
		'fullname',
		'email',
		'phone',


		array(
			'header' => 'KTP',
			'class' => 'CButtonColumn',
			'template' => '{KTP}',
			'buttons' => array(
				'KTP' =>
				array(
					'url' => 'Yii::app()->createUrl("main/member/view", array("id"=>$data->id_member,"type"=>1))',
					'options' => array(
						'ajax' => array(
							'type' => 'POST',
							'url' => "js:$(this).attr('href')",
							'success' => 'function(data) { $("#viewModal .modal-body p").html(data); $("#viewModal").modal(); }'
						),
					),
				),
			),
		),


		array(
			'header' => 'Foto',
			'class' => 'CButtonColumn',
			'template' => '{Foto}',
			'buttons' => array(
				'Foto' =>
				array(
					'url' => 'Yii::app()->createUrl("main/member/view", array("id"=>$data->id_member,"type"=>2))',
					'options' => array(
						'ajax' => array(
							'type' => 'POST',
							'url' => "js:$(this).attr('href')",
							'success' => 'function(data) { $("#viewModal .modal-body p").html(data); $("#viewModal").modal(); }'
						),
					),
				),
			),
		),


		array(
			'header' => 'Follow Sosmed',
			'class' => 'CButtonColumn',
			'template' => '{Follow Sosmed}',
			'buttons' => array(
				'Follow Sosmed' =>
				array(
					'url' => 'Yii::app()->createUrl("main/member/view", array("id"=>$data->id_member,"type"=>3))',
					'options' => array(
						'ajax' => array(
							'type' => 'POST',
							'url' => "js:$(this).attr('href')",
							'success' => 'function(data) { $("#viewModal .modal-body p").html(data); $("#viewModal").modal(); }'
						),
					),
				),
			),
		),



	),
)); ?>



<!-- Modal -->
<div class="modal fade" id="viewModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<!-- Popup Header -->
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				<!-- <h4 class="modal-title"><strong>Detail</strong> Penilaian</h4> -->
			</div>
			<!-- Popup Content -->
			<div class="modal-body">
				<p>Data</p>
			</div>
		</div>
	</div>
</div>




<div class="form-normal form-horizontal clearfix">
	<div class="col-md-8 col-md-offset-2">
		<?php $form = $this->beginWidget('CActiveForm', array(
			'id' => 'paper-form',
			'enableAjaxValidation' => false,
			'enableClientValidation' => true,
			'clientOptions' => array(
				'validateOnSubmit' => true,
		// 'afterValidate'=>'js:notificationForm',
			),
			'errorMessageCssClass' => 'parsley-errors-list filled',
			'htmlOptions' => array('enctype' => 'multipart/form-data','autocomplete'=>'off'),
		)); ?>

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


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


			<?php if ($model->status == 0 || $model->status == 2) : ?>
				<div class="form-group">

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

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

							)
						);
						?>
					</div>

				</div>


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

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

				</div>


				<div class="form-group">

					<div class="col-sm-10">
					</div>
					<div class="col-sm-2">
						<?php echo CHtml::submitButton($model->isNewRecord ? 'Kirim' : 'Kirim', array('class' => 'btn btn-info btn-lg btn-block pull-right')); ?>
					</div>

				</div>

			<?php endif; ?>

		<?php endif; ?>

		<?php if (YII::app()->user->record->level == 3) : ?>
			<?php if ($model->paper_file == '') : ?>

				<!-- <div class="alert alert-danger">Batas Waktu Input Link Video Telah Berakhir pada Tanggal 18 Mei 2021 Pukul 23.59 WIB</div> -->


				<div class="form-group">

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

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

				</div>


				<div class="form-group">

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

					<div class="col-sm-10">
						<?php echo $form->fileField($model,'paper_image',array('class'=>'btn btn-info btn-block','type'=>'ppt, pptx')); ?>
						<?php echo $form->error($model,'paper_image'); ?>
					</div>

				</div>


				<div class="form-group">

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

					<div class="col-sm-10">
						<?php echo $form->fileField($model,'paper_file',array('class'=>'btn btn-info btn-block')); ?>
						<?php echo $form->error($model,'paper_file'); ?>
					</div>

				</div>


				<div class="form-group">

					<div class="col-sm-10">
					</div>
					<div class="col-sm-2">
						<?php echo CHtml::submitButton($model->isNewRecord ? 'Kirim' : 'Kirim', array('class' => 'btn btn-info btn-lg btn-block pull-right')); ?>
					</div>

				</div>

			<?php endif; ?>
		<?php endif; ?>


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

	</div>
</div>



<?php if ($model->paper_file != NULL || $model->paper_file != '') : ?>

	<!-- <iframe  width="100%" height="768px" border="0" src="<?php echo YII::app()->getBaseUrl(true); ?>/image/paper/pdf/<?php echo $model->paper_file; ?>"></iframe> -->

	<HR>

	<center>
		<div class="col-md-12 row no-padding">
			<div class="col-md-6">
				<a class="btn btn-block btn-success" target="_blank" href="<?php echo YII::app()->getBaseUrl(true); ?>/main/paper/link/id/<?php echo $model->id_paper; ?>">Download Karya Tulis (PDF)</a>
			</div>
			<div class="col-md-6">
				<a class="btn btn-block btn-success" target="_blank" href="<?php echo YII::app()->getBaseUrl(true); ?>/main/paper/link/id/<?php echo $model->id_paper; ?>">Download Paparan Karya Tulis (PPT)</a>
			</div>
		</div>
	</center>

<?php endif; ?>



<script>
	$(document).ready(function() {
		$('#description').hide();
		$('#Paper_status_1').click(function() {
			$('#description').show();
		});
		$('#Paper_status_0').click(function() {
			$('#description').hide();
		});
	});
</script>