Beispiel #1
0
 /**
  * Build flight and place registration in it. Create flight if necessary.
  * @return flight_id updated or created
  */
 private function makeTeam($team_str)
 {
     $team_arr = explode('-', $team_str->id);
     // team-123
     $team = Team::findOne($team_arr[1]);
     if (!$team) {
         // need to create it
         $team = new Team();
         $team->name = $team_arr[1];
         $team->save();
         $team->refresh();
     }
     $name = '';
     foreach ($team_str->registrations as $registration_str) {
         $registration_arr = explode('-', $registration_str);
         // registration-456
         if ($registration = Registration::findOne($registration_arr[1])) {
             $registration->team_id = $team->id;
         }
         $registration->save();
         $name .= $registration->golfer->name . ' / ';
     }
     $name = rtrim($name, ' /');
     $team->name = substr($name, 0, 80);
     $team->handicap = $team_str->handicap;
     $team->save();
     return $team->id;
 }
 /**
  * Displays and/or update Score models for a competition.
  * @return mixed
  */
 public function actionCompetition($id)
 {
     $competition = $this->findCompetition($id);
     if (isset($_POST['ScorecardForCompetition'])) {
         $models = ScorecardForCompetition::find()->andWhere(['id' => array_keys($_POST['ScorecardForCompetition'])])->indexBy('id')->all();
         if (!ScorecardForCompetition::loadMultiple($models, Yii::$app->request->post()) || !ScorecardForCompetition::validateMultiple($models)) {
             $errors = [];
             foreach ($models as $model) {
                 $errors += $model->errors;
             }
             if (count($errors) > 0) {
                 Yii::$app->session->setFlash('danger', Yii::t('igolf', 'Error(s): {0}', [VarDumper::dumpAsString($errors, 4, true)]));
             }
         } else {
             foreach ($models as $model) {
                 $model->save();
             }
             Yii::$app->session->setFlash('success', Yii::t('igolf', 'Scores updated.'));
         }
     } else {
         //@todo do not loop on getScorecards twice...
         $scorecards = [];
         foreach ($competition->getRegistrations()->andWhere(['registration.status' => array_merge([Registration::STATUS_CONFIRMED], Registration::getPostCompetitionStatuses())])->each() as $registration) {
             $scorecards[] = $registration->getScorecard();
             // this will create a scorecard if none exists
         }
     }
     return $this->render('competition', ['competition' => $competition, 'dataProvider' => new ActiveDataProvider(['query' => $competition->getScorecards()])]);
 }
 /**
  * Approve invitation
  */
 public function actionApprove($id)
 {
     $model = Registration::findOne($id);
     $model->status = Registration::STATUS_REGISTERED;
     $model->save();
     Yii::$app->session->setFlash('success', Yii::t('igolf', 'You registered to competition "{0}".', $model->competition->name));
     return $this->render('view', ['model' => $model, 'competition' => $model->competition]);
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Registration::find()->notDeleted()->with(['hotel', 'country', 'roomType', 'departmentRel']);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10]]);
     $this->status = self::STATUS_CONFIRM;
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'department_id' => $this->department_id, 'status' => $this->status, 'country_id' => $this->country_id, 'hotel_id' => $this->hotel_id, 'check_in' => $this->check_in ? strtotime($this->check_in) : null, 'check_out' => $this->check_out ? strtotime($this->check_out) : null, 'room_type_id' => $this->room_type_id, 'room_rate' => $this->room_rate, 'created_at' => $this->created_at, 'created_by' => $this->created_by, 'updated_at' => $this->updated_at, 'updated_by' => $this->updated_by, 'deleted' => $this->deleted]);
     $query->andFilterWhere(['like', 'code', $this->code])->andFilterWhere(['like', 'auth_key', $this->auth_key])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'first_name', $this->first_name])->andFilterWhere(['like', 'last_name', $this->last_name])->andFilterWhere(['like', 'company', $this->company])->andFilterWhere(['like', 'department', $this->department])->andFilterWhere(['like', 'cost_center', $this->cost_center])->andFilterWhere(['like', 'street', $this->street])->andFilterWhere(['like', 'zip', $this->zip])->andFilterWhere(['like', 'city', $this->city])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'special_request', $this->special_request]);
     return $dataProvider;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Registration::find();
     $query->joinWith(['golfer', 'competition', 'flight']);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->sort->attributes['tee_time'] = ['asc' => ['flight.start_time' => SORT_ASC], 'desc' => ['flight.start_time' => SORT_DESC]];
     $dataProvider->sort->attributes['golfer_name'] = ['asc' => ['golfer.name' => SORT_ASC], 'desc' => ['golfer.name' => SORT_DESC]];
     $dataProvider->sort->attributes['competition_name'] = ['asc' => ['competition.name' => SORT_ASC], 'desc' => ['competition.name' => SORT_DESC]];
     $dataProvider->sort->attributes['competition_type'] = ['asc' => ['competition.competition_type' => SORT_ASC], 'desc' => ['competition.competition_type' => SORT_DESC]];
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['registration.id' => $this->id, 'registration.competition_id' => $this->competition_id, 'registration.golfer_id' => $this->golfer_id, 'registration.flight_id' => $this->flight_id, 'registration.team_id' => $this->team_id, 'registration.tees_id' => $this->tees_id, 'registration.created_at' => $this->created_at, 'registration.updated_at' => $this->updated_at, 'competition.competition_type' => $this->competition_type]);
     $query->andFilterWhere(['like', 'registration.status', $this->status])->andFilterWhere(['like', 'registration.note', $this->note]);
     $query->andFilterWhere(['like', 'golfer.name', $this->golfer_name]);
     $query->andFilterWhere(['like', 'competition.name', $this->competition_name]);
     return $dataProvider;
 }
