[QSL Card] Feature for adding more QSOs to a QSL Card

这个提交包含在:
Andreas 2021-07-22 07:55:34 +02:00
父节点 431122d22e
当前提交 edd518cabc
共有 6 个文件被更改,包括 292 次插入12 次删除

查看文件

@ -143,7 +143,32 @@ class Qsl extends CI_Controller {
}
}
function loadSearchForm() {
$data['filename'] = $this->input->post('filename');
$this->load->view('qslcard/searchform', $data);
}
function searchQsos() {
$this->load->model('Qsl_model');
$callsign = $this->input->post('callsign');
$data['results'] = $this->Qsl_model->searchQsos($callsign);
$data['filename'] = $this->input->post('filename');
$this->load->view('qslcard/searchresult', $data);
}
function addQsoToQsl() {
$qsoid = $this->input->post('qsoid');
$filename = $this->input->post('filename');
$this->load->model('Qsl_model');
$insertid = $this->Qsl_model->addQsotoQsl($qsoid, $filename);
header("Content-type: application/json");
$result['status'] = 'Success';
$result['insertid'] = $insertid;
$result['filename'] = $filename;
echo json_encode($result);
}
}
@ -166,27 +191,27 @@ function folderSize($dir){
return $count_size;
}
function sizeFormat($bytes){
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';
}
}
}

查看文件

@ -60,4 +60,31 @@ class Qsl_model extends CI_Model {
return $this->db->get();
}
}
function searchQsos($callsign) {
$CI =& get_instance();
$CI->load->model('Stations');
$station_id = $CI->Stations->find_active();
$this->db->select('*');
$this->db->from($this->config->item('table_name'));
$this->db->where('station_id', $station_id);
$this->db->where('col_call', $callsign);
return $this->db->get();
}
function addQsotoQsl($qsoid, $filename) {
$clean_qsoid = $this->security->xss_clean($qsoid);
$clean_filename = $this->security->xss_clean($filename);
$data = array(
'qsoid' => $qsoid,
'filename' => $filename
);
$this->db->insert('qsl_images', $data);
return $this->db->insert_id();
}
}

查看文件

