2022-12-18 15:49:54 +00:00
|
|
|
<?php
|
|
|
|
use Cloudlog\QSLManager\QSO;
|
|
|
|
|
|
|
|
class Logbookadvanced_model extends CI_Model {
|
2023-08-18 18:02:47 +00:00
|
|
|
|
|
|
|
public function searchDb($searchCriteria) {
|
2022-12-18 15:49:54 +00:00
|
|
|
$conditions = [];
|
|
|
|
$binding = [$searchCriteria['user_id']];
|
|
|
|
|
2023-10-19 04:56:45 +00:00
|
|
|
if ((isset($searchCriteria['dupes'])) && ($searchCriteria['dupes'] !== '')) {
|
2023-11-23 19:43:45 +00:00
|
|
|
$id_sql="select GROUP_CONCAT(col_primary_key separator ',') as qsoids, COL_CALL, COL_MODE, COL_SUBMODE, station_callsign, COL_SAT_NAME, COL_BAND, min(col_time_on) Mintime, max(col_time_on) Maxtime from " . $this->config->item('table_name') . "
|
2023-10-17 10:23:51 +00:00
|
|
|
join station_profile on " . $this->config->item('table_name') . ".station_id = station_profile.station_id where station_profile.user_id=?
|
2023-11-23 19:43:45 +00:00
|
|
|
group by col_call, col_mode, COL_SUBMODE, STATION_CALLSIGN, col_band, COL_SAT_NAME having count(*) > 1 and timediff(maxtime, mintime) < 3000";
|
2023-10-17 10:14:10 +00:00
|
|
|
$id_query = $this->db->query($id_sql, $searchCriteria['user_id']);
|
2023-11-23 19:43:45 +00:00
|
|
|
$ids2fetch = '';
|
2023-10-17 10:14:10 +00:00
|
|
|
foreach ($id_query->result() as $id) {
|
2023-11-23 19:43:45 +00:00
|
|
|
$ids2fetch .= ','.$id->qsoids;
|
2023-10-17 10:14:10 +00:00
|
|
|
}
|
2023-11-23 19:43:45 +00:00
|
|
|
$ids2fetch = ltrim($ids2fetch, ',');
|
2023-10-17 12:23:40 +00:00
|
|
|
if ($ids2fetch ?? '' !== '') {
|
2023-10-17 10:14:10 +00:00
|
|
|
$conditions[] = "qsos.COL_PRIMARY_KEY in (".$ids2fetch.")";
|
2023-10-17 12:23:40 +00:00
|
|
|
} else {
|
|
|
|
$conditions[] = "1=0";
|
2023-10-17 10:14:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-18 15:49:54 +00:00
|
|
|
if ($searchCriteria['dateFrom'] !== '') {
|
2023-11-17 16:24:24 +00:00
|
|
|
$from = $searchCriteria['dateFrom'];
|
2022-12-18 15:49:54 +00:00
|
|
|
$conditions[] = "date(COL_TIME_ON) >= ?";
|
|
|
|
$binding[] = $from;
|
|
|
|
}
|
|
|
|
if ($searchCriteria['dateTo'] !== '') {
|
2023-11-17 16:24:24 +00:00
|
|
|
$to = $searchCriteria['dateTo'];
|
2022-12-18 15:49:54 +00:00
|
|
|
$conditions[] = "date(COL_TIME_ON) <= ?";
|
|
|
|
$binding[] = $to;
|
|
|
|
}
|
|
|
|
if ($searchCriteria['de'] !== '') {
|
|
|
|
$conditions[] = "COL_STATION_CALLSIGN = ?";
|
|
|
|
$binding[] = trim($searchCriteria['de']);
|
|
|
|
}
|
|
|
|
if ($searchCriteria['dx'] !== '') {
|
|
|
|
$conditions[] = "COL_CALL LIKE ?";
|
|
|
|
$binding[] = '%' . trim($searchCriteria['dx']) . '%';
|
|
|
|
}
|
|
|
|
if ($searchCriteria['mode'] !== '') {
|
2022-12-27 17:56:04 +00:00
|
|
|
$conditions[] = "(COL_MODE = ? or COL_SUBMODE = ?)";
|
|
|
|
$binding[] = $searchCriteria['mode'];
|
|
|
|
$binding[] = $searchCriteria['mode'];
|
2022-12-18 15:49:54 +00:00
|
|
|
}
|
|
|
|
if ($searchCriteria['band'] !== '') {
|
2022-12-21 09:49:23 +00:00
|
|
|
if($searchCriteria['band'] != "SAT") {
|
|
|
|
$conditions[] = "COL_BAND = ? and COL_PROP_MODE != 'SAT'";
|
|
|
|
$binding[] = trim($searchCriteria['band']);
|
|
|
|
} else {
|
|
|
|
$conditions[] = "COL_PROP_MODE = 'SAT'";
|
2023-05-01 06:58:13 +00:00
|
|
|
if ($searchCriteria['sats'] !== 'All') {
|
|
|
|
$conditions[] = "COL_SAT_NAME = ?";
|
|
|
|
$binding[] = trim($searchCriteria['sats']);
|
|
|
|
}
|
2022-12-21 09:49:23 +00:00
|
|
|
}
|
2022-12-18 15:49:54 +00:00
|
|
|
}
|
|
|
|
if ($searchCriteria['qslSent'] !== '') {
|
2023-07-29 16:11:38 +00:00
|
|
|
$condition = "COL_QSL_SENT = ?";
|
|
|
|
if ($searchCriteria['qslSent'] == 'N') {
|
|
|
|
$condition = '('.$condition;
|
|
|
|
$condition .= " OR COL_QSL_SENT IS NULL OR COL_QSL_SENT = '')";
|
|
|
|
}
|
|
|
|
$conditions[] = $condition;
|
2022-12-18 15:49:54 +00:00
|
|
|
$binding[] = $searchCriteria['qslSent'];
|
|
|
|
}
|
|
|
|
if ($searchCriteria['qslReceived'] !== '') {
|
2023-07-29 16:11:38 +00:00
|
|
|
$condition = "COL_QSL_RCVD = ?";
|
|
|
|
if ($searchCriteria['qslReceived'] == 'N') {
|
|
|
|
$condition = '('.$condition;
|
|
|
|
$condition .= " OR COL_QSL_RCVD IS NULL OR COL_QSL_RCVD = '')";
|
|
|
|
}
|
|
|
|
$conditions[] = $condition;
|
2022-12-18 15:49:54 +00:00
|
|
|
$binding[] = $searchCriteria['qslReceived'];
|
|
|
|
}
|
2023-10-04 08:46:34 +00:00
|
|
|
|
2023-10-04 07:27:28 +00:00
|
|
|
if ($searchCriteria['qslSentMethod'] !== '') {
|
2023-10-04 11:40:43 +00:00
|
|
|
$condition = "COL_QSL_SENT_VIA = ?";
|
2023-10-03 23:28:11 +00:00
|
|
|
$conditions[] = $condition;
|
2023-10-04 11:40:43 +00:00
|
|
|
$binding[] = $searchCriteria['qslSentMethod'];
|
2023-10-04 07:27:28 +00:00
|
|
|
}
|
2023-10-04 08:46:34 +00:00
|
|
|
|
2023-10-04 07:27:28 +00:00
|
|
|
if ($searchCriteria['qslReceivedMethod'] !== '') {
|
2023-10-04 14:01:45 +00:00
|
|
|
$condition = "COL_QSL_RCVD_VIA = ?";
|
2023-10-04 07:27:28 +00:00
|
|
|
$conditions[] = $condition;
|
2023-10-04 11:40:43 +00:00
|
|
|
$binding[] = $searchCriteria['qslReceivedMethod'];
|
2023-10-03 23:28:11 +00:00
|
|
|
}
|
2023-10-04 08:46:34 +00:00
|
|
|
|
2023-06-29 16:59:12 +00:00
|
|
|
if ($searchCriteria['lotwSent'] !== '') {
|
2023-07-29 16:11:38 +00:00
|
|
|
$condition = "COL_LOTW_QSL_SENT = ?";
|
|
|
|
if ($searchCriteria['lotwSent'] == 'N') {
|
|
|
|
$condition = '('.$condition;
|
|
|
|
$condition .= " OR COL_LOTW_QSL_SENT IS NULL OR COL_LOTW_QSL_SENT = '')";
|
|
|
|
}
|
|
|
|
$conditions[] = $condition;
|
2023-06-29 16:59:12 +00:00
|
|
|
$binding[] = $searchCriteria['lotwSent'];
|
|
|
|
}
|
|
|
|
if ($searchCriteria['lotwReceived'] !== '') {
|
2023-07-29 16:11:38 +00:00
|
|
|
$condition = "COL_LOTW_QSL_RCVD = ?";
|
|
|
|
if ($searchCriteria['lotwReceived'] == 'N') {
|
|
|
|
$condition = '('.$condition;
|
|
|
|
$condition .= " OR COL_LOTW_QSL_RCVD IS NULL OR COL_LOTW_QSL_RCVD = '')";
|
|
|
|
}
|
|
|
|
$conditions[] = $condition;
|
2023-06-29 16:59:12 +00:00
|
|
|
$binding[] = $searchCriteria['lotwReceived'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($searchCriteria['eqslSent'] !== '') {
|
2023-08-14 04:03:46 +00:00
|
|
|
$condition = "COL_EQSL_QSL_SENT = ?";
|
2023-07-29 16:11:38 +00:00
|
|
|
if ($searchCriteria['eqslSent'] == 'N') {
|
|
|
|
$condition = '('.$condition;
|
2023-08-14 04:03:46 +00:00
|
|
|
$condition .= " OR COL_EQSL_QSL_SENT IS NULL OR COL_EQSL_QSL_SENT = '')";
|
2023-07-29 16:11:38 +00:00
|
|
|
}
|
|
|
|
$conditions[] = $condition;
|
2023-06-29 16:59:12 +00:00
|
|
|
$binding[] = $searchCriteria['eqslSent'];
|
|
|
|
}
|
|
|
|
if ($searchCriteria['eqslReceived'] !== '') {
|
2023-08-14 04:03:46 +00:00
|
|
|
$condition = "COL_EQSL_QSL_RCVD = ?";
|
2023-07-29 16:11:38 +00:00
|
|
|
if ($searchCriteria['eqslReceived'] == 'N') {
|
|
|
|
$condition = '('.$condition;
|
2023-08-14 04:03:46 +00:00
|
|
|
$condition .= " OR COL_EQSL_QSL_RCVD IS NULL OR COL_EQSL_QSL_RCVD = '')";
|
2023-07-29 16:11:38 +00:00
|
|
|
}
|
|
|
|
$conditions[] = $condition;
|
2023-06-29 16:59:12 +00:00
|
|
|
$binding[] = $searchCriteria['eqslReceived'];
|
|
|
|
}
|
|
|
|
|
2022-12-18 15:49:54 +00:00
|
|
|
if ($searchCriteria['iota'] !== '') {
|
|
|
|
$conditions[] = "COL_IOTA = ?";
|
|
|
|
$binding[] = $searchCriteria['iota'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($searchCriteria['dxcc'] !== '') {
|
|
|
|
$conditions[] = "COL_DXCC = ?";
|
|
|
|
$binding[] = $searchCriteria['dxcc'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($searchCriteria['state'] !== '') {
|
|
|
|
$conditions[] = "COL_STATE = ?";
|
|
|
|
$binding[] = $searchCriteria['state'];
|
|
|
|
}
|
|
|
|
|
2023-07-05 07:29:13 +00:00
|
|
|
if ($searchCriteria['cqzone'] !== '') {
|
|
|
|
$conditions[] = "COL_CQZ = ?";
|
|
|
|
$binding[] = $searchCriteria['cqzone'];
|
|
|
|
}
|
|
|
|
|
2023-07-07 08:03:52 +00:00
|
|
|
if ($searchCriteria['qslvia'] !== '') {
|
|
|
|
$conditions[] = "COL_QSL_VIA like ?";
|
|
|
|
$binding[] = $searchCriteria['qslvia'].'%';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($searchCriteria['sota'] !== '') {
|
|
|
|
$conditions[] = "COL_SOTA_REF like ?";
|
|
|
|
$binding[] = $searchCriteria['sota'].'%';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($searchCriteria['pota'] !== '') {
|
|
|
|
$conditions[] = "COL_POTA_REF like ?";
|
|
|
|
$binding[] = $searchCriteria['pota'].'%';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($searchCriteria['wwff'] !== '') {
|
|
|
|
$conditions[] = "COL_WWFF_REF like ?";
|
|
|
|
$binding[] = $searchCriteria['wwff'].'%';
|
|
|
|
}
|
|
|
|
|
2023-12-04 13:21:59 +00:00
|
|
|
if ($searchCriteria['operator'] !== '') {
|
|
|
|
$conditions[] = "COL_OPERATOR like ?";
|
|
|
|
$binding[] = $searchCriteria['operator'].'%';
|
|
|
|
}
|
|
|
|
|
2022-12-18 15:49:54 +00:00
|
|
|
if ($searchCriteria['gridsquare'] !== '') {
|
|
|
|
$conditions[] = "(COL_GRIDSQUARE like ? or COL_VUCC_GRIDS like ?)";
|
|
|
|
$binding[] = '%' . $searchCriteria['gridsquare'] . '%';
|
|
|
|
$binding[] = '%' . $searchCriteria['gridsquare'] . '%';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($searchCriteria['propmode'] !== '') {
|
|
|
|
$conditions[] = "COL_PROP_MODE = ?";
|
|
|
|
$binding[] = $searchCriteria['propmode'];
|
2023-05-08 18:27:53 +00:00
|
|
|
if($searchCriteria['propmode'] == "SAT") {
|
|
|
|
if ($searchCriteria['sats'] !== 'All') {
|
|
|
|
$conditions[] = "COL_SAT_NAME = ?";
|
|
|
|
$binding[] = trim($searchCriteria['sats']);
|
|
|
|
}
|
|
|
|
}
|
2022-12-18 15:49:54 +00:00
|
|
|
}
|
2023-05-01 06:58:13 +00:00
|
|
|
|
2023-08-21 12:18:05 +00:00
|
|
|
if (($searchCriteria['ids'] ?? '') !== '') {
|
|
|
|
$conditions[] = "qsos.COL_PRIMARY_KEY in (".implode(",",$searchCriteria['ids']).")";
|
|
|
|
}
|
|
|
|
|
2022-12-18 15:49:54 +00:00
|
|
|
$where = trim(implode(" AND ", $conditions));
|
|
|
|
if ($where != "") {
|
|
|
|
$where = "AND $where";
|
|
|
|
}
|
|
|
|
|
2022-12-19 17:20:55 +00:00
|
|
|
$limit = $searchCriteria['qsoresults'];
|
2022-12-18 15:49:54 +00:00
|
|
|
|
2023-08-11 17:13:13 +00:00
|
|
|
$where2 = '';
|
|
|
|
|
|
|
|
if ($searchCriteria['qslimages'] !== '') {
|
|
|
|
if ($searchCriteria['qslimages'] == 'Y') {
|
|
|
|
$where2 .= ' and x.qslcount > "0"';
|
|
|
|
}
|
|
|
|
if ($searchCriteria['qslimages'] == 'N') {
|
|
|
|
$where2 .= ' and x.qslcount is null';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-18 15:49:54 +00:00
|
|
|
$sql = "
|
2023-09-07 13:36:01 +00:00
|
|
|
SELECT *
|
2022-12-18 15:49:54 +00:00
|
|
|
FROM " . $this->config->item('table_name') . " qsos
|
|
|
|
INNER JOIN station_profile ON qsos.station_id=station_profile.station_id
|
2023-09-07 12:54:14 +00:00
|
|
|
LEFT OUTER JOIN dxcc_entities ON qsos.col_dxcc=dxcc_entities.adif
|
2023-05-26 08:38:31 +00:00
|
|
|
LEFT OUTER JOIN lotw_users ON qsos.col_call=lotw_users.callsign
|
2023-06-30 21:36:35 +00:00
|
|
|
LEFT OUTER JOIN (
|
|
|
|
select count(*) as qslcount, qsoid
|
|
|
|
from qsl_images
|
|
|
|
group by qsoid
|
|
|
|
) x on qsos.COL_PRIMARY_KEY = x.qsoid
|
2022-12-18 15:49:54 +00:00
|
|
|
WHERE station_profile.user_id = ?
|
|
|
|
$where
|
2023-08-11 17:13:13 +00:00
|
|
|
$where2
|
2023-01-25 23:57:38 +00:00
|
|
|
ORDER BY qsos.COL_TIME_ON desc, qsos.COL_PRIMARY_KEY desc
|
2022-12-18 15:49:54 +00:00
|
|
|
LIMIT $limit
|
|
|
|
";
|
|
|
|
$data = $this->db->query($sql, $binding);
|
|
|
|
|
|
|
|
$results = $data->result('array');
|
2023-08-18 18:02:47 +00:00
|
|
|
return $results;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @param array $searchCriteria
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function searchQsos($searchCriteria) : array {
|
|
|
|
$results = $this->searchDb($searchCriteria);
|
|
|
|
|
2022-12-18 15:49:54 +00:00
|
|
|
$qsos = [];
|
|
|
|
foreach ($results as $data) {
|
|
|
|
$qsos[] = new QSO($data);
|
|
|
|
}
|
2023-07-07 08:03:52 +00:00
|
|
|
|
2023-08-18 18:02:47 +00:00
|
|
|
return $qsos;
|
2022-12-18 15:49:54 +00:00
|
|
|
}
|
|
|
|
|
2023-05-02 11:46:23 +00:00
|
|
|
public function getQsosForAdif($ids, $user_id, $sortorder = null) : object {
|
2022-12-18 15:49:54 +00:00
|
|
|
$binding = [$user_id];
|
|
|
|
$conditions[] = "COL_PRIMARY_KEY in ?";
|
|
|
|
$binding[] = json_decode($ids, true);
|
|
|
|
|
|
|
|
$where = trim(implode(" AND ", $conditions));
|
|
|
|
if ($where != "") {
|
|
|
|
$where = "AND $where";
|
|
|
|
}
|
|
|
|
|
2023-05-02 18:53:29 +00:00
|
|
|
$order = $this->getSortorder($sortorder);
|
2023-05-02 11:46:23 +00:00
|
|
|
|
2022-12-18 15:49:54 +00:00
|
|
|
$sql = "
|
2023-06-30 21:36:35 +00:00
|
|
|
SELECT qsos.*, d2.*, lotw_users.*, station_profile.*, x.qslcount, dxcc_entities.name AS station_country
|
2022-12-18 15:49:54 +00:00
|
|
|
FROM " . $this->config->item('table_name') . " qsos
|
|
|
|
INNER JOIN station_profile ON qsos.station_id = station_profile.station_id
|
2023-04-28 13:14:59 +00:00
|
|
|
LEFT OUTER JOIN dxcc_entities ON qsos.COL_MY_DXCC = dxcc_entities.adif
|
2023-06-28 07:17:48 +00:00
|
|
|
LEFT OUTER JOIN dxcc_entities d2 ON qsos.COL_DXCC = d2.adif
|
2023-06-28 06:27:44 +00:00
|
|
|
LEFT OUTER JOIN lotw_users ON qsos.col_call=lotw_users.callsign
|
2023-06-30 21:36:35 +00:00
|
|
|
LEFT OUTER JOIN (
|
|
|
|
select count(*) as qslcount, qsoid
|
|
|
|
from qsl_images
|
|
|
|
group by qsoid
|
|
|
|
) x on qsos.COL_PRIMARY_KEY = x.qsoid
|
2022-12-18 15:49:54 +00:00
|
|
|
WHERE station_profile.user_id = ?
|
|
|
|
$where
|
2023-05-01 10:35:24 +00:00
|
|
|
$order
|
2022-12-18 15:49:54 +00:00
|
|
|
";
|
|
|
|
|
|
|
|
return $this->db->query($sql, $binding);
|
|
|
|
}
|
|
|
|
|
2023-05-02 18:53:29 +00:00
|
|
|
public function getSortOrder($sortorder) {
|
|
|
|
if ($sortorder == null) {
|
|
|
|
return 'ORDER BY qsos.COL_TIME_ON desc';
|
|
|
|
} else {
|
|
|
|
$sortorder = explode(',', $sortorder);
|
|
|
|
|
|
|
|
if ($this->session->userdata('user_lotw_name') != "" && $this->session->userdata('user_eqsl_name') != ""){
|
|
|
|
switch($sortorder[0]) {
|
|
|
|
case 1: return 'ORDER BY qsos.COL_TIME_ON ' . $sortorder[1];
|
|
|
|
case 2: return 'ORDER BY station_profile.station_callsign ' . $sortorder[1];
|
|
|
|
case 3: return 'ORDER BY qsos.COL_CALL ' . $sortorder[1];
|
|
|
|
case 4: return 'ORDER BY qsos.COL_MODE' . $sortorder[1] . ', qsos.COL_SUBMODE ' . $sortorder[1];
|
|
|
|
case 7: return 'ORDER BY qsos.COL_BAND ' . $sortorder[1] . ', qsos.COL_SAT_NAME ' . $sortorder[1];
|
|
|
|
case 16: return 'ORDER BY qsos.COL_COUNTRY ' . $sortorder[1];
|
|
|
|
case 17: return 'ORDER BY qso.COL_STATE ' . $sortorder[1];
|
|
|
|
case 18: return 'ORDER BY qsos.COL_CQZ ' . $sortorder[1];
|
|
|
|
case 19: return 'ORDER BY qsos.COL_IOTA ' . $sortorder[1];
|
|
|
|
default: return 'ORDER BY qsos.COL_TIME_ON desc';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (($this->session->userdata('user_eqsl_name') != "" && $this->session->userdata('user_lotw_name') == "") || ($this->session->userdata('user_eqsl_name') == "" && $this->session->userdata('user_lotw_name') != "")) {
|
|
|
|
switch($sortorder[0]) {
|
|
|
|
case 1: return 'ORDER BY qsos.COL_TIME_ON ' . $sortorder[1];
|
|
|
|
case 2: return 'ORDER BY station_profile.station_callsign ' . $sortorder[1];
|
|
|
|
case 3: return 'ORDER BY qsos.COL_CALL ' . $sortorder[1];
|
|
|
|
case 4: return 'ORDER BY qsos.COL_MODE' . $sortorder[1] . ', qsos.COL_SUBMODE ' . $sortorder[1];
|
|
|
|
case 7: return 'ORDER BY qsos.COL_BAND ' . $sortorder[1] . ', qsos.COL_SAT_NAME ' . $sortorder[1];
|
|
|
|
case 15: return 'ORDER BY qsos.COL_COUNTRY ' . $sortorder[1];
|
|
|
|
case 16: return 'ORDER BY qso.COL_STATE ' . $sortorder[1];
|
|
|
|
case 17: return 'ORDER BY qsos.COL_CQZ ' . $sortorder[1];
|
|
|
|
case 18: return 'ORDER BY qsos.COL_IOTA ' . $sortorder[1];
|
|
|
|
default: return 'ORDER BY qsos.COL_TIME_ON desc';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if ($this->session->userdata('user_eqsl_name') == "" && $this->session->userdata('user_lotw_name') == ""){
|
|
|
|
switch($sortorder[0]) {
|
|
|
|
case 1: return 'ORDER BY qsos.COL_TIME_ON ' . $sortorder[1];
|
|
|
|
case 2: return 'ORDER BY station_profile.station_callsign ' . $sortorder[1];
|
|
|
|
case 3: return 'ORDER BY qsos.COL_CALL ' . $sortorder[1];
|
|
|
|
case 4: return 'ORDER BY qsos.COL_MODE' . $sortorder[1] . ', qsos.COL_SUBMODE ' . $sortorder[1];
|
|
|
|
case 7: return 'ORDER BY qsos.COL_BAND ' . $sortorder[1] . ', qsos.COL_SAT_NAME ' . $sortorder[1];
|
|
|
|
case 14: return 'ORDER BY qsos.COL_COUNTRY ' . $sortorder[1];
|
|
|
|
case 15: return 'ORDER BY qso.COL_STATE ' . $sortorder[1];
|
|
|
|
case 16: return 'ORDER BY qsos.COL_CQZ ' . $sortorder[1];
|
|
|
|
case 17: return 'ORDER BY qsos.COL_IOTA ' . $sortorder[1];
|
|
|
|
default: return 'ORDER BY qsos.COL_TIME_ON desc';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-14 07:44:36 +00:00
|
|
|
public function updateQsl($ids, $user_id, $method, $sent) {
|
|
|
|
$this->load->model('user_model');
|
2022-12-18 15:49:54 +00:00
|
|
|
|
2023-12-14 07:44:36 +00:00
|
|
|
if(!$this->user_model->authorize(2)) {
|
|
|
|
return array('message' => 'Error');
|
|
|
|
} else {
|
|
|
|
if ($method != '') {
|
|
|
|
$data = array(
|
|
|
|
'COL_QSLSDATE' => date('Y-m-d H:i:s'),
|
|
|
|
'COL_QSL_SENT' => $sent,
|
|
|
|
'COL_QSL_SENT_VIA' => $method
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
$data = array(
|
|
|
|
'COL_QSLSDATE' => date('Y-m-d H:i:s'),
|
|
|
|
'COL_QSL_SENT' => $sent,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
$this->db->where_in('COL_PRIMARY_KEY', json_decode($ids, true));
|
|
|
|
$this->db->update($this->config->item('table_name'), $data);
|
2023-07-07 08:03:52 +00:00
|
|
|
|
2023-12-14 07:44:36 +00:00
|
|
|
return array('message' => 'OK');
|
|
|
|
}
|
|
|
|
}
|
2022-12-20 21:23:22 +00:00
|
|
|
|
2023-06-28 06:27:44 +00:00
|
|
|
public function updateQslReceived($ids, $user_id, $method, $sent) {
|
|
|
|
$this->load->model('user_model');
|
|
|
|
|
|
|
|
if(!$this->user_model->authorize(2)) {
|
|
|
|
return array('message' => 'Error');
|
|
|
|
} else {
|
|
|
|
$data = array(
|
|
|
|
'COL_QSLRDATE' => date('Y-m-d H:i:s'),
|
|
|
|
'COL_QSL_RCVD' => $sent,
|
|
|
|
'COL_QSL_RCVD_VIA' => $method
|
|
|
|
);
|
|
|
|
$this->db->where_in('COL_PRIMARY_KEY', json_decode($ids, true));
|
|
|
|
$this->db->update($this->config->item('table_name'), $data);
|
2023-07-07 08:03:52 +00:00
|
|
|
|
2023-06-28 06:27:44 +00:00
|
|
|
return array('message' => 'OK');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-20 21:23:22 +00:00
|
|
|
public function updateQsoWithCallbookInfo($qsoID, $qso, $callbook) {
|
|
|
|
$updatedData = array();
|
|
|
|
if (!empty($callbook['name']) && empty($qso['COL_NAME'])) {
|
|
|
|
$updatedData['COL_NAME'] = $callbook['name'];
|
|
|
|
}
|
|
|
|
if (!empty($callbook['gridsquare']) && empty($qso['COL_GRIDSQUARE']) && empty($qso['COL_VUCC_GRIDS'] )) {
|
|
|
|
if (strpos(trim($callbook['gridsquare']), ',') === false) {
|
|
|
|
$updatedData['COL_GRIDSQUARE'] = strtoupper(trim($callbook['gridsquare']));
|
|
|
|
} else {
|
|
|
|
$updatedData['COL_VUCC_GRIDS'] = strtoupper(trim($callbook['gridsquare']));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!empty($callbook['city']) && empty($qso['COL_QTH'])) {
|
|
|
|
$updatedData['COL_QTH'] = $callbook['city'];
|
|
|
|
}
|
|
|
|
if (!empty($callbook['lat']) && empty($qso['COL_LAT'])) {
|
|
|
|
$updatedData['COL_LAT'] = $callbook['lat'];
|
|
|
|
}
|
|
|
|
if (!empty($callbook['long']) && empty($qso['COL_LON'])) {
|
|
|
|
$updatedData['COL_LON'] = $callbook['long'];
|
|
|
|
}
|
|
|
|
if (!empty($callbook['iota']) && empty($qso['COL_IOTA'])) {
|
|
|
|
$updatedData['COL_IOTA'] = $callbook['iota'];
|
|
|
|
}
|
|
|
|
if (!empty($callbook['state']) && empty($qso['COL_STATE'])) {
|
|
|
|
$updatedData['COL_STATE'] = $callbook['state'];
|
|
|
|
}
|
|
|
|
if (!empty($callbook['us_county']) && empty($qso['COL_USACA_COUNTIES'])) {
|
|
|
|
$updatedData['COL_USACA_COUNTIES'] = $callbook['us_county'];
|
|
|
|
}
|
|
|
|
if (!empty($callbook['qslmgr']) && empty($qso['COL_QSL_VIA'])) {
|
|
|
|
$updatedData['COL_QSL_VIA'] = $callbook['qslmgr'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (count($updatedData) > 0) {
|
|
|
|
$this->db->where('COL_PRIMARY_KEY', $qsoID);
|
|
|
|
$this->db->update($this->config->item('table_name'), $updatedData);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2022-12-27 17:56:04 +00:00
|
|
|
|
|
|
|
function get_modes() {
|
|
|
|
$CI =& get_instance();
|
|
|
|
$CI->load->model('logbooks_model');
|
|
|
|
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
2023-07-07 08:03:52 +00:00
|
|
|
|
2022-12-27 17:56:04 +00:00
|
|
|
if (!$logbooks_locations_array) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
$modes = array();
|
2023-07-07 08:03:52 +00:00
|
|
|
|
2022-12-27 17:56:04 +00:00
|
|
|
$this->db->select('distinct col_mode, coalesce(col_submode, "") col_submode', FALSE);
|
|
|
|
$this->db->where_in('station_id', $logbooks_locations_array);
|
|
|
|
$this->db->order_by('col_mode, col_submode', 'ASC');
|
|
|
|
|
|
|
|
$query = $this->db->get($this->config->item('table_name'));
|
2023-07-07 08:03:52 +00:00
|
|
|
|
2022-12-27 17:56:04 +00:00
|
|
|
foreach($query->result() as $mode){
|
|
|
|
if ($mode->col_submode == null || $mode->col_submode == "") {
|
|
|
|
array_push($modes, $mode->col_mode);
|
|
|
|
} else {
|
2023-02-10 16:02:40 +00:00
|
|
|
// Make sure we don't add LSB or USB as submodes in the array list
|
|
|
|
if ($mode->col_mode != "SSB") {
|
|
|
|
array_push($modes, $mode->col_submode);
|
|
|
|
}
|
2022-12-27 17:56:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $modes;
|
|
|
|
}
|
2023-08-11 17:13:13 +00:00
|
|
|
|
|
|
|
function getQslsForQsoIds($ids) {
|
|
|
|
$CI =& get_instance();
|
|
|
|
$CI->load->model('logbooks_model');
|
|
|
|
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
|
|
|
|
|
|
|
$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');
|
|
|
|
$this->db->where_in('qsoid', $ids);
|
|
|
|
$this->db->where_in('station_id', $logbooks_locations_array);
|
|
|
|
$this->db->order_by("id", "desc");
|
|
|
|
|
|
|
|
return $this->db->get()->result();
|
|
|
|
}
|
2023-10-04 12:46:18 +00:00
|
|
|
}
|