Beispiel #6
0
 public function apply($competition)
 {
     $params = $this->getParameters();
     $this->bestOf = isset($params['bestOf']) ? intval($params['bestOf']) : null;
     $children_competitions = $competition->getCompetitions()->andWhere(['status' => Competition::STATUS_CLOSED])->select('id');
     Yii::trace('children comp=' . print_r($children_competitions->asArray()->all(), true));
     foreach ($competition->getScorecards()->andWhere(['status' => Scorecard::STATUS_OPEN])->each() as $scorecard) {
         Yii::trace('scorecard=' . $scorecard->id);
         $registrations = Registration::find()->andWhere(['competition_id' => $children_competitions])->andWhere(['golfer_id' => $scorecard->registration->golfer_id]);
         $children_scorecards = Scorecard::find()->andWhere(['registration_id' => $registrations->select('id')])->andWhere(['status' => Scorecard::STATUS_RETURNED]);
         if (intval($this->bestOf) > 0) {
             $children_scorecards->orderBy([$this->source_type => $this->source_direction])->limit($this->bestOf);
         }
         $count_children = clone $children_scorecards;
         $sum_children = $children_scorecards->sum($this->source_type);
         $scorecard->{$this->destination_type} = $sum_children;
         $scorecard->rounds = $count_children->count();
         $scorecard->save();
     }
     Yii::trace('bestOf=' . $this->bestOf);
 }
Beispiel #7
0
 /**
  * Deregister golfer from event
  * 
  * @var  Golfer $golfer Golfer to register
  * @return Deregistration status
  */
 public function deregister($golfer)
 {
     if ($model = Registration::findOne(['golfer_id' => $golfer->id, 'competition_id' => $this->id])) {
         return $model->cancel();
     }
     return false;
 }
Beispiel #8
0
<?php

use yii\helpers\Html;
use common\components\GridView;
use common\models\Hotel;
use common\models\RoomType;
use common\models\Registration;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\RoomSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('app', 'Rooms');
?>
<div class="room-index">
    <?php 
