[Station Location][Edit] Allows selecting and editing Canadian Provinces

Fixes issue #2190
This commit is contained in:
Peter Goodhall 2023-06-15 13:14:10 +01:00
parent 028825f107
commit b319b190f3
3 changed files with 43 additions and 3 deletions

View File

@ -97,6 +97,12 @@ class Stations extends CI_Model {
} }
function edit() { function edit() {
if ($this->input->post('dxcc') == 1 && $this->input->post('station_ca_state') !="") {
$state = $this->input->post('station_ca_state');
} else {
$state = $this->input->post('station_state');
}
$data = array( $data = array(
'station_profile_name' => xss_clean($this->input->post('station_profile_name', true)), 'station_profile_name' => xss_clean($this->input->post('station_profile_name', true)),
'station_gridsquare' => xss_clean($this->input->post('gridsquare', true)), 'station_gridsquare' => xss_clean($this->input->post('gridsquare', true)),
@ -113,7 +119,7 @@ class Stations extends CI_Model {
'station_cnty' => xss_clean($this->input->post('station_cnty', true)), 'station_cnty' => xss_clean($this->input->post('station_cnty', true)),
'station_cq' => xss_clean($this->input->post('station_cq', true)), 'station_cq' => xss_clean($this->input->post('station_cq', true)),
'station_itu' => xss_clean($this->input->post('station_itu', true)), 'station_itu' => xss_clean($this->input->post('station_itu', true)),
'state' => xss_clean($this->input->post('station_state', true)), 'state' => $state,
'eqslqthnickname' => xss_clean($this->input->post('eqslnickname', true)), 'eqslqthnickname' => xss_clean($this->input->post('eqslnickname', true)),
'qrzapikey' => xss_clean($this->input->post('qrzapikey', true)), 'qrzapikey' => xss_clean($this->input->post('qrzapikey', true)),
'qrzrealtime' => xss_clean($this->input->post('qrzrealtime', true)), 'qrzrealtime' => xss_clean($this->input->post('qrzrealtime', true)),

View File

@ -87,7 +87,7 @@
</div> </div>
<!-- US State --> <!-- US State -->
<div class="form-group"> <div class="form-group" id="us_state">
<label for="stateInput">Station State</label> <label for="stateInput">Station State</label>
<select class="form-control custom-select" name="station_state" id="StateHelp" aria-describedby="stationCntyInputHelp"> <select class="form-control custom-select" name="station_state" id="StateHelp" aria-describedby="stationCntyInputHelp">
<option value=""></option> <option value=""></option>
@ -142,6 +142,15 @@
<option value="WI" <?php if($my_station_profile->state == "WI") { echo "selected"; } ?>>Wisconsin</option> <option value="WI" <?php if($my_station_profile->state == "WI") { echo "selected"; } ?>>Wisconsin</option>
<option value="WV" <?php if($my_station_profile->state == "WV") { echo "selected"; } ?>>West Virginia</option> <option value="WV" <?php if($my_station_profile->state == "WV") { echo "selected"; } ?>>West Virginia</option>
<option value="WY" <?php if($my_station_profile->state == "WY") { echo "selected"; } ?>>Wyoming</option> <option value="WY" <?php if($my_station_profile->state == "WY") { echo "selected"; } ?>>Wyoming</option>
</select>
<small id="StateHelp" class="form-text text-muted">Station state. Applies to certain countries only. Leave blank if not applicable.</small>
</div>
<!-- Canada State -->
<div class="form-group" id="canada_state">
<label for="stateInput">Canadian Province</label>
<select class="form-control custom-select" name="station_ca_state" id="StateHelp" aria-describedby="stationCntyInputHelp">
<option value=""></option>
<option value="AB" <?php if($my_station_profile->state == "AB") { echo "selected"; } ?>>Alberta</option> <option value="AB" <?php if($my_station_profile->state == "AB") { echo "selected"; } ?>>Alberta</option>
<option value="BC" <?php if($my_station_profile->state == "BC") { echo "selected"; } ?>>British Columbia</option> <option value="BC" <?php if($my_station_profile->state == "BC") { echo "selected"; } ?>>British Columbia</option>
<option value="MB" <?php if($my_station_profile->state == "MB") { echo "selected"; } ?>>Manitoba</option> <option value="MB" <?php if($my_station_profile->state == "MB") { echo "selected"; } ?>>Manitoba</option>
@ -157,7 +166,7 @@
<option value="YT" <?php if($my_station_profile->state == "YT") { echo "selected"; } ?>>Yukon</option> <option value="YT" <?php if($my_station_profile->state == "YT") { echo "selected"; } ?>>Yukon</option>
</select> </select>
<small id="StateHelp" class="form-text text-muted">Station state. Applies to certain countries only. Leave blank if not applicable.</small> <small id="StateHelp" class="form-text text-muted">Station state. Applies to certain countries only. Leave blank if not applicable.</small>
</div> </div>
<!-- US County --> <!-- US County -->
<div class="form-group"> <div class="form-group">

View File

@ -1,5 +1,30 @@
$(document).ready( function () { $(document).ready( function () {
// Use Jquery to hide div ca_state
$('#station_locations_table').DataTable({ $('#station_locations_table').DataTable({
"stateSave": true "stateSave": true
}); });
$("#canada_state").hide();
var selectedDXCCID = $('#dxcc_select').find(":selected").val();
console.log(selectedDXCCID);
if(selectedDXCCID == '1'){
$("#canada_state").show();
$("#us_state").hide();
}
$('#dxcc_select').change(function(){
if($(this).val() == '1'){ // or this.value == 'volvo'
console.log("CANADA!");
$("#canada_state").show();
$("#us_state").hide();
} else {
$("#canada_state").hide();
$("#us_state").show();
}
});
} ); } );