示例#1
0
文件: comp.php 项目: robchett/uknxcl
 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()));
 }