Cloudlog/application/models/Activators_model.php
phl0 22e74b55e4
Add table for (VUCC) gridsquare activators top list
Squashed commit of the following:

commit 1091c0321e49b37f29d2997ff28051f137efc53f
Author: phl0 <florian@florian-wolters.de>
Date:   Tue Mar 22 17:31:08 2022 +0100

    Also take VUCC_GRIDS into account

commit c396e87c78e659c98c86ebf96ce21ba9a34203d0
Author: phl0 <florian@florian-wolters.de>
Date:   Thu Jan 27 23:19:39 2022 +0100

    Add ShowQSO function for detailed view

commit 52d3ef9b60de6a82c9239e6be387aa35050db203
Author: phl0 <florian@florian-wolters.de>
Date:   Thu Jan 27 20:59:58 2022 +0100

    Distinguish between LEO and GEO in SAT selection

commit 019d1d71bf3f06abbd38c65b0278c52c785bf407
Author: phl0 <florian@florian-wolters.de>
Date:   Thu Jan 27 19:57:48 2022 +0100

    Make sure mincount is numeric

commit 3802f9269d7e6bae7891e814909bd364afbfdf73
Author: phl0 <florian@florian-wolters.de>
Date:   Thu Jan 27 00:37:35 2022 +0100

    Implement optional minimin grid count

commit d206f2429d2bbaab1336c2266e7036e2ea77718d
Author: phl0 <florian@florian-wolters.de>
Date:   Wed Jan 26 23:21:55 2022 +0100

    Add table showing gridsquare activators
2022-03-22 17:41:03 +01:00

117 行
4.3 KiB
PHP

<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
class Activators_model extends CI_Model
{
function get_activators($band, $mincount, $leogeo) {
$CI =& get_instance();
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
if ($mincount == '' || $mincount == 0 || ! is_numeric($mincount)) {
$mincount = 2;
}
if (!$logbooks_locations_array) {
return null;
}
$location_list = "'".implode("','",$logbooks_locations_array)."'";
$sql = "select COL_CALL as `call`, COUNT(DISTINCT(SUBSTR(COL_GRIDSQUARE,1,4))) AS `count`, GROUP_CONCAT(DISTINCT SUBSTR(`COL_GRIDSQUARE`,1,4) ORDER BY `COL_GRIDSQUARE` SEPARATOR ', ') AS `grids` from ".$this->config->item('table_name')." WHERE station_id in (" . $location_list . ")";
if ($band != 'All') {
if ($band == 'SAT') {
switch ($leogeo) {
case 'both' :
$sql .= " and col_prop_mode ='" . $band . "'";
break;
case 'leo' :
$sql .= " and col_prop_mode = '" . $band . "'";
$sql .= " and col_sat_name != 'QO-100'";
break;
case 'geo' :
$sql .= " and col_prop_mode = '" . $band . "'";
$sql .= " and col_sat_name = 'QO-100'";
break;
default :
$sql .= " and col_prop_mode ='" . $band . "'";
break;
}
}
else {
$sql .= " and col_prop_mode !='SAT'";
$sql .= " and COL_BAND ='" . $band . "'";
}
}
$sql .= " AND `COL_GRIDSQUARE` != '' GROUP BY `COL_CALL` HAVING `count` >= ".$mincount." ORDER BY `count` DESC;";
$query = $this->db->query($sql);
return $query->result();
}
function get_activators_vucc($band, $leogeo) {
$CI =& get_instance();
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
if (!$logbooks_locations_array) {
return null;
}
$location_list = "'".implode("','",$logbooks_locations_array)."'";
$sql = "SELECT DISTINCT COL_CALL AS `call`, GROUP_CONCAT(REGEXP_REPLACE(COL_VUCC_GRIDS, '([A-Z]{2}[0-9]{2})[A-Z]{2}', '$1')) AS `vucc_grids` FROM ".$this->config->item('table_name')." WHERE station_id in (" . $location_list . ")";
if ($band != 'All') {
if ($band == 'SAT') {
switch ($leogeo) {
case 'both' :
$sql .= " and col_prop_mode ='" . $band . "'";
break;
case 'leo' :
$sql .= " and col_prop_mode = '" . $band . "'";
$sql .= " and col_sat_name != 'QO-100'";
break;
case 'geo' :
$sql .= " and col_prop_mode = '" . $band . "'";
$sql .= " and col_sat_name = 'QO-100'";
break;
default :
$sql .= " and col_prop_mode ='" . $band . "'";
break;
}
}
else {
$sql .= " and col_prop_mode !='SAT'";
$sql .= " and COL_BAND ='" . $band . "'";
}
}
$sql .= " AND COL_VUCC_GRIDS != '' GROUP BY COL_CALL;";
$query = $this->db->query($sql);
return $query->result();
}
function get_max_activated_grids() {
$CI =& get_instance();
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
if (!$logbooks_locations_array) {
return array();
}
$location_list = "'".implode("','",$logbooks_locations_array)."'";
// Get max no of activated grids of single operator
$data = $this->db->query(
"select COUNT(DISTINCT(SUBSTR(COL_GRIDSQUARE,1,4))) AS `count` from TABLE_HRD_CONTACTS_V01 WHERE station_id in (" . $location_list . ") AND `COL_GRIDSQUARE` != '' GROUP BY `COL_CALL` ORDER BY `count` DESC LIMIT 1"
);
foreach($data->result() as $row){
$max = $row->count;
}
return $max;
}
}