From 21562bffc46a7d4421b37b7fbe16ad9f2d854e33 Mon Sep 17 00:00:00 2001 From: phl0 Date: Wed, 10 May 2023 16:03:30 +0200 Subject: [PATCH] Add eQSL card list/view --- application/controllers/Eqsl.php | 63 ++++++++++++++++++- application/models/Eqsl_images.php | 9 ++- application/views/eqslcard/index.php | 59 +++++++++++++++++ application/views/interface_assets/footer.php | 27 +++++++- application/views/interface_assets/header.php | 2 + 5 files changed, 157 insertions(+), 3 deletions(-) create mode 100644 application/views/eqslcard/index.php diff --git a/application/controllers/Eqsl.php b/application/controllers/Eqsl.php index 2268d553..fa7a69e6 100644 --- a/application/controllers/Eqsl.php +++ b/application/controllers/Eqsl.php @@ -8,6 +8,23 @@ class eqsl extends CI_Controller { $this->load->helper(array('form', 'url')); } + // Default view when loading controller. + public function index() { + + $this->lang->load('qslcard'); + $folder_name = "assets/qslcard"; + $data['storage_used'] = $this->sizeFormat($this->folderSize($folder_name)); + + // Render Page + $data['page_title'] = "eQSL Cards"; + + $this->load->model('eqsl_images'); + $data['qslarray'] = $this->eqsl_images->eqsl_qso_list(); + + $this->load->view('interface_assets/header', $data); + $this->load->view('eqslcard/index'); + $this->load->view('interface_assets/footer'); + } public function import() { $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'); } @@ -599,5 +616,49 @@ class eqsl extends CI_Controller { $status = $this->uploadQso($adif, $qsl); } } - + +// Functions for storage, these need shifted to a libary to use across Cloudlog + function folderSize($dir){ + $count_size = 0; + $count = 0; + $dir_array = scandir($dir); + foreach($dir_array as $key=>$filename){ + if($filename!=".." && $filename!="."){ + if(is_dir($dir."/".$filename)){ + $new_foldersize = foldersize($dir."/".$filename); + $count_size = $count_size+ $new_foldersize; + }else if(is_file($dir."/".$filename)){ + $count_size = $count_size + filesize($dir."/".$filename); + $count++; + } + } + } + return $count_size; + } + + function sizeFormat($bytes){ + $kb = 1024; + $mb = $kb * 1024; + $gb = $mb * 1024; + $tb = $gb * 1024; + + if (($bytes >= 0) && ($bytes < $kb)) { + return $bytes . ' B'; + + } elseif (($bytes >= $kb) && ($bytes < $mb)) { + return ceil($bytes / $kb) . ' KB'; + + } elseif (($bytes >= $mb) && ($bytes < $gb)) { + return ceil($bytes / $mb) . ' MB'; + + } elseif (($bytes >= $gb) && ($bytes < $tb)) { + return ceil($bytes / $gb) . ' GB'; + + } elseif ($bytes >= $tb) { + return ceil($bytes / $tb) . ' TB'; + } else { + return $bytes . ' B'; + } + } + } // end class diff --git a/application/models/Eqsl_images.php b/application/models/Eqsl_images.php index 88137b01..521f8fba 100644 --- a/application/models/Eqsl_images.php +++ b/application/models/Eqsl_images.php @@ -24,6 +24,13 @@ class Eqsl_images extends CI_Model { $this->db->insert('eQSL_images', $data); } + function eqsl_qso_list() { + $this->db->select('qso_id, COL_CALL, COL_MODE, , COL_SUBMODE, COL_TIME_ON, COL_BAND, COL_SAT_NAME, image_file'); + $this->db->join($this->config->item('table_name'), 'qso_id = COL_PRIMARY_KEY', 'left outer'); + $this->db->order_by('COL_TIME_ON', 'DESC'); + return $this->db->get('eQSL_images'); + } + } -?> \ No newline at end of file +?> diff --git a/application/views/eqslcard/index.php b/application/views/eqslcard/index.php new file mode 100644 index 00000000..979f4ee3 --- /dev/null +++ b/application/views/eqslcard/index.php @@ -0,0 +1,59 @@ +
+ +
+ +

lang->line('general_word_eqslcards'); ?>

+ + + + 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'); + } + + if (is_array($qslarray->result())) { + echo ' + + + + + + + + + + + '; + + foreach ($qslarray->result() as $qsl) { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + echo '
'.$this->lang->line('gen_hamradio_callsign').''.$this->lang->line('gen_hamradio_mode').''.$this->lang->line('general_word_date').''.$this->lang->line('general_word_time').''.$this->lang->line('gen_hamradio_band').''.$this->lang->line('gen_hamradio_qsl').'
' . $qsl->COL_CALL . ''; + echo $qsl->COL_SUBMODE==null?$qsl->COL_MODE:$qsl->COL_SUBMODE; + echo ''; + $timestamp = strtotime($qsl->COL_TIME_ON); echo date($custom_date_format, $timestamp); + echo ''; + $timestamp = strtotime($qsl->COL_TIME_ON); echo date('H:i', $timestamp); + echo ''; + if($qsl->COL_SAT_NAME != null) { echo $qsl->COL_SAT_NAME; } else { echo strtolower($qsl->COL_BAND); }; + echo '' . $qsl->image_file . '
'; + } + ?> + +
diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index ffb92314..cfef5485 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -2123,7 +2123,7 @@ $(document).ready(function(){ -uri->segment(1) == "qsl") { +uri->segment(1) == "qsl" || $this->uri->segment(1) == "eqsl") { // Get Date format if($this->session->userdata('user_date_format')) { // If Logged in and session exists @@ -2244,6 +2244,31 @@ function deleteQsl(id) { }); } +