<commit_before><?php

use yii\helpers\Html;
use yii\helpers\Url;
use yii\bootstrap\Dropdown;
use kartik\grid\GridView;
use kartik\widgets\Select2;
use kartik\widgets\DepDrop;
use backend\models\ActivityRoom;
use backend\models\TrainingClass;

$this->title = 'Training';
$this->params['breadcrumbs'][] = $this->title;

$controller = $this->context;
$menus = $controller->module->getMenuItems();
$this->params['sideMenu'][$controller->module->uniqueId]=$menus;
?>
<div class="training-index">

	<?php \yii\widgets\Pjax::begin([
		'id'=>'pjax-gridview',
	]); ?>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            	['class' => 'kartik\grid\SerialColumn'],
                        
				[
					'class' => 'kartik\grid\EditableColumn',
					'format' => 'raw',
					'attribute' => 'name',
					'vAlign'=>'middle',
					'hAlign' => 'left',
					'headerOptions'=>['class'=>'kv-sticky-column'],
					'contentOptions'=>['class'=>'kv-sticky-column'],
					'editableOptions'=>['header'=>'Name', 'size'=>'md','formOptions'=>['action'=>\yii\helpers\Url::to('editable')]],
					'value' => function ($data) {
						return '<div data-toggle="tooltip" data-placement="top" title="'.$data->note.'">'.$data->name.'</div>';
					}
				],
            
				[
					'attribute' => 'start',
					'vAlign'=>'middle',
					'width'=>'100px',
					'headerOptions'=>['class'=>'kv-sticky-column'],
					'contentOptions'=>['class'=>'kv-sticky-column'],
					'value' => function ($data)
					{
						return date('d M Y', strtotime($data->start));
					}
				],
            
				[
					'attribute' => 'finish',
					'vAlign'=>'middle',
					'width'=>'100px',
					'headerOptions'=>['class'=>'kv-sticky-column'],
					'contentOptions'=>['class'=>'kv-sticky-column'],
					'value' => function ($data)
					{
						return date('d M Y', strtotime($data->finish));
					}
				],
            
				[
					'attribute' => 'classCount',
					'vAlign'=>'middle',
					'hAlign' => 'center',
					'label' => 'Class',
					'width'=>'80px',
					'format' => 'raw',
					'headerOptions'=>['class'=>'kv-sticky-column'],
					'contentOptions'=>[
						'class'=>'kv-sticky-column',
					],
					'value' => function ($data)
					{
						$fOut = '<div class="btn-group">';

						if ($data->classCount == null) {
							$fOut .= Html::a(0, null, [
								'class' => 'btn btn-default btn-xs',
								'data-container' => "body",
								'data-toggle' => "tooltip",
								'data-placement' => "top",
								'data-original-title' => "Rencana jumlah kelas",
								'data-pjax' => "0"
							]);
						}
						else {
							$fOut .= Html::a($data->classCount, null, [
								'class' => 'btn btn-default btn-xs',
								'data-container' => "body",
								'data-toggle' => "tooltip",
								'data-placement' => "top",
								'data-original-title' => "Rencana jumlah kelas",
								'data-pjax' => "0"
							]);
						}

						$classCount = TrainingClass::find()->where(['tb_training_id' => $data->id])->count();

						if ($classCount != 0) {
							$fOut .= '<a class="btn btn-info btn-xs" data-pjax="0" data-container="body" data-toggle="tooltip" data-placement="top" data-original-title="Kelas yang telah dibuat" href="'.Url::to(['training-class/index', 'trainingId' => $data->id]).'">
										'.$classCount.'
										</a>';
						}
						else {
							$fOut .= '<a class="btn btn-info btn-xs" data-pjax="0" data-container="body" data-toggle="tooltip" data-placement="top" data-original-title="Kelas yang telah dibuat" href="'.Url::to(['training-class/index', 'trainingId' => $data->id]).'">
										<i class="fa fa-fw fa-plus-circle"></i>
										</a>';
						}
						$fOut .= '</div>';

						return $fOut;
					}
				],
            
				[
					'label' => 'Student',
					'attribute' => 'studentCount',
					'vAlign'=>'middle',
					'format' => 'raw',
					'hAlign'=>'center',
					'width'=>'80px',
					'headerOptions'=>['class'=>'kv-sticky-column'],
					'contentOptions'=>['class'=>'kv-sticky-column'],
					'value' => function ($data)
					{
						$fOut = '<div class="btn-group">';

						if ($data->studentCount == null) {
							$fOut .= Html::a(0, null, [
								'class' => 'btn btn-default btn-xs',
								'data-container' => "body",
								'data-toggle' => "tooltip",
								'data-placement' => "top",
								'data-original-title' => "Rencana jumlah peserta",
								'data-pjax' => "0"
							]);
						}
						else {
							$fOut .= Html::a($data->studentCount, null, [
								'class' => 'btn btn-default btn-xs',
								'data-container' => "body",
								'data-toggle' => "tooltip",
								'data-placement' => "top",
								'data-original-title' => "Rencana jumlah peserta",
								'data-pjax' => "0"
							]);
						}

						// masih belum final, tar aja

						$studentCount = TrainingClass::find()->where(['tb_training_id' => $data->id])->count();

						if ($studentCount != 0) {
							$fOut .= '<a class="btn btn-info btn-xs" data-pjax="0" data-toggle="tooltip" data-container="body" data-placement="top" data-original-title="Peserta yang telah diinput" href="'.Url::to(['training-class/index', 'trainingId' => $data->id]).'">
										'.$studentCount.'
										</a>';
						}
						else {
							$fOut .= '<a class="btn btn-info btn-xs" data-pjax="0" data-toggle="tooltip" data-container="body" data-placement="top" data-original-title="Peserta yang telah diinput" href="'.Url::to(['training-class/index', 'trainingId' => $data->id]).'">
										<i class="fa fa-fw fa-plus-circle"></i>
										</a>';
						}
						$fOut .= '</div>';

						return $fOut;
					}
				],

				[
					'format' => 'raw',<commit_msg>Fix invalid student count button<commit_after><?php

use yii\helpers\Html;
use yii\helpers\Url;
use yii\bootstrap\Dropdown;
use kartik\grid\GridView;
use kartik\widgets\Select2;
use kartik\widgets\DepDrop;
use backend\models\ActivityRoom;
use backend\models\TrainingClass;
use backend\models\TrainingClassStudent;

$this->title = 'Training';
$this->params['breadcrumbs'][] = $this->title;

$controller = $this->context;
$menus = $controller->module->getMenuItems();
$this->params['sideMenu'][$controller->module->uniqueId]=$menus;
?>
<div class="training-index">

	<?php \yii\widgets\Pjax::begin([
		'id'=>'pjax-gridview',
	]); ?>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            	['class' => 'kartik\grid\SerialColumn'],
                        
				[
					'class' => 'kartik\grid\EditableColumn',
					'format' => 'raw',
					'attribute' => 'name',
					'vAlign'=>'middle',
					'hAlign' => 'left',
					'headerOptions'=>['class'=>'kv-sticky-column'],
					'contentOptions'=>['class'=>'kv-sticky-column'],
					'editableOptions'=>['header'=>'Name', 'size'=>'md','formOptions'=>['action'=>\yii\helpers\Url::to('editable')]],
					'value' => function ($data) {
						return '<div data-toggle="tooltip" data-placement="top" title="'.$data->note.'">'.$data->name.'</div>';
					}
				],
            
				[
					'attribute' => 'start',
					'vAlign'=>'middle',
					'width'=>'100px',
					'headerOptions'=>['class'=>'kv-sticky-column'],
					'contentOptions'=>['class'=>'kv-sticky-column'],
					'value' => function ($data)
					{
						return date('d M Y', strtotime($data->start));
					}
				],
            
				[
					'attribute' => 'finish',
					'vAlign'=>'middle',
					'width'=>'100px',
					'headerOptions'=>['class'=>'kv-sticky-column'],
					'contentOptions'=>['class'=>'kv-sticky-column'],
					'value' => function ($data)
					{
						return date('d M Y', strtotime($data->finish));
					}
				],
            
				[
					'attribute' => 'classCount',
					'vAlign'=>'middle',
					'hAlign' => 'center',
					'label' => 'Class',
					'width'=>'80px',
					'format' => 'raw',
					'headerOptions'=>['class'=>'kv-sticky-column'],
					'contentOptions'=>[
						'class'=>'kv-sticky-column',
					],
					'value' => function ($data)
					{
						$fOut = '<div class="btn-group">';

						if ($data->classCount == null) {
							$fOut .= Html::a(0, null, [
								'class' => 'btn btn-default btn-xs',
								'data-container' => "body",
								'data-toggle' => "tooltip",
								'data-placement' => "top",
								'data-original-title' => "Rencana jumlah kelas",
								'data-pjax' => "0"
							]);
						}
						else {
							$fOut .= Html::a($data->classCount, null, [
								'class' => 'btn btn-default btn-xs',
								'data-container' => "body",
								'data-toggle' => "tooltip",
								'data-placement' => "top",
								'data-original-title' => "Rencana jumlah kelas",
								'data-pjax' => "0"
							]);
						}

						$classCount = TrainingClass::find()->where(['tb_training_id' => $data->id])->count();

						if ($classCount != 0) {
							$fOut .= '<a class="btn btn-info btn-xs" data-pjax="0" data-container="body" data-toggle="tooltip" data-placement="top" data-original-title="Kelas yang telah dibuat" href="'.Url::to(['training-class/index', 'trainingId' => $data->id]).'">
										'.$classCount.'
										</a>';
						}
						else {
							$fOut .= '<a class="btn btn-info btn-xs" data-pjax="0" data-container="body" data-toggle="tooltip" data-placement="top" data-original-title="Kelas yang telah dibuat" href="'.Url::to(['training-class/index', 'trainingId' => $data->id]).'">
										<i class="fa fa-fw fa-plus-circle"></i>
										</a>';
						}
						$fOut .= '</div>';

						return $fOut;
					}
				],
            
				[
					'label' => 'Student',
					'attribute' => 'studentCount',
					'vAlign'=>'middle',
					'format' => 'raw',
					'hAlign'=>'center',
					'width'=>'80px',
					'headerOptions'=>['class'=>'kv-sticky-column'],
					'contentOptions'=>['class'=>'kv-sticky-column'],
					'value' => function ($data)
					{
						$fOut = '<div class="btn-group">';

						if ($data->studentCount == null) {
							$fOut .= Html::a(0, null, [
								'class' => 'btn btn-default btn-xs',
								'data-container' => "body",
								'data-toggle' => "tooltip",
								'data-placement' => "top",
								'data-original-title' => "Rencana jumlah peserta",
								'data-pjax' => "0"
							]);
						}
						else {
							$fOut .= Html::a($data->studentCount, null, [
								'class' => 'btn btn-default btn-xs',
								'data-container' => "body",
								'data-toggle' => "tooltip",
								'data-placement' => "top",
								'data-original-title' => "Rencana jumlah peserta",
								'data-pjax' => "0"
							]);
						}

						// masih belum final, tar aja

						$studentCount = TrainingClassStudent::find()->where(['tb_training_class_id' => $data->id])->count();

						if ($studentCount != 0) {
							$fOut .= '<a class="btn btn-info btn-xs" data-pjax="0" data-toggle="tooltip" data-container="body" data-placement="top" data-original-title="Peserta yang telah diinput" href="'.Url::to(['training-student/index', 'trainingId' => $data->id]).'">
										'.$studentCount.'
										</a>';
						}
						else {
							$fOut .= '<a class="btn btn-info btn-xs" data-pjax="0" data-toggle="tooltip" data-container="body" data-placement="top" data-original-title="Peserta yang telah diinput" href="'.Url::to(['training-student/index', 'trainingId' => $data->id]).'">
										<i class="fa fa-fw fa-plus-circle"></i>
										</a>';
						}
						$fOut .= '</div>';

						return $fOut;
					}
				],

				[
					'format' => 'raw',
{'fraction_non_alphanumeric': 0.22505881327873137, 'fraction_numerical': 0.004008016032064128, 'mean_word_length': 2.585754451733833, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 277, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6198268', 'n_tokens_mistral': 5245, 'n_tokens_neox': 3869, 'n_words': 635}