[Custom Map] Fixed error if logbook is empty

这个提交包含在:
Andreas 2021-11-14 17:17:20 +01:00
父节点 8c7fa355fb
当前提交 8719441eb6
共有 2 个文件被更改,包括 42 次插入31 次删除

查看文件

@ -69,7 +69,12 @@ class Map extends CI_Controller {
$CI =& get_instance(); $CI =& get_instance();
$CI->load->model('logbooks_model'); $CI->load->model('logbooks_model');
$result = $CI->logbooks_model->logbook($this->session->userdata('active_station_logbook'))->result(); $result = $CI->logbooks_model->logbook($this->session->userdata('active_station_logbook'))->result();
$logbook_name = $result[0]->logbook_name;
if ($result) {
$logbook_name = $result[0]->logbook_name;
} else {
$logbook_name = '';
}
// load the view // load the view
$data['logbook_name'] = $logbook_name; $data['logbook_name'] = $logbook_name;
@ -111,39 +116,41 @@ class Map extends CI_Controller {
echo "{\"markers\": ["; echo "{\"markers\": [";
$count = 1; $count = 1;
foreach ($qsos->result() as $row) { if ($qsos) {
//print_r($row); foreach ($qsos->result() as $row) {
if($row->COL_GRIDSQUARE != null) { //print_r($row);
$stn_loc = $this->qra->qra2latlong($row->COL_GRIDSQUARE); if($row->COL_GRIDSQUARE != null) {
if($count != 1) { $stn_loc = $this->qra->qra2latlong($row->COL_GRIDSQUARE);
echo ",";
}
if($row->COL_SAT_NAME != null) {
echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date/Time: ".$row->COL_TIME_ON."<br />SAT: ".$row->COL_SAT_NAME."<br />Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\"}";
} else {
echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date/Time: ".$row->COL_TIME_ON."<br />Band: ".$row->COL_BAND."<br />Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\"}";
}
$count++;
} else {
$query = $this->db->query('
SELECT *
FROM dxcc_entities
WHERE prefix = SUBSTRING( \''.$row->COL_CALL.'\', 1, LENGTH( prefix ) )
ORDER BY LENGTH( prefix ) DESC
LIMIT 1
');
foreach ($query->result() as $dxcc) {
if($count != 1) { if($count != 1) {
echo ","; echo ",";
} }
echo "{\"lat\":\"".$dxcc->lat."\",\"lng\":\"".$dxcc->long."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date/Time: ".$row->COL_TIME_ON."<br />Band: ".$row->COL_BAND."<br />Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\"}";
if($row->COL_SAT_NAME != null) {
echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date/Time: ".$row->COL_TIME_ON."<br />SAT: ".$row->COL_SAT_NAME."<br />Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\"}";
} else {
echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date/Time: ".$row->COL_TIME_ON."<br />Band: ".$row->COL_BAND."<br />Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\"}";
}
$count++; $count++;
} else {
$query = $this->db->query('
SELECT *
FROM dxcc_entities
WHERE prefix = SUBSTRING( \''.$row->COL_CALL.'\', 1, LENGTH( prefix ) )
ORDER BY LENGTH( prefix ) DESC
LIMIT 1
');
foreach ($query->result() as $dxcc) {
if($count != 1) {
echo ",";
}
echo "{\"lat\":\"".$dxcc->lat."\",\"lng\":\"".$dxcc->long."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date/Time: ".$row->COL_TIME_ON."<br />Band: ".$row->COL_BAND."<br />Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\"}";
$count++;
}
} }
} }
} }
echo "]"; echo "]";

查看文件

@ -1074,6 +1074,10 @@ class Logbook_model extends CI_Model {
$CI->load->model('logbooks_model'); $CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
if (!$logbooks_locations_array) {
return null;
}
$this->db->where("COL_TIME_ON BETWEEN '".$start."' AND '".$end."'"); $this->db->where("COL_TIME_ON BETWEEN '".$start."' AND '".$end."'");
$this->db->where_in("station_id", $logbooks_locations_array); $this->db->where_in("station_id", $logbooks_locations_array);