Exemplo n.º 1
0
 /**
  * @param pilot|pilot_official $pilot
  * @param $num
  */
 function set_from_pilot($pilot, $num)
 {
     $this->max_pilots = $num;
     $this->name = $pilot->club;
     $this->score = $pilot->score;
     $this->total = $this->score;
     $this->content = $pilot->output(1);
 }
Exemplo n.º 2
0
 public function get_latest_pilots()
 {
     $pilots = pilot::get_all(['pid', 'name', 'bhpa_no', 'email'], ['limit' => 5, 'order' => 'pid DESC']);
     $table = node::create('table#latest_pilots.module.table.table-striped', [], node::create('thead', [], node::create('th', [], 'ID') . node::create('th', [], 'Pilot') . node::create('th', [], 'BHPA Number') . node::create('th', [], 'Email')) . $pilots->iterate_return(function (pilot $pilot) {
         return node::create('tr', [], node::create('td a', ['href' => '/cms/module/3/' . $pilot->pid, 'title' => 'Pilot: ' . $pilot->name], $pilot->pid) . node::create('td a', ['href' => '/cms/module/3/' . $pilot->pid, 'title' => 'Pilot: ' . $pilot->name], $pilot->name) . node::create('td a', ['href' => '/cms/module/3/' . $pilot->pid, 'title' => 'Pilot: ' . $pilot->name], $pilot->bhpa_no) . node::create('td a', ['href' => '/cms/module/3/' . $pilot->pid, 'title' => 'Pilot: ' . $pilot->name], $pilot->email));
     }));
     return $table;
 }
Exemplo n.º 3
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.º 4
0
 public function get_table()
 {
     if ($this->options->pilot_id) {
         $this->options->layout = league_table_options::LAYOUT_PILOT_LOG;
     }
     switch ($this->options->layout) {
         case league_table_options::LAYOUT_LEAGUE:
             $this->result = new result_league();
             $this->Title .= ' League';
             break;
         case league_table_options::LAYOUT_CLUB:
             $this->result = new result_club();
             $this->Title .= ' Club League';
             break;
         case league_table_options::LAYOUT_PILOT_LOG:
             $this->result = new result_pilot();
             $pilot = new pilot();
             $pilot->do_retrieve_from_id(['name'], $this->options->pilot_id);
             $this->Title .= ' Pilot Log (' . $pilot->name . ')';
             $this->options->set_minimum_score(0);
             break;
         case league_table_options::LAYOUT_TOP_TEN:
             $this->result = new result_top_ten();
             $this->Title .= ' Top 10s';
             break;
         case league_table_options::LAYOUT_RECORDS:
             $this->result = new result_records();
             return $this->result->make_table($this);
         case league_table_options::LAYOUT_LIST:
             $this->OrderBy = 'date';
             $this->result = new result_list();
             $this->Title .= ' List';
             break;
     }
     if ($this->options->official) {
         $this->class = $this->official_class;
     }
     $this->get_flights();
     return $this->result->make_table($this);
 }
Exemplo n.º 5
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()));
 }