diff --git a/application/config/migration.php b/application/config/migration.php index 70841b48..2b1e5243 100644 --- a/application/config/migration.php +++ b/application/config/migration.php @@ -21,7 +21,7 @@ $config['migration_enabled'] = TRUE; | be upgraded / downgraded to. | */ -$config['migration_version'] = 52; +$config['migration_version'] = 54; /* |-------------------------------------------------------------------------- diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php index 61e06e58..ac8b85ef 100755 --- a/application/controllers/Logbook.php +++ b/application/controllers/Logbook.php @@ -411,6 +411,9 @@ class Logbook extends CI_Controller { $data['measurement_base'] = $this->session->userdata('user_measurement_base'); } + $this->load->model('Qsl_model'); + $data['qslimages'] = $this->Qsl_model->getQslForQsoId($id); + $this->load->view('interface_assets/mini_header', $data); $this->load->view('view_log/qso'); $this->load->view('interface_assets/footer'); diff --git a/application/controllers/Qsl.php b/application/controllers/Qsl.php new file mode 100644 index 00000000..3c8f5919 --- /dev/null +++ b/application/controllers/Qsl.php @@ -0,0 +1,104 @@ +load->model('user_model'); + if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } + } + + public function index() { + // Render Page + $data['page_title'] = "QSL Cards"; + + $this->load->model('qsl_model'); + $data['qslarray'] = $this->qsl_model->getQsoWithQslList(); + + $this->load->view('interface_assets/header', $data); + $this->load->view('qslcard/index'); + $this->load->view('interface_assets/footer'); + } + + public function upload() { + // Render Page + $data['page_title'] = "Upload QSL Cards"; + $this->load->view('interface_assets/header', $data); + $this->load->view('qslcard/upload'); + $this->load->view('interface_assets/footer'); + } + + public function delete() { + $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'); } + + $id = $this->input->post('id'); + $this->load->model('Qsl_model'); + + $path = './assets/qslcard/'; + $file = $this->Qsl_model->getFilename($id)->row(); + $filename = $file->filename; + unlink($path.$filename); + + $this->Qsl_model->deleteQsl($id); + } + + public function uploadqsl() { + $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'); } + + if (!file_exists('./assets/qslcard')) { + mkdir('./assets/qslcard', 0755, true); + } + $qsoid = $this->input->post('qsoid'); + + if (isset($_FILES['qslcardfront']) && $_FILES['qslcardfront']['name'] != "" && $_FILES['qslcardfront']['error'] == 0) + { + $result = $this->uploadQslCard($qsoid); + } + + // Set Page Title + $data['page_title'] = "QSL Upload"; + + // Load Views + $this->load->view('interface_assets/header', $data); + $this->load->view('qslcard/upload_done', $result); + $this->load->view('interface_assets/footer'); + } + + function uploadQslCard($qsoid) { + $config['upload_path'] = './assets/qslcard'; + $config['allowed_types'] = 'jpg|gif|png'; + $array = explode(".", $_FILES['qslcardfront']['name']); + $ext = end($array); + $config['file_name'] = $qsoid . '_' . time() . '.' . $ext; + + $this->load->library('upload', $config); + + if ( ! $this->upload->do_upload('qslcardfront')) { + // Upload of QSL card Failed + $error = array('error' => $this->upload->display_errors()); + + return $error; + } + else { + // Load database queries + $this->load->model('Qsl_model'); + + //Upload of QSL card was successful + $data = $this->upload->data(); + + // Now we need to insert info into database about file + $filename = $data['file_name']; + $this->Qsl_model->saveQsl($qsoid, $filename); + + return 'Success'; + } + } + +} \ No newline at end of file diff --git a/application/migrations/054_add_qsl_images.php b/application/migrations/054_add_qsl_images.php new file mode 100644 index 00000000..9b3538fa --- /dev/null +++ b/application/migrations/054_add_qsl_images.php @@ -0,0 +1,19 @@ +db->query("CREATE TABLE `qsl_images` + (`id` integer NOT NULL auto_increment, `qsoid` int, `filename` text, primary key (id)) + ENGINE=myisam DEFAULT CHARSET=utf8;"); + } + + public function down() + { + $this->db->query(""); + } +} \ No newline at end of file diff --git a/application/models/Qsl_model.php b/application/models/Qsl_model.php new file mode 100644 index 00000000..4071ffd7 --- /dev/null +++ b/application/models/Qsl_model.php @@ -0,0 +1,61 @@ +load->model('Stations'); + $station_id = $CI->Stations->find_active(); + + $this->db->select('*'); + $this->db->from($this->config->item('table_name')); + $this->db->join('qsl_images', 'qsl_images.qsoid = ' . $this->config->item('table_name') . '.col_primary_key'); + $this->db->where('station_id', $station_id); + + return $this->db->get(); + } + + function getQslForQsoId($id) { + // Clean ID + $clean_id = $this->security->xss_clean($id); + + $this->db->select('*'); + $this->db->from('qsl_images'); + $this->db->where('qsoid', $clean_id); + + return $this->db->get()->result(); + } + + function saveQsl($qsoid, $filename) { + $data = array( + 'qsoid' => $qsoid, + 'filename' => $filename + ); + + $this->db->insert('qsl_images', $data); + } + + function deleteQsl($id) { + // Clean ID + $clean_id = $this->security->xss_clean($id); + + // Delete Mode + $this->db->delete('qsl_images', array('id' => $clean_id)); + } + + function getFilename($id) { + // Clean ID + $clean_id = $this->security->xss_clean($id); + + $this->db->select('filename'); + $this->db->from('qsl_images'); + $this->db->where('id', $clean_id); + + return $this->db->get(); + } +} \ No newline at end of file diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index d0af4c4e..d5bd0858 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -2265,5 +2265,63 @@ $(document).ready(function(){ +uri->segment(1) == "qsl") { ?> + + + diff --git a/application/views/interface_assets/header.php b/application/views/interface_assets/header.php index d7125e90..867f069a 100644 --- a/application/views/interface_assets/header.php +++ b/application/views/interface_assets/header.php @@ -67,6 +67,8 @@ Live QSO Post QSO + + View QSL diff --git a/application/views/qslcard/index.php b/application/views/qslcard/index.php new file mode 100644 index 00000000..d00f5ac5 --- /dev/null +++ b/application/views/qslcard/index.php @@ -0,0 +1,28 @@ +
+

+ + result())) { + echo ' + + + + + + + + '; + + foreach ($qslarray->result() as $qsl) { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + echo '
CallsignQSL
' . $qsl->COL_CALL . '' . $qsl->filename . '
'; + } + ?> +
\ No newline at end of file diff --git a/application/views/qslcard/upload_done.php b/application/views/qslcard/upload_done.php new file mode 100644 index 00000000..fb04ab55 --- /dev/null +++ b/application/views/qslcard/upload_done.php @@ -0,0 +1,15 @@ +
+ +

+
+ + + + + +
+
\ No newline at end of file diff --git a/application/views/view_log/qso.php b/application/views/view_log/qso.php index c8c035eb..0ebf77f3 100644 --- a/application/views/view_log/qso.php +++ b/application/views/view_log/qso.php @@ -1,274 +1,382 @@ num_rows() > 0) { foreach ($query->result() as $row) { ?> -
+
-
-
-

QSO Details

-
-
+
+ +
+ +
+ + config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE) { ?> +
+

Edit QSO

+ + + COL_SAT_NAME != null) { + $twitter_band_sat = $row->COL_SAT_NAME; + $hashtags = "#hamr #cloudlog #amsat"; + } else { + $twitter_band_sat = $row->COL_BAND; + $hashtags = "#hamr #cloudlog"; + } + + $twitter_string = urlencode("Just worked ".$row->COL_CALL." in ".ucwords(strtolower(($row->COL_COUNTRY)))." (Gridsquare: ".$row->COL_GRIDSQUARE.") on ".$twitter_band_sat." using ".$row->COL_MODE." ".$hashtags); + ?> + + + +
+
+ + + config->item('use_auth')) && ($this->session->userdata('user_type') >= 2)) { + ?> +
+ 0) { + echo ' + + + + + + '; + + foreach ($qslimages as $qsl) { + echo ''; + echo ''; + echo ''; + echo ''; + } + + echo '
QSL image file
' . $qsl->filename . '
'; + } + ?> +
+
+ +
+ + +
+ + + + + +
+
+
+ +
+ + + + Previous + + + + Next + +
+ + + +