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

$this->breadcrumbs = array(
	'Papers' => array('index'),
	'Manage',
);

$this->pageTitle = 'Kelola File Logo & Tagline';

Yii::app()->clientScript->registerScript('search', "
$('.add-button').click(function(){
	$('.add-form').toggle();
	return false;
});
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$('#paper-grid').yiiGridView('update', {
		data: $(this).serialize()
	});
	return false;
});

function notificationForm(form, data, hasError){
	notification('Informasi','Data Berhasil di Simpan','success');
	if (!hasError){
		$.post(form.attr('action'), form.serialize(), function(res){
			if (res.result)
			console.log(res.data);
		});
	}
	$('#paper-grid').yiiGridView('update', {
		data: $(this).serialize()
	});
	return false;
}

function notification(heading,data,color){
	$.extend(
		$.gritter.options, {
			position: 'bottom-right'
		});
		$.gritter.add({
			title: heading,
			text: data,
			class_name: 'color '+ color + ''
		});
	}
	
	");
	?>
	
	<span class="visible-xs">
	
	<?php echo CHtml::link('<i class="mdi mdi-plus"></i>', '#', array('class' => 'add-button btn btn-primary btn-flat')); ?>
	</span>
	
	<span class="hidden-xs">
	
	<?php echo CHtml::link('Tambah', '#', array('class' => 'add-button btn btn-primary btn-flat')); ?>
	
	</span>
	
	<div class="add-form" style="display:none">
	<?php echo $this->renderPartial('_form', array('data' => $data)); ?>
	</div><!-- add-form -->
	
	<?php $this->widget('zii.widgets.grid.CGridView', array(
		'id' => 'paper-grid',
		'dataProvider' => $model->search(),
		'filter' => $model,
		'itemsCssClass' => 'table-responsive table table-striped table-hover table-vcenter',
		'columns' => array(
			
			array(
				'header' => 'No',
				'value' => '$this->grid->dataProvider->pagination->currentPage*$this->grid->dataProvider->pagination->pageSize + $row+1',
				'htmlOptions' => array(
					'width' => '10px',
					'style' => 'text-align: center;'
					)
				),
				
				// 'id_paper',
				'created_date',
				// 'created_id',
				// 'update_date',
				// 'update_id',
				array('name' => 'researchers_id', 'value' => '$data->Researchers->fullname', 'filter' => CHtml::listData(Users::model()->findAllByAttributes(array('level' => 3)), 'id_user', 'fullname'),),
				// array('header' => 'Jenjang Peneliti', 'value' => '$data->Researchers->description'),
				// array('header' => 'Unit Kerja', 'value' => 'Department::model()->getName($data->Researchers->division)'),
				// 'researchers_id',
				'paper_name',
				array('header' => 'Nilai Total', 'value' => 'Review::model()->getTotalList($data->id_paper,1)'),
				array('header' => 'Nilai Rata-Rata', 'value' => 'Review::model()->getTotalList($data->id_paper,2)'),
				array('header' => 'Total Penilai', 'value' => 'Review::model()->getTotalList($data->id_paper,3)'),
				// 'paper_image',
				// 'paper_file',
				// 'status',
				
				array(
					'class' => 'CButtonColumn',
					// 'template'=>'{view}{update}{delete}',
					'template' => '{view}',
					'buttons' => array(
						'view' =>
						array(
							'url' => 'Yii::app()->createUrl("main/paper/view", array("id"=>$data->id_paper))',
							'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> Makalah</h4>
		</div>
		<!-- Popup Content -->
		<div class="modal-body">
		<p>Data</p>
		</div>
		</div>
		</div>
		</div>