Exemplo n.º 1
0
 protected function get_flight_defined($ftid, $class, $gender)
 {
     $flight = new flight();
     $flight->do_retrieve(['fid', 'p.name AS p_name', 'base_score', 'date', 'speed'], ['join' => ['pilot p' => 'p.pid = flight.pid', 'glider g' => 'g.gid = flight.gid'], 'where_equals' => ['ftid' => $ftid, 'g.class' => $class, 'p.gender' => $gender], 'order' => 'speed DESC']);
     $html = '';
     if ($flight->fid) {
         $html .= node::create('tr', [], node::create('td', [], 'Speed') . node::create('td', [], $class) . node::create('td', [], $gender) . node::create('td', [], $flight->p_name) . node::create('td', [], number_format($flight->speed, 2)) . node::create('td', [], date('d/m/Y', $flight->date)));
     }
     return $html;
 }
Exemplo n.º 2
0
 public function get_template_data()
 {
     $root = root . '/uploads/comp/' . $this->module->current->get_primary_key();
     $files = glob($root . '/*.igc');
     $flights = [];
     foreach ($files as $file) {
         $name = str_replace($root, '', $file);
         $name = str_replace('.igc', '', $name);
         $name = preg_replace('/[0-9.\\-_\\/]/', ' ', $name);
         $name = preg_replace('/\\s+/', ' ', $name);
         $name = trim($name);
         $pilot = new pilot();
         $parts = explode(' ', $name);
         $match = false;
         if ($pilot->do_retrieve([], ['where_equals' => ['name' => $name]]) || $pilot->do_retrieve([], ['where_equals' => ['name' => implode(' ', array_reverse($parts))]])) {
             $flight = new flight();
             $match = $flight->do_retrieve([], ['where_equals' => ['pid' => $pilot->get_primary_key(), 'date' => date('Y-m-d', $this->module->current->date)]]);
         }
         $flights[] = ['data' => ['path' => $file, 'name' => $name, 'cid' => $this->module->current->get_primary_key()], 'name' => $name, 'matched' => $match];
     }
     return ['rows' => $flights];
 }
Exemplo n.º 3
0
 /**
  * Generates a sub table showing the top flights in each category.
  *
  * @param string $where - a complete sql WHERE clause
  * @param array $params
  *
  * @return string
  */
 function ShowTop4($where, $params = [])
 {
     $html = '';
     $launch_by_number = [1 => 'Foot', 2 => 'Aerotow', 3 => 'Winch'];
     $where['delayed'] = '`delayed`=:delayed';
     $params['delayed'] = 0;
     $where['personal'] = 'personal=:personal';
     $params['personal'] = 0;
     foreach ($launch_by_number as $j => $val) {
         $where_extend = implode(' AND ', $where);
         $where_extend .= ' AND lid=:lid';
         $params['lid'] = $j;
         $html .= '<tr><td>' . $val . '</td>';
         for ($i = 1; $i < 5; $i++) {
             $where_extend .= ' AND ftid=:ftid';
             $params['ftid'] = $i;
             $flight = new flight();
             $flight->do_retrieve(['flight.*', $this->class . '.name AS name', 'glider.class AS class'], ['join' => flight::$default_joins, 'where' => $where_extend, 'order' => 'score DESC', 'parameters' => $params]);
             if (isset($flight->fid) && $flight->fid) {
                 $prefix = $flight->name . ' (' . ($flight->class == 5 ? 'R' : 'F') . ') ';
                 $html .= $flight->to_print($prefix)->get();
             } else {
                 $html .= node::create('td', [], 'No Flights Fit');
             }
         }
         $html .= '</tr>';
     }
     return node::create('table.top4.main.results', [], node::create('thead', [], node::create('tr', [], node::create('th', ['style' => 'width:52px'], 'Category') . node::create('th', ['style' => 'width:155px;color:black'], 'Open Dist') . node::create('th', ['style' => 'width:155px;color:green'], 'Out & Return') . node::create('th', ['style' => 'width:155px;color:red'], 'Goal') . node::create('th', ['style' => 'width:155px;color:blue'], 'Triangle'))) . $html);
 }
Exemplo n.º 4
0
 public function add_flight()
 {
     $this->do_retrieve_from_id([], $_REQUEST['cid']);
     $coords = json_decode($this->coords);
     $form = new igc_upload_form();
     $form->file = $_REQUEST['path'];
     $form->coords = implode(';', array_map(function ($coord) {
         $point = new lat_lng($coord->lat, $coord->lon);
         return geometry::lat_long_to_os($point);
     }, $coords));
     $form->do_submit();
     $form = new igc_form();
     $form->vis_info = 'Flown in comp: ' . $this->type . ' Round ' . $this->round . ' Task ' . $this->task;
     $pilot = new pilot();
     $parts = explode(' ', $_REQUEST['name']);
     if ($pilot->do_retrieve([], ['where_equals' => ['name' => $_REQUEST['name']]]) || $pilot->do_retrieve([], ['where_equals' => ['name' => implode(' ', array_reverse($parts))]])) {
         $form->pid = $pilot->get_primary_key();
         $flight = new flight();
         if ($flight->do_retrieve([], ['where_equals' => ['pid' => $pilot->get_primary_key()], 'order' => 'date DESC'])) {
             $form->gid = $flight->gid;
             $form->cid = $flight->cid;
         }
     }
     ajax::update(node::create('div#second_form', [], $form->get_html()));
 }