Basics for a eQSL image download page

This commit is contained in:
phl0 2023-05-10 21:36:46 +02:00
parent 21562bffc4
commit c317a63236
No known key found for this signature in database
GPG Key ID: 48EA1E640798CA9A
6 changed files with 89 additions and 3 deletions

View File

@ -552,6 +552,48 @@ class eqsl extends CI_Controller {
$this->load->view('interface_assets/footer');
}
public function download() {
// Check logged in
$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'); }
$data['page_title'] = "eQSL Card Image Download";
$this->load->model('eqslmethods_model');
$rows = '';
$qslsnotdownloaded = $this->eqslmethods_model->eqsl_not_yet_downloaded();
foreach ($qslsnotdownloaded->result_array() as $qsl) {
$rows .= "<tr>";
// eQSL username changes for linked account.
// i.e. when operating /P it must be callsign/p
// the password, however, is always the same as the main account
$data['user_eqsl_name'] = $qsl['station_callsign'];
$adif = $this->generateAdif($qsl, $data);
$status = $this->uploadQso($adif, $qsl);
$timestamp = strtotime($qsl['COL_TIME_ON']);
$rows .= "<td>".date($custom_date_format, $timestamp)."</td>";
$rows .= "<td>".date('H:i', $timestamp)."</td>";
$rows .= "<td>".str_replace("0","&Oslash;",$qsl['COL_CALL'])."</td>";
$rows .= "<td>".$qsl['COL_MODE']."</td>";
if(isset($qsl['COL_SUBMODE'])) {
$rows .= "<td>".$qsl['COL_SUBMODE']."</td>";
} else {
$rows .= "<td></td>";
}
$rows .= "<td>".$qsl['COL_BAND']."</td>";
$rows .= "<td>".$status."</td>";
}
$rows .= "</tr>";
$data['eqsl_table'] = $this->generateResultTable($custom_date_format, $rows);
// Load frontend
$this->load->view('interface_assets/header', $data);
$this->load->view('eqsl/download');
$this->load->view('interface_assets/footer');
}
public function mark_all_sent() {
// Check logged in
$this->load->model('user_model');

View File

@ -49,7 +49,7 @@ class Eqslmethods_model extends CI_Model {
array_push($logbooks_locations_array, $row->station_id);
}
}
$this->db->select('station_profile.*, '.$this->config->item('table_name').'.COL_PRIMARY_KEY, '.$this->config->item('table_name').'.COL_TIME_ON, '.$this->config->item('table_name').'.COL_CALL, '.$this->config->item('table_name').'.COL_MODE, '.$this->config->item('table_name').'.COL_SUBMODE, '.$this->config->item('table_name').'.COL_BAND, '.$this->config->item('table_name').'.COL_COMMENT, '.$this->config->item('table_name').'.COL_RST_SENT, '.$this->config->item('table_name').'.COL_PROP_MODE, '.$this->config->item('table_name').'.COL_SAT_NAME, '.$this->config->item('table_name').'.COL_SAT_MODE, '.$this->config->item('table_name').'.COL_QSLMSG');
$this->db->from('station_profile');
$this->db->join($this->config->item('table_name'),'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
@ -63,7 +63,38 @@ class Eqslmethods_model extends CI_Model {
$this->db->or_where($this->config->item('table_name').'.COL_EQSL_QSL_SENT', 'N');
$this->db->group_end();
$this->db->where_in('station_profile.station_id', $logbooks_locations_array);
return $this->db->get();
}
// Show all QSOs whose eQSL card images we did not download yet
function eqsl_not_yet_downloaded($userid = null) {
$CI =& get_instance();
if ($userid == null) {
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
} else {
$stations = $this->get_all_user_locations($userid);
$logbooks_locations_array = array();
foreach ($stations->result() as $row) {
array_push($logbooks_locations_array, $row->station_id);
}
}
$this->db->select('station_profile.*, '.$this->config->item('table_name').'.COL_PRIMARY_KEY, '.$this->config->item('table_name').'.COL_TIME_ON, '.$this->config->item('table_name').'.COL_CALL, '.$this->config->item('table_name').'.COL_MODE, '.$this->config->item('table_name').'.COL_SUBMODE, '.$this->config->item('table_name').'.COL_BAND, '.$this->config->item('table_name').'.COL_COMMENT, '.$this->config->item('table_name').'.COL_RST_SENT, '.$this->config->item('table_name').'.COL_PROP_MODE, '.$this->config->item('table_name').'.COL_SAT_NAME, '.$this->config->item('table_name').'.COL_SAT_MODE, '.$this->config->item('table_name').'.COL_QSLMSG');
$this->db->from('station_profile');
$this->db->join($this->config->item('table_name'),'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
$this->db->where("coalesce(station_profile.eqslqthnickname, '') <> ''");
$this->db->where($this->config->item('table_name').'.COL_CALL !=', '');
$this->db->group_start();
$this->db->where($this->config->item('table_name').'.COL_EQSL_QSL_SENT is null');
$this->db->or_where($this->config->item('table_name').'.COL_EQSL_QSL_SENT', '');
$this->db->or_where($this->config->item('table_name').'.COL_EQSL_QSL_SENT', 'R');
$this->db->or_where($this->config->item('table_name').'.COL_EQSL_QSL_SENT', 'Q');
$this->db->or_where($this->config->item('table_name').'.COL_EQSL_QSL_SENT', 'N');
$this->db->group_end();
$this->db->where_in('station_profile.station_id', $logbooks_locations_array);
return $this->db->get();
}
@ -165,4 +196,4 @@ class Eqslmethods_model extends CI_Model {
}
?>
?>

View File

@ -16,6 +16,9 @@ $custom_date_format = $this->session->userdata('user_date_format');
<li class="nav-item">
<a class="nav-link" href="<?php echo site_url('eqsl/tools');?>">Tools</a>
</li>
<li class="nav-item">
<a class="nav-link" href="<?php echo site_url('eqsl/download');?>">Download eQSL Images</a>
</li>
</ul>
</div>

View File

@ -14,6 +14,9 @@
<li class="nav-item">
<a class="nav-link" href="<?php echo site_url('eqsl/tools');?>">Tools</a>
</li>
<li class="nav-item">
<a class="nav-link" href="<?php echo site_url('eqsl/download');?>">Download eQSL Images</a>
</li>
</ul>
</div>

View File

@ -14,6 +14,9 @@
<li class="nav-item">
<a class="nav-link" href="<?php echo site_url('eqsl/tools');?>">Tools</a>
</li>
<li class="nav-item">
<a class="nav-link" href="<?php echo site_url('eqsl/download');?>">Download eQSL Images</a>
</li>
</ul>
</div>
<div class="card-body">

View File

@ -15,6 +15,10 @@
<li class="nav-item">
<a class="nav-link active" href="<?php echo site_url('eqsl/tools');?>">Tools</a>
</li>
<li class="nav-item">
<a class="nav-link" href="<?php echo site_url('eqsl/download');?>">Download eQSL Images</a>
</li>
</ul>
</div>