Ejemplo n.º 1
0
 /**
  * @param bool|true $ispublic
  * @return Team[]
  */
 function getTeams($ispublic = true)
 {
     if (!$ispublic) {
         $teamIds = Model::pluck(SeasonTeam::find('seasonid = ?', [$this->seasonid]), 'teamid');
     } else {
         $teamIds = Model::pluck(SeasonTeam::find('seasonid = ? and ispublic', [$this->seasonid]), 'teamid');
     }
     if (!$teamIds) {
         return [];
     }
     return Model::orderBy(Team::getMultiple($teamIds), 'name');
 }
Ejemplo n.º 2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getSeasonTeams()
 {
     return $this->hasMany(SeasonTeam::className(), ['team_id' => 'id']);
 }
Ejemplo n.º 3
0
    private function showTeamSeasons()
    {
        $teamSeasonIds = Model::pluck(SeasonTeam::find('teamid = ?', [$this->team->teamid]), 'seasonid');
        $teamSeasons = Season::getMultiple($teamSeasonIds);
        Model::orderBy($teamSeasons, 'seasonid');

        $teamMatches = Match::find('team1id = ? or team2id = ?', [$this->team->teamid, $this->team->teamid]);
        // $games = [];
        $playedGames = [];
        $wins = [];
        $losses = [];

        foreach($teamMatches as $match) {
            if (!$match->isPublished()) continue;
            // $games[$match->seasonid]++;
            if ($match->getWinner() == $this->team->teamid) {
                $playedGames[$match->seasonid]++;
                $wins[$match->seasonid]++;
            }
            if ($match->getLooser() == $this->team->teamid) {
                $playedGames[$match->seasonid]++;
                $losses[$match->seasonid]++;
            }
        }

        ?>
        <h2>Actividad por temporadas</h2>

        <table style="width: 400px">
        <thead><tr>
            <td>Nombre</td>
            <td>Combates</td>
            <td>Victorias</td>
            <td>Derrotas</td>
        </tr></thead>
        <?
        foreach($teamSeasons as $season) {
            if (!$season->ispublic && !Team::isSuperAdmin()) continue;
            ?>
            <tr>
                <td>
                    <a href="/<?=$season->getLink()?>/equipos/<?=$this->team->getLink()?>/">
                        <?= htmlentities($season->name) ?>
                    </a>
                </td>
                <td><?= $playedGames[$season->seasonid] * 1 ?></td>
                <td><?= $wins[$season->seasonid] * 1 ?></td>
                <td><?= $losses[$season->seasonid] * 1 ?></td>
            </tr>
            <?
        }
        ?></table><br><?

    }
Ejemplo n.º 4
0
 public function history()
 {
     $current_season_team = new SeasonTeam($this->getSeasonTeamId());
     $current_season_team->build();
     db_insert('season_team_history')->fields(array('season_teamid' => $current_season_team->getSeasonTeamId(), 'seasonid' => $current_season_team->getSeasonId(), 'teamid' => $current_season_team->getTeamId(), 'saved_userid' => $current_season_team->getSavedUserID(), 'saved_datetime' => $current_season_team->getSavedDateTime(), 'history_userid' => $this->getSavedUserID(), 'history_datetime' => $this->getSavedDateTime()))->execute();
 }
Ejemplo n.º 5
0
 public function getSeasonTeams()
 {
     if ($this->seasonTeams == NULL) {
         $seasonTeams = array();
         $query = db_select('season_team', 'st');
         $query->innerJoin('team', 't', 't.teamid = st.teamid');
         $query->fields('st');
         $query->addField('t', 'name', 'name');
         $query->orderBy('t.name');
         $query->condition('seasonid', $this->getSeasonId());
         $result = $query->execute();
         while ($record = $result->fetchAssoc()) {
             $seasonTeam = new SeasonTeam($record['season_teamid'], $record['seasonid'], $record['teamid'], $record['name']);
             $seasonTeam->setSavedDateTimeAndUser($record['saved_datetime'], $record['saved_userid']);
             array_push($seasonTeams, $seasonTeam);
         }
         $this->setSeasonTeams($seasonTeams);
     }
     return $this->seasonTeams;
 }
Ejemplo n.º 6
0
<?php

/**
 * Created by PhpStorm.
 * User: Jakub
 * Date: 11/03/2016
 * Time: 14:45
 */
class SeasonTeam extends Model
{
    public $seasonteamid;
    public $seasonid;
    public $teamid;
    public $ispublic;
}
SeasonTeam::init('seasonteams', 'seasonteamid');
Ejemplo n.º 7
0
 public function getAllPlayersList()
 {
     $homeTeam = new SeasonTeam(NULL, $this->getSeasonId(), $this->getHomeTeamId());
     $homeTeam->build();
     $homeTeamPlayers = array($this->getHomeTeamName() => $homeTeam->getPlayerList());
     $visitingTeam = new SeasonTeam(NULL, $this->getSeasonId(), $this->getVisitingTeamId());
     $visitingTeam->build();
     $visitingTeamPlayers = array($this->getVisitingTeamName() => $visitingTeam->getPlayerList());
     return $visitingTeamPlayers + $homeTeamPlayers;
 }