コード例 #1
0
ファイル: competition.php プロジェクト: kleitz/golfleague
/* @var $searchModel app\models\RegistrationSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = $competition->getFullName();
$this->params['breadcrumbs'][] = ['label' => Yii::t('igolf', 'Competitions'), 'url' => ['competition/index']];
$this->params['breadcrumbs'][] = $this->title;
$input_decimal = ['type' => function ($model, $key, $index, $widget) {
    return $model->hasDetails() ? TabularForm::INPUT_STATIC : TabularForm::INPUT_TEXT;
}, 'columnOptions' => ['width' => '100px']];
$apply_rule = in_array($competition->competition_type, [Competition::TYPE_TOURNAMENT, Competition::TYPE_SEASON]) ? Html::a(Yii::t('igolf', 'Compute'), Url::to(['competition/apply', 'id' => $competition->id]), ['class' => 'btn btn-primary']) : '';
?>
<div class="scorecard-index">

	<?php 
$form = ActiveForm::begin();
?>

     <?php 
echo TabularForm::widget(['form' => $form, 'dataProvider' => $dataProvider, 'gridSettings' => ['panel' => ['heading' => '<h4>' . $this->title . '</h4>', 'footer' => Html::submitButton('Save', ['class' => 'btn btn-primary']) . ' ' . $apply_rule . ' ' . Html::a(Yii::t('igolf', 'Scorecard Status'), Url::to(['status', 'id' => $competition->id]), ['class' => 'btn btn-primary']) . ' ' . Html::a(Yii::t('igolf', 'Publish'), Url::to(['publish', 'id' => $competition->id]), ['class' => 'btn btn-success'])]], 'serialColumn' => false, 'actionColumn' => false, 'checkboxColumn' => false, 'attributes' => ['id' => ['type' => TabularForm::INPUT_HIDDEN, 'columnOptions' => ['visible' => false]], 'golfer_name' => ['type' => TabularForm::INPUT_STATIC, 'value' => function ($model, $key, $index, $widget) {
    return $model->registration->golfer->name;
}, 'noWrap' => true], 'tee_time' => ['type' => TabularForm::INPUT_STATIC, 'value' => function ($model, $key, $index, $widget) {
    return $model->registration->flight ? $model->registration->flight->start_time : '';
}, 'noWrap' => true], 'golfer_hdcp' => ['type' => TabularForm::INPUT_STATIC, 'label' => Yii::t('igolf', 'Handicap'), 'value' => function ($model, $key, $index, $widget) {
    return $model->registration->golfer->handicap;
}, 'noWrap' => true], 'thru' => $input_decimal, 'score' => $input_decimal, 'score_net' => $input_decimal, 'stableford' => $input_decimal, 'stableford_net' => $input_decimal, 'points' => $input_decimal, 'rounds' => $input_decimal, 'status' => ['type' => TabularForm::INPUT_DROPDOWN_LIST, 'items' => Scorecard::getLocalizedConstants('STATUS_')]]]);
?>

	<?php 
ActiveForm::end();
?>
	
</div>
コード例 #2
0
ファイル: competition.php プロジェクト: kleitz/golfleague
use kartik\widgets\ActiveForm;
use yii\helpers\Html;
use yii\helpers\Url;
Icon::map($this, Icon::WHHG);
/* @var $this yii\web\View */
/* @var $searchModel app\models\RegistrationSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('igolf', 'Scorecards for competition «{0}»', $competition->name);
$this->params['breadcrumbs'][] = ['label' => Yii::t('igolf', 'Competitions'), 'url' => ['competition/index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="scorecard-index">

     <?php 
echo GridView::widget(['options' => ['id' => 'registration'], 'dataProvider' => $dataProvider, 'panel' => ['heading' => '<h4>' . $this->title . '</h4>', 'footer' => Html::a(Yii::t('igolf', 'Publish'), Url::to(['scorecard/publish', 'id' => $competition->id]), ['class' => 'btn btn-success'])], 'export' => false, 'columns' => [['attribute' => 'golfer_name', 'label' => Yii::t('igolf', 'Player'), 'value' => function ($model, $key, $index, $widget) {
    return $model->player->name;
}], ['attribute' => 'status', 'label' => Yii::t('igolf', 'Scorecard Status'), 'value' => function ($model, $key, $index, $widget) {
    return Yii::t('igolf', $model->status);
}, 'filter' => Scorecard::getLocalizedConstants('STATUS_')], ['attribute' => 'status', 'label' => Yii::t('igolf', 'Registration Status'), 'value' => function ($model, $key, $index, $widget) {
    return $model->registration ? Yii::t('igolf', $model->registration->status) : '';
}, 'filter' => Registration::getLocalizedPostCompetitionStatuses()], ['class' => 'kartik\\grid\\ActionColumn', 'template' => '{view} {update} {reset}', 'buttons' => ['reset' => function ($url, $model) {
    if ($model->hasDetails()) {
        $url = Url::to(['delete', 'id' => $model->id]);
        return Html::a('<i class="glyphicon glyphicon-remove"></i>', $url, ['title' => Yii::t('igolf', 'Delete score details'), 'data-confirm' => Yii::t('igolf', 'Delete score details for this golfer?')]);
    } else {
        return '<i class="glyphicon glyphicon-remove disabled"></i>';
    }
}]]]]);
?>
	
</div>
コード例 #3
0
ファイル: _scorecards.php プロジェクト: kleitz/golfleague
}, 'visible' => $competition === null], ['attribute' => 'competition_type', 'label' => Yii::t('igolf', 'Competition Type'), 'value' => function ($model, $key, $index, $widget) {
    return Yii::t('igolf', $model->registration->competition->competition_type);
}, 'filter' => Competition::getLocalizedConstants('TYPE_'), 'visible' => $competition === null], ['attribute' => 'golfer_name', 'label' => Yii::t('igolf', 'Golfer'), 'value' => function ($model, $key, $index, $widget) {
    return $model->registration->golfer->name;
}], ['label' => Yii::t('igolf', 'Created At'), 'attribute' => 'created_at', 'format' => 'datetime', 'value' => function ($model, $key, $index, $widget) {
    return new DateTime($model->created_at);
}], ['label' => Yii::t('igolf', 'Last Update'), 'attribute' => 'updated_at', 'format' => 'datetime', 'value' => function ($model, $key, $index, $widget) {
    return new DateTime($model->updated_at);
}], ['attribute' => 'status', 'value' => function ($model, $key, $index, $widget) {
    return Yii::t('igolf', $model->status);
}, 'filter' => Scorecard::getLocalizedConstants('STATUS_')], ['class' => 'kartik\\grid\\CheckboxColumn']]]);
?>

<?php 
$statuses = '<div class="btn-group"><button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">' . Yii::t('igolf', 'Change Status of Selected Scorecards to ') . ' <span class="caret"></span></button><ul class="dropdown-menu" role="menu">';
foreach (Scorecard::getLocalizedConstants('STATUS_') as $key => $value) {
    $statuses .= '<li>' . Html::a(Yii::t('igolf', 'Change to {0}', $value), null, ['class' => 'igolf-bulk-action', 'data-status' => $key]) . '</li>';
}
$statuses .= '</ul></div>';
$buttons = $competition ? Html::a(Yii::t('igolf', 'Scores'), Url::to(['competition', 'id' => $competition->id]), ['class' => 'btn btn-primary']) : '';
$buttons .= ' ' . $statuses;
echo $buttons;
?>

</div>
<script type="text/javascript">
<?php 
$this->beginBlock('JS_PJAXREG');
?>
$("a.igolf-bulk-action").click(function(e) {
	collected = $('#scorecard').yiiGridView('getSelectedRows');