kopia lustrzana https://github.com/magicbug/Cloudlog
commit
abbbf72671
|
@ -14,8 +14,8 @@ class Maintenance extends CI_Controller {
|
|||
$this->load->model('Stations');
|
||||
$data['stations']=$this->Stations->all();
|
||||
$data['page_title'] = "Maintenance";
|
||||
$data['is_there_qsos_with_no_station_id'] = $this->Logbook_model->check_for_station_id();
|
||||
if ($data['is_there_qsos_with_no_station_id']) {
|
||||
$data['qsos_with_no_station_id'] = $this->Logbook_model->check_for_station_id();
|
||||
if ($data['qsos_with_no_station_id']) {
|
||||
$data['calls_wo_sid']=$this->Logbook_model->calls_without_station_id();
|
||||
}
|
||||
$this->load->view('interface_assets/header', $data);
|
||||
|
@ -29,6 +29,7 @@ class Maintenance extends CI_Controller {
|
|||
$this->load->model('Logbook_model');
|
||||
$this->load->model('Stations');
|
||||
$call = xss_clean(($this->input->post('call')));
|
||||
$qsoids = xss_clean(($this->input->post('qsoids')));
|
||||
$station_profile_id = xss_clean(($this->input->post('station_id')));
|
||||
|
||||
// Check if target-station-id exists
|
||||
|
@ -39,8 +40,7 @@ class Maintenance extends CI_Controller {
|
|||
if ($station->station_id == $station_profile_id) { $allowed=true; }
|
||||
}
|
||||
if ($allowed) {
|
||||
log_message("error",$call." to ".$station_profile_id);
|
||||
$status=$this->Logbook_model->update_all_station_ids($station_profile_id,$call);
|
||||
$status=$this->Logbook_model->update_station_ids($station_profile_id,$call,$qsoids);
|
||||
} else {
|
||||
$status=false;
|
||||
}
|
||||
|
|
|
@ -4109,10 +4109,12 @@ function check_if_callsign_worked_in_logbook($callsign, $StationLocationsArray =
|
|||
}
|
||||
|
||||
public function check_for_station_id() {
|
||||
$this->db->select('COL_PRIMARY_KEY, COL_TIME_ON, COL_CALL, COL_MODE, COL_BAND');
|
||||
$this->db->where('station_id =', NULL);
|
||||
$query = $this->db->get($this->config->item('table_name'));
|
||||
log_message('debug','SQL: '.$this->db->last_query());
|
||||
if($query->num_rows() >= 1) {
|
||||
return $query->num_rows();
|
||||
return $query->result();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
@ -4165,24 +4167,29 @@ function check_if_callsign_worked_in_logbook($callsign, $StationLocationsArray =
|
|||
}
|
||||
}
|
||||
|
||||
public function update_all_station_ids($station_id,$station_callsign) {
|
||||
public function update_station_ids($station_id,$station_callsign,$qsoids) {
|
||||
|
||||
$data = array(
|
||||
'station_id' => $station_id,
|
||||
);
|
||||
if (! empty($qsoids)) {
|
||||
$data = array(
|
||||
'station_id' => $station_id,
|
||||
);
|
||||
|
||||
$this->db->where(array('station_id' => NULL));
|
||||
if ($station_callsign == '') {
|
||||
$this->db->where(array('col_station_callsign' => NULL));
|
||||
} else {
|
||||
$this->db->where('col_station_callsign', $station_callsign);
|
||||
}
|
||||
$this->db->update($this->config->item('table_name'), $data);
|
||||
if ($this->db->affected_rows() > 0) {
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
$this->db->where_in('COL_PRIMARY_KEY', $qsoids);
|
||||
$this->db->where(array('station_id' => NULL));
|
||||
if ($station_callsign == '') {
|
||||
$this->db->where(array('col_station_callsign' => NULL));
|
||||
} else {
|
||||
$this->db->where('col_station_callsign', $station_callsign);
|
||||
}
|
||||
$this->db->update($this->config->item('table_name'), $data);
|
||||
if ($this->db->affected_rows() > 0) {
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
public function parse_frequency($frequency)
|
||||
|
|
|
@ -13,11 +13,44 @@
|
|||
<div class="card-header">
|
||||
QSO-DB Maintenance
|
||||
</div>
|
||||
<?php if($is_there_qsos_with_no_station_id >= 1) { ?>
|
||||
<?php if(!empty($qsos_with_no_station_id)) { ?>
|
||||
<div class="alert alert-danger" role="alert" style="margin-bottom: 0px !important;">
|
||||
<span class="badge badge-pill badge-warning">Warning</span> The Database contains <?php echo $is_there_qsos_with_no_station_id; ?> QSO<?php echo $is_there_qsos_with_no_station_id > 1 ? 's' : '' ?> without a station-profile (location)<br/>
|
||||
<span class="badge badge-pill badge-warning">Warning</span> The Database contains <?php echo count($qsos_with_no_station_id); ?> QSO<?php echo count($qsos_with_no_station_id) > 1 ? 's' : '' ?> without a station-profile (location)<br/>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class?"table-responsive">
|
||||
<table id="unasigned_qsos_table" class="table table-sm table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col"><input type="checkbox" onClick="toggleAll(this)"></th>
|
||||
<th scope="col">Date</th>
|
||||
<th scope="col">Time</th>
|
||||
<th scope="col">Call</th>
|
||||
<th scope="col">Mode</th>
|
||||
<th scope="col">Band</th>
|
||||
</tr>
|
||||
<?php if($this->session->userdata('user_date_format')) {
|
||||
$custom_date_format = $this->session->userdata('user_date_format');
|
||||
} else {
|
||||
$custom_date_format = 'd.m.Y';
|
||||
}
|
||||
foreach ($qsos_with_no_station_id as $qso) {
|
||||
echo '<tr>';
|
||||
echo '<td><input type="checkbox" id="'.$qso->COL_PRIMARY_KEY.'" name="cBox[]" value="'.$qso->COL_PRIMARY_KEY.'"></td>';
|
||||
$timestamp = strtotime($qso->COL_TIME_ON);
|
||||
echo '<td>'.date($custom_date_format, $timestamp).'</td>';
|
||||
$timestamp = strtotime($qso->COL_TIME_ON);
|
||||
echo '<td>'.date('H:i', $timestamp).'</td>';
|
||||
echo '<td>'.$qso->COL_CALL.'</td>';
|
||||
echo '<td>'.$qso->COL_MODE.'</td>';
|
||||
echo '<td>'.$qso->COL_BAND.'</td>';
|
||||
echo '</tr>';
|
||||
} ?>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<p class="card-text">Please reassign those QSOs to an existing station location:</p>
|
||||
|
||||
|
||||
|
@ -38,7 +71,7 @@
|
|||
foreach ($stations->result() as $station) {
|
||||
$options.='<option value='.$station->station_id.'>'.$station->station_profile_name.' ('.$station->station_callsign.')</option>';
|
||||
}
|
||||
echo $options.'</select></td><td><button class="btn btn-warning" onClick="reassign(\''.$call['COL_STATION_CALLSIGN'].'\',$(\'#station_profile option:selected\').val());"><i class="fas fa-sync"></i>Reassign</a></button></td></tr>';
|
||||
echo $options.'</select></td><td><button class="btn btn-warning" onClick="reassign(\''.$call['COL_STATION_CALLSIGN'].'\',$(\'#station_profile option:selected\').val());"><i class="fas fa-sync"></i> Reassign</a></button></td></tr>';
|
||||
} ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
|
@ -1,8 +1,15 @@
|
|||
function reassign(call,target_profile_id) {
|
||||
let qsoids = [];
|
||||
let elements = document.getElementsByName("cBox[]");
|
||||
elements.forEach((item) => {
|
||||
if (item.checked) {
|
||||
qsoids.push(item.value);
|
||||
}
|
||||
});
|
||||
$.ajax({
|
||||
url: base_url + 'index.php/maintenance/reassign',
|
||||
type: 'post',
|
||||
data: {'call': call, 'station_id': target_profile_id},
|
||||
data: {'call': call, 'station_id': target_profile_id, 'qsoids' : qsoids},
|
||||
success: function (resu) {
|
||||
if (resu.status) {
|
||||
location.reload();
|
||||
|
@ -10,3 +17,21 @@ function reassign(call,target_profile_id) {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
function toggleAll(source) {
|
||||
console.log('test');
|
||||
if (source.checked) {
|
||||
let elements = document.getElementsByName("cBox[]");
|
||||
elements.forEach((item) => {
|
||||
item.checked = true;
|
||||
})
|
||||
source.checked = true;
|
||||
}
|
||||
if (!source.checked) {
|
||||
let elements = document.getElementsByName("cBox[]");
|
||||
elements.forEach((item) => {
|
||||
item.checked = false;
|
||||
})
|
||||
source.checked = false;
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue