<?php
/* @var $this PostController */
/* @var $model Post */

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

$this->menu=array(
	array('label'=>'<i class="fe fe-plus-circle"></i> Event', 'url'=>array('create')),
);

$this->pageTitle='Kelola Timeline';
?>

<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'post-grid',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
	'itemsCssClass' => 'table table-sm table-nowrap card-table',
	'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;')),

		// array(
		// 	'name'=>'created_id',
		// 	'filter'=>CHtml::listData(Users::model()->findAllByAttributes(array('level'=>3)),'fullname','fullname'),
		// 	'value'=>'$data->CreatedBy->fullname'
		// ),

			// 'created_date',

		array(
			'class'=>'CButtonColumn',
			'template'=>'{update}',
			'htmlOptions'=>array('width'=>'100px',
				'style' => 'text-align: center;'),
			'buttons'=>array(
				'update'=>
				array(
					// 'visible' => '$data->created_id==YII::app()->user->id',
					'url'=>'Yii::app()->createUrl("main/event/update", array("id"=>$data->id_event))',
					// 'options'=>array(
					// 	'ajax'=>array(
					// 		'type'=>'POST',
					// 		'url'=>"js:$(this).attr('href')",
					// 		'success'=>'function(data) { $("#viewModal .modal-body p").html(data); $("#viewModal").modal(); }'
					// 	),
					// ),
				),
			),
		),

		// 'created_date',
		// 'update_date',

		array(
			'name' => 'title',
			'type' => 'raw',
			'value' => function($data) {
				return CHtml::link($data->title, array('/main/event/update', 'id' => $data->id_event));
			}
		),

		'start_date',
		'end_date',
		'start_time',
		'end_time',
		// 'location',

		// 'end_date',
		// 'powered_by',

		// array(
		// 	'filter'=>CHtml::listData(Category::model()->findAllByAttributes(array('status'=>1)),'id_category','name'),
		// 	'name'=>'id_category',
		// 	'value'=>'$data->Category->name'
		// ),

		// array(
		// 	'filter'=>CHtml::listData(Tag::model()->findAllByAttributes(array('status'=>1)),'id_category_sub','name'),
		// 	'name'=>'id_tag',
		// 	'value'=>'$data->Tag->name'
		// ),

		// array(
		// 	'name'=>'status',
		// 	'filter'=>array('0'=>'Disable','1'=>'Enable'),
		// 	'value'=>'Post::model()->status($data->status)',
		// ),

		// array(
		// 	'name'=>'status',
		// 	'type'=>'raw',
		// 	'value'=>'CHtml::link(Post::model()->status($data->status), array("updateStats", "id"=>$data->id_event), array("class"=>"ajaxupdate"));',
		// ),

		// array(
		// 	'header'=>'Pendaftar',
		// 	'value'=>'Registration::model()->getTotalRegister($data->id_event,1)'
		// ),

		// array(
		// 	'header'=>'Hadir',
		// 	'value'=>'Registration::model()->getTotalRegister($data->id_event,2)'
		// ),

		// array(
		// 	'header'=>'Tidak Hadir',
		// 	'value'=>'Registration::model()->getTotalRegister($data->id_event,3)'
		// ),

		array(
			'header' => 'Status',
			'htmlOptions' => array('nowrap' => 'nowrap'),
			'class' => 'CButtonColumn',
			'template' => '{aktif}{nonaktif}',
			'buttons' => array(
				'aktif' => array(
					'label' => 'Non Aktif',
					'visible' => '$data->status==0',
					'url' => 'Yii::app()->createUrl("main/event/enable", array("id" => $data["id_event"],))',
				),
				'nonaktif' => array(
					'visible' => '$data->status==1',
					'label' => 'Aktif',
					'url' => 'Yii::app()->createUrl("main/event/disable", array("id" => $data["id_event"],))',
				),
			),
		),

		// array(
		// 	'class'=>'CButtonColumn',
		// 	'template'=>'{delete}',
		// 	'htmlOptions'=>array('width'=>'100px',
		// 		'style' => 'text-align: center;'),
		// 	'buttons'=>array(
		// 		'delete'=>
		// 		array(							// 'visible' => '$data->created_id==YII::app()->user->id',
		// 			'url'=>'Yii::app()->createUrl("main/event/delete", array("id"=>$data->id_event))',
		// 			// '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 modal-lg">
		<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>View</strong> Post</h4> -->
			</div>
			<!-- Popup Content -->
			<div class="modal-body">
				<p>Details</p>
			</div>
			<!-- Popup Footer -->
			<div class="modal-footer">
				<BR>
				<button type="button" class="btn btn-default waves-effect" data-dismiss="modal">Close</button>
			</div>
		</div>
	</div>
</div>





