示例#1
0
 /**
  * gets team info from db
  *
  * @return array of JLGRankingTeam objects
  */
 static function _initTeams($pid, $division = 0)
 {
     $db = JFactory::getDbo();
     $query = ' SELECT pt.id AS ptid, pt.is_in_score, pt.start_points, pt.division_id, ' . ' t.name, t.id as teamid, pt.neg_points_finally, ' . ' pt.use_finally, pt.points_finally,pt.matches_finally,pt.won_finally,pt.draws_finally,pt.lost_finally, ' . ' pt.homegoals_finally, pt.guestgoals_finally,pt.diffgoals_finally ' . ' FROM #__joomleague_project_team AS pt ' . ' INNER JOIN #__joomleague_team AS t ON t.id = pt.team_id ' . ' WHERE pt.project_id = ' . $db->Quote($pid);
     if ($division > 0) {
         $query .= ' AND pt.division_id = ' . $division;
     }
     //only show it in ranking when is_in_score=1
     $query .= ' AND pt.is_in_score=1';
     $db->setQuery($query);
     $res = $db->loadObjectList();
     $teams = array();
     foreach ((array) $res as $r) {
         $t = new JLGRankingTeam($r->ptid);
         $t->setTeamid($r->teamid);
         $t->setDivisionid($r->division_id);
         $t->setStartpoints($r->start_points);
         $t->setNegpoints($r->neg_points_finally);
         $t->setName($r->name);
         // new for is_in_score
         $t->setIs_In_Score($r->is_in_score);
         // new for use_finally
         $t->setuse_finally($r->use_finally);
         $t->setpoints_finally($r->points_finally);
         $t->setneg_points_finally($r->neg_points_finally);
         $t->setmatches_finally($r->matches_finally);
         $t->setwon_finally($r->won_finally);
         $t->setdraws_finally($r->draws_finally);
         $t->setlost_finally($r->lost_finally);
         $t->sethomegoals_finally($r->homegoals_finally);
         $t->setguestgoals_finally($r->guestgoals_finally);
         $t->setdiffgoals_finally($r->diffgoals_finally);
         if ($r->use_finally) {
             $t->sum_points = $r->points_finally;
             $t->neg_points = $r->neg_points_finally;
             $t->cnt_matches = $r->matches_finally;
             $t->cnt_won = $r->won_finally;
             $t->cnt_draw = $r->draws_finally;
             $t->cnt_lost = $r->lost_finally;
             $t->sum_team1_result = $r->homegoals_finally;
             $t->sum_team2_result = $r->guestgoals_finally;
             $t->diff_team_results = $r->diffgoals_finally;
             //       		if ( empty($t->diff_team_results) )
             //       		{
             //       			$t->diff_team_results = $r->homegoals_finally - $r->guestgoals_finally;
             //       		}
             //       		if ( empty($t->cnt_matches) )
             //       		{
             //       			$t->cnt_matches = $r->won_finally + $r->draws_finally + $r->lost_finally;
             //       		}
         }
         $teams[$r->ptid] = $t;
     }
     return $teams;
 }
 /**
  * gets team info from db
  *
  * @return array of JLGRankingTeam objects
  */
 function _initTeams($pid, $division)
 {
     $db = Jfactory::getDBO();
     if ($division) {
         $query = ' SELECT pt.id AS ptid, pt.is_in_score, pt.start_points, pt.division_id, ' . ' t.name, t.id as teamid, pt.neg_points_finally, ' . ' pt.use_finally, pt.points_finally,pt.matches_finally,pt.won_finally,pt.draws_finally,pt.lost_finally, ' . ' pt.homegoals_finally, pt.guestgoals_finally,pt.diffgoals_finally,pt.penalty_points ' . ' FROM #__joomleague_project_team AS pt ' . ' INNER JOIN #__joomleague_team AS t ON t.id = pt.team_id ' . ' INNER JOIN #__joomleague_match AS m 
     ON ( m.projectteam1_id = pt.id OR m.projectteam2_id = pt.id )' . ' WHERE pt.project_id = ' . $db->Quote($pid) . ' AND pt.is_in_score = 1' . ' AND m.division_id = ' . $division;
     } else {
         $query = ' SELECT pt.id AS ptid, pt.is_in_score, pt.start_points, pt.division_id, ' . ' t.name, t.id as teamid, pt.neg_points_finally, ' . ' pt.use_finally, pt.points_finally,pt.matches_finally,pt.won_finally,pt.draws_finally,pt.lost_finally, ' . ' pt.homegoals_finally, pt.guestgoals_finally,pt.diffgoals_finally,pt.penalty_points ' . ' FROM #__joomleague_project_team AS pt ' . ' INNER JOIN #__joomleague_team AS t ON t.id = pt.team_id ' . ' WHERE pt.project_id = ' . $db->Quote($pid) . ' AND pt.is_in_score=1';
     }
     $db->setQuery($query);
     $res = $db->loadObjectList();
     $teams = array();
     foreach ((array) $res as $r) {
         $t = new JLGRankingTeam($r->ptid);
         $t->setTeamid($r->teamid);
         // diddipoeler
         $t->setDivisionid($division);
         //$t->setDivisionid($r->division_id);
         $t->setStartpoints($r->start_points);
         $t->setNegpoints($r->neg_points_finally);
         $t->setName($r->name);
         // new for is_in_score
         $t->setIs_In_Score($r->is_in_score);
         // new for use_finally
         $t->setuse_finally($r->use_finally);
         $t->setpoints_finally($r->points_finally);
         $t->setneg_points_finally($r->neg_points_finally);
         $t->setmatches_finally($r->matches_finally);
         $t->setwon_finally($r->won_finally);
         $t->setdraws_finally($r->draws_finally);
         $t->setlost_finally($r->lost_finally);
         $t->sethomegoals_finally($r->homegoals_finally);
         $t->setguestgoals_finally($r->guestgoals_finally);
         $t->setdiffgoals_finally($r->diffgoals_finally);
         $t->penalty_points = $r->penalty_points;
         if ($r->use_finally) {
             $t->sum_points = $r->points_finally;
             $t->neg_points = $r->neg_points_finally;
             $t->cnt_matches = $r->matches_finally;
             $t->cnt_won = $r->won_finally;
             $t->cnt_draw = $r->draws_finally;
             $t->cnt_lost = $r->lost_finally;
             $t->sum_team1_result = $r->homegoals_finally;
             $t->sum_team2_result = $r->guestgoals_finally;
             $t->diff_team_results = $r->diffgoals_finally;
             //       		if ( empty($t->diff_team_results) )
             //       		{
             //       			$t->diff_team_results = $r->homegoals_finally - $r->guestgoals_finally;
             //       		}
             //       		if ( empty($t->cnt_matches) )
             //       		{
             //       			$t->cnt_matches = $r->won_finally + $r->draws_finally + $r->lost_finally;
             //       		}
         }
         $teams[$r->ptid] = $t;
     }
     // echo '_initTeams teams<br><pre>';
     // print_r($teams);
     // echo '</pre>';
     return $teams;
 }