/** * Retourne les informations sur l'association * @param string $id */ public function qualif_pilote($pilot = "1029") { $id = $this->config->item('ffvv_id'); // fetch les informations pilotes $request = $this->heva_request("/persons/{$pilot}"); if (!$request->success) { echo "status_code = " . $request->status_code . br(); echo "success = " . $request->success . br(); return; } $info_pilot = json_decode($request->body, true); $first_name = isset($info_pilot['first_name']) ? $info_pilot['first_name'] : ""; $last_name = isset($info_pilot['last_name']) ? $info_pilot['last_name'] : ""; // fetch les qualifs $request = $this->heva_request("/persons/{$pilot}/qualifications"); if (!$request->success) { echo "status_code = " . $request->status_code . br(); echo "success = " . $request->success . br(); return; } $result = json_decode($request->body, true); // var_dump($result);exit; $table = array(); foreach ($result as $row) { $row['type_name'] = isset($row['type']['name']) ? $row['type']['name'] : ""; $table[] = $row; } $attrs['fields'] = array('awarded_at', 'type_name'); $data['controller'] = $this->controller; $data['data_table'] = datatable('heva_qualifs', $table, $attrs); $data['table_title'] = 'Qualifications pour ' . $first_name . ' ' . $last_name; $this->load->view('default_table', $data); }
/** * Display the flight logs for an airfield and a date */ function display() { // set rules $this->form_validation->set_rules('a', "Airfield", "required|max_length[4]"); $this->form_validation->set_rules('d', "Date", "required|callback_valid_date"); $this->form_validation->set_error_delimiters('<div class="error">', '</div>'); // var_dump($_POST);exit; if ($this->form_validation->run() == FALSE) { // invalid input, reload the form $this->load->view('flight_logs/select'); } else { // successful validation $t = $this->input->post('t'); $a = $this->input->post('a'); $d = $this->input->post('d'); $s = $this->input->post('s'); $u = $this->input->post('u'); $z = $this->input->post('z'); // TODO: translate the date depending on the languange // date=2016-05-02 french for february // English version $sdate = substr($d, 8, 2) . substr($d, 5, 2) . substr($d, 0, 4); // mise au format jjmmaaaa $url = "http://live.glidernet.org/flightlog"; $data = array('d' => $sdate, 'a' => $a, 'j' => '2', 's' => $s, 'u' => $u, 'z' => $z); $headers = array('Accept' => 'application/json'); $request = Requests::get($url, $headers, $data); if (!$request->success) { $data['title'] = "Connection error"; $data['message'] = "Error from {$url}" . br() . "Code = " . $request->status_code; $this->load->view('message', $data); } else { $planche = json_decode($request->body, true); /** * array (size=5) 'date' => string '05022016' (length=8) 'airfield' => string 'LFNF' (length=4) 'alt_setting' => string 'QFE' (length=3) 'unit' => string 'm' (length=1) 'flights' => array (size=6) 0 => array (size=8) 'plane' => string 'F-GMKA' (length=6) 'glider' => string '' (length=0) 'takeoff' => string '13.59' (length=5) 'plane_landing' => string '16.17' (length=5) 'glider_landing' => string '' (length=0) 'plane_time' => string '02h17' (length=5) 'glider_time' => string '-----' (length=5) 'towplane_max_alt' => string '' (length=0) 1 => array (size=8) 'plane' => string 'F-GORY' (length=6) 'glider' => string 'F-CHGO' (length=6) 'takeoff' => string '14.18' (length=5) 'plane_landing' => string '14.26' (length=5) 'glider_landing' => string '14.39' (length=5) 'plane_time' => string '00h07' (length=5) 'glider_time' => string '00h21' (length=5) 'towplane_max_alt' => string '818' (length=3) */ $attrs['fields'] = array('plane', 'glider', 'takeoff', 'plane_landing', 'glider_landing', 'plane_time', 'glider_time', 'towplane_max_alt'); $data['controller'] = $this->controller; $data['data_table'] = datatable('flight_logs', $planche['flights'], $attrs); $data['table_title'] = 'Flight logs ' . $planche['airfield']; $date = $planche['date']; $day = substr($date, 0, 2); $month = substr($date, 2, 2); $year = substr($date, 4, 4); $sdate = "{$day}/{$month}/{$year}"; $data['message'] = "Date = " . $sdate; $this->load->view('default_table', $data); } } }
public static function handle($model) { return datatable($model, new static()); }