Added checks if logbooks exists. Cloudlog would load with an error when starting a new install.

pull/1277/head
Andreas 2021-11-06 20:53:36 +01:00
rodzic 1b2a88b355
commit b8ce4fa33d
2 zmienionych plików z 123 dodań i 97 usunięć

Wyświetl plik

@ -904,13 +904,18 @@ class Logbook_model extends CI_Model {
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
//$this->db->select('COL_CALL, COL_BAND, COL_TIME_ON, COL_RST_RCVD, COL_RST_SENT, COL_MODE, COL_SUBMODE, COL_NAME, COL_COUNTRY, COL_PRIMARY_KEY, COL_SAT_NAME, COL_STX_STRING, COL_SRX_STRING, COL_IOTA, COL_STATE, COL_GRIDSQUARE');
$this->db->where_in('station_id', $logbooks_locations_array);
$this->db->order_by("COL_TIME_ON", "desc");
$this->db->limit($num);
$query = $this->db->get($this->config->item('table_name'));
if ($logbooks_locations_array) {
//$this->db->select('COL_CALL, COL_BAND, COL_TIME_ON, COL_RST_RCVD, COL_RST_SENT, COL_MODE, COL_SUBMODE, COL_NAME, COL_COUNTRY, COL_PRIMARY_KEY, COL_SAT_NAME, COL_STX_STRING, COL_SRX_STRING, COL_IOTA, COL_STATE, COL_GRIDSQUARE');
$this->db->where_in('station_id', $logbooks_locations_array);
$this->db->order_by("COL_TIME_ON", "desc");
$this->db->limit($num);
$query = $this->db->get($this->config->item('table_name'));
return $query;
} else {
return null;
}
return $query;
}
/* Get all QSOs with a valid grid for use in the KML export */
@ -1003,17 +1008,20 @@ class Logbook_model extends CI_Model {
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
if ($logbooks_locations_array) {
$this->db->select('COUNT( * ) as count', FALSE);
$this->db->where_in('station_id', $logbooks_locations_array);
$query = $this->db->get($this->config->item('table_name'));
$this->db->select('COUNT( * ) as count', FALSE);
$this->db->where_in('station_id', $logbooks_locations_array);
$query = $this->db->get($this->config->item('table_name'));
if ($query->num_rows() > 0)
{
foreach ($query->result() as $row)
if ($query->num_rows() > 0)
{
return $row->count;
foreach ($query->result() as $row)
{
return $row->count;
}
}
} else {
return null;
}
}
@ -1023,23 +1031,27 @@ class Logbook_model extends CI_Model {
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
if ($logbooks_locations_array) {
$morning = date('Y-m-d 00:00:00');
$night = date('Y-m-d 23:59:59');
$morning = date('Y-m-d 00:00:00');
$night = date('Y-m-d 23:59:59');
$this->db->select('COUNT( * ) as count', FALSE);
$this->db->where_in('station_id', $logbooks_locations_array);
$this->db->where('COL_TIME_ON >=', $morning);
$this->db->where('COL_TIME_ON <=', $night);
$query = $this->db->get($this->config->item('table_name'));
$this->db->select('COUNT( * ) as count', FALSE);
$this->db->where_in('station_id', $logbooks_locations_array);
$this->db->where('COL_TIME_ON >=', $morning);
$this->db->where('COL_TIME_ON <=', $night);
$query = $this->db->get($this->config->item('table_name'));
if ($query->num_rows() > 0)
{
foreach ($query->result() as $row)
if ($query->num_rows() > 0)
{
return $row->count;
foreach ($query->result() as $row)
{
return $row->count;
}
}
} else {
return null;
}
}
/* Return QSOs over a period of days */
@ -1103,6 +1115,8 @@ class Logbook_model extends CI_Model {
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
if ($logbooks_locations_array) {
$morning = date('Y-m-01 00:00:00');
$date = new DateTime('now');
@ -1123,6 +1137,9 @@ class Logbook_model extends CI_Model {
return $row->count;
}
}
} else {
return null;
}
}
/* Return QSOs for the year for the active profile */
@ -1146,6 +1163,8 @@ class Logbook_model extends CI_Model {
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
if ($logbooks_locations_array) {
$morning = date('Y-01-01 00:00:00');
$night = date('Y-12-31 23:59:59');
@ -1162,6 +1181,9 @@ class Logbook_model extends CI_Model {
return $row->count;
}
}
} else {
return null;
}
}
/* Return total amount of SSB QSOs logged */

