From 35363f2374ef825295bfd78b6b8c58c1a2533dec Mon Sep 17 00:00:00 2001 From: Andy Date: Sun, 28 Feb 2016 14:09:08 +0000 Subject: [PATCH 01/16] Stored Proc for DXCC info --- application/config/migration.php | 2 +- application/controllers/logbook.php | 13 ++++++ application/logs/index.html | 10 ---- .../migrations/013_add_dxcc_stored_proc.php | 46 +++++++++++++++++++ application/models/logbook_model.php | 19 ++++++++ application/views/update/index.php | 4 +- 6 files changed, 81 insertions(+), 13 deletions(-) delete mode 100644 application/logs/index.html create mode 100644 application/migrations/013_add_dxcc_stored_proc.php diff --git a/application/config/migration.php b/application/config/migration.php index 947334c3..993f1dc4 100644 --- a/application/config/migration.php +++ b/application/config/migration.php @@ -21,7 +21,7 @@ $config['migration_enabled'] = TRUE; | be upgraded / downgraded to. | */ -$config['migration_version'] = 12; +$config['migration_version'] = 13; /* diff --git a/application/controllers/logbook.php b/application/controllers/logbook.php index 477d8fbc..6965aa1a 100644 --- a/application/controllers/logbook.php +++ b/application/controllers/logbook.php @@ -351,6 +351,19 @@ class Logbook extends CI_Controller { echo $json; } + /* + * Provide a dxcc search, returning results json encoded + */ + function local_find_dxcc($call = "", $date = "") { + $this->load->model("logbook_model"); + if ($date == ''){ + $date = date("Y-m-d"); + } + $ans = $this->logbook_model->check_dxcc_stored_proc($call, $date); + print json_encode($ans); + } + + /* return station bearing */ function bearing() { $this->load->library('Qra'); diff --git a/application/logs/index.html b/application/logs/index.html deleted file mode 100644 index 7f684dff..00000000 --- a/application/logs/index.html +++ /dev/null @@ -1,10 +0,0 @@ - - - 403 Forbidden - - - -

Directory access is forbidden.

- - - diff --git a/application/migrations/013_add_dxcc_stored_proc.php b/application/migrations/013_add_dxcc_stored_proc.php new file mode 100644 index 00000000..e490719d --- /dev/null +++ b/application/migrations/013_add_dxcc_stored_proc.php @@ -0,0 +1,46 @@ +db->query("drop procedure if exists `find_country`"); + if (!$res){ + print ("Error dropping stored proc"); + exit(0); + } + + $sql = <<0 do + select `entity`, `adif` into country, dxcc_id + from dxcc_prefixes + where `call`= substring(callsign, 1, calllen) + and (`start` <= qso_date or `start`='0000-00-00') + and (`end` >= qso_date or `end`='0000-00-00'); + if (FOUND_ROWS() >0) THEN + LEAVE L1; + else + set calllen = calllen - 1; + end IF; + end WHILE; +end +EOF; + + $res = $this->db->query($sql); + if (!$res){ + print ("Error setting stored proc"); + exit(0); + } + } + + public function down(){ + $this->db->query("drop procedure if exists `find_country`"); + } +} diff --git a/application/models/logbook_model.php b/application/models/logbook_model.php index 3a628f35..ae715d72 100644 --- a/application/models/logbook_model.php +++ b/application/models/logbook_model.php @@ -967,6 +967,21 @@ class Logbook_model extends CI_Model { return array("Not Found", "Not Found"); } + /* + * Same as check_dxcc_table, but the functionality is in + * a stored procedure which we call + */ + public function check_dxcc_stored_proc($call, $date){ + $this->db->query("call find_country('".$call."','".$date."', @country, @adif)"); + $res = $this->db->query("select @country as country, @adif as adif"); + $d = $res->result_array(); + + // Should only be one result. + // NOTE: might cause unexpected data if there's an + // error with clublog.org data. + return $d[0]; + } + public function check_missing_dxcc_id($all){ // get all records with no COL_DXCC $this->db->select("COL_PRIMARY_KEY, COL_CALL, COL_TIME_ON, COL_TIME_OFF"); @@ -986,8 +1001,12 @@ class Logbook_model extends CI_Model { $qso_date = $row['COL_TIME_OFF']=='' ? $row['COL_TIME_ON'] : $row['COL_TIME_ON']; $qso_date = strftime("%Y-%m-%d", strtotime($qso_date)); + // Manual call $d = $this->check_dxcc_table($row['COL_CALL'], $qso_date); + // Stored procedure call + //$d = $this->check_dxcc_stored_proc($row["COL_CALL"], $qso_date); + if ($d[0] != 'Not Found'){ $sql = sprintf("update %s set COL_COUNTRY = '%s', COL_DXCC='%s' where COL_PRIMARY_KEY=%d", $this->config->item('table_name'), addslashes(ucwords(strtolower($d[1]))), $d[0], $row['COL_PRIMARY_KEY']); diff --git a/application/views/update/index.php b/application/views/update/index.php index f8a64a7f..25be3943 100644 --- a/application/views/update/index.php +++ b/application/views/update/index.php @@ -8,8 +8,8 @@ Status:

- Check missing DXCC/Countries values - [Re-Check ALL] + Check missing DXCC/Countries values + [Re-Check ALL] + From d8f236c1478b6736cfbe5e4edede7a10782247a9 Mon Sep 17 00:00:00 2001 From: Andy Date: Sun, 17 Apr 2016 11:39:56 +0100 Subject: [PATCH 09/16] CQ zone map --- application/controllers/awards.php | 2 +- application/views/awards/cq/index.php | 100 +++++++++++++----------- application/views/awards/dxcc/index.php | 1 + 3 files changed, 55 insertions(+), 48 deletions(-) diff --git a/application/controllers/awards.php b/application/controllers/awards.php index 4f765b76..3ae33a37 100644 --- a/application/controllers/awards.php +++ b/application/controllers/awards.php @@ -60,7 +60,7 @@ class Awards extends CI_Controller { // Render Page $data['page_title'] = "Log View - DXCC"; - $data['filter'] = $a["Country"] . " and " . $a["Band"]; + $data['filter'] = str_replace("(and)", ", ", $q);//implode(", ", array_keys($a)); $this->load->view('layout/header', $data); $this->load->view('awards/dxcc/details'); $this->load->view('layout/footer'); diff --git a/application/views/awards/cq/index.php b/application/views/awards/cq/index.php index f5c26711..27b667c3 100644 --- a/application/views/awards/cq/index.php +++ b/application/views/awards/cq/index.php @@ -5,53 +5,53 @@

CQ Zones worked:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + " usemap="#CQ" border="0"> @@ -70,4 +70,10 @@ $('.zone_'+el).data('maphilight', {'alwaysOn':true}).trigger('alwaysOn.maphilight'); } + + Maps from JF9EXF site. +

Notes:

+
    +
  • All US callsigns are allocated zone 5 by the FCC. This may not be correct
  • +
diff --git a/application/views/awards/dxcc/index.php b/application/views/awards/dxcc/index.php index b9371f54..4b4b2c38 100644 --- a/application/views/awards/dxcc/index.php +++ b/application/views/awards/dxcc/index.php @@ -51,6 +51,7 @@ top: 40px; display: none; background-color: white; + border: 1px solid black; }