$gridColumns = [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'hotel_id', 'value' => function ($data) {
    return $data->hotel->name;
}, 'filter' => Hotel::getMap()], ['attribute' => 'room_type_id', 'value' => function ($data) {
    return $data->roomType->name;
}, 'filter' => RoomType::getMap()], ['attribute' => 'date', 'format' => ['date', 'php:d-m-Y'], 'filterType' => GridView::FILTER_DATE, 'filterWidgetOptions' => ['pluginOptions' => ['autoclose' => true, 'format' => 'dd-mm-yyyy']], 'width' => '180px'], 'allotment', ['attribute' => 'booked', 'value' => function ($data) {
    $data->booked = $data->getBooked();
    return $data->booked;
}], ['attribute' => 'free', 'value' => function ($data) {
    return $data->allotment - $data->booked;
}], ['attribute' => 'price', 'value' => function ($data) {
    return Registration::generateRoomRate($data->price);
}, 'format' => 'raw']];
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => $gridColumns, 'responsive' => true, 'hover' => true, 'pjax' => true, 'resizableColumns' => false, 'toolbar' => [Html::a('<i class="glyphicon glyphicon-repeat"></i>', ['index'], ['data-pjax' => 0, 'class' => 'btn btn-default', 'title' => Yii::t('kvgrid', 'Reset Grid')]), '{export}', '{toggleData}'], 'toggleDataOptions' => ['default' => 'all'], 'panelBeforeTemplate' => '<div class="pull-right"><div class="btn-toolbar kv-grid-toolbar" role="toolbar"><span class="pager-mini">{pager}</span>{toolbar}</div></div>{before}<div class="clearfix"></div>', 'panelAfterTemplate' => '{after}<span class="pager-mini clearfix">{pager}</span>', 'panel' => ['type' => GridView::TYPE_PRIMARY, 'heading' => '<h3 class="panel-title"><i class="glyphicon glyphicon-user"></i>' . Html::encode($this->title) . '</h3>', 'footer' => false], 'exportConfig' => [GridView::EXCEL => [], GridView::CSV => ['config' => ['colDelimiter' => ';', 'rowDelimiter' => "\r\n"]], GridView::PDF => []]]);
?>

</div>
Beispiel #9
0
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>
Beispiel #10
0
$this->registerJsFile('@web/js/grid/main.js', ['depends' => ['yii\\web\\JqueryAsset']]);
?>
<div class="registration-index">
    <?php 