@ -1793,6 +1793,66 @@ function deleteQsl(id) {
});
}
</script>
<script>
function addQsosToQsl(filename) {
var title = 'Add additional QSOs to a QSL Card';
var baseURL= "<?php echo base_url();?>";
$.ajax({
url: baseURL + 'index.php/qsl/loadSearchForm',
type: 'post',
data: {'filename': filename},
success: function(html) {
BootstrapDialog.show({
title: title,
size: BootstrapDialog.SIZE_WIDE,
cssClass: 'qso-search_results',
nl2br: false,
message: html,
buttons: [{
label: 'Close',
action: function (dialogItself) {
dialogItself.close();
}
}]
});
}
});
}
function addQsoToQsl(qsoid, filename, id) {
var title = 'Add additional QSOs to a QSL Card';
var baseURL= "<?php echo base_url();?>";
$.ajax({
url: baseURL + 'index.php/qsl/addQsoToQsl',
type: 'post',
data: {'filename': filename, 'qsoid': qsoid},
success: function(html) {
if (html.status == 'Success') {
location.reload();
} else {
$(".alert").remove();
$('#searchresult').prepend('<div class="alert alert-danger"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>Something went wrong. Please try again!</div>');
}
}
});
}
function searchAdditionalQsos(filename) {
var baseURL= "<?php echo base_url();?>";
$.ajax({
url: baseURL + 'index.php/qsl/searchQsos',
type: 'post',
data: {'callsign': $('#callsign').val(), 'filename': filename},
success: function(html) {
$('#searchresult').empty();
$('#searchresult').append(html);
}
});
}
</script>
<?php if ($this->uri->segment(1) == "contesting") { ?>
<script src="<?php echo base_url() ;?>assets/js/sections/contesting.js"></script>
<script>
@ -2013,8 +2073,7 @@ function deleteQsl(id) {
$.ajax({
url: baseURL + 'index.php/awards/counties_details_ajax',
type: 'post',
data: {'State': state, 'County': county
},
data: {'State': state, 'County': county },
success: function(html) {
BootstrapDialog.show({
title: 'QSO Data',

查看文件

@ -5,7 +5,7 @@
<h2><?php echo $this->lang->line('general_word_qslcards'); ?></h2>
<div class="alert alert-info" role="alert">
<?php echo $this->lang->line('qslcard_string_your_are_using'); ?> <?php echo $storage_used; ?> <?php echo $this->lang->line('qslcard_string_disk_space'); ?>
<?php echo $this->lang->line('qslcard_string_your_are_using'); ?> <?php echo $storage_used; ?> <?php echo $this->lang->line('qslcard_string_disk_space'); ?>
</div>
<?php
@ -17,6 +17,7 @@
<th style=\'text-align: center\'>'.$this->lang->line('gen_hamradio_qsl').'</th>
<th style=\'text-align: center\'></th>
<th style=\'text-align: center\'></th>
<th style=\'text-align: center\'></th>
</tr>
</thead><tbody>';
@ -26,6 +27,7 @@
echo '<td style=\'text-align: center\'>' . $qsl->filename . '</td>';
echo '<td id="'.$qsl->id.'" style=\'text-align: center\'><button onclick="deleteQsl(\''.$qsl->id.'\')" class="btn btn-sm btn-danger">Delete</button></td>';
echo '<td style=\'text-align: center\'><button onclick="viewQsl(\''.$qsl->filename.'\', \''. $qsl->COL_CALL . '\')" class="btn btn-sm btn-success">View</button></td>';
echo '<td style=\'text-align: center\'><button onclick="addQsosToQsl(\''.$qsl->filename.'\')" class="btn btn-sm btn-success">Add Qsos</button></td>';
echo '</tr>';
}
@ -33,4 +35,4 @@
}
?>
</div>
</div>

查看文件

@ -0,0 +1,13 @@
<form method="post" action="" id="search_box" name="test">
<div class="form-group row col-sm-12">
<label for="callsign" class="col-sm-2 col-form-label">Callsign</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="callsign" value="">
</div>
<div class="col-sm-2">
<button onclick="searchAdditionalQsos('<?php echo $filename; ?>')" class="btn-sm btn-success" type="button"><i class="fas fa-search"></i> Search</button>
</div>
</div>
</form>
<div id="searchresult"></div>

查看文件

@ -0,0 +1,154 @@
<div class="table-responsive">
<table class="table table-sm table-striped table-hover">
<tr class="titles">
<td><?php echo $this->lang->line('general_word_date'); ?></td>
<?php if(($this->config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE || ($this->config->item('show_time'))) { ?>
<td><?php echo $this->lang->line('general_word_time'); ?></td>
<?php } ?>
<td><?php echo $this->lang->line('gen_hamradio_call'); ?></td>
<?php
echo '<td>';
switch($this->session->userdata('user_column1')==""?'Mode':$this->session->userdata('user_column1')) {
case 'Mode': echo $this->lang->line('gen_hamradio_mode'); break;
case 'RSTS': echo $this->lang->line('gen_hamradio_rsts'); break;
case 'RSTR': echo $this->lang->line('gen_hamradio_rstr'); break;
case 'Country': echo $this->lang->line('general_word_country'); break;
case 'IOTA': echo $this->lang->line('gen_hamradio_iota'); break;
case 'State': echo $this->lang->line('gen_hamradio_state'); break;
case 'Grid': echo $this->lang->line('gen_hamradio_gridsquare'); break;
case 'Band': echo $this->lang->line('gen_hamradio_band'); break;
}
echo '</td>';
echo '<td>';
switch($this->session->userdata('user_column2')==""?'RSTS':$this->session->userdata('user_column2')) {
case 'Mode': echo $this->lang->line('gen_hamradio_mode'); break;
case 'RSTS': echo $this->lang->line('gen_hamradio_rsts'); break;
case 'RSTR': echo $this->lang->line('gen_hamradio_rstr'); break;
case 'Country': echo $this->lang->line('general_word_country'); break;
case 'IOTA': echo $this->lang->line('gen_hamradio_iota'); break;
case 'State': echo $this->lang->line('gen_hamradio_state'); break;
case 'Grid': echo $this->lang->line('gen_hamradio_gridsquare'); break;
case 'Band': echo $this->lang->line('gen_hamradio_band'); break;
}
echo '</td>';
echo '<td>';
switch($this->session->userdata('user_column3')==""?'RSTR':$this->session->userdata('user_column3')) {
case 'Mode': echo $this->lang->line('gen_hamradio_mode'); break;
case 'RSTS': echo $this->lang->line('gen_hamradio_rsts'); break;
case 'RSTR': echo $this->lang->line('gen_hamradio_rstr'); break;
case 'Country': echo $this->lang->line('general_word_country'); break;
case 'IOTA': echo $this->lang->line('gen_hamradio_iota'); break;
case 'State': echo $this->lang->line('gen_hamradio_state'); break;
case 'Grid': echo $this->lang->line('gen_hamradio_gridsquare'); break;
case 'Band': echo $this->lang->line('gen_hamradio_band'); break;
}
echo '</td>';
echo '<td>';
switch($this->session->userdata('user_column4')==""?'Band':$this->session->userdata('user_column4')) {
case 'Mode': echo $this->lang->line('gen_hamradio_mode'); break;
case 'RSTS': echo $this->lang->line('gen_hamradio_rsts'); break;
case 'RSTR': echo $this->lang->line('gen_hamradio_rstr'); break;
case 'Country': echo $this->lang->line('general_word_country'); break;
case 'IOTA': echo $this->lang->line('gen_hamradio_iota'); break;
case 'State': echo $this->lang->line('gen_hamradio_state'); break;
case 'Grid': echo $this->lang->line('gen_hamradio_gridsquare'); break;
case 'Band': echo $this->lang->line('gen_hamradio_band'); break;
}
echo '</td>';
echo '<td>';
switch($this->session->userdata('user_column5')==""?'Country':$this->session->userdata('user_column5')) {
case 'Mode': echo $this->lang->line('gen_hamradio_mode'); break;
case 'RSTS': echo $this->lang->line('gen_hamradio_rsts'); break;
case 'RSTR': echo $this->lang->line('gen_hamradio_rstr'); break;
case 'Country': echo $this->lang->line('general_word_country'); break;
case 'IOTA': echo $this->lang->line('gen_hamradio_iota'); break;
case 'State': echo $this->lang->line('gen_hamradio_state'); break;
case 'Grid': echo $this->lang->line('gen_hamradio_gridsquare'); break;
case 'Band': echo $this->lang->line('gen_hamradio_band'); break;
}
echo '</td><td></td></tr>';
$i = 0; foreach ($results->result() as $row) { ?>
<?php
// Get Date format
if($this->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');
}
?>
<?php echo '<tr class="tr'.($i & 1).'" id ="qso_'. $row->COL_PRIMARY_KEY .'">'; ?>
<td><?php $timestamp = strtotime($row->COL_TIME_ON); echo date($custom_date_format, $timestamp); ?></td>
<?php if(($this->config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE || ($this->config->item('show_time'))) { ?>
<td><?php $timestamp = strtotime($row->COL_TIME_ON); echo date('H:i', $timestamp); ?></td>
<?php } ?>
<td>
<a id="edit_qso" href="javascript:displayQso(<?php echo $row->COL_PRIMARY_KEY; ?>)"><?php echo str_replace("0","&Oslash;",strtoupper($row->COL_CALL)); ?></a>
</td>
<?php
switch($this->session->userdata('user_column1')==""?'Mode':$this->session->userdata('user_column1')) {
case 'Mode': echo '<td>'; echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE; break;
case 'RSTS': echo '<td>' . $row->COL_RST_SENT; if ($row->COL_STX) { echo '<span class="badge badge-light">' . $row->COL_STX . '</span>';}if ($row->COL_STX_STRING) { echo '<span class="badge badge-light">' . $row->COL_STX_STRING . '</span>';}; break;
case 'RSTR': echo '<td>' . $row->COL_RST_RCVD; if ($row->COL_SRX) { echo '<span class="badge badge-light">' . $row->COL_SRX . '</span>';}if ($row->COL_SRX_STRING) { echo '<span class="badge badge-light">' . $row->COL_SRX_STRING . '</span>';}; break;
case 'Country': echo '<td>' . ucwords(strtolower(($row->COL_COUNTRY)));; break;
case 'IOTA': echo '<td>' . ($row->COL_IOTA); break;
case 'Grid': echo '<td>'; echo strlen($row->COL_GRIDSQUARE)==0?$row->COL_VUCC_GRIDS:$row->COL_GRIDSQUARE; break;
case 'Band': echo '<td>'; if($row->COL_SAT_NAME != null) { echo $row->COL_SAT_NAME; } else { echo strtolower($row->COL_BAND); }; break;
case 'State': echo '<td>' . ($row->COL_STATE); break;
}
echo '</td>';
switch($this->session->userdata('user_column2')==""?'RSTS':$this->session->userdata('user_column2')) {
case 'Mode': echo '<td>'; echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE; break;
case 'RSTS': echo '<td>' . $row->COL_RST_SENT; if ($row->COL_STX) { echo '<span class="badge badge-light">' . $row->COL_STX . '</span>';}if ($row->COL_STX_STRING) { echo '<span class="badge badge-light">' . $row->COL_STX_STRING . '</span>';}; break;
case 'RSTR': echo '<td>' . $row->COL_RST_RCVD; if ($row->COL_SRX) { echo '<span class="badge badge-light">' . $row->COL_SRX . '</span>';}if ($row->COL_SRX_STRING) { echo '<span class="badge badge-light">' . $row->COL_SRX_STRING . '</span>';}; break;
case 'Country': echo '<td>' . ucwords(strtolower(($row->COL_COUNTRY)));; break;
case 'IOTA': echo '<td>' . ($row->COL_IOTA); break;
case 'Grid': echo '<td>'; echo strlen($row->COL_GRIDSQUARE)==0?$row->COL_VUCC_GRIDS:$row->COL_GRIDSQUARE; break;
case 'Band': echo '<td>'; if($row->COL_SAT_NAME != null) { echo $row->COL_SAT_NAME; } else { echo strtolower($row->COL_BAND); }; break;
case 'State': echo '<td>' . ($row->COL_STATE); break;
}
echo '</td>';
switch($this->session->userdata('user_column3')==""?'RSTR':$this->session->userdata('user_column3')) {
case 'Mode': echo '<td>'; echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE; break;
case 'RSTS': echo '<td>' . $row->COL_RST_SENT; if ($row->COL_STX) { echo '<span class="badge badge-light">' . $row->COL_STX . '</span>';}if ($row->COL_STX_STRING) { echo '<span class="badge badge-light">' . $row->COL_STX_STRING . '</span>';}; break;
case 'RSTR': echo '<td>' . $row->COL_RST_RCVD; if ($row->COL_SRX) { echo '<span class="badge badge-light">' . $row->COL_SRX . '</span>';}if ($row->COL_SRX_STRING) { echo '<span class="badge badge-light">' . $row->COL_SRX_STRING . '</span>';}; break;
case 'Country': echo '<td>' . ucwords(strtolower(($row->COL_COUNTRY)));; break;
case 'IOTA': echo '<td>' . ($row->COL_IOTA); break;
case 'Grid': echo '<td>'; echo strlen($row->COL_GRIDSQUARE)==0?$row->COL_VUCC_GRIDS:$row->COL_GRIDSQUARE; break;
case 'Band': echo '<td>'; if($row->COL_SAT_NAME != null) { echo $row->COL_SAT_NAME; } else { echo strtolower($row->COL_BAND); }; break;
case 'State': echo '<td>' . ($row->COL_STATE); break;
}
echo '</td>';
switch($this->session->userdata('user_column4')==""?'Band':$this->session->userdata('user_column4')) {
case 'Mode': echo '<td>'; echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE; break;
case 'RSTS': echo '<td>' . $row->COL_RST_SENT; if ($row->COL_STX) { echo '<span class="badge badge-light">' . $row->COL_STX . '</span>';}if ($row->COL_STX_STRING) { echo '<span class="badge badge-light">' . $row->COL_STX_STRING . '</span>';}; break;
case 'RSTR': echo '<td>' . $row->COL_RST_RCVD; if ($row->COL_SRX) { echo '<span class="badge badge-light">' . $row->COL_SRX . '</span>';}if ($row->COL_SRX_STRING) { echo '<span class="badge badge-light">' . $row->COL_SRX_STRING . '</span>';}; break;
case 'Country': echo '<td>' . ucwords(strtolower(($row->COL_COUNTRY)));; break;
case 'IOTA': echo '<td>' . ($row->COL_IOTA); break;
case 'Grid': echo '<td>'; echo strlen($row->COL_GRIDSQUARE)==0?$row->COL_VUCC_GRIDS:$row->COL_GRIDSQUARE; break;
case 'Band': echo '<td>'; if($row->COL_SAT_NAME != null) { echo $row->COL_SAT_NAME; } else { echo strtolower($row->COL_BAND); }; break;
case 'State': echo '<td>' . ($row->COL_STATE); break;
}
echo '</td>';
switch($this->session->userdata('user_column5')==""?'Country':$this->session->userdata('user_column5')) {
case 'Mode': echo '<td>'; echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE; break;
case 'RSTS': echo '<td>' . $row->COL_RST_SENT; if ($row->COL_STX) { echo '<span class="badge badge-light">' . $row->COL_STX . '</span>';}if ($row->COL_STX_STRING) { echo '<span class="badge badge-light">' . $row->COL_STX_STRING . '</span>';}; break;
case 'RSTR': echo '<td>' . $row->COL_RST_RCVD; if ($row->COL_SRX) { echo '<span class="badge badge-light">' . $row->COL_SRX . '</span>';}if ($row->COL_SRX_STRING) { echo '<span class="badge badge-light">' . $row->COL_SRX_STRING . '</span>';}; break;
case 'Country': echo '<td>' . ucwords(strtolower(($row->COL_COUNTRY)));; break;
case 'IOTA': echo '<td>' . ($row->COL_IOTA); break;
case 'Grid': echo '<td>'; echo strlen($row->COL_GRIDSQUARE)==0?$row->COL_VUCC_GRIDS:$row->COL_GRIDSQUARE; break;
case 'Band': echo '<td>'; if($row->COL_SAT_NAME != null) { echo $row->COL_SAT_NAME; } else { echo strtolower($row->COL_BAND); }; break;
case 'State': echo '<td>' . ($row->COL_STATE); break;
}
echo '</td>
<td><button onclick="addQsoToQsl(' . $row->COL_PRIMARY_KEY . ', \'' . $filename . '\')" class="btn-sm btn-success" type="button"> Add to QSL</button></td>';
echo '</tr>';
$i++; } ?>
</table>
</div>
</div>