diff --git a/application/controllers/Dashboard.php b/application/controllers/Dashboard.php index 29d223bc..7420fb9f 100644 --- a/application/controllers/Dashboard.php +++ b/application/controllers/Dashboard.php @@ -127,6 +127,15 @@ class Dashboard extends CI_Controller $data['total_countries_needed'] = count($dxcc->result()) - $current; + $this->load->model('Workabledxcc_model'); + $data['thisWeekRecords'] = $this->Workabledxcc_model->GetThisWeek(); + + usort($data['thisWeekRecords'], function($a, $b) { + $dateA = new DateTime($a['1']); + $dateB = new DateTime($b['1']); + return $dateA <=> $dateB; + }); + $this->load->view('interface_assets/header', $data); $this->load->view('dashboard/index'); $this->load->view('interface_assets/footer'); diff --git a/application/controllers/Workabledxcc.php b/application/controllers/Workabledxcc.php index c4271853..141d7c46 100644 --- a/application/controllers/Workabledxcc.php +++ b/application/controllers/Workabledxcc.php @@ -166,4 +166,5 @@ class Workabledxcc extends CI_Controller return $return;; } } + } diff --git a/application/models/Workabledxcc_model.php b/application/models/Workabledxcc_model.php new file mode 100644 index 00000000..bc8e561c --- /dev/null +++ b/application/models/Workabledxcc_model.php @@ -0,0 +1,163 @@ +setISODate((new DateTime())->format('o'), (new DateTime())->format('W'), 1); + $endOfWeek = (clone $startOfWeek)->modify('+6 days'); + + // Step 4: Iterate over the array. + foreach ($data as $record) { + + // Convert "0" and "1" to DateTime objects. + $startDate = new DateTime($record['0']); + $endDate = new DateTime($record['1']); + + // Step 5: Check if the start date or end date is within this week. + if (($startDate >= $startOfWeek && $startDate <= $endOfWeek) || ($endDate >= $startOfWeek && $endDate <= $endOfWeek)) { + $endDate = new DateTime($record['1']); + $now = new DateTime(); + $interval = $now->diff($endDate); + $daysLeft = $interval->days; + + // If daysLeft is 0, set it to "Last day" + if ($daysLeft == 0) { + $daysLeft = "Last day"; + } else { + $daysLeft = $daysLeft . " days left"; + } + + // Add daysLeft to record + $record['daysLeft'] = $daysLeft; + // 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'); + } + + // Create a new array with the required fields and add it to the main array + $oldStartDate = DateTime::createFromFormat('Y-m-d', $record['0']); + + $StartDate = $oldStartDate->format($custom_date_format); + $record['startDate'] = $StartDate; + + $oldEndDate = DateTime::createFromFormat('Y-m-d', $record['1']); + $EndDate = $oldEndDate->format($custom_date_format); + $record['endDate'] = $EndDate; + + $record['confirmed'] = true; // or false, depending on your logic + + $CI = &get_instance(); + $CI->load->model('logbook_model'); + $dxccInfo = $CI->logbook_model->dxcc_lookup($record['3'], $startDate->format('Y-m-d')); + + // Call DXCC Worked function to check if the DXCC has been worked before + if (isset($dxccInfo['entity'])) { + $dxccWorkedData = $this->dxccWorked($dxccInfo['entity']); + $record = array_merge($record, $dxccWorkedData); + } else { + // Handle the case where 'entity' is not set in $dxccInfo + $itemsToAdd = array( + 'workedBefore' => false, + 'confirmed' => false, + ); + $record = array_merge($record, $itemsToAdd); + } + + $thisWeekRecords[] = $record; + } + } + return $thisWeekRecords; + + } + + function dxccWorked($country) + { + + $return = [ + "workedBefore" => false, + "confirmed" => false, + ]; + + $user_default_confirmation = $this->session->userdata('user_default_confirmation'); + $this->load->model('logbooks_model'); + $logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + $this->load->model('logbook_model'); + + if (!empty($logbooks_locations_array)) { + $this->db->where('COL_PROP_MODE !=', 'SAT'); + + $this->db->where_in('station_id', $logbooks_locations_array); + $this->db->where('COL_COUNTRY', urldecode($country)); + + $query = $this->db->get($this->config->item('table_name'), 1, 0); + foreach ($query->result() as $workedBeforeRow) { + $return['workedBefore'] = true; + } + + $extrawhere = ''; + if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'Q') !== false) { + $extrawhere = "COL_QSL_RCVD='Y'"; + } + if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'L') !== false) { + if ($extrawhere != '') { + $extrawhere .= " OR"; + } + $extrawhere .= " COL_LOTW_QSL_RCVD='Y'"; + } + if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'E') !== false) { + if ($extrawhere != '') { + $extrawhere .= " OR"; + } + $extrawhere .= " COL_EQSL_QSL_RCVD='Y'"; + } + + if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'Z') !== false) { + if ($extrawhere != '') { + $extrawhere .= " OR"; + } + $extrawhere .= " COL_QRZCOM_QSO_DOWNLOAD_STATUS='Y'"; + } + + + $this->load->model('logbook_model'); + $this->db->where('COL_PROP_MODE !=', 'SAT'); + if ($extrawhere != '') { + $this->db->where('(' . $extrawhere . ')'); + } else { + $this->db->where("1=0"); + } + + + $this->db->where_in('station_id', $logbooks_locations_array); + $this->db->where('COL_COUNTRY', urldecode($country)); + + $query = $this->db->get($this->config->item('table_name'), 1, 0); + foreach ($query->result() as $workedBeforeRow) { + $return['confirmed'] = true; + } + + return $return; + } else { + $return['workedBefore'] = false; + $return['confirmed'] = false; + + + return $return;; + } + } +} diff --git a/application/views/dashboard/index.php b/application/views/dashboard/index.php index 67330e1c..9ca564a6 100644 --- a/application/views/dashboard/index.php +++ b/application/views/dashboard/index.php @@ -1,356 +1,480 @@ '.$ctx->lang->line('gen_hamradio_mode').''; break; - case 'RSTS': echo ''.$ctx->lang->line('gen_hamradio_rsts').''; break; - case 'RSTR': echo ''.$ctx->lang->line('gen_hamradio_rstr').''; break; - case 'Country': echo ''.$ctx->lang->line('general_word_country').''; break; - case 'IOTA': echo ''.$ctx->lang->line('gen_hamradio_iota').''; break; - case 'SOTA': echo ''.$ctx->lang->line('gen_hamradio_sota').''; break; - case 'WWFF': echo ''.$ctx->lang->line('gen_hamradio_wwff').''; break; - case 'POTA': echo ''.$ctx->lang->line('gen_hamradio_pota').''; break; - case 'State': echo ''.$ctx->lang->line('gen_hamradio_state').''; break; - case 'Grid': echo ''.$ctx->lang->line('gen_hamradio_gridsquare').''; break; - case 'Distance': echo ''.$ctx->lang->line('gen_hamradio_distance').''; break; - case 'Band': echo ''.$ctx->lang->line('gen_hamradio_band').''; break; - case 'Frequency': echo ''.$ctx->lang->line('gen_hamradio_frequency').''; break; - case 'Operator': echo ''.$ctx->lang->line('gen_hamradio_operator').''; break; - case 'Name': echo ''.$ctx->lang->line('general_word_name').''; break; +function echo_table_header_col($ctx, $name) +{ + switch ($name) { + case 'Mode': + echo '' . $ctx->lang->line('gen_hamradio_mode') . ''; + break; + case 'RSTS': + echo '' . $ctx->lang->line('gen_hamradio_rsts') . ''; + break; + case 'RSTR': + echo '' . $ctx->lang->line('gen_hamradio_rstr') . ''; + break; + case 'Country': + echo '' . $ctx->lang->line('general_word_country') . ''; + break; + case 'IOTA': + echo '' . $ctx->lang->line('gen_hamradio_iota') . ''; + break; + case 'SOTA': + echo '' . $ctx->lang->line('gen_hamradio_sota') . ''; + break; + case 'WWFF': + echo '' . $ctx->lang->line('gen_hamradio_wwff') . ''; + break; + case 'POTA': + echo '' . $ctx->lang->line('gen_hamradio_pota') . ''; + break; + case 'State': + echo '' . $ctx->lang->line('gen_hamradio_state') . ''; + break; + case 'Grid': + echo '' . $ctx->lang->line('gen_hamradio_gridsquare') . ''; + break; + case 'Distance': + echo '' . $ctx->lang->line('gen_hamradio_distance') . ''; + break; + case 'Band': + echo '' . $ctx->lang->line('gen_hamradio_band') . ''; + break; + case 'Frequency': + echo '' . $ctx->lang->line('gen_hamradio_frequency') . ''; + break; + case 'Operator': + echo '' . $ctx->lang->line('gen_hamradio_operator') . ''; + break; + case 'Name': + echo '' . $ctx->lang->line('general_word_name') . ''; + break; } } -function echo_table_col($row, $name) { - $ci =& get_instance(); - switch($name) { - case 'Mode': echo ''; echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE . ''; break; - case 'RSTS': echo '' . $row->COL_RST_SENT; if ($row->COL_STX) { echo ' COL_CONTEST_ID:"n/a").'" class="badge text-bg-light">'; printf("%03d", $row->COL_STX); echo '';} if ($row->COL_STX_STRING) { echo ' COL_CONTEST_ID:"n/a").'" class="badge text-bg-light">' . $row->COL_STX_STRING . '';} echo ''; break; - case 'RSTR': echo '' . $row->COL_RST_RCVD; if ($row->COL_SRX) { echo ' COL_CONTEST_ID:"n/a").'" class="badge text-bg-light">'; printf("%03d", $row->COL_SRX); echo '';} if ($row->COL_SRX_STRING) { echo ' COL_CONTEST_ID:"n/a").'" class="badge text-bg-light">' . $row->COL_SRX_STRING . '';} echo ''; break; - case 'Country': echo '' . ucwords(strtolower(($row->COL_COUNTRY))); if ($row->end != NULL) echo ' '.$ci->lang->line('gen_hamradio_deleted_dxcc').'' . ''; break; - case 'IOTA': echo '' . ($row->COL_IOTA) . ''; break; - case 'SOTA': echo '' . ($row->COL_SOTA_REF) . ''; break; - case 'WWFF': echo '' . ($row->COL_WWFF_REF) . ''; break; - case 'POTA': echo '' . ($row->COL_POTA_REF) . ''; break; - case 'Grid': echo ''; echoQrbCalcLink($row->station_gridsquare, $row->COL_VUCC_GRIDS, $row->COL_GRIDSQUARE); echo ''; break; - case 'Distance': echo '' . ($row->COL_DISTANCE ? $row->COL_DISTANCE . ' km' : '') . ''; break; - case 'Band': echo ''; if($row->COL_SAT_NAME != null) { echo ''.$row->COL_SAT_NAME.''; } else { echo strtolower($row->COL_BAND); } echo ''; break; - case 'Frequency': echo ''; if($row->COL_SAT_NAME != null) { echo ''.$row->COL_SAT_NAME.''; } else { if($row->COL_FREQ != null) { echo $ci->frequency->hz_to_mhz($row->COL_FREQ); } else { echo strtolower($row->COL_BAND); } } echo ''; break; - case 'State': echo '' . ($row->COL_STATE) . ''; break; - case 'Operator': echo '' . ($row->COL_OPERATOR) . ''; break; - case 'Name': echo '' . ($row->COL_NAME) . ''; break; +function echo_table_col($row, $name) +{ + $ci = &get_instance(); + switch ($name) { + case 'Mode': + echo ''; + echo $row->COL_SUBMODE == null ? $row->COL_MODE : $row->COL_SUBMODE . ''; + break; + case 'RSTS': + echo '' . $row->COL_RST_SENT; + if ($row->COL_STX) { + echo ' COL_CONTEST_ID : "n/a") . '" class="badge text-bg-light">'; + printf("%03d", $row->COL_STX); + echo ''; + } + if ($row->COL_STX_STRING) { + echo ' COL_CONTEST_ID : "n/a") . '" class="badge text-bg-light">' . $row->COL_STX_STRING . ''; + } + echo ''; + break; + case 'RSTR': + echo '' . $row->COL_RST_RCVD; + if ($row->COL_SRX) { + echo ' COL_CONTEST_ID : "n/a") . '" class="badge text-bg-light">'; + printf("%03d", $row->COL_SRX); + echo ''; + } + if ($row->COL_SRX_STRING) { + echo ' COL_CONTEST_ID : "n/a") . '" class="badge text-bg-light">' . $row->COL_SRX_STRING . ''; + } + echo ''; + break; + case 'Country': + echo '' . ucwords(strtolower(($row->COL_COUNTRY))); + if ($row->end != NULL) echo ' ' . $ci->lang->line('gen_hamradio_deleted_dxcc') . '' . ''; + break; + case 'IOTA': + echo '' . ($row->COL_IOTA) . ''; + break; + case 'SOTA': + echo '' . ($row->COL_SOTA_REF) . ''; + break; + case 'WWFF': + echo '' . ($row->COL_WWFF_REF) . ''; + break; + case 'POTA': + echo '' . ($row->COL_POTA_REF) . ''; + break; + case 'Grid': + echo ''; + echoQrbCalcLink($row->station_gridsquare, $row->COL_VUCC_GRIDS, $row->COL_GRIDSQUARE); + echo ''; + break; + case 'Distance': + echo '' . ($row->COL_DISTANCE ? $row->COL_DISTANCE . ' km' : '') . ''; + break; + case 'Band': + echo ''; + if ($row->COL_SAT_NAME != null) { + echo '' . $row->COL_SAT_NAME . ''; + } else { + echo strtolower($row->COL_BAND); + } + echo ''; + break; + case 'Frequency': + echo ''; + if ($row->COL_SAT_NAME != null) { + echo '' . $row->COL_SAT_NAME . ''; + } else { + if ($row->COL_FREQ != null) { + echo $ci->frequency->hz_to_mhz($row->COL_FREQ); + } else { + echo strtolower($row->COL_BAND); + } + } + echo ''; + break; + case 'State': + echo '' . ($row->COL_STATE) . ''; + break; + case 'Operator': + echo '' . ($row->COL_OPERATOR) . ''; + break; + case 'Name': + echo '' . ($row->COL_NAME) . ''; + break; } } -function echoQrbCalcLink($mygrid, $grid, $vucc) { +function echoQrbCalcLink($mygrid, $grid, $vucc) +{ if (!empty($grid)) { echo $grid . ' '; } else if (!empty($vucc)) { - echo $vucc .' '; + echo $vucc . ' '; } } ?>
-config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE) { ?> + config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE) { ?> - - - - - - - - - - - - - - - - - optionslib->get_option('dashboard_banner') != "false") { ?> - = 1) { ?> - - - - - - - - - - - session->userdata('user_id')) { ?> - LotwCert->lotw_cert_expired($this->session->userdata('user_id'), $current_date) == true) { ?> + - LotwCert->lotw_cert_expiring($this->session->userdata('user_id'), $current_date) == true) { ?> - -config->item('option_dashboard_map ') != "false" && $this->config->item('option_dashboard_map ') != "map_at_right") { ?> - -
+config->item('option_dashboard_map ') != "false" && $this->config->item('option_dashboard_map ') != "map_at_right") { ?> + +
- -
-
+ +
+
-
- +
+
- - - + + + - config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE || ($this->config->item('show_time'))) { ?> - - - - session->userdata('user_column1')==""?'Mode':$this->session->userdata('user_column1')); - echo_table_header_col($this, $this->session->userdata('user_column2')==""?'RSTS':$this->session->userdata('user_column2')); - echo_table_header_col($this, $this->session->userdata('user_column3')==""?'RSTR':$this->session->userdata('user_column3')); - echo_table_header_col($this, $this->session->userdata('user_column4')==""?'Band':$this->session->userdata('user_column4')); - ?> - - - - 0) { - foreach ($last_five_qsos->result() as $row) { ?> - COL_PRIMARY_KEY.'" class="tr'.($i & 1).'">'; ?> + config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE || ($this->config->item('show_time'))) { ?> + + + + session->userdata('user_column1') == "" ? 'Mode' : $this->session->userdata('user_column1')); + echo_table_header_col($this, $this->session->userdata('user_column2') == "" ? 'RSTS' : $this->session->userdata('user_column2')); + echo_table_header_col($this, $this->session->userdata('user_column3') == "" ? 'RSTR' : $this->session->userdata('user_column3')); + echo_table_header_col($this, $this->session->userdata('user_column4') == "" ? 'Band' : $this->session->userdata('user_column4')); + ?> + + 0) { + foreach ($last_five_qsos->result() as $row) { ?> + COL_PRIMARY_KEY . '" class="tr' . ($i & 1) . '">'; ?> - // 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'); + 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'); + } + + ?> + + + config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE || ($this->config->item('show_time'))) { ?> + + + + + session->userdata('user_column1') == "" ? 'Mode' : $this->session->userdata('user_column1')); + echo_table_col($row, $this->session->userdata('user_column2') == "" ? 'RSTS' : $this->session->userdata('user_column2')); + echo_table_col($row, $this->session->userdata('user_column3') == "" ? 'RSTR' : $this->session->userdata('user_column3')); + echo_table_col($row, $this->session->userdata('user_column4') == "" ? 'Band' : $this->session->userdata('user_column4')); + ?> + + +
COL_TIME_ON); + echo date($custom_date_format, $timestamp); ?>COL_TIME_ON); + echo date('H:i', $timestamp); ?> + COL_CALL)); ?> +
+
+
+ +
+ config->item('dashboard_map') == "map_at_right") { ?> + +
+ +
+ + +
+ + + + + + + '; + echo ''; // Date + echo ''; // Callsign + echo ''; // Country + echo ''; } - ?> - - config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE || ($this->config->item('show_time'))) { ?> - +
DXPeditions (This Week)
' . $record['daysLeft'] . '' . $record['callsign'] . '' . $record['2'] . '
COL_TIME_ON); echo date($custom_date_format, $timestamp); ?>COL_TIME_ON); echo date('H:i', $timestamp); ?>
- - - COL_CALL)); ?> - - session->userdata('user_column1')==""?'Mode':$this->session->userdata('user_column1')); - echo_table_col($row, $this->session->userdata('user_column2')==""?'RSTS':$this->session->userdata('user_column2')); - echo_table_col($row, $this->session->userdata('user_column3')==""?'RSTR':$this->session->userdata('user_column3')); - echo_table_col($row, $this->session->userdata('user_column4')==""?'Band':$this->session->userdata('user_column4')); - ?> - - - + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ / + / + +
+ + config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE) && ($total_qsl_sent != 0 || $total_qsl_rcvd != 0 || $total_qsl_requested != 0)) { ?> + + + + + + + + + + + + + + + + + + + + + + + +
+ + + config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE) && ($total_eqsl_sent != 0 || $total_eqsl_rcvd != 0)) { ?> + + + + + + + + + + + + + + + + + +
+ + + config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === false) && ($total_lotw_sent != 0 || $total_lotw_rcvd != 0)) { ?> + + + + + + + + + + + + + + + + + +
+ + + config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === false) && ($total_qrz_sent != 0 || $total_qrz_rcvd != 0)) { ?> + + + + + + + + + + + + + + + + + +
QRZ.com
+ + + config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE)) { ?> + + + + + + + + + + + + + + + + + + +
VUCC-GridsSAT
+ +
+
-
-
- config->item('dashboard_map') == "map_at_right") { ?> - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- / - / - -
- - config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE) && ($total_qsl_sent != 0 || $total_qsl_rcvd != 0 || $total_qsl_requested != 0)) { ?> - - - - - - - - - - - - - - - - - - - - - - - -
- - - config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE) && ($total_eqsl_sent != 0 || $total_eqsl_rcvd != 0)) { ?> - - - - - - - - - - - - - - - - - -
- - - config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === false) && ($total_lotw_sent != 0 || $total_lotw_rcvd != 0)) { ?> - - - - - - - - - - - - - - - - - -
- - - config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === false) && ($total_qrz_sent != 0 || $total_qrz_rcvd != 0)) { ?> - - - - - - - - - - - - - - - - - -
QRZ.com
- - - config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE)) { ?> - - - - - - - - - - - - - - - - - - -
VUCC-GridsSAT
- -
-
-
- -
+
\ No newline at end of file