/**
  * @return string
  */
 public function actionHotelRooming()
 {
     /**
      * @var $models Registration[]
      */
     $eventDates = Registration::$eventDates;
     $query = Registration::find()->notDeleted()->with(['hotel', 'country', 'roomType', 'departmentRel'])->andWhere(['status' => Registration::STATUS_CONFIRM])->orderBy('hotel_id');
     //->asArray()
     $models = $query->all();
     $data = [];
     foreach ($models as $model) {
         foreach ($eventDates as $key => $time) {
             $model[$key] = $time >= $model['check_in'] && $time < $model['check_out'];
         }
         $parts[$model->hotel_id][] = $model;
     }
     foreach ($parts as $k => $part) {
         $data = array_merge($data, $part);
         $counts = [];
         foreach ($eventDates as $key => $time) {
             $counts[$key] = array_sum(ArrayHelper::getColumn($part, $key));
         }
         $data[] = $counts;
         $data[] = [];
     }
     $dataProvider = new ArrayDataProvider(['allModels' => $data]);
     return $this->render('hotel-rooming', ['dataProvider' => $dataProvider]);
 }
 /**
  * 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;
 }
Exemple #4
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);
 }
Exemple #5
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']);
Exemple #6
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;
 }
 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]);
 }