예제 #1
0
 public function get_latest_flights()
 {
     $flights = flight::get_all(['fid', 'date', 'pilot.pid', 'pilot.name', 'glider.gid', 'glider.name', 'club.cid', 'club.title', 'admin_info', 'delayed'], ['join' => flight::$default_joins, 'limit' => 14, 'order' => 'fid DESC']);
     $table = node::create('table#latest_flights.module.table.table-striped', [], node::create('thead', [], node::create('th', [], 'ID') . node::create('th', [], 'Date Added') . node::create('th', [], 'Pilot') . node::create('th', [], 'Glider') . node::create('th', [], 'Club') . node::create('th', [], 'Admin Notes') . node::create('th', [], 'Delayed')) . $flights->iterate_return(function (flight $flight) {
         return node::create('tr', [], node::create('td a', ['href' => '/cms/module/2/' . $flight->fid, 'title' => 'Flight: ' . $flight->fid], $flight->fid) . node::create('td a', ['href' => '/cms/module/2/' . $flight->fid, 'title' => 'Flight: ' . $flight->fid], date('d/m/Y', $flight->date)) . node::create('td a', ['href' => '/cms/module/3/' . $flight->pilot->pid, 'title' => 'Pilot: ' . $flight->pilot->name], $flight->pilot->name) . node::create('td a', ['href' => '/cms/module/4/' . $flight->glider->gid, 'title' => 'Glider: ' . $flight->glider->name], $flight->glider->name) . node::create('td a', ['href' => '/cms/module/12/' . $flight->club->cid, 'title' => 'Club: ' . $flight->club->name], $flight->club->name) . node::create('td.col-md-5', [], $flight->admin_info) . node::create('td', [], $flight->delayed ? 'Yes' : 'No'));
     }));
     return $table;
 }
예제 #2
0
 public function get_view()
 {
     $flights = flight::get_all(['flight.*', 'pilot.name', 'pilot.pid'], ['join' => ['pilot' => 'flight.pid = pilot.pid'], 'where' => '`delayed` = 0 AND personal = 0', 'limit' => 40, 'order' => 'fid DESC']);
     $wrapper = node::create('h1.page-header', [], 'Latest') . node::create('div.table_wrapper', [], node::create('table.results.main', [], node::create('thead', [], node::create('tr', [], node::create('th', [], 'ID') . node::create('th', [], 'Pilot') . node::create('th', [], 'Date Flown') . node::create('th', [], 'Date Added') . node::create('th', [], 'Score') . node::create('th', [], 'Flight Waypoints'))) . node::create('tbody', [], $flights->iterate_return(function (flight $flight) use(&$body) {
         $added = substr($flight->created, 0, 10);
         return node::create('tr', [], node::create('td', [], $flight->fid) . node::create('td', [], $flight->pilot->name) . node::create('td', [], date('Y-m-d', $flight->date)) . node::create('td', [], $added != '0000-00-00' ? $added : 'Unknown') . $flight->to_print() . node::create('td', [], $flight->coords));
     }))));
     return $wrapper;
 }
예제 #3
0
 function make_table(league_table $data)
 {
     $html = '';
     for ($i = 1; $i < 5; $i++) {
         $where = $data->where . ' AND ftid=' . $i;
         $flights = flight::get_all(['fid', 'flight.pid', 'flight.gid', $data->class_table_alias . '.' . $data->class_primary_key . ' AS ClassID', $data->class_table_alias . '.name AS p_name', $data->S_alias . '.title AS c_name', 'g.class AS class', 'g.name AS g_name', 'coords', 'g.mid', 'g.kingpost', 'did', 'defined', 'lid', 'multi', 'ftid', $data->ScoreType . ' AS score'], ['join' => ["glider g" => "flight.gid=g.gid", "club c" => "flight.cid=c.cid", "pilot p" => "flight.pid=p.pid", 'manufacturer gm' => 'g.mid = gm.mid'], 'where' => $where, 'order' => 'score DESC', 'limit' => 10, 'parameters' => $data->parameters]);
         if ($flights) {
             $html .= node::create('div.table_wrapper', [], node::create('h3.heading', [], flight_type::get_type($i) . ' - ' . $data->year_title) . node::create('table.main.results', [], node::create('thead tr', [], node::create('th', ['style' => 'width:20px'], 'Pos') . node::create('th', ['style' => 'width:100px'], $data->class_table_alias == 'p' ? 'Name' : 'Glider') . node::create('th', ['style' => 'width:70px'], $data->class_table_alias == 'p' ? 'Club' : 'Manufacturer') . ($data->class_table_alias == 'p' ? node::create('th', ['style' => 'width:100px'], 'Glider') : '') . node::create('th', ['style' => 'width:58px'], 'Score') . node::create('th', ['style' => 'width:300px'], 'Flight Waypoints')) . $flights->iterate_return(function (flight $flight, $count) use(&$html, $data) {
                 $count++;
                 return node::create('tr', [], node::create('td', [], $count) . node::create('td', [], $flight->p_name) . node::create('td', [], $flight->c_name) . ($data->class_table_alias == 'p' ? node::create('td', [], $flight->g_name) : '') . $flight->to_print() . node::create('td', [], $flight->coords));
             })));
         }
     }
     return $html;
 }
예제 #4
0
 public function get_flights()
 {
     if (!$this->flights) {
         $this->options->get_sql();
         $this->set_modifier_string();
         $this->where[] = '`delayed`=0';
         $this->where = implode(' AND ', $this->where);
         if (isset($this->type) && $this->type == league_table_options::LAYOUT_PILOT_LOG) {
             $this->where .= ' AND p.pid=' . $this->options->pilot_id;
             $this->OrderBy = "date";
         } else {
             $this->where .= " AND personal=0 ";
         }
         $this->flights = flight::get_all(['fid', 'p.pid AS p_pid', 'g.gid', $this->class_table_alias . '.' . $this->class_primary_key . ' AS ClassID', 'p.name AS p_name', $this->S_alias . '.title AS c_name', 'g.class AS class', 'g.name AS g_name', 'gm.title AS gm_title', 'g.kingpost AS g_kingpost', 'did', 'defined', 'lid', 'multi', 'ftid', $this->modifier_string . ' AS score', 'date', 'coords'], ['join' => ['glider g' => 'flight.gid=g.gid', 'club c' => 'flight.cid=c.cid', 'pilot p' => 'flight.pid=p.pid', 'manufacturer gm' => 'g.mid = gm.mid'], 'where' => is_array($this->where) ? implode(' AND ', $this->where) : $this->where, 'order' => $this->OrderBy . ' DESC', 'parameters' => $this->parameters]);
     }
 }