Browse Source

Allow editing/viewing QSO length in "Edit QSO" and "Enter QSO" forms

acma
Fabian Kurz 9 months ago
parent
commit
89d58a02cc
  1. 15
      api.php
  2. 19
      functions.php
  3. 15
      index.php

15
api.php

@ -173,7 +173,7 @@
if ($o = json_decode($postdata)) {
# check validity
$items = array("id", "hiscall", "nr", "date", "band", "dxcc", "waz", "was", "wae");
$items = array("id", "hiscall", "nr", "date", "band", "dxcc", "waz", "was", "wae", "qsolength");
if ($o->was == "0") {
$o->was = "";
@ -181,6 +181,9 @@
if ($o->wae == "0") {
$o->wae = "";
}
if ($o->qsolength == "") {
$o->qsolength = 1;
}
$err = "";
foreach ($items as $i) {
@ -254,7 +257,7 @@
# Log a new QSO
else {
$qsos = array();
array_push($qsos, array('call' => $o->hiscall, 'nr' => $o->nr, 'date' => $o->date, 'qsolength' => 0, 'band' => $o->band, 'dxcc' => $o->dxcc, 'was' => $o->was, 'waz' => $o->waz, 'wae' => $o->wae));
array_push($qsos, array('call' => $o->hiscall, 'nr' => $o->nr, 'date' => $o->date, 'qsolength' => $o->qsolength, 'band' => $o->band, 'dxcc' => $o->dxcc, 'was' => $o->was, 'waz' => $o->waz, 'wae' => $o->wae));
$qso_filtered = filter_qsos($qsos, $_SESSION['callsign']);
if (count($qso_filtered)) {
echo "Saved QSO: ".$qso_filtered[0]['call']." ".$qso_filtered[0]['date']." ".$qso_filtered[0]['band']." needed for: ".$qso_filtered[0]['reasons']."\n";
@ -292,6 +295,7 @@
$waz = validate_get('waz');
$was = validate_get('was');
$wae = validate_get('wae');
$qsolength = validate_get('qsolength');
$query = "select * from cwops_log where mycall='".$_SESSION['callsign']."' and ";
@ -329,6 +333,9 @@
array_push($conditions, " wae='$wae'");
}
if ($qsolength) {
array_push($conditions, " qsolength='$qsolength'");
}
if (!count($conditions)) {
echo "Invalid search parameters!";
return;
@ -339,11 +346,11 @@
$count = 0;
echo "<h2>Search results</h2><table><tr><th>Callsign</th><th>CWops #</th><th>Date (YYYY-MM-DD)</th><th>Band</th><th>DXCC</th><th>WAZ</th><th>WAS</th><th>WAE</th><th>Submit</th><th>Delete</th></tr>\n";
echo "<h2>Search results</h2><table><tr><th>Callsign</th><th>CWops #</th><th>Date (YYYY-MM-DD)</th><th>Band</th><th>DXCC</th><th>WAZ</th><th>WAS</th><th>WAE</th><th>Length (min)</th><th>Submit</th><th>Delete</th></tr>\n";
while ($r = mysqli_fetch_array($q, MYSQLI_ASSOC)) {
$count++;
editformline($r['hiscall'], $r['nr'], $r['date'], $r['band'], $r['dxcc'], $r['waz'], $r['was'], $r['wae'], $r['id']);
editformline($r['hiscall'], $r['nr'], $r['date'], $r['band'], $r['dxcc'], $r['waz'], $r['was'], $r['wae'], $r['qsolength'], $r['id']);
if ($count > 100) {
echo "Stopped after 100 results. Use finer search query please.<br>";

19
functions.php

@ -669,6 +669,12 @@ function parse_adif($adif, $members, $ign, $startdate) {
$qso['dxcc'] = 0;
$qso['qsolength'] = $qso_length;
# make sure every QSO is at least one minute long, we use 0
# as an invalid value
if ($qso['qsolength'] == 0) {
$qso['qsolength'] = 1;
}
if (!$ign) {
# see if there's a state in ADIF which overrides the state
# from the database
@ -1034,7 +1040,7 @@ function get_log ($call) {
return $out;
}
function editformline($hiscallv, $nrv, $datev, $bandv, $dxccv, $wazv, $wasv, $waev, $edit) {
function editformline($hiscallv, $nrv, $datev, $bandv, $dxccv, $wazv, $wasv, $waev, $qsolengthv, $edit) {
global $dxcc;
global $states;
global $waes;
@ -1127,6 +1133,9 @@ onblur="javascript:dxcc_lookup(this.value);member_lookup(this.value);"
?>
</select>
</td>
<td>
<input type="text" name="qsolength<?=$edit;?>" id="qsolength<?=$edit;?>" value="<?=$qsolengthv;?>" size=3>
</td>
<?
if ($new or $edit) {
?>
@ -1209,6 +1218,14 @@ function validate ($type, $value) {
return "";
}
break;
case 'qsolength':
if (preg_match('/^[0-9]{1,4}$/', $value)) {
return $value;
}
else {
return 0;
}
break;
default:
return "";
}

15
index.php

@ -105,11 +105,12 @@ if (array_key_exists("id", $_SESSION)) {
var waz = document.searchform.waz.value;
var was = document.searchform.was.value;
var wae = document.searchform.wae.value;
var qsolength = document.searchform.qsolength.value;
console.log("search " + hiscall+ " " + nr + " " + band + " " + dxcc + " " + waz + " " + was + " " + wae);
console.log("search " + hiscall+ " " + nr + " " + band + " " + dxcc + " " + waz + " " + was + " " + wae + " " + qsolength);
var request = new XMLHttpRequest();
request.open("GET", '/api?action=search&hiscall=' + hiscall + "&nr=" + nr + "&date=" + ddate + "&band=" + band + "&dxcc=" + dxcc + "&waz=" + waz + "&was=" + was + "&wae=" + wae, true);
request.open("GET", '/api?action=search&hiscall=' + hiscall + "&nr=" + nr + "&date=" + ddate + "&band=" + band + "&dxcc=" + dxcc + "&waz=" + waz + "&was=" + was + "&wae=" + wae + "&qsolength=" + qsolength, true);
request.onreadystatechange = function() {
var done = 4, ok = 200;
if (request.readyState == done && request.status == ok) {
@ -144,7 +145,7 @@ if (array_key_exists("id", $_SESSION)) {
function save (id) {
//try {
var items = ['hiscall', 'nr', 'date', 'band', 'dxcc', 'waz', 'was', 'wae'];
var items = ['hiscall', 'nr', 'date', 'band', 'dxcc', 'waz', 'was', 'wae', 'qsolength'];
var o = new Object();
for (var i = 0; i < items.length; i++) {
@ -383,10 +384,10 @@ search item below and hit <button id='search' onClick="javascript:search();">Sea
<form name="searchform">
<table>
<tr><th>Callsign</th><th>CWops #</th><th>Date (YYYY-MM-DD)</th><th>Band</th><th>DXCC</th><th>WAZ</th><th>WAS</th><th>WAE</th></tr>
<tr><th>Callsign</th><th>CWops #</th><th>Date (YYYY-MM-DD)</th><th>Band</th><th>DXCC</th><th>WAZ</th><th>WAS</th><th>WAE</th><th>Length (min)</th></tr>
<?
editformline("", "", "", "", "", "", "", "", "");
editformline("", "", "", "", "", "", "", "", "", "");
?>
</table>
</form>
@ -404,9 +405,9 @@ If you like to start over (re-upload your whole log), you can delete all QSOs th
<h2>Log contacts manually</h2>
<p>Here you can easily enter contacts manually, for example to add QSOs with members on DXpeditions. <button id='search' onClick="javascript:clear_form(0);">Clear Form</button></p>
<table>
<tr><th>Callsign</th><th>CWops #</th><th>Date (YYYY-MM-DD)</th><th>Band</th><th>DXCC</th><th>WAZ</th><th>WAS</th><th>WAE</th><th>Save</th><th>Delete</th></tr>
<tr><th>Callsign</th><th>CWops #</th><th>Date (YYYY-MM-DD)</th><th>Band</th><th>DXCC</th><th>WAZ</th><th>WAS</th><th>WAE</th><th>Length (min)</th><th>Save</th><th>Delete</th></tr>
<?
editformline("", "", "", "", "", "", "", "", "new");
editformline("", "", "", "", "", "", "", "", "", "new");
?>
</table>

Loading…
Cancel
Save