2020-10-28 22:20:03 +00:00
|
|
|
<?php
|
|
|
|
class Qsl_model extends CI_Model {
|
|
|
|
function getQsoWithQslList() {
|
|
|
|
$CI =& get_instance();
|
2021-11-14 16:50:11 +00:00
|
|
|
$CI->load->model('logbooks_model');
|
|
|
|
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
2020-10-28 22:20:03 +00:00
|
|
|
|
|
|
|
$this->db->select('*');
|
|
|
|
$this->db->from($this->config->item('table_name'));
|
|
|
|
$this->db->join('qsl_images', 'qsl_images.qsoid = ' . $this->config->item('table_name') . '.col_primary_key');
|
2021-11-14 16:50:11 +00:00
|
|
|
$this->db->where_in('station_id', $logbooks_locations_array);
|
2022-05-06 06:02:16 +00:00
|
|
|
$this->db->order_by("id", "desc");
|
2020-10-28 22:20:03 +00:00
|
|
|
|
|
|
|
return $this->db->get();
|
|
|
|
}
|
|
|
|
|
|
|
|
function getQslForQsoId($id) {
|
|
|
|
// Clean ID
|
|
|
|
$clean_id = $this->security->xss_clean($id);
|
|
|
|
|
2021-11-14 16:50:11 +00:00
|
|
|
// be sure that QSO belongs to user
|
|
|
|
$CI =& get_instance();
|
|
|
|
$CI->load->model('logbook_model');
|
|
|
|
if (!$CI->logbook_model->check_qso_is_accessible($clean_id)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-10-28 22:20:03 +00:00
|
|
|
$this->db->select('*');
|
|
|
|
$this->db->from('qsl_images');
|
|
|
|
$this->db->where('qsoid', $clean_id);
|
|
|
|
|
|
|
|
return $this->db->get()->result();
|
|
|
|
}
|
|
|
|
|
|
|
|
function saveQsl($qsoid, $filename) {
|
2021-11-14 16:50:11 +00:00
|
|
|
// Clean ID
|
|
|
|
$clean_id = $this->security->xss_clean($qsoid);
|
|
|
|
|
|
|
|
// be sure that QSO belongs to user
|
|
|
|
$CI =& get_instance();
|
|
|
|
$CI->load->model('logbook_model');
|
|
|
|
if (!$CI->logbook_model->check_qso_is_accessible($clean_id)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-10-28 22:20:03 +00:00
|
|
|
$data = array(
|
2021-11-14 16:50:11 +00:00
|
|
|
'qsoid' => $clean_id,
|
2020-10-28 22:20:03 +00:00
|
|
|
'filename' => $filename
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->db->insert('qsl_images', $data);
|
2020-11-01 11:36:02 +00:00
|
|
|
|
|
|
|
return $this->db->insert_id();
|
2020-10-28 22:20:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function deleteQsl($id) {
|
|
|
|
// Clean ID
|
|
|
|
$clean_id = $this->security->xss_clean($id);
|
|
|
|
|
2021-11-14 16:50:11 +00:00
|
|
|
// be sure that QSO belongs to user
|
|
|
|
$CI =& get_instance();
|
|
|
|
$CI->load->model('logbook_model');
|
2022-12-28 20:58:09 +00:00
|
|
|
$this->db->select('qsoid');
|
|
|
|
$this->db->from('qsl_images');
|
|
|
|
$this->db->where('id', $clean_id);
|
|
|
|
$qsoid = $this->db->get()->row()->qsoid;
|
|
|
|
if (!$CI->logbook_model->check_qso_is_accessible($qsoid)) {
|
2021-11-14 16:50:11 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-10-28 22:20:03 +00:00
|
|
|
// Delete Mode
|
|
|
|
$this->db->delete('qsl_images', array('id' => $clean_id));
|
|
|
|
}
|
|
|
|
|
|
|
|
function getFilename($id) {
|
|
|
|
// Clean ID
|
|
|
|
$clean_id = $this->security->xss_clean($id);
|
|
|
|
|
2021-11-14 16:50:11 +00:00
|
|
|
// be sure that QSO belongs to user
|
|
|
|
$CI =& get_instance();
|
|
|
|
$CI->load->model('logbook_model');
|
2022-12-28 20:58:09 +00:00
|
|
|
$this->db->select('qsoid');
|
|
|
|
$this->db->from('qsl_images');
|
|
|
|
$this->db->where('id', $clean_id);
|
|
|
|
$qsoid = $this->db->get()->row()->qsoid;
|
|
|
|
if (!$CI->logbook_model->check_qso_is_accessible($qsoid)) {
|
2021-11-14 16:50:11 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-10-28 22:20:03 +00:00
|
|
|
$this->db->select('filename');
|
|
|
|
$this->db->from('qsl_images');
|
|
|
|
$this->db->where('id', $clean_id);
|
|
|
|
|
|
|
|
return $this->db->get();
|
|
|
|
}
|
2021-07-22 05:55:34 +00:00
|
|
|
|
2021-11-14 16:50:11 +00:00
|
|
|
function searchQsos($callsign) {
|
|
|
|
$CI =& get_instance();
|
|
|
|
$CI->load->model('logbooks_model');
|
|
|
|
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
2021-07-22 05:55:34 +00:00
|
|
|
|
|
|
|
$this->db->select('*');
|
|
|
|
$this->db->from($this->config->item('table_name'));
|
2021-11-14 16:50:11 +00:00
|
|
|
$this->db->where_in('station_id', $logbooks_locations_array);
|
2021-07-22 05:55:34 +00:00
|
|
|
$this->db->where('col_call', $callsign);
|
|
|
|
|
|
|
|
return $this->db->get();
|
|
|
|
}
|
|
|
|
|
|
|
|
function addQsotoQsl($qsoid, $filename) {
|
|
|
|
$clean_qsoid = $this->security->xss_clean($qsoid);
|
|
|
|
$clean_filename = $this->security->xss_clean($filename);
|
|
|
|
|
2021-11-14 16:50:11 +00:00
|
|
|
// be sure that QSO belongs to user
|
|
|
|
$CI =& get_instance();
|
|
|
|
$CI->load->model('logbook_model');
|
|
|
|
if (!$CI->logbook_model->check_qso_is_accessible($clean_qsoid)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-07-22 05:55:34 +00:00
|
|
|
$data = array(
|
2021-11-14 16:50:11 +00:00
|
|
|
'qsoid' => $clean_qsoid,
|
2021-07-22 05:55:34 +00:00
|
|
|
'filename' => $filename
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->db->insert('qsl_images', $data);
|
|
|
|
|
|
|
|
return $this->db->insert_id();
|
|
|
|
}
|
|
|
|
}
|