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

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

$this->pageTitle = 'Profil';
?>

<?php if (Paper::model()->getStatus() == 2) : ?>
<div class="alert alert-danger">Status Pendaftaran Reject: <b><?php echo Paper::model()->getNotification(); ?></b> Silahkan Perbaiki Data Anda.</div>
<?php endif; ?>

<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id' => 'users-grid',
	'dataProvider' => $dataProvider,
		// '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',
		'email',
		'phone',
		array(
			'name' => 'type',
			'filter' => array('1' => 'Perseorangan', '2' => 'Kelompok'),
			'value' => 'Users::model()->type($data->type)',
		),

		'username',
				// 'status',

		array('header' => 'Nilai Akhir', 'value' => 'Review::model()->getTotalTeam($data->id_user,2)'),


				// 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'),
						// 	'value'=>'Users::model()->level($data->level)',
						// ),

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

		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(
			'header' => 'File',
			'class' => 'CButtonColumn',
			'template' => '{Link Video}',
			'htmlOptions' => array('width' => '70px', 'style' => 'text-align: center;'),
			'buttons' => array(
				'Link Video' =>
				array(
					'visible' => '$data->status_video==1',
					'url' => 'Yii::app()->createUrl("main/paper/link", array("id"=>$data->id_user))',
					'imageUrl' => YII::app()->baseUrl . '/image/setting/document.png',
					'options' => array('target' => '_new'),
				),
			),
		),

		array(
			'header' => 'Pernyataan',
			'class' => 'CButtonColumn',
			'template' => '{Download}{Upload}',
			'htmlOptions' => array('width' => '120px', 'style' => 'text-align: center;'),
			'buttons' => array(
				'Download' =>
				array(
					'url' => 'Yii::app()->createUrl("main/paper/download", array("id"=>$data->id_user))',
					'imageUrl' => YII::app()->baseUrl . '/image/setting/document.png',
					'options' => array('target' => '_new'),
				),
				'Upload' =>
				array(
					'visible' => '$data->status!=1',
					'url' => 'Yii::app()->createUrl("file")',
					'imageUrl' => YII::app()->baseUrl . '/image/setting/upload-file.png',
					'options' => array(
						'ajax' => array(
							'type' => 'POST',
							'url' => "js:$(this).attr('href')",
							'success' => 'function(data) { $("#viewModal .modal-body p").html(data); $("#viewModal").modal(); }'
						),
					),
				),
			),
		),


							// array(
								// 	'header'=>'',
								// 	'class'=>'CButtonColumn',
								// 	'template'=>'{Unverified}',
								// 	'htmlOptions'=>array('width'=>'70px', 'style' => 'text-align: center;'),
								// 	'buttons'=>array(
									// 		'Unverified'=>
									// 		array(
										// 			'visible'=>'$data->status==0',
										// 			'url'=>'Yii::app()->createUrl("main/paper/verified", array("id"=>$data->id_user))',
										// 			'imageUrl'=>YII::app()->baseUrl.'/image/setting/check.png',
										// 		),
										// 	),
										// ),

		array(
											// 'header' => 'Kelola Tim',
			'class' => 'CButtonColumn',
			'template' => '{Update}',
			'htmlOptions' => array('width' => '70px', 'style' => 'text-align: center;'),
			'buttons' => array(
				'Update' =>
				array(
					'visible' => '$data->status!=1',
					'url' => 'Yii::app()->createUrl("main/member/my")',
													// 'url'=>'Yii::app()->createUrl("main/paper/view", array("id"=>$data->id_user))',
					'imageUrl' => YII::app()->baseUrl . '/image/setting/pencil.png',
				),
			),
		),


		array(
			'header' => '',
			'class' => 'CButtonColumn',
			'template' => '{Detail}',
			'htmlOptions' => array('width' => '70px', 'style' => 'text-align: center;'),
			'buttons' => array(
				'Detail' =>
				array(
					'visible' => '$data->status==1',
					'url' => 'Yii::app()->createUrl("main/paper/update", array("id"=>$data->id_user))',
													// 'url'=>'Yii::app()->createUrl("main/paper/view", array("id"=>$data->id_user))',
					'imageUrl' => YII::app()->baseUrl . '/image/setting/eye.png',
				),
			),
		),



	),
)); ?>



<!-- 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>Upload File</strong> Pernyataan</h4>
			</div>
			<!-- Popup Content -->
			<div class="modal-body">
				<p>Data</p>
			</div>
		</div>
	</div>
</div>