mirror of
https://github.com/magicbug/Cloudlog
synced 2024-11-22 08:13:41 +00:00
[Advanced Logbook] ADIF export fetches sort order from table sort (not all columns)
This commit is contained in:
parent
4d56a09d09
commit
cb71e0961f
@ -125,9 +125,10 @@ class Logbookadvanced extends CI_Controller {
|
||||
$this->load->model('logbookadvanced_model');
|
||||
|
||||
$ids = xss_clean($this->input->post('id'));
|
||||
$sortorder = xss_clean($this->input->post('sortorder'));
|
||||
$user_id = (int)$this->session->userdata('user_id');
|
||||
|
||||
$data['qsos'] = $this->logbookadvanced_model->getQsosForAdif($ids, $user_id);
|
||||
$data['qsos'] = $this->logbookadvanced_model->getQsosForAdif($ids, $user_id, $sortorder);
|
||||
|
||||
$this->load->view('adif/data/exportall', $data);
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ class Logbookadvanced_model extends CI_Model {
|
||||
return $qsos;
|
||||
}
|
||||
|
||||
public function getQsosForAdif($ids, $user_id) : object {
|
||||
public function getQsosForAdif($ids, $user_id, $sortorder) : object {
|
||||
$binding = [$user_id];
|
||||
$conditions[] = "COL_PRIMARY_KEY in ?";
|
||||
$binding[] = json_decode($ids, true);
|
||||
@ -122,6 +122,21 @@ class Logbookadvanced_model extends CI_Model {
|
||||
$where = "AND $where";
|
||||
}
|
||||
|
||||
$sortorder = explode(',', $sortorder);
|
||||
|
||||
switch($sortorder[0]) {
|
||||
case 1: $order = 'ORDER BY qsos.COL_TIME_ON ' . $sortorder[1]; break;
|
||||
case 2: $order = 'ORDER BY station_profile.station_callsign ' . $sortorder[1]; break;
|
||||
case 3: $order = 'ORDER BY qsos.COL_CALL ' . $sortorder[1]; break;
|
||||
case 4: $order = 'ORDER BY qsos.COL_MODE' . $sortorder[1] . ', qsos.COL_SUBMODE ' . $sortorder[1]; break;
|
||||
case 7: $order = 'ORDER BY qsos.COL_BAND ' . $sortorder[1] . ', qsos.COL_SAT_NAME ' . $sortorder[1]; break;
|
||||
case 15: $order = 'ORDER BY qsos.COL_COUNTRY ' . $sortorder[1]; break;
|
||||
case 16: $order = 'ORDER BY qso.COL_STATE ' . $sortorder[1]; break;
|
||||
case 17: $order = 'ORDER BY qsos.COL_CQZ ' . $sortorder[1]; break;
|
||||
case 18: $order = 'ORDER BY qsos.COL_IOTA ' . $sortorder[1]; break;
|
||||
default: $order = 'ORDER BY qsos.COL_TIME_ON desc'; break;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *, dxcc_entities.name AS station_country
|
||||
FROM " . $this->config->item('table_name') . " qsos
|
||||
@ -129,7 +144,7 @@ class Logbookadvanced_model extends CI_Model {
|
||||
LEFT OUTER JOIN dxcc_entities ON qsos.COL_MY_DXCC = dxcc_entities.adif
|
||||
WHERE station_profile.user_id = ?
|
||||
$where
|
||||
ORDER BY qsos.COL_TIME_ON desc
|
||||
$order
|
||||
";
|
||||
|
||||
return $this->db->query($sql, $binding);
|
||||
|
@ -50,7 +50,7 @@ function loadQSOTable(rows) {
|
||||
"scrollCollapse": true,
|
||||
"paging": false,
|
||||
"scrollX": true,
|
||||
"order": [ 0, 'asc' ],
|
||||
"order": [ 1, 'desc' ],
|
||||
});
|
||||
});
|
||||
|
||||
@ -293,7 +293,7 @@ $(document).ready(function () {
|
||||
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
||||
// You should set responseType as blob for binary responses
|
||||
xhttp.responseType = 'blob';
|
||||
xhttp.send("id=" + JSON.stringify(id_list, null, 2));
|
||||
xhttp.send("id=" + JSON.stringify(id_list, null, 2)+"&sortorder=" +$('.table').DataTable().order());
|
||||
$('#exportAdif').prop("disabled", false);
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user