diff --git a/application/controllers/Dashboard.php b/application/controllers/Dashboard.php index 318a9cea..cf50479b 100644 --- a/application/controllers/Dashboard.php +++ b/application/controllers/Dashboard.php @@ -56,10 +56,13 @@ class Dashboard extends CI_Controller { $data['month_qsos'] = $this->logbook_model->month_qsos(); $data['year_qsos'] = $this->logbook_model->year_qsos(); - $data['total_countries'] = $this->logbook_model->total_countries(); - $data['total_countries_confirmed_paper'] = $this->logbook_model->total_countries_confirmed_paper(); - $data['total_countries_confirmed_eqsl'] = $this->logbook_model->total_countries_confirmed_eqsl(); - $data['total_countries_confirmed_lotw'] = $this->logbook_model->total_countries_confirmed_lotw(); + // Load Countries Breakdown data into array + $CountriesBreakdown = $this->logbook_model->total_countries_confirmed(); + + $data['total_countries'] = $CountriesBreakdown['Countries_Worked']; + $data['total_countries_confirmed_paper'] = $CountriesBreakdown['Countries_Worked_QSL']; + $data['total_countries_confirmed_eqsl'] = $CountriesBreakdown['Countries_Worked_EQSL']; + $data['total_countries_confirmed_lotw'] = $CountriesBreakdown['Countries_Worked_LOTW']; $data['total_qsl_sent'] = $this->logbook_model->total_qsl_sent(); $data['total_qsl_recv'] = $this->logbook_model->total_qsl_recv(); diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 047bfecb..5f437d12 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -1662,6 +1662,47 @@ class Logbook_model extends CI_Model { } } + /* Return total number of countries confirmed with along with qsl types confirmed */ + function total_countries_confirmed($StationLocationsArray = null) { + + if($StationLocationsArray == null) { + $CI =& get_instance(); + $CI->load->model('logbooks_model'); + $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + } else { + $logbooks_locations_array = StationLocationsArray; + } + + if(!empty($logbooks_locations_array)) { + $this->db->select('COUNT(DISTINCT COL_COUNTRY) as Countries_Worked, + COUNT(DISTINCT IF(COL_QSL_RCVD = "Y", COL_COUNTRY, NULL)) as Countries_Worked_QSL, + COUNT(DISTINCT IF(COL_EQSL_QSL_RCVD = "Y", COL_COUNTRY, NULL)) as Countries_Worked_EQSL, + COUNT(DISTINCT IF(COL_LOTW_QSL_RCVD = "Y", COL_COUNTRY, NULL)) as Countries_Worked_LOTW'); + $this->db->where_in('station_id', $logbooks_locations_array); + $this->db->where('COL_COUNTRY !=', 'Invalid'); + $this->db->where('COL_DXCC >', '0'); + + if ($query = $this->db->get($this->config->item('table_name'))) + { + foreach ($query->result() as $row) + { + $CountriesBreakdown['Countries_Worked'] = $row->Countries_Worked; + $CountriesBreakdown['Countries_Worked_QSL'] = $row->Countries_Worked_QSL; + $CountriesBreakdown['Countries_Worked_EQSL'] = $row->Countries_Worked_EQSL; + $CountriesBreakdown['Countries_Worked_LOTW'] = $row->Countries_Worked_LOTW; + } + + return $CountriesBreakdown; + } + else + { + return false; + } + } else { + return false; + } + } + /* Return total number of countries confirmed with paper QSL */ function total_countries_confirmed_paper() { $CI =& get_instance();