diff --git a/.gitignore b/.gitignore index a1c29b94..31205243 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ /updates/*.html /images/eqsl_card_images/*.jpg /updates/clublog_scp.txt +/assets/qslcard/* .idea/* .DS_Store sync.sh diff --git a/application/config/migration.php b/application/config/migration.php index 9b82e009..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'] = 53; +$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..7a590d15 --- /dev/null +++ b/application/controllers/Qsl.php @@ -0,0 +1,140 @@ +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['front'] = $this->uploadQslCardFront($qsoid); + } + + if (isset($_FILES['qslcardback']) && $_FILES['qslcardback']['name'] != "" && $_FILES['qslcardback']['error'] == 0) + { + $result['back'] = $this->uploadQslCardBack($qsoid); + } + + header("Content-type: application/json"); + echo json_encode(['status' => $result]); + } + + function uploadQslCardFront($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']; + $insertid = $this->Qsl_model->saveQsl($qsoid, $filename); + + $result['status'] = 'Success'; + $result['insertid'] = $insertid; + $result['filename'] = $filename; + return $result; + } + } + + function uploadQslCardBack($qsoid) { + $config['upload_path'] = './assets/qslcard'; + $config['allowed_types'] = 'jpg|gif|png'; + $array = explode(".", $_FILES['qslcardback']['name']); + $ext = end($array); + $config['file_name'] = $qsoid . '_' . time() . '.' . $ext; + + $this->load->library('upload', $config); + + if ( ! $this->upload->do_upload('qslcardback')) { + // 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']; + $insertid = $this->Qsl_model->saveQsl($qsoid, $filename); + + $result['status'] = 'Success'; + $result['insertid'] = $insertid; + $result['filename'] = $filename; + return $result; + } + } + +} \ 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..a66093d9 --- /dev/null +++ b/application/migrations/054_add_qsl_images.php @@ -0,0 +1,19 @@ +db->query("CREATE TABLE IF NOT EXISTS `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..cb7640c9 --- /dev/null +++ b/application/models/Qsl_model.php @@ -0,0 +1,63 @@ +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); + + return $this->db->insert_id(); + } + + 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 370ee8c0..4e7764a3 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -1449,7 +1449,6 @@ $(document).ready(function(){ L.marker([lat,long], {icon: redIcon}).addTo(mymap) .bindPopup(callsign); - mymap.on('click', onMapClick); }, }); @@ -2267,5 +2266,160 @@ $(document).ready(function(){ +uri->segment(1) == "qsl") { ?> + + + + + diff --git a/application/views/interface_assets/header.php b/application/views/interface_assets/header.php index e04e46f9..10fadc6a 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..a968394b --- /dev/null +++ b/application/views/qslcard/upload_done.php @@ -0,0 +1,25 @@ +
+ +

+
+ + + + + + + + + + + +
+
\ No newline at end of file diff --git a/application/views/view_log/qso.php b/application/views/view_log/qso.php index 52a16e7b..2440de91 100644 --- a/application/views/view_log/qso.php +++ b/application/views/view_log/qso.php @@ -1,274 +1,388 @@ 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 + +
+ + + +