[Advanced Logbook] Refactor to reuse some code

This commit is contained in:
Andreas Kristiansen
2025-06-10 16:22:56 +02:00
parent d564c11bad
commit 8dff84c192
2 changed files with 19 additions and 51 deletions

View File

@@ -104,10 +104,8 @@ class Logbookadvanced extends CI_Controller {
$this->load->view('interface_assets/footer', $footerData);
}
public function search() {
$this->load->model('logbookadvanced_model');
$searchCriteria = array(
function mapParameters() {
return array(
'user_id' => (int)$this->session->userdata('user_id'),
'dateFrom' => xss_clean($this->input->post('dateFrom')),
'dateTo' => xss_clean($this->input->post('dateTo')),
@@ -149,7 +147,12 @@ class Logbookadvanced extends CI_Controller {
'comment' => xss_clean($this->input->post('comment')),
'qsoids' => xss_clean($this->input->post('qsoids'))
);
}
public function search() {
$this->load->model('logbookadvanced_model');
$searchCriteria = $this->mapParameters();
$qsos = [];
foreach ($this->logbookadvanced_model->searchQsos($searchCriteria) as $qso) {
@@ -213,11 +216,9 @@ class Logbookadvanced extends CI_Controller {
set_time_limit(0);
$this->load->model('logbookadvanced_model');
$postdata = $this->input->post();
$postdata['user_id'] = (int)$this->session->userdata('user_id');
$postdata['qsoresults'] = 'All';
$postdata['de'] = explode(',', $postdata['de']);
$postdata['qsoids'] = '';
$postdata = $this->mapParameters();
$postdata['de'] = explode(',', $postdata['de']); // The reason for doing this different, is that the parameter is sent in differently than the regular search
$postdata['qsoresults'] = 'All'; // We want all the QSOs regardless of what is set in the qsoresults, to be able to export all QSOs with the filter critera
$data['qsos'] = $this->logbookadvanced_model->getSearchResult($postdata);
$this->load->view('adif/data/exportall', $data);
@@ -346,46 +347,7 @@ class Logbookadvanced extends CI_Controller {
public function mapQsos() {
$this->load->model('logbookadvanced_model');
$searchCriteria = array(
'user_id' => (int)$this->session->userdata('user_id'),
'dateFrom' => xss_clean($this->input->post('dateFrom')),
'dateTo' => xss_clean($this->input->post('dateTo')),
'de' => xss_clean($this->input->post('de')),
'dx' => xss_clean($this->input->post('dx')),
'mode' => xss_clean($this->input->post('mode')),
'band' => xss_clean($this->input->post('band')),
'qslSent' => xss_clean($this->input->post('qslSent')),
'qslReceived' => xss_clean($this->input->post('qslReceived')),
'qslSentMethod' => xss_clean($this->input->post('qslSentMethod')),
'qslReceivedMethod' => xss_clean($this->input->post('qslReceivedMethod')),
'iota' => xss_clean($this->input->post('iota')),
'dxcc' => xss_clean($this->input->post('dxcc')),
'propmode' => xss_clean($this->input->post('propmode')),
'gridsquare' => xss_clean($this->input->post('gridsquare')),
'state' => xss_clean($this->input->post('state')),
'county' => xss_clean($this->input->post('county')),
'cqzone' => xss_clean($this->input->post('cqzone')),
'ituzone' => xss_clean($this->input->post('ituzone')),
'qsoresults' => xss_clean($this->input->post('qsoresults')),
'sats' => xss_clean($this->input->post('sats')),
'orbits' => xss_clean($this->input->post('orbits')),
'lotwSent' => xss_clean($this->input->post('lotwSent')),
'lotwReceived' => xss_clean($this->input->post('lotwReceived')),
'eqslSent' => xss_clean($this->input->post('eqslSent')),
'eqslReceived' => xss_clean($this->input->post('eqslReceived')),
'clublogSent' => xss_clean($this->input->post('clublogSent')),
'clublogReceived' => xss_clean($this->input->post('clublogReceived')),
'qslvia' => xss_clean($this->input->post('qslvia')),
'sota' => xss_clean($this->input->post('sota')),
'pota' => xss_clean($this->input->post('pota')),
'wwff' => xss_clean($this->input->post('wwff')),
'operator' => xss_clean($this->input->post('operator')),
'contest' => xss_clean($this->input->post('contest')),
'qslimages' => xss_clean($this->input->post('qslimages')),
'continent' => xss_clean($this->input->post('continent')),
'comment' => xss_clean($this->input->post('comment')),
'qsoids' => xss_clean($this->input->post('qsoids'))
);
$searchCriteria = $this->mapParameters();
$result = $this->logbookadvanced_model->getSearchResultArray($searchCriteria);
$this->prepareMappedQSos($result);

View File

@@ -559,6 +559,7 @@ function mapQsos(form) {
qslSentMethod: this.qslSentMethod.value,
qslReceivedMethod: this.qslReceivedMethod.value,
iota: form.iota.value,
operator: form.operator.value,
dxcc: form.dxcc.value,
propmode: form.propmode.value,
gridsquare: form.gridsquare.value,
@@ -568,14 +569,16 @@ function mapQsos(form) {
sats: form.sats.value,
orbits: form.orbits.value,
cqzone: form.cqzone.value,
ituzone: form.cqzone.value,
lotwSent: form.lotwSent.value,
lotwReceived: form.lotwReceived.value,
clublogSent: form.clublogSent.value,
clublogReceived: form.clublogReceived.value,
eqslSent: form.eqslSent.value,
eqslReceived: form.eqslReceived.value,
qslvia: $('[name="qslvia"]').val(),
sota: form.sota.value,
pota: form.pota.value,
operator: form.operator.value,
wwff: form.wwff.value,
qslimages: form.qslimages.value,
continent: form.continent.value,
@@ -650,6 +653,7 @@ function mapGlobeQsos(form) {
qslSentMethod: this.qslSentMethod.value,
qslReceivedMethod: this.qslReceivedMethod.value,
iota: form.iota.value,
operator: form.operator.value,
dxcc: form.dxcc.value,
propmode: form.propmode.value,
gridsquare: form.gridsquare.value,
@@ -659,14 +663,16 @@ function mapGlobeQsos(form) {
sats: form.sats.value,
orbits: form.orbits.value,
cqzone: form.cqzone.value,
ituzone: form.cqzone.value,
lotwSent: form.lotwSent.value,
lotwReceived: form.lotwReceived.value,
clublogSent: form.clublogSent.value,
clublogReceived: form.clublogReceived.value,
eqslSent: form.eqslSent.value,
eqslReceived: form.eqslReceived.value,
qslvia: $('[name="qslvia"]').val(),
sota: form.sota.value,
pota: form.pota.value,
operator: form.operator.value,
wwff: form.wwff.value,
qslimages: form.qslimages.value,
continent: form.continent.value,