mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
@@ -329,6 +329,31 @@ class Awards extends CI_Controller {
|
||||
$this->load->view('interface_assets/footer', $footerData);
|
||||
}
|
||||
|
||||
public function jcc_export() {
|
||||
$this->load->model('Jcc_model');
|
||||
$postdata['qsl'] = $this->security->xss_clean($this->input->post('qsl'));
|
||||
$postdata['lotw'] = $this->security->xss_clean($this->input->post('lotw'));
|
||||
$postdata['eqsl'] = $this->security->xss_clean($this->input->post('eqsl'));
|
||||
$postdata['qrz'] = $this->security->xss_clean($this->input->post('qrz'));
|
||||
$postdata['worked'] = $this->security->xss_clean($this->input->post('worked'));
|
||||
$postdata['confirmed'] = $this->security->xss_clean($this->input->post('confirmed'));
|
||||
$postdata['notworked'] = $this->security->xss_clean($this->input->post('notworked'));
|
||||
$postdata['band'] = $this->security->xss_clean($this->input->post('band'));
|
||||
$postdata['mode'] = $this->security->xss_clean($this->input->post('mode'));
|
||||
|
||||
$qsos = $this->Jcc_model->exportJcc($postdata);
|
||||
|
||||
$fp = fopen( 'php://output', 'w' );
|
||||
$i=1;
|
||||
fputcsv($fp, array('No', 'Callsign', 'Date', 'Band', 'Mode', 'Remarks'), ';');
|
||||
foreach ($qsos as $qso) {
|
||||
fputcsv($fp, array($i, $qso['call'], $qso['date'], ($qso['prop_mode'] != null ? $qso['band'].' / '.$qso['prop_mode'] : $qso['band']), $qso['mode'], $qso['cnty'].' - '.$qso['jcc']), ';');
|
||||
$i++;
|
||||
}
|
||||
fclose($fp);
|
||||
return;
|
||||
}
|
||||
|
||||
public function vucc() {
|
||||
$this->load->model('vucc');
|
||||
$this->load->model('bands');
|
||||
|
||||
@@ -825,9 +825,8 @@ class Jcc_model extends CI_Model {
|
||||
);
|
||||
|
||||
function get_jcc_array($bands, $postdata) {
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('logbooks_model');
|
||||
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||
$this->load->model('logbooks_model');
|
||||
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||
|
||||
if (!$logbooks_locations_array) {
|
||||
return null;
|
||||
@@ -1020,9 +1019,8 @@ class Jcc_model extends CI_Model {
|
||||
*/
|
||||
function get_jcc_summary($bands, $postdata)
|
||||
{
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('logbooks_model');
|
||||
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||
$this->load->model('logbooks_model');
|
||||
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||
|
||||
if (!$logbooks_locations_array) {
|
||||
return null;
|
||||
@@ -1131,5 +1129,59 @@ class Jcc_model extends CI_Model {
|
||||
$sql .= " and COL_CNTY in (".implode(',', array_keys($this->jaCities)).")";
|
||||
return $sql;
|
||||
}
|
||||
|
||||
function exportJcc($postdata) {
|
||||
$this->load->model('logbooks_model');
|
||||
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||
|
||||
if (!$logbooks_locations_array) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$location_list = "'".implode("','",$logbooks_locations_array)."'";
|
||||
|
||||
$jccArray = array_keys($this->jaCities);
|
||||
|
||||
$sql = "SELECT distinct col_cnty FROM " . $this->config->item('table_name') . " thcv
|
||||
where station_id in (" . $location_list . ")";
|
||||
|
||||
if ($postdata['mode'] != 'All') {
|
||||
$sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')";
|
||||
}
|
||||
|
||||
$sql .= $this->addStateToQuery();
|
||||
$sql .= $this->genfunctions->addBandToQuery($postdata['band']);
|
||||
$sql .= $this->genfunctions->addQslToQuery($postdata);
|
||||
$sql .= ' ORDER BY COL_CNTY ASC';
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
$jccs = array();
|
||||
foreach($query->result() as $line) {
|
||||
$jccs[] = $line->col_cnty;
|
||||
}
|
||||
$qsos = array();
|
||||
foreach($jccs as $jcc) {
|
||||
$qso = $this->getFirstQso($location_list, $jcc, $postdata);
|
||||
$qsos[] = array('call' => $qso[0]->COL_CALL, 'date' => $qso[0]->COL_TIME_ON, 'band' => $qso[0]->COL_BAND, 'mode' => $qso[0]->COL_MODE, 'prop_mode' => $qso[0]->COL_PROP_MODE, 'cnty' => $qso[0]->COL_CNTY, 'jcc' => $this->jaCities[$qso[0]->COL_CNTY]);
|
||||
}
|
||||
|
||||
return $qsos;
|
||||
}
|
||||
|
||||
function getFirstQso($location_list, $jcc, $postdata) {
|
||||
$sql = 'SELECT COL_CNTY, COL_CALL, COL_TIME_ON, COL_BAND, COL_MODE, COL_PROP_MODE FROM '.$this->config->item('table_name').' t1
|
||||
WHERE station_id in ('.$location_list.')';
|
||||
if ($postdata['mode'] != 'All') {
|
||||
$sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')";
|
||||
}
|
||||
$sql .= $this->addStateToQuery();
|
||||
$sql .= $this->genfunctions->addBandToQuery($postdata['band']);
|
||||
$sql .= $this->genfunctions->addQslToQuery($postdata);
|
||||
$sql .= ' AND COL_CNTY = \''.$jcc.'\'';
|
||||
$sql .= ' ORDER BY COL_TIME_ON ASC LIMIT 1';
|
||||
$query = $this->db->query($sql);
|
||||
return $query->result();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -98,6 +98,7 @@
|
||||
<div class="col-md-10">
|
||||
<button id="button2id" type="reset" name="button2id" class="btn btn-sm btn-warning">Reset</button>
|
||||
<button id="button1id" type="submit" name="button1id" class="btn btn-sm btn-primary">Show</button>
|
||||
<button id="button3id" type="button" onclick="export_qsos();" name="button3id" class="btn btn-sm btn-info">Export</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -15,4 +15,53 @@ $(document).ready(function () {
|
||||
'csv'
|
||||
]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function export_qsos() {
|
||||
$.ajax({
|
||||
url: base_url + 'index.php/awards/jcc_export',
|
||||
type: 'post',
|
||||
xhrFields: {
|
||||
responseType: 'text/csv;charset=utf8',
|
||||
},
|
||||
data: {
|
||||
band: $('#band2').val(),
|
||||
mode: $('#mode').val(),
|
||||
worked: +$('#worked').prop('checked'),
|
||||
confirmed: +$('#confirmed').prop('checked'),
|
||||
notworked: +$('#notworked').prop('checked'),
|
||||
qsl: +$('#qsl').prop('checked'),
|
||||
lotw: +$('#lotw').prop('checked'),
|
||||
qrz: +$('#qrz').prop('checked'),
|
||||
eqsl: +$('#eqsl').prop('checked'),
|
||||
includedeleted: +$('#includedeleted').prop('checked'),
|
||||
Africa: +$('#Africa').prop('checked'),
|
||||
Asia: +$('#Asia').prop('checked'),
|
||||
Europe: +$('#Europe').prop('checked'),
|
||||
NorthAmerica: +$('#NorthAmerica').prop('checked'),
|
||||
SouthAmerica: +$('#SouthAmerica').prop('checked'),
|
||||
Oceania: +$('#Oceania').prop('checked'),
|
||||
Antarctica: +$('#Antarctica').prop('checked'),
|
||||
sat: $("#sats").val(),
|
||||
orbit: $("#orbits").val(),
|
||||
},
|
||||
success: function(data) {
|
||||
var a = document.createElement('a');
|
||||
var fileData = ['\ufeff'+data];
|
||||
console.log(fileData);
|
||||
var blob = new Blob(fileData,{
|
||||
type: "text/csv;charset=utf-8;"
|
||||
});
|
||||
var url = URL.createObjectURL(blob);
|
||||
a.href = url;
|
||||
a.download = 'qso_export.csv';
|
||||
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
},
|
||||
error: function() {
|
||||
console.log("error");
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user