Wyświetl plik

@ -99,85 +99,89 @@
<?php
$i = 0;
foreach ($last_five_qsos->result() as $row) { ?>
<?php echo '<tr class="tr'.($i & 1).'">'; ?>
if ($last_five_qsos) {
foreach ($last_five_qsos->result() as $row) { ?>
<?php echo '<tr class="tr'.($i & 1).'">'; ?>
<?php
<?php
// Get 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 {
// Get Default date format from /config/cloudlog.php
$custom_date_format = $this->config->item('qso_date_format');
}
// Get 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 {
// Get Default date format from /config/cloudlog.php
$custom_date_format = $this->config->item('qso_date_format');
}
?>
?>
<td><?php $timestamp = strtotime($row->COL_TIME_ON); echo date($custom_date_format, $timestamp); ?></td>
<?php if(($this->config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE || ($this->config->item('show_time'))) { ?>
<td><?php $timestamp = strtotime($row->COL_TIME_ON); echo date('H:i', $timestamp); ?></td>
<td><?php $timestamp = strtotime($row->COL_TIME_ON); echo date($custom_date_format, $timestamp); ?></td>
<?php if(($this->config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE || ($this->config->item('show_time'))) { ?>
<td><?php $timestamp = strtotime($row->COL_TIME_ON); echo date('H:i', $timestamp); ?></td>
<?php } ?>
<td>
<a id="edit_qso" href="javascript:displayQso(<?php echo $row->COL_PRIMARY_KEY; ?>)"><?php echo str_replace("0","&Oslash;",strtoupper($row->COL_CALL)); ?></a>
</td>
<?php
switch($this->session->userdata('user_column1')==""?'Mode':$this->session->userdata('user_column1')) {
case 'Mode': echo '<td>'; echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE; break;
case 'RSTS': echo '<td class="d-none d-sm-table-cell">' . $row->COL_RST_SENT; if ($row->COL_STX_STRING) { echo '<span class="label">' . $row->COL_STX_STRING . '</span>';}; break;
case 'RSTR': echo '<td class="d-none d-sm-table-cell">' . $row->COL_RST_RCVD; if ($row->COL_SRX_STRING) { echo '<span class="label">' . $row->COL_SRX_STRING . '</span>';}; break;
case 'Country': echo '<td>' . ucwords(strtolower(($row->COL_COUNTRY)));; break;
case 'IOTA': echo '<td>' . ($row->COL_IOTA); break;
case 'SOTA': echo '<td>' . ($row->COL_SOTA_REF); break;
case 'Grid': echo '<td>'; echo strlen($row->COL_GRIDSQUARE)==0?$row->COL_VUCC_GRIDS:$row->COL_GRIDSQUARE; break;
case 'Band': echo '<td>'; if($row->COL_SAT_NAME != null) { echo $row->COL_SAT_NAME; } else { echo strtolower($row->COL_BAND); }; break;
case 'State': echo '<td>' . ($row->COL_STATE); break;
}
echo '</td>';
<?php } ?>
<td>
<a id="edit_qso" href="javascript:displayQso(<?php echo $row->COL_PRIMARY_KEY; ?>)"><?php echo str_replace("0","&Oslash;",strtoupper($row->COL_CALL)); ?></a>
</td>
<?php
switch($this->session->userdata('user_column1')==""?'Mode':$this->session->userdata('user_column1')) {
case 'Mode': echo '<td>'; echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE; break;
case 'RSTS': echo '<td class="d-none d-sm-table-cell">' . $row->COL_RST_SENT; if ($row->COL_STX_STRING) { echo '<span class="label">' . $row->COL_STX_STRING . '</span>';}; break;
case 'RSTR': echo '<td class="d-none d-sm-table-cell">' . $row->COL_RST_RCVD; if ($row->COL_SRX_STRING) { echo '<span class="label">' . $row->COL_SRX_STRING . '</span>';}; break;
case 'Country': echo '<td>' . ucwords(strtolower(($row->COL_COUNTRY)));; break;
case 'IOTA': echo '<td>' . ($row->COL_IOTA); break;
case 'SOTA': echo '<td>' . ($row->COL_SOTA_REF); break;
case 'Grid': echo '<td>'; echo strlen($row->COL_GRIDSQUARE)==0?$row->COL_VUCC_GRIDS:$row->COL_GRIDSQUARE; break;
case 'Band': echo '<td>'; if($row->COL_SAT_NAME != null) { echo $row->COL_SAT_NAME; } else { echo strtolower($row->COL_BAND); }; break;
case 'State': echo '<td>' . ($row->COL_STATE); break;
}
echo '</td>';
switch($this->session->userdata('user_column2')==""?'RSTS':$this->session->userdata('user_column2')) {
case 'Mode': echo '<td>'; echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE; break;
case 'RSTS': echo '<td class="d-none d-sm-table-cell">' . $row->COL_RST_SENT; if ($row->COL_STX_STRING) { echo '<span class="label">' . $row->COL_STX_STRING . '</span>';}; break;
case 'RSTR': echo '<td class="d-none d-sm-table-cell">' . $row->COL_RST_RCVD; if ($row->COL_SRX_STRING) { echo '<span class="label">' . $row->COL_SRX_STRING . '</span>';}; break;
case 'Country': echo '<td>' . ucwords(strtolower(($row->COL_COUNTRY)));; break;
case 'IOTA': echo '<td>' . ($row->COL_IOTA); break;
case 'SOTA': echo '<td>' . ($row->COL_SOTA_REF); break;
case 'Grid': echo '<td>'; echo strlen($row->COL_GRIDSQUARE)==0?$row->COL_VUCC_GRIDS:$row->COL_GRIDSQUARE; break;
case 'Band': echo '<td>'; if($row->COL_SAT_NAME != null) { echo $row->COL_SAT_NAME; } else { echo strtolower($row->COL_BAND); }; break;
case 'State': echo '<td>' . ($row->COL_STATE); break;
}
echo '</td>';
switch($this->session->userdata('user_column2')==""?'RSTS':$this->session->userdata('user_column2')) {
case 'Mode': echo '<td>'; echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE; break;
case 'RSTS': echo '<td class="d-none d-sm-table-cell">' . $row->COL_RST_SENT; if ($row->COL_STX_STRING) { echo '<span class="label">' . $row->COL_STX_STRING . '</span>';}; break;
case 'RSTR': echo '<td class="d-none d-sm-table-cell">' . $row->COL_RST_RCVD; if ($row->COL_SRX_STRING) { echo '<span class="label">' . $row->COL_SRX_STRING . '</span>';}; break;
case 'Country': echo '<td>' . ucwords(strtolower(($row->COL_COUNTRY)));; break;
case 'IOTA': echo '<td>' . ($row->COL_IOTA); break;
case 'SOTA': echo '<td>' . ($row->COL_SOTA_REF); break;
case 'Grid': echo '<td>'; echo strlen($row->COL_GRIDSQUARE)==0?$row->COL_VUCC_GRIDS:$row->COL_GRIDSQUARE; break;
case 'Band': echo '<td>'; if($row->COL_SAT_NAME != null) { echo $row->COL_SAT_NAME; } else { echo strtolower($row->COL_BAND); }; break;
case 'State': echo '<td>' . ($row->COL_STATE); break;
}
echo '</td>';
switch($this->session->userdata('user_column3')==""?'RSTR':$this->session->userdata('user_column3')) {
case 'Mode': echo '<td>'; echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE; break;
case 'RSTS': echo '<td class="d-none d-sm-table-cell">' . $row->COL_RST_SENT; if ($row->COL_STX_STRING) { echo '<span class="label">' . $row->COL_STX_STRING . '</span>';}; break;
case 'RSTR': echo '<td class="d-none d-sm-table-cell">' . $row->COL_RST_RCVD; if ($row->COL_SRX_STRING) { echo '<span class="label">' . $row->COL_SRX_STRING . '</span>';}; break;
case 'Country': echo '<td>' . ucwords(strtolower(($row->COL_COUNTRY)));; break;
case 'IOTA': echo '<td>' . ($row->COL_IOTA); break;
case 'SOTA': echo '<td>' . ($row->COL_SOTA_REF); break;
case 'Grid': echo '<td>'; echo strlen($row->COL_GRIDSQUARE)==0?$row->COL_VUCC_GRIDS:$row->COL_GRIDSQUARE; break;
case 'Band': echo '<td>'; if($row->COL_SAT_NAME != null) { echo $row->COL_SAT_NAME; } else { echo strtolower($row->COL_BAND); }; break;
case 'State': echo '<td>' . ($row->COL_STATE); break;
}
echo '</td>';
switch($this->session->userdata('user_column3')==""?'RSTR':$this->session->userdata('user_column3')) {
case 'Mode': echo '<td>'; echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE; break;
case 'RSTS': echo '<td class="d-none d-sm-table-cell">' . $row->COL_RST_SENT; if ($row->COL_STX_STRING) { echo '<span class="label">' . $row->COL_STX_STRING . '</span>';}; break;
case 'RSTR': echo '<td class="d-none d-sm-table-cell">' . $row->COL_RST_RCVD; if ($row->COL_SRX_STRING) { echo '<span class="label">' . $row->COL_SRX_STRING . '</span>';}; break;
case 'Country': echo '<td>' . ucwords(strtolower(($row->COL_COUNTRY)));; break;
case 'IOTA': echo '<td>' . ($row->COL_IOTA); break;
case 'SOTA': echo '<td>' . ($row->COL_SOTA_REF); break;
case 'Grid': echo '<td>'; echo strlen($row->COL_GRIDSQUARE)==0?$row->COL_VUCC_GRIDS:$row->COL_GRIDSQUARE; break;
case 'Band': echo '<td>'; if($row->COL_SAT_NAME != null) { echo $row->COL_SAT_NAME; } else { echo strtolower($row->COL_BAND); }; break;
case 'State': echo '<td>' . ($row->COL_STATE); break;
}
echo '</td>';
switch($this->session->userdata('user_column4')==""?'Band':$this->session->userdata('user_column4')) {
case 'Mode': echo '<td>'; echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE; break;
case 'RSTS': echo '<td class="d-none d-sm-table-cell">' . $row->COL_RST_SENT; if ($row->COL_STX_STRING) { echo '<span class="label">' . $row->COL_STX_STRING . '</span>';}; break;
case 'RSTR': echo '<td class="d-none d-sm-table-cell">' . $row->COL_RST_RCVD; if ($row->COL_SRX_STRING) { echo '<span class="label">' . $row->COL_SRX_STRING . '</span>';}; break;
case 'Country': echo '<td>' . ucwords(strtolower(($row->COL_COUNTRY)));; break;
case 'IOTA': echo '<td>' . ($row->COL_IOTA); break;
case 'SOTA': echo '<td>' . ($row->COL_SOTA_REF); break;
case 'Grid': echo '<td>'; echo strlen($row->COL_GRIDSQUARE)==0?$row->COL_VUCC_GRIDS:$row->COL_GRIDSQUARE; break;
case 'Band': echo '<td>'; if($row->COL_SAT_NAME != null) { echo $row->COL_SAT_NAME; } else { echo strtolower($row->COL_BAND); }; break;
case 'State': echo '<td>' . ($row->COL_STATE); break;
}
echo '</td>';
?>
</tr>
<?php $i++; } ?>
switch($this->session->userdata('user_column4')==""?'Band':$this->session->userdata('user_column4')) {
case 'Mode': echo '<td>'; echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE; break;
case 'RSTS': echo '<td class="d-none d-sm-table-cell">' . $row->COL_RST_SENT; if ($row->COL_STX_STRING) { echo '<span class="label">' . $row->COL_STX_STRING . '</span>';}; break;
case 'RSTR': echo '<td class="d-none d-sm-table-cell">' . $row->COL_RST_RCVD; if ($row->COL_SRX_STRING) { echo '<span class="label">' . $row->COL_SRX_STRING . '</span>';}; break;
case 'Country': echo '<td>' . ucwords(strtolower(($row->COL_COUNTRY)));; break;
case 'IOTA': echo '<td>' . ($row->COL_IOTA); break;
case 'SOTA': echo '<td>' . ($row->COL_SOTA_REF); break;
case 'Grid': echo '<td>'; echo strlen($row->COL_GRIDSQUARE)==0?$row->COL_VUCC_GRIDS:$row->COL_GRIDSQUARE; break;
case 'Band': echo '<td>'; if($row->COL_SAT_NAME != null) { echo $row->COL_SAT_NAME; } else { echo strtolower($row->COL_BAND); }; break;
case 'State': echo '<td>' . ($row->COL_STATE); break;
}
echo '</td>';
?>
</tr>
<?php $i++; }
}
?>
</table>
</div>
</div>