$gridColumns = [['class' => '\\kartik\\grid\\SerialColumn'], ['class' => '\\kartik\\grid\\ActionColumn', 'template' => '{view} {update} {cancel} {delete}', 'buttons' => ['cancel' => function ($key, $model) {
    $customUrl = Yii::$app->getUrlManager()->createUrl(['registration/cancel-admin', 'id' => $model->id]);
    return Html::a('<span class="glyphicon glyphicon-ban-circle"></span>', $customUrl, ['title' => Yii::t('app', 'Cancel'), 'data-pjax' => '0', 'confirm' => Yii::t('app', 'Do you really want cancel registration?')]);
}, 'delete' => function ($key, $model) {
    $customUrl = Yii::$app->getUrlManager()->createUrl(['registration/delete-admin', 'id' => $model->id]);
    return Html::a('<span class="glyphicon glyphicon-trash"></span>', $customUrl, ['title' => Yii::t('app', 'Delete'), 'data-pjax' => '0', 'confirm' => Yii::t('app', 'Do you really want delete registration?')]);
}], 'header' => '<span class="glyphicon glyphicon-info-sign"></span>', 'headerOptions' => ['style' => 'min-width:50px;']], ['attribute' => 'status', 'value' => function ($data) {
    return array_key_exists($data->status, Registration::$reverseStatus) ? Registration::$reverseStatus[$data->status] : null;
}, 'filterType' => GridView::FILTER_SELECT2, 'filterWidgetOptions' => ['data' => Registration::$statusNames + ['' => 'All']], 'headerOptions' => ['style' => 'min-width:115px;']], 'code', ['attribute' => 'title', 'value' => function ($data) {
    return Yii::t('general', $data->title);
}, 'filterType' => GridView::FILTER_SELECT2, 'filterWidgetOptions' => ['data' => Registration::getTitles(), 'options' => ['prompt' => Yii::t('general', 'All')]], 'width' => '250px'], 'first_name', 'last_name', 'company', 'department', 'street', 'zip', 'city', ['attribute' => 'country_id', 'value' => function ($data) {
    return $data->country ? $data->country->name : null;
}, 'filterType' => GridView::FILTER_SELECT2, 'filterWidgetOptions' => ['data' => Country::getMap(), 'options' => ['prompt' => Yii::t('general', 'All')]], 'headerOptions' => ['style' => 'min-width:150px;']], 'email:email', 'phone', ['attribute' => 'department_id', 'value' => function ($data) {
    return $data->departmentRel ? $data->departmentRel->name : null;
}, 'filterType' => GridView::FILTER_SELECT2, 'filterWidgetOptions' => ['data' => Department::getMap(), 'options' => ['prompt' => Yii::t('general', 'All')]], 'width' => '250px'], ['attribute' => 'hotel_id', 'value' => function ($data) {
    return $data->hotel ? $data->hotel->name : null;
}, 'filterType' => GridView::FILTER_SELECT2, 'filterWidgetOptions' => ['data' => Hotel::getMap(), 'options' => ['prompt' => Yii::t('general', 'All')]], 'headerOptions' => ['style' => 'min-width:155px;']], ['attribute' => 'check_in', 'format' => ['date', 'php:d/m/Y'], 'filterType' => GridView::FILTER_SELECT2, 'filterWidgetOptions' => ['data' => Registration::getCheckIn(), 'options' => ['prompt' => Yii::t('general', 'All')]], 'headerOptions' => ['style' => 'min-width:115px;']], ['attribute' => 'check_out', 'format' => ['date', 'php:d/m/Y'], 'filterType' => GridView::FILTER_SELECT2, 'filterWidgetOptions' => ['data' => Registration::getCheckOut(), 'options' => ['prompt' => Yii::t('general', 'All')]], 'headerOptions' => ['style' => 'min-width:115px;']], ['attribute' => 'room_type_id', 'value' => function ($data) {
    return $data->roomType ? $data->roomType->name : null;
}, 'filterType' => GridView::FILTER_SELECT2, 'filterWidgetOptions' => ['data' => \common\models\RoomType::getMap(), 'options' => ['prompt' => Yii::t('general', 'All')]]], ['attribute' => 'room_rate', 'value' => function ($data) {
    return Registration::generateRoomRate($data->room_rate);
}, 'format' => 'raw'], ['attribute' => 'special_request', 'hidden' => true], ['attribute' => 'updated_at', 'format' => ['date', 'php:h:i:s A d-m-Y']], ['attribute' => 'id', 'hiddenFromExport' => true, 'headerOptions' => ['style' => 'min-width:80px;']]];
// Generate a bootstrap responsive striped table with row highlighted on hover
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'responsive' => true, 'hover' => true, 'columns' => $gridColumns, 'pjax' => true, 'resizableColumns' => false, 'toolbar' => [Html::a('<i class="glyphicon glyphicon-repeat"></i>', ['index'], ['data-pjax' => 0, 'class' => 'btn btn-default', 'title' => Yii::t('kvgrid', 'Reset Grid')]), '{export}', '{toggleData}'], 'toggleDataOptions' => ['default' => 'all'], 'panelBeforeTemplate' => '<div class="pull-right"><div class="btn-toolbar kv-grid-toolbar" role="toolbar"><span class="pager-mini">{pager}</span>{toolbar}</div></div>{before}<div class="clearfix"></div>', 'panelAfterTemplate' => '{after}<span class="pager-mini clearfix">{pager}</span>', 'panel' => ['type' => GridView::TYPE_PRIMARY, 'heading' => '<h3 class="panel-title"><i class="glyphicon glyphicon-user"></i> Registrations</h3>', 'before' => Html::a('<i class="glyphicon glyphicon-list-alt"></i> Hotel Rooming List', ['hotel-rooming'], ['class' => 'btn btn-primary']), 'footer' => false], 'exportConfig' => [GridView::EXCEL => [], GridView::CSV => ['config' => ['colDelimiter' => ';', 'rowDelimiter' => "\r\n"]], GridView::PDF => []], 'beforeHeader' => [['columns' => [['options' => ['colspan' => 3]], ['content' => 'Personal Data', 'options' => ['colspan' => 12, 'class' => 'text-center warning']], ['content' => 'Hotel Information', 'options' => ['colspan' => 6, 'class' => 'text-center warning']]], 'options' => ['class' => 'skip-export']]]]);
?>

