Merge pull request #192 from teabreakninja/master

Check existing log entries against the new DXCC/Country list
pull/197/head
Peter Goodhall 2016-02-22 14:49:07 +00:00
commit 53589517b6
5 zmienionych plików z 60 dodań i 2 usunięć

Wyświetl plik

@ -206,6 +206,12 @@ class Update extends CI_Controller {
}
}
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');

Wyświetl plik

@ -7,4 +7,4 @@
<p>Directory access is forbidden.</p>
</body>
</html>
</html>

Wyświetl plik

@ -966,6 +966,53 @@ class Logbook_model extends CI_Model {
}
}
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");
}
}
?>

Wyświetl plik

@ -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>
@ -35,3 +37,6 @@ $(document).ready(function(){
});
</script>

Wyświetl plik

@ -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>