mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
formatted code
This commit is contained in:
@@ -1,14 +1,18 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
class Activators extends CI_Controller {
|
||||
class Activators extends CI_Controller
|
||||
{
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$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'); }
|
||||
if (!$this->user_model->authorize(2)) {
|
||||
$this->session->set_flashdata('notice', 'You\'re not allowed to do that!');
|
||||
redirect('dashboard');
|
||||
}
|
||||
}
|
||||
|
||||
public function index()
|
||||
@@ -20,8 +24,7 @@ class Activators extends CI_Controller {
|
||||
|
||||
if ($this->input->post('band') != NULL) { // Band is not set when page first loads.
|
||||
$band = $this->input->post('band');
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$band = 'All';
|
||||
}
|
||||
|
||||
@@ -38,38 +41,44 @@ class Activators extends CI_Controller {
|
||||
$this->load->view('interface_assets/footer');
|
||||
}
|
||||
|
||||
public function details() {
|
||||
public function details()
|
||||
{
|
||||
$this->load->model('logbook_model');
|
||||
|
||||
$call = str_replace('"', "", $this->input->post("Callsign"));
|
||||
$band = str_replace('"', "", $this->input->post("Band"));
|
||||
$leogeo = str_replace('"', "", $this->input->post("LeoGeo"));
|
||||
$data['results'] = $this->logbook_model->activator_details($call, $band, $leogeo);
|
||||
$data['filter'] = "Call ".$call;
|
||||
switch($band) {
|
||||
case 'All': $data['page_title'] = "Log View All Bands";
|
||||
$data['filter'] .= " and Band All";
|
||||
break;
|
||||
case 'SAT': $data['page_title'] = "Log View SAT";
|
||||
$data['filter'] .= " and Band SAT";
|
||||
break;
|
||||
default: $data['page_title'] = "Log View Band";
|
||||
$data['filter'] .= " and Band ".$band;
|
||||
break;
|
||||
$data['filter'] = "Call " . $call;
|
||||
switch ($band) {
|
||||
case 'All':
|
||||
$data['page_title'] = "Log View All Bands";
|
||||
$data['filter'] .= " and Band All";
|
||||
break;
|
||||
case 'SAT':
|
||||
$data['page_title'] = "Log View SAT";
|
||||
$data['filter'] .= " and Band SAT";
|
||||
break;
|
||||
default:
|
||||
$data['page_title'] = "Log View Band";
|
||||
$data['filter'] .= " and Band " . $band;
|
||||
break;
|
||||
}
|
||||
if ($band == "SAT") {
|
||||
switch($leogeo) {
|
||||
case 'both': $data['filter'] .= " and GEO/LEO";
|
||||
break;
|
||||
case 'leo': $data['filter'] .= " and LEO";
|
||||
break;
|
||||
case 'geo': $data['filter'] .= " and GEO";
|
||||
break;
|
||||
switch ($leogeo) {
|
||||
case 'both':
|
||||
$data['filter'] .= " and GEO/LEO";
|
||||
break;
|
||||
case 'leo':
|
||||
$data['filter'] .= " and LEO";
|
||||
break;
|
||||
case 'geo':
|
||||
$data['filter'] .= " and GEO";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->load->view('activators/details', $data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,115 +3,115 @@ 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'));
|
||||
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)) {
|
||||
if ($mincount == '' || $mincount == 0 || !is_numeric($mincount)) {
|
||||
$mincount = 2;
|
||||
}
|
||||
|
||||
if (!$logbooks_locations_array) {
|
||||
return null;
|
||||
}
|
||||
if (!$logbooks_locations_array) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$location_list = "'".implode("','",$logbooks_locations_array)."'";
|
||||
$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 = "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' :
|
||||
case 'leo':
|
||||
$sql .= " and col_prop_mode = '" . $band . "'";
|
||||
$sql .= " and col_sat_name != 'QO-100'";
|
||||
break;
|
||||
case 'geo' :
|
||||
case 'geo':
|
||||
$sql .= " and col_prop_mode = '" . $band . "'";
|
||||
$sql .= " and col_sat_name = 'QO-100'";
|
||||
break;
|
||||
default :
|
||||
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;";
|
||||
} 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);
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->result();
|
||||
}
|
||||
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'));
|
||||
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;
|
||||
}
|
||||
if (!$logbooks_locations_array) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$location_list = "'".implode("','",$logbooks_locations_array)."'";
|
||||
$location_list = "'" . implode("','", $logbooks_locations_array) . "'";
|
||||
|
||||
$sql = "SELECT DISTINCT COL_CALL AS `call`, GROUP_CONCAT(COL_VUCC_GRIDS) 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 = "SELECT DISTINCT COL_CALL AS `call`, GROUP_CONCAT(COL_VUCC_GRIDS) 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' :
|
||||
case 'leo':
|
||||
$sql .= " and col_prop_mode = '" . $band . "'";
|
||||
$sql .= " and col_sat_name != 'QO-100'";
|
||||
break;
|
||||
case 'geo' :
|
||||
case 'geo':
|
||||
$sql .= " and col_prop_mode = '" . $band . "'";
|
||||
$sql .= " and col_sat_name = 'QO-100'";
|
||||
break;
|
||||
default :
|
||||
default:
|
||||
$sql .= " and col_prop_mode ='" . $band . "'";
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$sql .= " and col_prop_mode !='SAT'";
|
||||
$sql .= " and COL_BAND ='" . $band . "'";
|
||||
}
|
||||
}
|
||||
} 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);
|
||||
$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'));
|
||||
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();
|
||||
}
|
||||
if (!$logbooks_locations_array) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$location_list = "'".implode("','",$logbooks_locations_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 " . $this->config->item('table_name') . " 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 ?? 0);
|
||||
}
|
||||
// Get max no of activated grids of single operator
|
||||
$data = $this->db->query(
|
||||
"select COUNT(DISTINCT(SUBSTR(COL_GRIDSQUARE,1,4))) AS `count` from " . $this->config->item('table_name') . " 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 ?? 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,59 +3,59 @@
|
||||
|
||||
<form class="form" action="<?php echo site_url('activators'); ?>" method="post" enctype="multipart/form-data">
|
||||
<!-- Select Basic -->
|
||||
<div class="mb-3 row">
|
||||
<label class="col-md-1 control-label" for="band"><?php echo lang('gen_hamradio_band'); ?></label>
|
||||
<div class="col-md-3">
|
||||
<select id="band" name="band" class="form-select">
|
||||
<option value="All" <?php if ($this->input->post('band') == "All" || $this->input->method() !== 'post') echo ' selected'; ?> ><?php echo lang('general_word_all'); ?></option>
|
||||
<?php foreach($worked_bands as $band) {
|
||||
echo '<option value="' . $band . '"';
|
||||
if ($this->input->post('band') == $band) echo ' selected';
|
||||
echo '>' . $band . '</option>'."\n";
|
||||
} ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3 row" id="leogeo">
|
||||
<label class="col-md-1 control-label" for="leogeo">LEO/GEO</label>
|
||||
<div class="col-md-3">
|
||||
<select id="leogeo" name="leogeo" class="form-select">
|
||||
<option value="both" <?php if ($this->input->post('leogeo') == "both" || $this->input->method() !== 'post') echo ' selected'; ?> >Both</option>
|
||||
<option value="leo" <?php if ($this->input->post('leogeo') == "leo") echo ' selected'; ?>>LEO</option>
|
||||
<option value="geo" <?php if ($this->input->post('leogeo') == "geo") echo ' selected'; ?>>GEO</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3 row">
|
||||
<label class="col-md-1 control-label" for="mincount"><?php echo lang('gridsquares_minimum_count'); ?></label>
|
||||
<div class="col-md-3">
|
||||
<select id="mincount" name="mincount" class="form-select">
|
||||
<?php
|
||||
$i = 1;
|
||||
do {
|
||||
echo '<option value="'.$i.'"';
|
||||
if ($this->input->post('mincount') == $i || ($this->input->method() !== 'post' && $i == 2)) echo ' selected';
|
||||
echo '>'.$i.'</option>'."\n";
|
||||
$i++;
|
||||
} while ($i <= $maxactivatedgrids);
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="mb-3 row">
|
||||
<label class="col-md-1 control-label" for="button1id"></label>
|
||||
<div class="col-md-10">
|
||||
<button id="button1id" type="submit" name="button1id" class="btn btn-primary"><?php echo lang('filter_options_show'); ?></button>
|
||||
</div>
|
||||
<div class="mb-3 row">
|
||||
<label class="col-md-1 control-label" for="band"><?php echo lang('gen_hamradio_band'); ?></label>
|
||||
<div class="col-md-3">
|
||||
<select id="band" name="band" class="form-select">
|
||||
<option value="All" <?php if ($this->input->post('band') == "All" || $this->input->method() !== 'post') echo ' selected'; ?>><?php echo lang('general_word_all'); ?></option>
|
||||
<?php foreach ($worked_bands as $band) {
|
||||
echo '<option value="' . $band . '"';
|
||||
if ($this->input->post('band') == $band) echo ' selected';
|
||||
echo '>' . $band . '</option>' . "\n";
|
||||
} ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3 row" id="leogeo">
|
||||
<label class="col-md-1 control-label" for="leogeo">LEO/GEO</label>
|
||||
<div class="col-md-3">
|
||||
<select id="leogeo" name="leogeo" class="form-select">
|
||||
<option value="both" <?php if ($this->input->post('leogeo') == "both" || $this->input->method() !== 'post') echo ' selected'; ?>>Both</option>
|
||||
<option value="leo" <?php if ($this->input->post('leogeo') == "leo") echo ' selected'; ?>>LEO</option>
|
||||
<option value="geo" <?php if ($this->input->post('leogeo') == "geo") echo ' selected'; ?>>GEO</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3 row">
|
||||
<label class="col-md-1 control-label" for="mincount"><?php echo lang('gridsquares_minimum_count'); ?></label>
|
||||
<div class="col-md-3">
|
||||
<select id="mincount" name="mincount" class="form-select">
|
||||
<?php
|
||||
$i = 1;
|
||||
do {
|
||||
echo '<option value="' . $i . '"';
|
||||
if ($this->input->post('mincount') == $i || ($this->input->method() !== 'post' && $i == 2)) echo ' selected';
|
||||
echo '>' . $i . '</option>' . "\n";
|
||||
$i++;
|
||||
} while ($i <= $maxactivatedgrids);
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="mb-3 row">
|
||||
<label class="col-md-1 control-label" for="button1id"></label>
|
||||
<div class="col-md-10">
|
||||
<button id="button1id" type="submit" name="button1id" class="btn btn-primary"><?php echo lang('filter_options_show'); ?></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<?php
|
||||
<?php
|
||||
// Get Date format
|
||||
if($this->session->userdata('user_date_format')) {
|
||||
if ($this->session->userdata('user_date_format')) {
|
||||
// If Logged in and session exists
|
||||
$custom_date_format = $this->session->userdata('user_date_format');
|
||||
} else {
|
||||
@@ -63,19 +63,18 @@
|
||||
$custom_date_format = $this->config->item('qso_date_format');
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
<?php
|
||||
$vucc_grids = array();
|
||||
if ($activators_vucc_array) {
|
||||
foreach ($activators_vucc_array as $line) {
|
||||
$vucc_grids[$line->call] = $line->vucc_grids;
|
||||
}
|
||||
foreach ($activators_vucc_array as $line) {
|
||||
$vucc_grids[$line->call] = $line->vucc_grids;
|
||||
}
|
||||
}
|
||||
if( $this->input->post('band') != NULL) {
|
||||
if ($this->input->post('band') != NULL) {
|
||||
if ($activators_array) {
|
||||
|
||||
$result = write_activators($activators_array, $vucc_grids, $custom_date_format, $this->input->post('band'), $this->input->post('leogeo'));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
echo '<div class="alert alert-danger" role="alert">Nothing found!</div>';
|
||||
}
|
||||
}
|
||||
@@ -86,12 +85,13 @@
|
||||
|
||||
<?php
|
||||
|
||||
function write_activators($activators_array, $vucc_grids, $custom_date_format, $band, $leogeo) {
|
||||
function write_activators($activators_array, $vucc_grids, $custom_date_format, $band, $leogeo)
|
||||
{
|
||||
if ($band == '') {
|
||||
$band = 'All';
|
||||
$band = 'All';
|
||||
}
|
||||
if ($leogeo == '') {
|
||||
$leogeo = 'both';
|
||||
$leogeo = 'both';
|
||||
}
|
||||
$i = 1;
|
||||
echo '<table style="width:100%" class="table table-sm activatorstable table-bordered table-hover table-striped table-condensed text-center">
|
||||
@@ -113,16 +113,16 @@ function write_activators($activators_array, $vucc_grids, $custom_date_format, $
|
||||
$grids = $line->grids;
|
||||
$count = $line->count;
|
||||
if (array_key_exists($line->call, $vucc_grids)) {
|
||||
foreach(explode(',', $vucc_grids[$line->call]) as $vgrid) {
|
||||
if(!strpos($grids, $vgrid)) {
|
||||
$grids .= ','.$vgrid;
|
||||
}
|
||||
}
|
||||
$grids = str_replace(' ', '', $grids);
|
||||
$grid_array = explode(',', $grids);
|
||||
sort($grid_array);
|
||||
$count = count($grid_array);
|
||||
$grids = implode(', ', $grid_array);
|
||||
foreach (explode(',', $vucc_grids[$line->call]) as $vgrid) {
|
||||
if (!strpos($grids, $vgrid)) {
|
||||
$grids .= ',' . $vgrid;
|
||||
}
|
||||
}
|
||||
$grids = str_replace(' ', '', $grids);
|
||||
$grid_array = explode(',', $grids);
|
||||
sort($grid_array);
|
||||
$count = count($grid_array);
|
||||
$grids = implode(', ', $grid_array);
|
||||
}
|
||||
array_push($activators, array($count, $call, $grids));
|
||||
}
|
||||
@@ -130,11 +130,11 @@ function write_activators($activators_array, $vucc_grids, $custom_date_format, $
|
||||
foreach ($activators as $line) {
|
||||
echo '<tr>
|
||||
<td>' . $i++ . '</td>
|
||||
<td>'.$line[1].'</td>
|
||||
<td>'.$line[0].'</td>
|
||||
<td style="text-align: left; font-family: monospace;">'.$line[2].'</td>
|
||||
<td><a href=javascript:displayActivatorsContacts("'.$line[1].'","'.$band.'","'.$leogeo.'")><i class="fas fa-list"></i></a></td>
|
||||
<td><a href=javascript:spawnActivatorsMap("'.$line[1].'","'.$line[0].'","'.str_replace(' ', '', $line[2]).'")><i class="fas fa-globe"></i></a></td>
|
||||
<td>' . $line[1] . '</td>
|
||||
<td>' . $line[0] . '</td>
|
||||
<td style="text-align: left; font-family: monospace;">' . $line[2] . '</td>
|
||||
<td><a href=javascript:displayActivatorsContacts("' . $line[1] . '","' . $band . '","' . $leogeo . '")><i class="fas fa-list"></i></a></td>
|
||||
<td><a href=javascript:spawnActivatorsMap("' . $line[1] . '","' . $line[0] . '","' . str_replace(' ', '', $line[2]) . '")><i class="fas fa-globe"></i></a></td>
|
||||
</tr>';
|
||||
}
|
||||
echo '</tfoot></table></div>';
|
||||
|
||||
Reference in New Issue
Block a user