You can now select station profile for ADIF file when importing

pull/425/head
Peter Goodhall 2019-08-19 22:25:50 +01:00
rodzic 74fec04b6b
commit c124a0200c
4 zmienionych plików z 46 dodań i 3 usunięć

Wyświetl plik

@ -95,6 +95,8 @@ class adif extends CI_Controller {
}
public function index() {
$this->load->model('stations');
$data['station_profile'] = $this->stations->all();
$data['page_title'] = "ADIF Import";
$data['max_upload'] = ini_get('upload_max_filesize');
$this->load->view('interface_assets/header', $data);
@ -103,6 +105,8 @@ class adif extends CI_Controller {
}
public function import() {
$this->load->model('stations');
$data['station_profile'] = $this->stations->all();
$data['page_title'] = "ADIF Import";
@ -145,7 +149,7 @@ class adif extends CI_Controller {
};
$this->logbook_model->import($record);
$this->logbook_model->import($record, $this->input->post('station_profile'));
};

Wyświetl plik

@ -917,10 +917,11 @@ class Logbook_model extends CI_Model {
return $this->db->get($this->config->item('table_name'));
}
function import($record) {
function import($record, $station_id = "0") {
$CI =& get_instance();
$CI->load->library('frequency');
// Join date+time
$time_on = date('Y-m-d', strtotime($record['qso_date'])) ." ".date('H:i', strtotime($record['time_on']));
@ -1197,6 +1198,33 @@ class Logbook_model extends CI_Model {
'COL_WEB' => (!empty($record['web'])) ? $record['web'] : ''
);
if($station_id != "0") {
$station_result = $this->db->where('station_id', $station_id)
->get('station_profile');
if ($station_result->num_rows() > 0){
$row = $station_result->row_array();
if (strpos(trim($row['station_gridsquare']), ',') !== false) {
$data['COL_MY_VUCC_GRIDS'] = strtoupper(trim($row['station_gridsquare']));
} else {
$data['COL_MY_GRIDSQUARE'] = strtoupper(trim($row['station_gridsquare']));
}
$data['COL_MY_CITY'] = strtoupper(trim($row['station_city']));
$data['COL_MY_IOTA'] = strtoupper(trim($row['station_iota']));
$data['COL_MY_SOTA_REF'] = strtoupper(trim($row['station_sota']));
$data['COL_STATION_CALLSIGN'] = strtoupper(trim($row['station_callsign']));
$data['COL_MY_DXCC'] = strtoupper(trim($row['station_dxcc']));
$data['COL_MY_COUNTRY'] = strtoupper(trim($row['station_country']));
$data['COL_MY_CNTY'] = strtoupper(trim($row['station_cnty']));
$data['COL_MY_CQ_ZONE'] = strtoupper(trim($row['station_cq']));
$data['COL_MY_ITU_ZONE'] = strtoupper(trim($row['station_itu']));
}
}
$this->add_qso($data);

Wyświetl plik

@ -12,6 +12,11 @@ class Stations extends CI_Model {
return $this->db->get('station_profile');
}
function profile($id) {
$this->db->where('station_id', $id);
return $this->db->get('station_profile');
}
function add() {
$data = array(

Wyświetl plik

@ -19,7 +19,13 @@
<p><span class="label important">Important</span> Log files must have the file type .adi</p>
<form class="form-inline" action="<?php echo site_url('adif/import'); ?>" method="post" enctype="multipart/form-data">
<form class="form" action="<?php echo site_url('adif/import'); ?>" method="post" enctype="multipart/form-data">
<select name="station_profile" class="custom-select mb-2 mr-sm-2" style="width: 20%;">
<option value="0">Select Station Profile</option>
<?php foreach ($station_profile->result() as $station) { ?>
<option value="<?php echo $station->station_id; ?>">Callsign: <?php echo $station->station_callsign; ?> (<?php echo $station->station_profile_name; ?>)</option>
<?php } ?>
</select>
<label class="sr-only" for="inlineFormInputName2">ADIF file</label>
<input class="file-input mb-2 mr-sm-2" type="file" name="userfile" size="20" />