示例#1
0
 public function do_submit()
 {
     $flight = new flight();
     $flight->set_from_request();
     $flight->dim = 1;
     if (strtotime($this->date) + 30 * 24 * 60 * 60 < time()) {
         $this->force_delay = true;
         $flight->admin_info .= 'delayed as flight is old.';
     }
     $track = new track();
     $task = $track->set_task($this->coords);
     $flight_type = new flight_type();
     $flight_type->do_retrieve(['ftid', 'multi', 'multi_defined'], ['where_equals' => ['fn' => $task->type]]);
     $flight->ftid = $flight_type->ftid;
     $flight->set_date($this->date);
     $flight->multi = !$this->ridge ? flight_type::get_multiplier($flight->ftid, $flight->season, $this->defined) : 1;
     $flight->base_score = $task->get_distance();
     $flight->coords = $this->coords;
     $flight->score = $flight->base_score * $flight->multi;
     $flight->delayed = $this->force_delay ? true : $this->delay;
     $flight->do_save();
     jquery::colorbox(['html' => 'Your flight has been added successfully', 'className' => 'success']);
     $form = new coordinates_form();
     ajax::update($form->get_html()->get());
 }