[Clublog] Started making GUI for syncing Clublog

This commit is contained in:
Andreas Kristiansen
2025-01-17 14:02:20 +01:00
parent dad530ce7b
commit 0e21df3ced
4 changed files with 182 additions and 9 deletions

View File

@@ -89,4 +89,30 @@ class Clublog extends CI_Controller
// echo ucfirst(strtolower($data['Name']));
return $data;
}
/*
* Used for displaying the uid for manually selecting log for upload to qrz
*/
public function export() {
$this->load->model('user_model');
if(!$this->user_model->authorize(2) || !clubaccess_check(9)) { $this->session->set_flashdata('error', __("You're not allowed to do that!")); redirect('dashboard'); }
$this->load->model('clublog_model');
$this->load->model('stations');
$data['page_title'] = __("Clublog");
$data['station_profiles'] = $this->stations->all_of_user();
$data['station_profile'] = $this->clublog_model->stations_with_clublog_enabled();
$data['callsigns'] = $this->stations->callsigns_of_user($this->session->userdata('user_id'));
$this->load->model('cron_model');
$data['next_run_up'] = $this->cron_model->get_next_run("clublog_upload");
$data['next_run_down'] = $this->cron_model->get_next_run("clublog_download");
$this->load->view('interface_assets/header', $data);
$this->load->view('clublog/export');
$this->load->view('interface_assets/footer');
}
}

View File

@@ -288,7 +288,7 @@ class Clublog_model extends CI_Model
}
function all_enabled($userid) {
$sql = "select sp.station_callsign, group_concat(sp.station_id) as station_ids from station_profile sp
$sql = "select sp.station_callsign, group_concat(sp.station_id) as station_ids from station_profile sp
inner join users u on (u.user_id=sp.user_id)
where u.user_clublog_name is not null and u.user_clublog_password is not null and sp.clublogignore=0 and u.user_id=?
group by sp.station_callsign";
@@ -312,4 +312,35 @@ class Clublog_model extends CI_Model
return $this->db->get();
}
function stations_with_clublog_enabled() {
$bindings=[];
$sql = "SELECT station_profile.station_id, station_profile.station_profile_name, station_profile.station_callsign, modc.modcount, notc.notcount, totc.totcount
FROM station_profile
LEFT OUTER JOIN (
SELECT count(*) modcount, station_id
FROM ". $this->config->item('table_name') .
" WHERE COL_CLUBLOG_QSO_UPLOAD_STATUS = 'M'
group by station_id
) as modc on station_profile.station_id = modc.station_id
LEFT OUTER JOIN (
SELECT count(*) notcount, station_id
FROM " . $this->config->item('table_name') .
" WHERE (coalesce(COL_CLUBLOG_QSO_UPLOAD_STATUS, '') = ''
or COL_CLUBLOG_QSO_UPLOAD_STATUS = 'N')
group by station_id
) as notc on station_profile.station_id = notc.station_id
LEFT OUTER JOIN (
SELECT count(*) totcount, station_id
FROM " . $this->config->item('table_name') .
" WHERE COL_CLUBLOG_QSO_UPLOAD_STATUS = 'Y'
group by station_id
) as totc on station_profile.station_id = totc.station_id
WHERE coalesce(station_profile.clublogignore, 1) = 0
AND station_profile.user_id = ?";
$bindings[]=$this->session->userdata('user_id');
$query = $this->db->query($sql, $bindings);
return $query;
}
}

View File

