load->model('user_model'); $this->load->model('modes'); $this->load->model('logbook_model'); $this->load->model('bands'); if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } $data['worked_bands'] = $this->bands->get_worked_bands(); // Used in the view for band select $data['modes'] = $this->modes->active(); // Used in the view for mode select $data['dxcc'] = $this->logbook_model->fetchDxcc(); // Used in the view for dxcc select $data['page_title'] = "KML Export"; $this->load->view('interface_assets/header', $data); $this->load->view('kml/index'); $this->load->view('interface_assets/footer'); } public function export() { $this->load->model('user_model'); if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } // Load Libraries $this->load->library('qra'); $this->load->helper('file'); // Load Database connections $this->load->model('logbook_model'); // Parameters $band = $this->input->post('band'); $mode = $this->input->post('mode'); $dxcc = $this->input->post('dxcc_id'); $cqz = $this->input->post('cqz'); $propagation = $this->input->post('prop_mode'); $fromdate = $this->input->post('from'); $todate = $this->input->post('to'); // Get QSOs with Valid QRAs $qsos = $this->logbook_model->kml_get_all_qsos($band, $mode, $dxcc, $cqz, $propagation, $fromdate, $todate); $output = ""; $output .= ""; $output .= ""; foreach ($qsos->result() as $row) { if($row->COL_GRIDSQUARE != null) { $stn_loc = $this->qra->qra2latlong($row->COL_GRIDSQUARE); $lat = $stn_loc[0]; $lng = $stn_loc[1]; } else { $query = $this->db->query(' SELECT * FROM dxcc_entities WHERE prefix = SUBSTRING( \''.$row->COL_CALL.'\', 1, LENGTH( prefix ) ) ORDER BY LENGTH( prefix ) DESC LIMIT 1 '); foreach ($query->result() as $dxcc) { $lat = $dxcc->lat; $lng = $dxcc->long; } } if (isset($lat) && isset($lng)) { $output .= ""; $timestamp = strtotime($row->COL_TIME_ON); $output .= "".$row->COL_CALL.""; $output .= "Date/Time: ".date('Y-m-d H:i:s', ($timestamp))."
Band: ".$row->COL_BAND."

]]>
"; $output .= ""; $output .= "".$lng.",".$lat.",0"; $output .= ""; $output .= "
"; } } $output .= "
"; $output .= "
"; header("Content-Disposition: attachment; filename=\"qsos.kml\""); echo $output; } }