From 440693167429cf2cd255fc4ac2f68d880790cfbd Mon Sep 17 00:00:00 2001 From: Corby Krick Date: Sun, 8 Sep 2013 15:30:24 -0500 Subject: [PATCH] Working on getting the export running. At the point where I am ready to start trying to do the HTTP posts to eQSL.cc --- application/controllers/eqsl.php | 75 +++++++++++++++++++++------- application/models/logbook_model.php | 8 +++ application/views/eqsl/export.php | 21 ++++++++ application/views/layout/header.php | 1 + 4 files changed, 87 insertions(+), 18 deletions(-) create mode 100644 application/views/eqsl/export.php diff --git a/application/controllers/eqsl.php b/application/controllers/eqsl.php index cd596abe..89cf80f2 100644 --- a/application/controllers/eqsl.php +++ b/application/controllers/eqsl.php @@ -100,7 +100,7 @@ class eqsl extends CI_Controller { { $file = $config['upload_path'] . 'eqslreport_download.adi'; - // Get credentials for LoTW + // Get credentials for eQSL $query = $this->user_model->get_by_id($this->session->userdata('user_id')); $q = $query->row(); $data['user_eqsl_name'] = $q->user_eqsl_name; @@ -182,23 +182,63 @@ class eqsl extends CI_Controller { } // end function public function export() { - $data['page_title'] = "eQSL Report Upload"; - - $config['upload_path'] = './uploads/'; - $config['allowed_types'] = 'tq8|TQ8'; - - $this->load->library('upload', $config); - - if ( ! $this->upload->do_upload()) + $this->load->model('logbook_model'); + + $data['page_title'] = "eQSL QSO Upload"; + + if ($this->input->post('eqslexport') == "export") { - $data['error'] = $this->upload->display_errors(); - - $this->load->view('layout/header', $data); - $this->load->view('eqsl/export'); - $this->load->view('layout/footer'); + // Check for credentials + + // Grab the list of QSOs to send information about + // perform an HTTP get on each one, and grab the status back + $qslsnotsent = $this->logbook_model->eqsl_not_yet_sent(); + + // Build out the ADIF info string + $adif = ""; + foreach ($qslsnotsent->result_array() as $qsl) + { + + } + // Perform a big HTTP POST with the ADIF information at the back + // http://www.eqsl.cc/qslcard/ImportADIF.txt + + // Dump out a table with the results } else - { + { + $qslsnotsent = $this->logbook_model->eqsl_not_yet_sent(); + + if ($qslsnotsent->num_rows() > 0) + { + $table = ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + + foreach ($qslsnotsent->result_array() as $qsl) + { + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + } + $table .= "
DateCallModeBand
".$qsl['COL_TIME_ON']."".strtoupper($qsl['COL_CALL'])."".$qsl['COL_MODE']."".$qsl['COL_BAND']."
"; + + $data['eqsl_table'] = $table; + } + } + + $this->load->view('layout/header', $data); + $this->load->view('eqsl/export'); + $this->load->view('layout/footer'); + + /* OLD STUFF from LOTW $data = array('upload_data' => $this->upload->data()); // Figure out how we should be marking QSLs confirmed via LoTW @@ -230,7 +270,6 @@ class eqsl extends CI_Controller { $ch = curl_init(); // extra headers - $headers[] = "Accept: */*"; $headers[] = "Connection: Keep-Alive"; // basic curl options for all requests @@ -297,11 +336,11 @@ class eqsl extends CI_Controller { // Now we need to clean up unlink($cookie_file_path); unlink('./uploads/'.$data['upload_data']['file_name']); - + $this->load->view('layout/header', $data); $this->load->view('eqsl/status'); $this->load->view('layout/footer'); - } + */ } } // end class \ No newline at end of file diff --git a/application/models/logbook_model.php b/application/models/logbook_model.php index 61211c28..253e2f94 100644 --- a/application/models/logbook_model.php +++ b/application/models/logbook_model.php @@ -654,6 +654,14 @@ class Logbook_model extends CI_Model { } } + // Show all QSOs we need to send to eQSL + function eqsl_not_yet_sent() { + $this->db->select('COL_PRIMARY_KEY, COL_TIME_ON, COL_CALL, COL_BAND, COL_MODE'); + $this->db->where('COL_EQSL_QSL_SENT', 'N'); + + return $this->db->get($this->config->item('table_name')); + } + function import($record) { // Join date+time //$datetime = date('Y-m-d') ." ". $this->input->post('start_time'); diff --git a/application/views/eqsl/export.php b/application/views/eqsl/export.php new file mode 100644 index 00000000..727ec2e4 --- /dev/null +++ b/application/views/eqsl/export.php @@ -0,0 +1,21 @@ +
+ +

+load->view('layout/messages'); ?> + +The following QSOs have not been sent to eQSL.cc

"; + echo $eqsl_table; + echo "

Clicking \"Upload QSOs\" will send QSO information to eQSL.cc.

"; + echo form_open('eqsl/export'); + echo ""; + echo ""; + } + else + { + echo "

There are no QSOs that need to be sent to eQSL.cc at this time. Go log some more QSOs!

"; + } +?> +
diff --git a/application/views/layout/header.php b/application/views/layout/header.php index 9ac5df5a..12b5451b 100644 --- a/application/views/layout/header.php +++ b/application/views/layout/header.php @@ -88,6 +88,7 @@
  • Data Export
  • API
  • eQSL Import
  • +
  • eQSL Export
  • LoTW Import
  • LoTW Export