<?php
/* @var $this UsersController */
/* @var $model Users */

$this->breadcrumbs = array(
	'Users' => array('admin'),
	'Kelola',
);

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

<span class="visible-xs">

	<?php echo CHtml::link(
		'<i class="icon mdi mdi-plus"></i>',
		array('create'),
		array('class' => 'btn btn-primary pull-right btn-md', 'title' => 'Tambah Pengguna')
	);
	?>

</span>

<span class="hidden-xs">

	<?php echo CHtml::link(
		'Tambah Pengguna',
		array('create'),
		array('class' => 'btn btn-primary pull-right btn-flat', 'title' => 'Tambah Pengguna')
	);
	?>

</span>

<HR>

<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id' => 'users-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;'
			)
		),


		'fullname',
		'username',
		'email',
		// 'description',

		// array(
		// 	'filter'=>CHtml::listData(Department::model()->findAllByAttributes(array('status'=>1)),'id_department','name'),
		// 	'name'=>'division',
		// 	'value'=>'Department::model()->getName($data->division)',
		// ),

		array(
			'name' => 'level',
			// 'filter' => array('1' => 'Administrator', '2' => 'Penilai', '3' => 'Peserta'),
			'filter' => false,
			'value' => 'Users::model()->level($data->level)',
		),

		array(
			'name' => 'visit_time',
			'filter' => false,
			'value' => '$data->visit_time',
		),

		array(
			'header' => 'Status',
			'class' => 'CButtonColumn',
			'template' => '{Belum Aktif}{Aktif}{Reject}{Expired}',
			'htmlOptions' => array('width' => '70px', 'style' => 'text-align: center;'),
			'buttons' => array(
				'Belum Aktif' =>
				array(
					'visible' => '$data->status==0',
					// 'url'=>'Yii::app()->createUrl("main/paper/verified", array("id"=>$data->id_user))',
					'imageUrl' => YII::app()->baseUrl . '/image/setting/warning.png',
				),
				'Aktif' =>
				array(
					'visible' => '$data->status==1',
					// 'url'=>'Yii::app()->createUrl("main/paper/verified", array("id"=>$data->id_user))',
					'imageUrl' => YII::app()->baseUrl . '/image/setting/verified.png',
				),
				'Reject' =>
				array(
					'visible' => '$data->status==2',
					// 'url'=>'Yii::app()->createUrl("main/paper/verified", array("id"=>$data->id_user))',
					'imageUrl' => YII::app()->baseUrl . '/image/setting/reject.png',
				),
				'Expired' =>
				array(
					'visible' => '$data->status==3',
					// 'url'=>'Yii::app()->createUrl("main/paper/verified", array("id"=>$data->id_user))',
					'imageUrl' => YII::app()->baseUrl . '/image/setting/expired.png',
				),
			),
		),

		// array(
		// 	'name' => 'status',
		// 	'filter' => array('0' => 'Belum di Verifikasi', '1' => 'Sudah di Verifikasi'),
		// 	'value' => 'Users::model()->status($data->status)',
		// ),


		array(
			'header' => 'Edit Password',
			'class' => 'CButtonColumn',
			'template' => '{Edit Password}',
			'htmlOptions' => array('width' => '70px', 'style' => 'text-align: center;'),
			'buttons' => array(
				'Edit Password' =>
				array(
					'url' => 'Yii::app()->createUrl("integration/users/editpassword", array("id"=>$data->id_user))',
					'imageUrl' => YII::app()->baseUrl . '/image/setting/lock.png',
				),
			),
		),

		array(
			'class' => 'CButtonColumn',
			'template' => '{update}',
			'htmlOptions' => array('width' => '70px', 'style' => 'text-align: center;'),
			'buttons' => array(
				'update' =>
				array(
					'url' => 'Yii::app()->createUrl("integration/users/edit", array("id"=>$data->id_user))',
				),
			),
		),

		array(
			'class' => 'CButtonColumn',
			'template' => '{delete}',
			'htmlOptions' => array('width' => '70px', 'style' => 'text-align: center;'),
			'buttons' => array(
				'delete' =>
				array(
					'url' => 'Yii::app()->createUrl("integration/users/delete", array("id"=>$data->id_user))',
				),
			),
		),


	),
)); ?>