Skip to content

Commit

Permalink
Merge pull request #192 from teabreakninja/master
Browse files Browse the repository at this point in the history
Check existing log entries against the new DXCC/Country list
  • Loading branch information
magicbug committed Feb 22, 2016
2 parents e363808 + 56b7333 commit 5358951
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 2 deletions.
6 changes: 6 additions & 0 deletions application/controllers/update.php
Expand Up @@ -206,6 +206,12 @@ private function fix_migrations(){
}
}

public function check_missing_dxcc(){
$this->load->model('logbook_model');
$this->logbook_model->check_missing_dxcc_id();

}

public function lotw_users() {
// Load Database connectors
$this->load->model('lotw');
Expand Down
2 changes: 1 addition & 1 deletion application/logs/index.html
Expand Up @@ -7,4 +7,4 @@
<p>Directory access is forbidden.</p>

</body>
</html>
</html>
47 changes: 47 additions & 0 deletions application/models/logbook_model.php
Expand Up @@ -966,6 +966,53 @@ function import($record) {
}
}


private function check_dxcc_table($call){
global $con;
$len = strlen($call);

// query the table, removing a character from the right until a match
for ($i = $len; $i > 0; $i--){
//printf("searching for %s\n", substr($call, 0, $i));
$dxcc_result = $this->db->query("select `call`, `entity`, `adif` from dxcc_prefixes where `call` = '".substr($call, 0, $i) ."'");


if ($dxcc_result->num_rows() > 0){
$row = $dxcc_result->row_array();
return array($row['adif'], $row['entity']);
}
}

return array("Not Found", "Not Found");
}

public function check_missing_dxcc_id(){
// get all records with no COL_DXCC
$this->db->select("COL_PRIMARY_KEY, COL_CALL");
$this->db->where("COL_DXCC is NULL");
$r = $this->db->get($this->config->item('table_name'));

$count = 0;
$this->db->trans_start();
//query dxcc_prefixes
if ($r->num_rows() > 0){
foreach($r->result_array() as $row){
$d = $this->check_dxcc_table($row['COL_CALL']);
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'), $d[1], $d[0], $row['COL_PRIMARY_KEY']);
$this->db->query($sql);
//print($sql."\n");
printf("Updating %s to %s and %s\n<br/>", $row['COL_PRIMARY_KEY'], $d[1], $d[0]);
$count++;
}
}
}
$this->db->trans_complete();

print("$count updated\n");
}

}

?>
5 changes: 5 additions & 0 deletions application/views/update/index.php
Expand Up @@ -7,6 +7,8 @@
<div id="dxcc_update_status">
Status:</br>
</div>
<br/>
<a href="update/check_missing_dxcc">Check missing DXCC/Countries values</a>
</div>

<style>
Expand Down Expand Up @@ -35,3 +37,6 @@ function update_stats(){

});
</script>



2 changes: 1 addition & 1 deletion application/views/view_log/partial/log.php
Expand Up @@ -53,7 +53,7 @@
</td>

<?php if ($this->session->userdata('user_eqsl_name') != ""){
if ($row->COL_EQSL_QSL_SENT != '') { ?>
if (($row->COL_EQSL_QSL_SENT != '') and ($row->COL_EQSL_QSL_SENT != 'I')){ ?>
<td class="eqsl">
<span class="eqsl-<?php echo ($row->COL_EQSL_QSL_SENT=='Y')?'green':'red'?>">&#9650;</span>
<span class="eqsl-<?php echo ($row->COL_EQSL_QSL_RCVD=='Y')?'green':'red'?>">&#9660;</span>
Expand Down

0 comments on commit 5358951

Please sign in to comment.