@@ -0,0 +1,115 @@
<div class="container adif" id="clublog_export">
<h2><?php echo $page_title; ?></h2>
<div class="card">
<div class="card-header">
<ul class="nav nav-tabs card-header-tabs pull-right" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="export-tab" data-bs-toggle="tab" href="#export" role="tab" aria-controls="import" aria-selected="true"><?= __("Upload Logbook"); ?></a>
</li>
<?php if (!($this->config->item('disable_manual_clublog'))) { ?>
<li class="nav-item">
<a class="nav-link" id="mark-tab" data-bs-toggle="tab" href="#import" role="tab" aria-controls="import" aria-selected="false"><?= __("Download QSOs"); ?></a>
</li>
<?php } ?>
<li class="nav-item">
<a class="nav-link" id="mark-tab" data-bs-toggle="tab" href="#mark" role="tab" aria-controls="export" aria-selected="false"><?= __("Mark QSOs"); ?></a>
</li>
</ul>
</div>
<div class="card-body">
<div class="tab-content">
<div class="tab-pane active" id="export" role="tabpanel" aria-labelledby="export-tab">
<?php if (($next_run_up ?? '') != '') { echo "<p>".__("The next automatic Upload to Clublog will happen at: ").$next_run_up."</p>"; } ?>
<p><?= __("Here you can see all QSOs which have not been previously uploaded to a Clublog logbook."); ?></p>
<p><?= __("You need to set a username and password in your user account. You will also need to enable upload for each station profile ."); ?></p>
<?php if (!($this->config->item('disable_manual_clublog'))) { echo '<p><span class="badge text-bg-warning">Warning</span> This might take a while as QSO uploads are processed sequentially.</p>'; } ?>
<?php
if ($station_profile->result()) {
echo '
<table class="table table-bordered table-hover table-striped table-condensed text-center">
<thead>
<tr>
<td>' . __("Profile name") . '</td>
<td>' . __("Station callsign") . '</td>
<td>' . __("Edited QSOs not uploaded") . '</td>
<td>' . __("Total QSOs not uploaded") . '</td>
<td>' . __("Total QSOs uploaded") . '</td>
<td>' . __("Actions") . '</td>
</thead>
<tbody>';
foreach ($station_profile->result() as $station) { // Fills the table with the data
echo '<tr>';
echo '<td>' . $station->station_profile_name . '</td>';
echo '<td>' . $station->station_callsign . '</td>';
echo '<td id ="modcount'.$station->station_id.'">' . $station->modcount . '</td>';
echo '<td id ="notcount'.$station->station_id.'">' . $station->notcount . '</td>';
echo '<td id ="totcount'.$station->station_id.'">' . $station->totcount . '</td>';
if (!($this->config->item('disable_manual_clublog'))) {
echo '<td><button id="clublogUpload" type="button" name="clublogUpload" class="btn btn-primary btn-sm ld-ext-right ld-ext-right-'.$station->station_id.'" onclick="ExportClublog('. $station->station_id .')"><i class="fas fa-cloud-upload-alt"></i> ' . __("Upload") . '<div class="ld ld-ring ld-spin"></div></button></td>';
} else {
echo '<td>&nbsp;</td>';
}
echo '</tr>';
}
echo '</tfoot></table>';
}
else {
echo '<div class="alert alert-danger" role="alert">' . __("Nothing found!") . '</div>';
}
?>
</div>
<?php if (!($this->config->item('disable_manual_clublog'))) { ?>
<div class="tab-pane fade" id="import" role="tabpanel" aria-labelledby="home-tab">
<form class="form" action="<?php echo site_url('clublog/import_clublog'); ?>" method="post" enctype="multipart/form-data">
<?php if (($next_run_down ?? '') != '') { echo "<p>".__("The next automatic Download from Clublog-QSLs will happen at: ").$next_run_down."</p>"; } ?>
<p><span class="badge text-bg-warning"><?= __("Warning"); ?></span> <?= __("If no startdate is given then all QSOs after last confirmation will be downloaded/updated!"); ?></p>
<div class="row">
<div class="col-md-2">
<label for="from"><?= __("From date") . ": " ?></label>
<input name="from" id="from" type="date" class="form-control w-auto">
</div>
</div>
<br>
<button type="submit" class="btn btn-sm btn-primary" value="Export"><?= __("Download from Clublog"); ?></button>
</form>
</div>
<?php } ?>
<div class="tab-pane fade" id="mark" role="tabpanel" aria-labelledby="home-tab">
<form class="form" action="<?php echo site_url('clublog/mark_clublog'); ?>" method="post" enctype="multipart/form-data">
<select name="station_profile" class="form-select mb-4 me-sm-4" style="width: 30%;">
<option disabled value="0"><?= __("Select Station Location"); ?></option>
<?php foreach ($station_profiles->result() as $station) { ?>
<option <?php if ($station->station_active) { echo "selected "; } ?>value="<?php echo $station->station_id; ?>">Callsign: <?php echo $station->station_callsign; ?> (<?php echo $station->station_profile_name; ?>)</option>
<?php } ?>
</select>
<p><span class="badge text-bg-warning"><?= __("Warning"); ?></span> <?= __("If a date range is not selected then all QSOs will be marked!"); ?></p>
<div class="row">
<div class="col-md-2">
<label for="from"><?= __("From date") . ": " ?></label>
<input name="from" id="from" type="date" class="form-control w-auto">
</div>
<div class="col-md-2">
<label for="to"><?= __("To date") . ": " ?></label>
<input name="to" id="to" type="date" class="form-control w-auto">
</div>
</div>
<br>
<button type="submit" class="btn btn-sm btn-primary" value="Export"><?= __("Mark QSOs as exported to Clublog"); ?></button>
</form>
</div>
</div>
</div>
</div>
</div>

