Added ADIF export functions either whole log or by date.

This commit is contained in:
Peter Goodhall 2011-09-21 14:30:01 +01:00
parent 7c6c27cce7
commit 5c8fd2ddfe
6 changed files with 139 additions and 2 deletions

View File

@ -26,6 +26,9 @@ $config['auth_level'][99] = "Administrator";
$config['beta'] = true;
$config['app_name'] = "Web Logger";
$config['app_version'] = "0.1";
/*
|--------------------------------------------------------------------------
| Base Site URL

View File

@ -0,0 +1,38 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class adif extends CI_Controller {
/* Controls ADIF Import/Export Functions */
/* Shows Export Views */
public function export() {
$this->load->view('layout/header');
$this->load->view('adif/main');
$this->load->view('layout/footer');
}
// Export all QSO Data in ASC Order of Date.
public function exportall()
{
$this->load->model('adif_data');
$data['qsos'] = $this->adif_data->export_all();
$this->load->view('adif/data/exportall', $data);
}
public function export_custom() {
$this->load->model('adif_data');
$data['qsos'] = $this->adif_data->export_custom($this->input->post('from'), $this->input->post('to'));
$this->load->view('adif/data/exportall', $data);
}
}
/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */

View File

@ -0,0 +1,28 @@
<?php
class adif_data extends CI_Model {
function __construct()
{
// Call the Model constructor
parent::__construct();
}
function export_all() {
//$this->db->limit(5);
$this->db->order_by("COL_TIME_ON", "ASC");
$query = $this->db->get($this->config->item('table_name'));
return $query;
}
function export_custom($from, $to) {
$this->db->where("COL_TIME_ON BETWEEN '".$from."' AND '".$to."'");
$this->db->order_by("COL_TIME_ON", "ASC");
$query = $this->db->get($this->config->item('table_name'));
return $query;
}
}
?>

View File

@ -0,0 +1,15 @@
<?php
header("content-type: plain/text");
header('Content-Disposition: attachment; filename="export_log.adi"')
?>
<ADIF_VERS:3>2.2
<PROGRAMID:14><?php echo $this->config->item('app_name')."\n"; ?>
<PROGRAMVERSION:22>Version <?php echo $this->config->item('app_version')."\n"; ?>
<EOH>
<?php foreach ($qsos->result() as $qso) { //print_r($qso);?>
<call:<?php echo strlen($qso->COL_CALL); ?>><?php echo $qso->COL_CALL; ?><band:<?php echo strlen($qso->COL_BAND); ?>><?php echo $qso->COL_BAND; ?><mode:<?php echo strlen($qso->COL_MODE); ?>><?php echo $qso->COL_MODE; ?><?php if($qso->COL_FREQ != "0") { ?><freq:<?php echo strlen($qso->COL_FREQ); ?>><?php echo $qso->COL_FREQ; ?><?php } ?><?php $date_on = strtotime($qso->COL_TIME_ON); $new_date = date('Ymd', $date_on); ?><qso_date:<?php echo strlen($new_date); ?>><?php echo $new_date; ?><?php $time_on = strtotime($qso->COL_TIME_ON); $new_on = date('Hi', $time_on); ?><time_on:<?php echo strlen($new_on); ?>><?php echo $new_on; ?><?php $time_off = strtotime($qso->COL_TIME_OFF); $new_off = date('Hi', $time_off); ?><time_off:<?php echo strlen($new_off); ?>><?php echo $new_off; ?><rst_rcvd:<?php echo strlen($qso->COL_RST_RCVD); ?>><?php echo $qso->COL_RST_RCVD; ?><rst_sent:<?php echo strlen($qso->COL_RST_SENT); ?>><?php echo $qso->COL_RST_SENT; ?><qsl_rcvd:<?php echo strlen($qso->COL_QSL_RCVD); ?>><?php echo $qso->COL_QSL_RCVD; ?><qsl_sent:<?php echo strlen($qso->COL_QSL_SENT); ?>><?php echo $qso->COL_QSL_SENT; ?><country:<?php echo strlen($qso->COL_COUNTRY); ?>><?php echo $qso->COL_COUNTRY; ?><?php if($qso->COL_GRIDSQUARE != "") { ?><gridsquare:<?php echo strlen($qso->COL_GRIDSQUARE); ?>><?php echo $qso->COL_GRIDSQUARE; ?><?php } ?><?php if($qso->COL_SAT_NAME) { ?><sat_mode:<?php echo strlen($qso->COL_SAT_MODE); ?>><?php echo $qso->COL_SAT_MODE; ?><sat_name:<?php echo strlen($qso->COL_SAT_NAME); ?>><?php echo $qso->COL_SAT_NAME; ?><?php } ?><?php if($qso->COL_PROP_MODE) { ?><prop_mode:<?php echo strlen($qso->COL_PROP_MODE); ?>><?php echo $qso->COL_PROP_MODE; ?><?php } ?><?php if($qso->COL_NAME) { ?><name:<?php echo strlen($qso->COL_NAME); ?>><?php echo $qso->COL_NAME; ?><?php } ?><?php if($qso->COL_COMMENT) { ?><comment:<?php echo strlen($qso->COL_COMMENT); ?>><?php echo $qso->COL_COMMENT; ?><?php } ?><eor>
<?php } ?>

