More work on QSO dialog for WAS award.

pull/614/head
Andreas 2020-08-24 20:16:06 +02:00
rodzic e30ea7a493
commit 712bbf1840
4 zmienionych plików z 163 dodań i 28 usunięć

Wyświetl plik

@ -369,6 +369,19 @@ class Awards extends CI_Controller {
$this->load->view('interface_assets/footer');
}
public function was_details_ajax() {
$this->load->model('logbook_model');
$state = str_replace('"', "", $this->input->post("State"));
$band = str_replace('"', "", $this->input->post("Band"));
$data['results'] = $this->logbook_model->was_qso_details($state, $band);
// Render Page
$data['page_title'] = "Log View - WAS";
$data['filter'] = "state ".$state. " and ".$band;
$this->load->view('awards/was/details_ajax', $data);
}
public function iota () {
$this->load->model('iota');
$data['worked_bands'] = $this->iota->get_worked_bands(); // Used in the view for band select

Wyświetl plik

@ -124,6 +124,36 @@ class QSO extends CI_Controller {
$this->load->view('qso/edit_done');
}
}
function edit_ajax() {
$this->load->model('logbook_model');
$this->load->model('user_model');
if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
$id = str_replace('"', "", $this->input->post("id"));
$query = $this->logbook_model->qso_info($id);
$this->load->library('form_validation');
$this->form_validation->set_rules('time_on', 'Start Date', 'required');
$this->form_validation->set_rules('time_off', 'End Date', 'required');
$this->form_validation->set_rules('callsign', 'Callsign', 'required');
$data['qso'] = $query->row();
$data['dxcc'] = $this->logbook_model->fetchDxcc();
$data['iota'] = $this->logbook_model->fetchIota();
if ($this->form_validation->run() == FALSE)
{
$this->load->view('qso/edit', $data);
}
else
{
$this->logbook_model->edit();
$this->session->set_flashdata('notice', 'Record Updated');
$this->load->view('qso/edit_done');
}
}
function qsl_rcvd($id, $method) {
$this->load->model('logbook_model');
@ -138,6 +168,27 @@ class QSO extends CI_Controller {
redirect('logbook');
}
function qsl_rcvd_ajax() {
$id = str_replace('"', "", $this->input->post("id"));
$method = str_replace('"', "", $this->input->post("method"));
$this->load->model('logbook_model');
$this->load->model('user_model');
header('Content-Type: application/json');
if(!$this->user_model->authorize(2)) {
echo json_encode(array('message' => 'Error'));
}
else {
// Update Logbook to Mark Paper Card Received
$this->logbook_model->paperqsl_update($id, $method);
echo json_encode(array('message' => 'OK'));
}
}
/* Delete QSO */
function delete($id) {
@ -156,6 +207,18 @@ class QSO extends CI_Controller {
redirect($_SERVER['HTTP_REFERER']);
}
}
/* Delete QSO */
function delete_ajax() {
$id = str_replace('"', "", $this->input->post("id"));
$this->load->model('logbook_model');
$this->logbook_model->delete($id);
header('Content-Type: application/json');
echo json_encode(array('message' => 'OK'));
return;
}
function band_to_freq($band, $mode) {

Wyświetl plik

@ -87,14 +87,14 @@ class was extends CI_Model {
if ($postdata['worked'] != NULL) {
$wasBand = $this->getWasWorked($station_id, $band, $postdata);
foreach ($wasBand as $line) {
$bandWas[$line->col_state][$band] = '<div class="alert-danger"><a href=\'was_details?State="' . str_replace("&", "%26", $line->col_state) . '"&Band="' . $band . '"\'>W</a></div>';
$bandWas[$line->col_state][$band] = '<div class="alert-danger"><a href=\'javascript:displayWasContacts("' . $line->col_state . '","' . $band . '")\'>W</a></div>';
$states[$line->col_state]['count']++;
}
}
if ($postdata['confirmed'] != NULL) {
$wasBand = $this->getWasConfirmed($station_id, $band, $postdata);
foreach ($wasBand as $line) {
$bandWas[$line->col_state][$band] = '<div class="alert-success"><a href=\'was_details?State="' . str_replace("&", "%26", $line->col_state) . '"&Band="' . $band . '"\'>C</a></div>';
$bandWas[$line->col_state][$band] = '<div class="alert-success"><a href=\'javascript:displayWasContacts("' . $line->col_state . '","' . $band . '")\'>C</a></div>';
$states[$line->col_state]['count']++;
}
}

Wyświetl plik

@ -1437,34 +1437,93 @@ $(document).ready(function(){
<script src="<?php echo base_url(); ?>assets/js/bootstrapdialog/js/bootstrap-dialog.min.js"></script>
<script>
function displayWasContacts(was, band) {
$.ajax({
url: 'include/get/getContacts.php',
type: 'post',
data: {'was': was,
'band': band
},
success: function(html) {
BootstrapDialog.show({
onshown: function (dialogRef) {
$('.qsotable').DataTable({
"pageLength": 10,
responsive: true,
ordering: false
});
},
title: 'QSO Data',
size: BootstrapDialog.SIZE_WIDE,
nl2br: false,
message: html,
buttons: [{
label: 'Close',
action: function (dialogItself) {
dialogItself.close();
var baseURL= "<?php echo base_url();?>";
$.ajax({
url: baseURL + 'index.php/awards/was_details_ajax',
type: 'post',
data: {'State': was,
'Band': band
},
success: function(html) {
BootstrapDialog.show({
title: 'QSO Data',
size: BootstrapDialog.SIZE_WIDE,
nl2br: false,
message: html,
buttons: [{
label: 'Close',
action: function (dialogItself) {
dialogItself.close();
}
}]
});
}
});
}
}]
});
function qsl_rcvd(id, method) {
var baseURL= "<?php echo base_url();?>";
$.ajax({
url: baseURL + 'index.php/qso/qsl_rcvd_ajax',
type: 'post',
data: {'id': id,
'method': method
},
success: function(data) {
if (data.message == 'OK') {
$("#qso_" + id).find("td:eq(8)").find("span:eq(1)").attr('class', 'qsl-green'); // Paints arrow green
$(".qsl_" + id).remove(); // removes choice from menu
}
else {
$(".bootstrap-dialog-message").append('<div class="alert alert-danger"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>You are not allowed to update QSL status!</div>');
}
}
});
}
});
function qso_delete(id, call) {
BootstrapDialog.confirm({
title: 'DANGER',
message: 'Warning! Are you sure you want delete QSO with ' + call + '?' ,
type: BootstrapDialog.TYPE_DANGER,
closable: true,
draggable: true,
btnOKClass: 'btn-danger',
callback: function(result) {
if(result) {
//BootstrapDialog.closeAll()
var baseURL= "<?php echo base_url();?>";
$.ajax({
url: baseURL + 'index.php/qso/delete_ajax',
type: 'post',
data: {'id': id
},
success: function(data) {
$(".bootstrap-dialog-message").append('<div class="alert alert-danger"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>The contact with ' + call + ' has been deleted!</div>');
$("#qso_" + id).remove(); // removes qso from table in dialog
}
});
}
}
});
}
function qso_edit(id) {
var baseURL= "<?php echo base_url();?>";
$.ajax({
url: baseURL + 'index.php/qso/edit_ajax',
type: 'post',
data: {'id': id
},
success: function(html) {
BootstrapDialog.show({
title: 'QSO Data',
size: BootstrapDialog.SIZE_WIDE,
nl2br: false,
message: html,
});
}
});
}
</script>
<?php } ?>