diff --git a/application/controllers/Qso.php b/application/controllers/Qso.php index f54c6d04e..eec495ce1 100755 --- a/application/controllers/Qso.php +++ b/application/controllers/Qso.php @@ -48,6 +48,11 @@ class QSO extends CI_Controller { $this->form_validation->set_rules('callsign', 'Callsign', 'required'); $this->form_validation->set_rules('locator', 'Locator', 'callback_check_locator'); + // [eQSL default msg] GET user options (option_type='eqsl_default_qslmsg'; option_name='key_station_id'; option_key=station_id) // + $this->load->model('user_options_model'); + $options_object = $this->user_options_model->get_options('eqsl_default_qslmsg',array('option_name'=>'key_station_id','option_key'=>$data['active_station_profile']))->result(); + $data['qslmsg'] = (isset($options_object[0]->option_value))?$options_object[0]->option_value:''; + if ($this->form_validation->run() == FALSE) { $data['page_title'] = "Add QSO"; diff --git a/application/controllers/Station.php b/application/controllers/Station.php index f4e1d9129..f0600ec13 100644 --- a/application/controllers/Station.php +++ b/application/controllers/Station.php @@ -55,8 +55,14 @@ class Station extends CI_Controller { } else { - $this->stations->add(); - + if (($station_id = $this->stations->add()) !== false) { + // [eQSL default msg] ADD to user options (option_type='eqsl_default_qslmsg'; option_name='key_station_id'; option_key=station_id; option_value=value) // + $eqsl_default_qslmsg = xss_clean($this->input->post('eqsl_default_qslmsg', true)); + if (!empty(trim($eqsl_default_qslmsg))) { + $this->load->model('user_options_model'); + $this->user_options_model->set_option('eqsl_default_qslmsg','key_station_id',array($station_id=>$eqsl_default_qslmsg)); + } + } redirect('station'); } } @@ -68,11 +74,25 @@ class Station extends CI_Controller { $data['page_title'] = lang('station_location_edit') . $data['my_station_profile']->station_profile_name; if ($this->form_validation->run() == FALSE) { + // [eQSL default msg] GET from user options (option_type='eqsl_default_qslmsg'; option_name='key_station_id'; option_key=station_id) // + $this->load->model('user_options_model'); + $options_object = $this->user_options_model->get_options('eqsl_default_qslmsg',array('option_name'=>'key_station_id','option_key'=>$id))->result(); + $data['eqsl_default_qslmsg'] = (isset($options_object[0]->option_value))?$options_object[0]->option_value:''; + $this->load->view('interface_assets/header', $data); $this->load->view('station_profile/edit'); $this->load->view('interface_assets/footer'); } else { - $this->stations->edit(); + if ($this->stations->edit() !== false) { + // [eQSL default msg] ADD to user options (option_type='eqsl_default_qslmsg'; option_name='key_station_id'; option_key=station_id; option_value=value) // + $eqsl_default_qslmsg = xss_clean($this->input->post('eqsl_default_qslmsg', true)); + $this->load->model('user_options_model'); + if (!empty(trim($eqsl_default_qslmsg))) { + $this->user_options_model->set_option('eqsl_default_qslmsg','key_station_id',array($id=>$eqsl_default_qslmsg)); + } else { + $this->user_options_model->del_option('eqsl_default_qslmsg','key_station_id',array('option_key'=>$id)); + } + } $data['notice'] = lang('station_location') . $this->security->xss_clean($this->input->post('station_profile_name', true)) . " Updated"; @@ -163,6 +183,9 @@ class Station extends CI_Controller { $this->load->model('stations'); if ($this->stations->check_station_is_accessible($id)) { $this->stations->delete($id); + // [eQSL default msg] DELETE user options // + $this->load->model('user_options_model'); + $this->user_options_model->del_option('eqsl_default_qslmsg','key_station_id',array('option_key'=>$id)); } redirect('station'); } @@ -208,4 +231,18 @@ class Station extends CI_Controller { echo json_encode($json); } + // [eQSL default msg] Function return options from this station (but can be general use) // + public function get_options() { + $return_json = array(); + $option_type = $this->input->post('option_type'); + $option_name = $this->input->post('option_name'); + $option_key = $this->input->post('option_key'); + if (!empty($option_type) && !empty($option_name) && ($option_key>0)) { + $this->load->model('user_options_model'); + $options_object = $this->user_options_model->get_options($option_type,array('option_name'=>$option_name,'option_key'=>$option_key))->result(); + $return_json[$option_type] = (isset($options_object[0]->option_value))?$options_object[0]->option_value:''; + } + header('Content-Type: application/json'); + echo json_encode($return_json); + } } diff --git a/application/language/english/qso_lang.php b/application/language/english/qso_lang.php index 337b7f205..958090cbf 100644 --- a/application/language/english/qso_lang.php +++ b/application/language/english/qso_lang.php @@ -26,6 +26,8 @@ $lang['qso_dok_helptext'] = 'For example: Q03'; $lang['qso_notes_helptext'] = 'Note content is used within Cloudlog only and is not exported to other services.'; $lang['qsl_notes_helptext'] = 'This note content is exported to QSL services like eqsl.cc.'; +$lang['qso_eqsl_qslmsg_helptext'] = "Get the default message for eQSL, for this station."; + // Button Text on /qso Display $lang['qso_btn_reset_qso'] = 'Reset'; diff --git a/application/language/english/station_lang.php b/application/language/english/station_lang.php index 130bf8e5a..e6ab31889 100644 --- a/application/language/english/station_lang.php +++ b/application/language/english/station_lang.php @@ -94,6 +94,8 @@ $lang['station_location_signature_name_hint'] = "Station Signature (e.g. GMA).." $lang['station_location_signature_info'] = "Signature Information"; $lang['station_location_signature_info_hint'] = "Station Signature Info (e.g. DA/NW-357)."; $lang['station_location_eqsl_hint'] = 'The QTH Nickname which is configured in your eQSL Profile'; +$lang['station_location_eqsl_defaultqslmsg'] = "Default QSLMSG"; +$lang['station_location_eqsl_defaultqslmsg_hint'] = "You can define a default message that will be populated and sent for each QSO for this station location. Max length:"; $lang['station_location_qrz_subscription'] = 'Subscription Required'; $lang['station_location_qrz_hint'] = "Find your API key on the QRZ.com Logbook settings page"; $lang['station_location_qrz_realtime_upload'] = 'QRZ.com Logbook Realtime Upload'; diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 200b28ce9..6352e4b7d 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -260,6 +260,13 @@ class Logbook_model extends CI_Model { $station = $this->check_station($station_id); $data['station_id'] = $station_id; + // [eQSL default msg] add info to QSO for Contest or SFLE // + if (empty($data['COL_QSLMSG']) && (($this->input->post('isSFLE')==true) || (!empty($data['COL_CONTEST_ID'])))) { + $this->load->model('user_options_model'); + $options_object = $this->user_options_model->get_options('eqsl_default_qslmsg',array('option_name'=>'key_station_id','option_key'=>$station_id))->result(); + $data['COL_QSLMSG'] = (isset($options_object[0]->option_value))?$options_object[0]->option_value:''; + } + if (strpos(trim($station['station_gridsquare']), ',') !== false) { $data['COL_MY_VUCC_GRIDS'] = strtoupper(trim($station['station_gridsquare'])); } else { diff --git a/application/models/Stations.php b/application/models/Stations.php index 6a51e0185..496748245 100644 --- a/application/models/Stations.php +++ b/application/models/Stations.php @@ -114,8 +114,13 @@ class Stations extends CI_Model { 'webadifrealtime' => xss_clean($this->input->post('webadifrealtime', true)), ); - // Insert Records - $this->db->insert('station_profile', $data); + // Insert Records & return insert id // + if ($this->db->insert('station_profile', $data)===true) { + $station_user_list = $this->all_of_user()->result(); + if ((count($station_user_list)>0) && (isset($station_user_list[intval(count($station_user_list)-1)]->station_id))) { + return $station_user_list[intval(count($station_user_list)-1)]->station_id; + } + } } function edit() { diff --git a/application/models/User_options_model.php b/application/models/User_options_model.php index 9a383338d..71253ecd8 100644 --- a/application/models/User_options_model.php +++ b/application/models/User_options_model.php @@ -16,16 +16,32 @@ class User_options_model extends CI_Model { } } - public function get_options($option_type) { + public function get_options($option_type, $option_array=null) { $uid=$this->session->userdata('user_id'); - $sql='select option_name,option_key,option_value from user_options where user_id=? and option_type=?'; - return $this->db->query($sql, array($uid, $option_type)); + $sql_more = ""; + $array_sql_value = array($uid, $option_type); + if (is_array($option_array)) { + foreach ($option_array as $key => $value) { + $sql_more .= ' and '.$key.'=?'; + $array_sql_value[] = $value; + } + } + $sql='select option_name,option_key,option_value from user_options where user_id=? and option_type=?'.$sql_more; + return $this->db->query($sql, $array_sql_value); } - public function del_option($option_type, $option_name) { + public function del_option($option_type, $option_name, $option_array=null) { $uid=$this->session->userdata('user_id'); - $sql='delete from user_options where user_id=? and option_type=? and option_name=?'; - return $this->db->query($sql, array($uid, $option_type,$option_name)); + $sql_more = ""; + $array_sql_value = array($uid, $option_type, $option_name); + if (is_array($option_array)) { + foreach ($option_array as $key => $value) { + $sql_more .= ' and '.$key.'=?'; + $array_sql_value[] = $value; + } + } + $sql='delete from user_options where user_id=? and option_type=? and option_name=?'.$sql_more; + return $this->db->query($sql, $array_sql_value); } } diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index 7c00b086d..7b713aaac 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -1239,7 +1239,11 @@ $(document).on('keypress',function(e) { $('#transmit_power').val(''); }, }); + // [eQSL default msg] change value on change station profle // + qso_set_eqsl_qslmsg(stationProfile,false,'.qso_panel'); }); + // [eQSL default msg] change value on clic // + $('.qso_panel .qso_eqsl_qslmsg_update').off('click').on('click',function() { qso_set_eqsl_qslmsg($('.qso_panel #stationProfile').val(),true,'.qso_panel'); }); session->userdata('user_qth_lookup') == 1) { ?> $('#qth').focusout(function() { diff --git a/application/views/qso/edit_ajax.php b/application/views/qso/edit_ajax.php index 1236be472..3efde2b18 100644 --- a/application/views/qso/edit_ajax.php +++ b/application/views/qso/edit_ajax.php @@ -511,13 +511,14 @@
- +
- + +
diff --git a/application/views/qso/index.php b/application/views/qso/index.php index 3a5811137..b6cbed4bc 100755 --- a/application/views/qso/index.php +++ b/application/views/qso/index.php @@ -532,8 +532,9 @@
- - + + +
diff --git a/application/views/station_profile/create.php b/application/views/station_profile/create.php index 4418fa0a2..bcd2ff0b5 100644 --- a/application/views/station_profile/create.php +++ b/application/views/station_profile/create.php @@ -249,6 +249,12 @@ +
+ + + 240. +
+
eqslqthnickname; } ?>">
+
+ + + + 240. +