</div>
Beispiel #11
0
 /**
  * Checks if registered to children competitions (if any)
  * @return boolean Has registrations to children competitons
  */
 public function hasChildren()
 {
     $has_children = false;
     if ($competition = $this->competition) {
         foreach ($competition->getCompetitions()->each() as $child) {
             if (!$has_children) {
                 $has_children = Registration::find()->andWhere(['competition_id' => $child->id, 'golfer_id' => $this->golfer_id])->exists();
             }
         }
     }
     Yii::trace('return=' . ($has_children ? 'true' : 'false'), 'hasChildren');
     return $has_children;
 }
 protected function findModelByCode($code)
 {
     if (($model = Registration::getByCode($code)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Beispiel #13
0
?>

    <?php 
echo $form->field($model, 'check_in')->dropDownList(Registration::getCheckIn(), ['prompt' => Yii::t('general', 'Please select'), 'id' => 'check_in', 'disabled' => $model->status !== $model::STATUS_CONFIRM]);
?>

    <?php 
echo $form->field($model, 'check_out')->dropDownList(Registration::getCheckOut(), ['prompt' => Yii::t('general', 'Please select'), 'id' => 'check_out', 'disabled' => $model->status !== $model::STATUS_CONFIRM]);
?>

    <?php 
echo $form->field($model, 'hotel_id')->dropDownList(ArrayHelper::map($hotels, 'id', 'name'), ['prompt' => Yii::t('general', 'Please select'), 'id' => 'hotel_id', 'disabled' => $model->status !== $model::STATUS_CONFIRM]);
?>

    <?php 
echo $form->field($model, 'title')->dropDownList(Registration::getTitles(), ['prompt' => Yii::t('general', 'Please select')]);
?>

    <?php 
echo $form->field($model, 'first_name')->textInput(['maxlength' => 60]);
?>

    <?php 
echo $form->field($model, 'last_name')->textInput(['maxlength' => 60]);
?>

    <?php 
echo $form->field($model, 'company')->textInput(['maxlength' => 60]);
?>

    <?php 
Beispiel #14
0
<?php

use yii\helpers\Html;
use common\components\GridView;
use common\models\Registration;
use common\models\Hotel;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\RegistrationSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('app', 'Registrations');
?>
<div class="registration-index">
    <?php 
$gridColumns = [['attribute' => 'status', 'value' => function ($data) {
    return isset($data->status) && array_key_exists($data->status, Registration::$reverseStatus) ? Registration::$reverseStatus[$data->status] : null;
}, 'filterType' => GridView::FILTER_SELECT2, 'filterWidgetOptions' => ['data' => Registration::$statusNames + ['' => 'All']], 'headerOptions' => ['style' => 'min-width:115px;']], 'first_name', 'last_name', 'company', 'department', ['attribute' => 'hotel_id', 'value' => function ($data) {
    return isset($data->hotel) && $data->hotel ? $data->hotel->name : null;
}, 'filterType' => GridView::FILTER_SELECT2, 'filterWidgetOptions' => ['data' => Hotel::getMap(), 'options' => ['prompt' => Yii::t('general', 'All')]], 'headerOptions' => ['style' => 'min-width:155px;']], ['attribute' => 'check_in', 'format' => ['date', 'php:d/m/Y'], 'filterType' => GridView::FILTER_SELECT2, 'filterWidgetOptions' => ['data' => Registration::getCheckIn(), 'options' => ['prompt' => Yii::t('general', 'All')]], 'headerOptions' => ['style' => 'min-width:115px;']], ['attribute' => 'check_out', 'format' => ['date', 'php:d/m/Y'], 'filterType' => GridView::FILTER_SELECT2, 'filterWidgetOptions' => ['data' => Registration::getCheckOut(), 'options' => ['prompt' => Yii::t('general', 'All')]], 'headerOptions' => ['style' => 'min-width:115px;']], ['attribute' => 'room_type_id', 'value' => function ($data) {
    return isset($data->roomType) && $data->roomType ? $data->roomType->name : null;
}, 'filterType' => GridView::FILTER_SELECT2, 'filterWidgetOptions' => ['data' => \common\models\RoomType::getMap(), 'options' => ['prompt' => Yii::t('general', 'All')]]], ['attribute' => 'room_rate', 'value' => function ($data) {
    return isset($data->room_rate) ? Registration::generateRoomRate($data->room_rate) : null;
}, 'format' => 'raw'], ['attribute' => 'updated_at', 'format' => ['date', 'php:h:i:s A d-m-Y']], 'd12', 'd13', 'd14', 'd15', 'd16'];
// Generate a bootstrap responsive striped table with row highlighted on hover
echo GridView::widget(['dataProvider' => $dataProvider, 'responsive' => true, 'hover' => true, 'columns' => $gridColumns, 'pjax' => true, 'resizableColumns' => false, 'toolbar' => [Html::a('<i class="glyphicon glyphicon-repeat"></i>', ['index'], ['data-pjax' => 0, 'class' => 'btn btn-default', 'title' => Yii::t('kvgrid', 'Reset Grid')]), '{export}', '{toggleData}'], 'toggleDataOptions' => ['default' => 'all'], 'panelBeforeTemplate' => '<div class="pull-right"><div class="btn-toolbar kv-grid-toolbar" role="toolbar"><span class="pager-mini">{pager}</span>{toolbar}</div></div>{before}<div class="clearfix"></div>', 'panelAfterTemplate' => '{after}<span class="pager-mini clearfix">{pager}</span>', 'panel' => ['type' => GridView::TYPE_PRIMARY, 'heading' => '<h3 class="panel-title"><i class="glyphicon glyphicon-list-alt"></i> Hotel Rooming List</h3>', 'footer' => false], 'exportConfig' => [GridView::EXCEL => [], GridView::CSV => ['config' => ['colDelimiter' => ';', 'rowDelimiter' => "\r\n"]], GridView::PDF => []]]);
?>

</div>
Beispiel #15
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getRegistrations()
 {
     return $this->hasMany(Registration::className(), ['competition_id' => 'id']);
 }
Beispiel #16
0
}, 'visible' => $competition === null], ['attribute' => 'competition_type', 'label' => Yii::t('igolf', 'Competition Type'), 'value' => function ($model, $key, $index, $widget) {
    return Yii::t('igolf', $model->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->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' => Registration::getLocalizedPreCompetitionStatuses()], ['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 Registrations to ') . ' <span class="caret"></span></button><ul class="dropdown-menu" role="menu">';
foreach (Registration::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 = '';
if ($competition) {
    $buttons = Html::a(Yii::t('igolf', 'New Registration'), ['create', 'id' => $competition->id], ['class' => 'btn btn-success']);
    $buttons .= ' ' . Html::a(Yii::t('igolf', 'Bulk Registrations'), ['bulk', 'id' => $competition->id], ['class' => 'btn btn-success']);
}
$buttons .= ' ' . Html::a(Yii::t('igolf', 'Delete Selected Registrations'), null, ['class' => 'btn btn-danger igolf-bulk-action', 'data' => ['status' => Registration::ACTION_DELETE, 'confirm-local' => Yii::t('igolf', 'Are you sure you want to delete selected registration(s)?')]]);
$buttons .= ' ' . $statuses;
if ($competition) {
    if (in_array($competition->competition_type, [Competition::TYPE_SEASON, Competition::TYPE_TOURNAMENT])) {
        if ($competition->getCompetitions()->exists()) {
            $children = '<div class="btn-group"><button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">' . Yii::t('igolf', 'Register Selected to ') . ' <span class="caret"></span></button><ul class="dropdown-menu" role="menu">';
            foreach ($competition->getCompetitions()->each() as $child) {
Beispiel #17
0
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="registration-index">

     <?php 
echo GridView::widget(['options' => ['id' => 'registration'], 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'panel' => ['heading' => '<h4>' . $this->title . '</h4>', 'footer' => false], 'pjax' => true, 'pjaxSettings' => ['neverTimeout' => true], 'export' => false, 'columns' => [['class' => 'kartik\\grid\\SerialColumn'], ['attribute' => 'competition_name', 'label' => Yii::t('igolf', 'Competition'), 'value' => function ($model, $key, $index, $widget) {
    return $model->competition->name;
}, 'visible' => $competition === null], ['attribute' => 'competition_type', 'label' => Yii::t('igolf', 'Competition Type'), 'value' => function ($model, $key, $index, $widget) {
    return Yii::t('igolf', $model->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->golfer->name;
}], ['attribute' => 'tees_id', 'filter' => $starts, 'format' => 'raw', 'value' => function ($model, $key, $index, $widget) {
    return $model->tees ? $model->tees->getLabel() : '';
}], ['attribute' => 'status', 'value' => function ($model, $key, $index, $widget) {
    return Yii::t('igolf', $model->status);
}, 'filter' => Registration::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', 'Set Tees of Selected Golfer to ') . ' <span class="caret"></span></button><ul class="dropdown-menu" role="menu">';
foreach ($starts as $key => $value) {
    $statuses .= '<li>' . Html::a(Yii::t('igolf', $value), null, ['class' => 'igolf-bulk-action', 'data-tees_id' => $key]) . '</li>';
}
$statuses .= '</ul></div>';
$buttons = Html::a(Yii::t('igolf', 'Assign Tees'), ['assign-tees', 'id' => $competition->id], ['class' => 'btn btn-success']);
$buttons .= ' ' . $statuses;
echo $buttons;
?>

</div>
<script type="text/javascript">
 public function actionAssignTees($id)
 {
     $model = $this->findCompetition($id);
     foreach (Registration::find()->where(['competition_id' => $model->id, 'status' => array(Registration::STATUS_PENDING, Registration::STATUS_REGISTERED)])->each() as $registration) {
         $model->setTees($registration);
     }
     return $this->redirect(['tees', 'id' => $model->id]);
 }
Beispiel #19
0
<?php

use common\models\Competition;
use common\models\Registration;
use common\models\Scorecard;
use kartik\grid\GridView;
use yii\helpers\Html;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $searchModel app\models\RegistrationSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
?>
<div class="registration-list">

     <?php 
echo GridView::widget(['options' => ['id' => 'registration'], 'dataProvider' => $dataProvider, 'panel' => ['heading' => '<h4>' . Yii::t('igolf', 'Scorecards') . '</h4>', 'footer' => false], 'pjax' => true, 'pjaxSettings' => ['neverTimeout' => true], 'export' => false, 'columns' => [['attribute' => 'golfer_name', 'label' => Yii::t('igolf', 'Golfer'), 'value' => function ($model, $key, $index, $widget) {
    return $model->player->name;
}], 'score', 'score_net', 'stableford', 'stableford_net', 'points', 'rounds', ['attribute' => 'status', 'label' => Yii::t('igolf', 'Scorecard Status'), 'value' => function ($model, $key, $index, $widget) {
    return Yii::t('igolf', $model->status);
}, 'filter' => Registration::getLocalizedPostCompetitionStatuses()]]]);
?>

</div>
Beispiel #20
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getRegistration()
 {
     return $this->hasOne(Registration::className(), ['id' => 'registration_id']);
 }
Beispiel #21
0
<div class="competition-view">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => [['attribute' => 'competition_type', 'label' => 'Competition Type', 'value' => Yii::t('igolf', $model->competition_type)], 'name', 'description', 'course.name', 'holes', 'rules.name', 'start_date', ['attribute' => 'status', 'label' => 'Status', 'value' => Yii::t('igolf', $model->status)]]]);
?>

<div class="competition-score">

<?php 
//TabularForm requires that dataProvider is build from Model::find()
$query = Registration::find();
$query->andWhere(['competition_id' => $model->id])->orderBy('points desc');
$dataProvider = new ActiveDataProvider(['query' => $query]);
if ($model->competition_type == Competition::TYPE_MATCH) {
    echo $this->render('../registration/scores-matches', ['dataProvider' => $dataProvider, 'model' => $model]);
} else {
    echo $this->render('../registration/scores-competitions', ['dataProvider' => $dataProvider, 'model' => $model]);
}
?>

<p></p>
<div>
	<?php 
if ($model->competition_type != Competition::TYPE_MATCH) {
    echo ' ' . Html::a(Yii::t('igolf', 'Update Points'), ['points', 'id' => $model->id], ['class' => 'btn btn-success']);
    echo ' ' . Html::a(Yii::t('igolf', 'Close Competition'), ['close', 'id' => $model->id], ['class' => 'btn btn-warning']);
Beispiel #22
0
 /**
  * Build flight and place registration in it. Create flight if necessary.
  * @return flight_id updated or created
  */
 private function makeFlight($flight_str, $competition)
 {
     $competition_date = substr($competition->start_date, 0, 10);
     $flight_arr = explode('-', $flight_str->id);
     // flight-123
     $flight = Flight::findOne($flight_arr[1]);
     if (!$flight) {
         // need to create it
         $flight = new Flight();
     } else {
         // remove existings
         $flight->cleanRegistrations();
     }
     $flight->position = $flight_str->position;
     Yii::trace($competition_date . ' ' . $flight_str->start_time . ':00', 'FlightController::makeFlight');
     $flight->start_time = $competition_date . ' ' . $flight_str->start_time . ':00';
     $flight->save();
     // add currents
     if ($competition->isTeamCompetition()) {
         foreach ($flight_str->registrations as $registration_str) {
             $registration_arr = explode('-', $registration_str);
             // registration-456
             $team = Team::findOne($registration_arr[1]);
             if ($team) {
                 foreach ($team->getRegistrations()->each() as $registration) {
                     $registration->flight_id = $flight->id;
                     $registration->save();
                 }
             }
         }
     } else {
         foreach ($flight_str->registrations as $registration_str) {
             $registration_arr = explode('-', $registration_str);
             // registration-456
             $registration = Registration::findOne($registration_arr[1]);
             if ($registration) {
                 $registration->flight_id = $flight->id;
                 $registration->save();
             }
         }
     }
     return $flight->id;
 }