2020-08-13 16:24:07 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class LotwCert extends CI_Model {
|
|
|
|
|
2020-08-13 16:28:22 +00:00
|
|
|
/*
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
| Function: lotw_certs
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
| Returns all lotw_certs for a selected user via the $user_id parameter
|
|
|
|
|
|
|
|
|
*/
|
2020-08-13 16:24:07 +00:00
|
|
|
function lotw_certs($user_id) {
|
2020-09-03 22:05:38 +00:00
|
|
|
|
2020-08-13 16:24:07 +00:00
|
|
|
$this->db->where('user_id', $user_id);
|
2020-08-17 16:02:54 +00:00
|
|
|
$this->db->order_by('cert_dxcc', 'ASC');
|
2020-08-13 16:24:07 +00:00
|
|
|
$query = $this->db->get('lotw_certs');
|
|
|
|
|
|
|
|
return $query;
|
|
|
|
}
|
2020-08-17 16:02:54 +00:00
|
|
|
|
2020-12-26 12:08:43 +00:00
|
|
|
function lotw_cert_details($callsign, $dxcc) {
|
|
|
|
$this->db->where('cert_dxcc', $dxcc);
|
2020-08-22 21:26:04 +00:00
|
|
|
$this->db->where('callsign', $callsign);
|
|
|
|
$query = $this->db->get('lotw_certs');
|
|
|
|
|
|
|
|
return $query->row();
|
|
|
|
}
|
|
|
|
|
2020-12-28 13:42:26 +00:00
|
|
|
function find_cert($callsign, $dxcc, $user_id) {
|
2020-08-17 16:02:54 +00:00
|
|
|
$this->db->where('user_id', $user_id);
|
2020-12-28 13:42:26 +00:00
|
|
|
$this->db->where('cert_dxcc', $dxcc);
|
2020-08-17 16:02:54 +00:00
|
|
|
$this->db->where('callsign', $callsign);
|
|
|
|
$query = $this->db->get('lotw_certs');
|
|
|
|
|
|
|
|
return $query->num_rows();
|
|
|
|
}
|
|
|
|
|
2022-08-26 14:24:28 +00:00
|
|
|
function store_certificate($user_id, $callsign, $dxcc, $date_created, $date_expires, $qso_start_date, $qso_end_date, $cert_key, $general_cert) {
|
2020-08-17 16:02:54 +00:00
|
|
|
$data = array(
|
|
|
|
'user_id' => $user_id,
|
|
|
|
'callsign' => $callsign,
|
|
|
|
'cert_dxcc' => $dxcc,
|
|
|
|
'date_created' => $date_created,
|
|
|
|
'date_expires' => $date_expires,
|
2022-08-24 10:16:41 +00:00
|
|
|
'qso_start_date' => $qso_start_date,
|
|
|
|
'qso_end_date' => $qso_end_date,
|
2020-08-17 16:02:54 +00:00
|
|
|
'cert_key' => $cert_key,
|
2020-08-26 15:31:35 +00:00
|
|
|
'cert' => $general_cert,
|
2020-08-17 16:02:54 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
$this->db->insert('lotw_certs', $data);
|
|
|
|
}
|
|
|
|
|
2020-08-26 15:31:35 +00:00
|
|
|
function update_certficiate($user_id, $callsign, $dxcc, $date_created, $date_expires, $cert_key, $general_cert) {
|
2020-08-17 16:02:54 +00:00
|
|
|
$data = array(
|
|
|
|
'cert_dxcc' => $dxcc,
|
|
|
|
'date_created' => $date_created,
|
|
|
|
'date_expires' => $date_expires,
|
|
|
|
'cert_key' => $cert_key,
|
2020-08-26 15:31:35 +00:00
|
|
|
'cert' => $general_cert
|
2020-08-17 16:02:54 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
$this->db->where('user_id', $user_id);
|
|
|
|
$this->db->where('callsign', $callsign);
|
2020-12-28 13:45:06 +00:00
|
|
|
$this->db->where('cert_dxcc', $dxcc);
|
2020-08-17 16:02:54 +00:00
|
|
|
$this->db->update('lotw_certs', $data);
|
|
|
|
}
|
|
|
|
|
|
|
|
function delete_certficiate($user_id, $lotw_cert_id) {
|
|
|
|
$this->db->where('lotw_cert_id', $lotw_cert_id);
|
|
|
|
$this->db->where('user_id', $user_id);
|
|
|
|
$this->db->delete('lotw_certs');
|
|
|
|
}
|
2020-08-26 20:20:58 +00:00
|
|
|
|
|
|
|
function last_upload($certID) {
|
|
|
|
|
|
|
|
$data = array(
|
|
|
|
'last_upload' => date("Y-m-d H:i:s"),
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
$this->db->where('lotw_cert_id', $certID);
|
|
|
|
|
|
|
|
$this->db->update('lotw_certs', $data);
|
|
|
|
|
|
|
|
return "Updated";
|
|
|
|
}
|
2020-08-13 16:24:07 +00:00
|
|
|
|
|
|
|
function empty_table($table) {
|
|
|
|
$this->db->empty_table($table);
|
|
|
|
}
|
|
|
|
}
|
2022-08-24 10:16:41 +00:00
|
|
|
?>
|