<?php
	header('Content-Type: text/plain; charset=utf-8');
	header('Content-Disposition: attachment; filename="'.$this->session->userdata('user_callsign').'-'.date('dmY-Hi').'.adi"')
?>
<ADIF_VERS:5>3.1.0
<PROGRAMID:<?php echo strlen($this->config->item('app_name')); ?>><?php echo $this->config->item('app_name')."\n"; ?>
<PROGRAMVERSION:<?php echo strlen($this->config->item('app_version')); ?>>Version <?php echo $this->config->item('app_version')."\n"; ?>
<EOH>

<?php foreach ($qsos->result() as $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_SUBMODE) { ?><SUBMODE:<?php echo strlen($qso->COL_SUBMODE); ?>><?php echo $qso->COL_SUBMODE; ?><?php } ?><?php if($qso->COL_FREQ != "0") { ?><?php $freq_in_mhz = $qso->COL_FREQ / 1000000; ?><freq:<?php echo strlen($freq_in_mhz); ?>><?php echo $freq_in_mhz; ?><?php } ?><?php if($qso->COL_FREQ_RX != "0") { ?><?php $freq_rx_in_mhz = $qso->COL_FREQ_RX / 1000000; ?><FREQ_RX:<?php echo strlen($freq_rx_in_mhz); ?>><?php echo $freq_rx_in_mhz; ?><?php } ?><?php if($qso->COL_BAND_RX) { ?><BAND_RX:<?php echo strlen($qso->COL_BAND_RX); ?>><?php echo $qso->COL_BAND_RX; ?><?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('His', $time_on); ?><time_on:<?php echo strlen($new_on); ?>><?php echo $new_on; ?><?php $time_off = strtotime($qso->COL_TIME_OFF); $new_off = date('His', $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_VUCC_GRIDS != "") { ?><vucc_grids:<?php echo strlen($qso->COL_VUCC_GRIDS); ?>><?php echo $qso->COL_VUCC_GRIDS; ?><?php } ?><?php if($qso->COL_VUCC_GRIDS == "" && $qso->COL_GRIDSQUARE != "") { ?><gridsquare:<?php echo strlen($qso->COL_GRIDSQUARE); ?>><?php echo $qso->COL_GRIDSQUARE; ?><?php } ?><?php if($qso->COL_SAT_NAME) { ?><?php if($qso->COL_SAT_MODE != 0 || $qso->COL_SAT_MODE !="") {?><sat_mode:<?php echo strlen($qso->COL_SAT_MODE); ?>><?php echo $qso->COL_SAT_MODE; ?><?php } ?><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_STATE) { ?><state:<?php echo strlen($qso->COL_STATE); ?>><?php echo $qso->COL_STATE; ?><?php } ?><?php if($qso->COL_SOTA_REF) { ?><sota_ref:<?php echo strlen($qso->COL_SOTA_REF); ?>><?php echo $qso->COL_SOTA_REF; ?><?php } ?><?php if($qso->COL_OPERATOR) { ?><operator:<?php echo strlen($qso->COL_OPERATOR); ?>><?php echo $qso->COL_OPERATOR; ?><?php } ?><?php if($qso->station_callsign) { ?><STATION_CALLSIGN:<?php echo strlen($qso->station_callsign); ?>><?php echo $qso->station_callsign; ?><?php } ?><?php if($qso->station_city) { ?><MY_CITY:<?php echo strlen($qso->station_city); ?>><?php echo $qso->station_city; ?><?php } ?><?php if($qso->station_country) { ?><MY_COUNTRY:<?php echo strlen($qso->station_country); ?>><?php echo $qso->station_country; ?><?php } ?><?php if($qso->station_dxcc) { ?><MY_DXCC:<?php echo strlen($qso->station_dxcc); ?>><?php echo $qso->station_dxcc; ?><?php } ?><?php if( strpos($qso->station_gridsquare, ',') !== false ) { ?><MY_VUCC_GRIDS:<?php echo strlen($qso->station_gridsquare); ?>><?php echo $qso->station_gridsquare; ?><?php } else { ?><MY_GRIDSQUARE:<?php echo strlen($qso->station_gridsquare); ?>><?php echo $qso->station_gridsquare; ?><?php } ?><?php if($qso->station_iota) { ?><MY_IOTA:<?php echo strlen($qso->station_iota); ?>><?php echo $qso->station_iota; ?><?php } ?><?php if($qso->station_sota) { ?><MY_SOTA_REF:<?php echo strlen($qso->station_sota); ?>><?php echo $qso->station_sota; ?><?php } ?><?php if($qso->station_cq) { ?><MY_CQ_ZONE:<?php echo strlen($qso->station_cq); ?>><?php echo $qso->station_cq; ?><?php } ?><?php if($qso->station_itu) { ?><MY_ITU_ZONE:<?php echo strlen($qso->station_itu); ?>><?php echo $qso->station_itu; ?><?php } ?><?php if($qso->station_cnty) { ?><MY_CNTY:<?php echo strlen($qso->station_cnty); ?>><?php echo $qso->station_cnty; ?><?php } ?><?php if($qso->state) { ?><MY_STATE:<?php echo strlen($qso->state); ?>><?php echo $qso->state; ?><?php } ?><eor>
<?php } ?>