View File

@@ -376,13 +376,13 @@
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" data-bs-toggle="dropdown" href="#">
<?php if ($this->session->userdata('clubstation') == 1) {
echo '<i class="fas fa-users"></i> '
echo '<i class="fas fa-users"></i> '
. '<b>' . str_replace("0","&Oslash;", strtoupper($this->session->userdata('user_callsign'))) . '</b>'
. ' <br><small>'
. sprintf(_pgettext("Operator: Callsign", "Op: %s"), str_replace("0","&Oslash;", strtoupper($this->session->userdata('operator_callsign'))))
. '</small>';
} else {
echo '<i class="fas fa-user"></i> ' . str_replace("0","&Oslash;", strtoupper($this->session->userdata('user_callsign')));
. ' <br><small>'
. sprintf(_pgettext("Operator: Callsign", "Op: %s"), str_replace("0","&Oslash;", strtoupper($this->session->userdata('operator_callsign'))))
. '</small>';
} else {
echo '<i class="fas fa-user"></i> ' . str_replace("0","&Oslash;", strtoupper($this->session->userdata('user_callsign')));
} ?>
</a>
@@ -415,7 +415,7 @@
</a>
<?php } ?>
</div>
</li>
</li>
<?php } ?>
<?php } else if ($this->session->userdata('user_type') === '99') { ?>
<div class="dropdown-divider"></div>
@@ -471,6 +471,7 @@
<li><a class="dropdown-item" href="<?php echo site_url('hrdlog/export'); ?>" title="Upload to HRDLog.net logbook"><i class="fas fa-sync"></i> <?= __("HRDLog Logbook"); ?></a></li>
<li><a class="dropdown-item" href="<?php echo site_url('qrz/export'); ?>" title="Upload to QRZ.com logbook"><i class="fas fa-sync"></i> <?= __("QRZ Logbook"); ?></a></li>
<li><a class="dropdown-item" href="<?php echo site_url('webadif/export'); ?>" title="Upload to webADIF"><i class="fas fa-sync"></i> <?= __("QO-100 Dx Club Upload"); ?></a></li>
<li><a class="dropdown-item" href="<?php echo site_url('clublog/export'); ?>" title="Upload to Clublog"><i class="fas fa-sync"></i> <?= __("Clublog Import / Export"); ?></a></li>
</ul>
</li>
<div class="dropdown-divider"></div>
@@ -593,7 +594,7 @@
</ul>
</div>
</div>
</nav>
</nav>
<div id="clubswitchModal-container"></div>
<div id="stopImpersonateModal-container"></div>
<script>