Browse Source

Allow editing a single QSO (closes #1)

master
Fabian Kurz 2 years ago
parent
commit
23cc98b22a
  1. 18
      api.php
  2. 8
      functions.php
  3. 20
      index.php

18
api.php

@ -85,6 +85,10 @@
case 'save':
save();
break;
case 'del':
$id = validate_get('nr');
del($id);
break;
case 'update_account':
update_account();
break;
@ -110,6 +114,18 @@
echo $ret;
}
function del ($nr) {
global $db;
$q = mysqli_query($db, "DELETE from cwops_log where mycall='".$_SESSION['callsign']."' and id=$nr");
if ($q) {
echo "OK";
}
else {
echo "An error occured. Maybe the QSO was deleted in the meantime or you tried to delete a QSO from a different user.";
error_log("del: ".mysqli_error($q));
}
}
function save() {
global $db;
@ -284,7 +300,7 @@
$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></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>Submit</th><th>Delete</th></tr>\n";
while ($r = mysqli_fetch_array($q, MYSQLI_ASSOC)) {
$count++;

8
functions.php

@ -940,7 +940,13 @@ onblur="javascript:dxcc_lookup(this.value);"
<?
if ($new or $edit) {
?>
<td><button onClick="javascript:save(<?=$edit;?>);">Save</button></td>
<td><button id="save<?=$edit;?>" onClick="javascript:save(<?=$edit;?>);">Save</button></td>
<?
}
if ($edit) {
?>
<td><button id="del<?=$edit;?>" onClick="javascript:del(<?=$edit;?>);">Delete</button></td>
<?
}
?>

20
index.php

@ -112,6 +112,24 @@ if (array_key_exists("id", $_SESSION)) {
request.send();
}
function del (id) {
// disable buttons to avoid further editing after deleting
document.getElementById('save' + id).disabled = true;
document.getElementById('del' + id).disabled = true;
var request = new XMLHttpRequest();
request.open("GET", '/api?action=del&nr=' + id, true);
request.onreadystatechange = function() {
var done = 4, ok = 200;
if (request.readyState == done && request.status == ok) {
if (request.responseText) {
alert(request.responseText);
}
}
}
request.send();
}
function save (id) {
//try {
var items = ['hiscall', 'nr', 'date', 'band', 'dxcc', 'waz', 'was', 'wae'];
@ -314,7 +332,7 @@ 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></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>Save</th><th>Delete</th></tr>
<?
editformline("", "", "", "", "", "", "", "", "new");
?>

Loading…
Cancel
Save