View File

@ -0,0 +1,52 @@
<h2>ADIF Export</h2>
<div class="wrap_content note">
<p>Exporting your log is simple you can either export the whole log or use the finer controls to set the date.</p>
<ul class="notes_list">
<li><a href="<?php echo site_url('adif/exportall'); ?>" title="Export All" target="_blank">Export All QSOs</a></li>
</ul>
<h3>Export Options</h3>
<form method="post" action="<?php echo site_url('adif/export_custom');?>" >
<table>
<tr>
<td>Start Date</td>
<td><input type="text" id="from" name="from"/></td>
</tr>
<tr>
<td>End Date</td>
<td><input type="text" id="to" name="to"/></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="submit" value="Download" /></td>
</tr>
</table>
</form>
</div>
<script>
$(function() {
var dates = $( "#from, #to" ).datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 1,
dateFormat: "yy-mm-dd",
onSelect: function( selectedDate ) {
var option = this.id == "from" ? "minDate" : "maxDate",
instance = $( this ).data( "datepicker" ),
date = $.datepicker.parseDate(
instance.settings.dateFormat ||
$.datepicker._defaults.dateFormat,
selectedDate, instance.settings );
dates.not( this ).datepicker( "option", option, date );
}
});
});
</script>

View File

@ -114,7 +114,7 @@ ul.notes_list {list-style-type: circle; padding-left: 20px; }
p {
line-height: 1.7;
margin: 10px 0;
margin: 0px 0;
}
.contest_wrap { margin: 0 auto; width: 95%; }
@ -151,7 +151,7 @@ border-radius: 10px;
<ul id="navlist">
<?php if((($this->config->item('use_auth')) && ($this->session->userdata('user_type') >= $this->config->item('auth_mode'))) || $this->config->item('use_auth') === FALSE) { ?>
<li><a href="<?php echo site_url();?> " title="Dashboard">Dashboard</a></li>
<li><a href="<?php echo site_url('logbook');?>" title="View Log">View Log</a></li>
<li><a href="<?php echo site_url('logbook');?>" title="Logbook">Logbook</a></li>
<li><a href="<?php echo site_url('search');?>" title="Search">Search</a></li>
<?php if(($this->config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE) { ?>
<li><a href="<?php echo site_url('qso');?>" title="Add QSO">Add QSO</a></li>
@ -182,6 +182,7 @@ border-radius: 10px;
<?php if(($this->config->item('use_auth') && $this->session->userdata('user_type') >= 99) || $this->config->item('use_auth') === FALSE){ ?>
<li class="ui-corner-all"><a href="<?php echo site_url('user');?>" title="Users">Users</a></li>
<li><a href="<?php echo site_url('setup');?>" title="Setup">Setup</a></li>
<li><a href="<?php echo site_url('adif/export');?>" title="ADIF Export">ADIF Export</a></li>
<?php } ?>
</ul>
</div>