mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
Merge pull request #51 from int2001/edgefix
This commit is contained in:
@@ -206,9 +206,17 @@ class Band extends CI_Controller {
|
||||
$frequencyfrom = $this->security->xss_clean($this->input->post('frequencyfrom', true));
|
||||
$frequencyto = $this->security->xss_clean($this->input->post('frequencyto', true));
|
||||
$mode = $this->security->xss_clean($this->input->post('mode', true));
|
||||
|
||||
$this->bands->saveBandEdge($id, $frequencyfrom, $frequencyto, $mode);
|
||||
echo json_encode(array('message' => 'OK'));
|
||||
if ((is_numeric($frequencyfrom)) && (is_numeric($frequencyfrom))) {
|
||||
$overlap=$this->bands->check4overlapEdges($id, $frequencyfrom, $frequencyto, $mode);
|
||||
if (!($overlap)) {
|
||||
$this->bands->saveBandEdge($id, $frequencyfrom, $frequencyto, $mode);
|
||||
echo json_encode(array('message' => 'OK'));
|
||||
} else {
|
||||
echo json_encode(array('message' => 'Overlapping'));
|
||||
}
|
||||
} else {
|
||||
echo json_encode(array('message' => 'No Number entered'));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -459,6 +459,21 @@ class Bands extends CI_Model {
|
||||
$this->db->delete('bandedges', array('id' => $clean_id, 'userid' => $this->session->userdata('user_id')));
|
||||
}
|
||||
|
||||
function check4overlapEdges($id, $frequencyfrom, $frequencyto, $mode) {
|
||||
$edges = $this->bands->get_all_bandedges_for_user();
|
||||
foreach ($edges as $item) {
|
||||
if ($item->id == ($id ?? -1000)) {
|
||||
continue;
|
||||
}
|
||||
$from = (int)$item->frequencyfrom;
|
||||
$to = (int)$item->frequencyto;
|
||||
if (!($frequencyto < $from || $frequencyfrom > $to)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function saveBandEdge($id, $frequencyfrom, $frequencyto, $mode) {
|
||||
$data = array(
|
||||
'frequencyfrom' => $frequencyfrom,
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
<script>
|
||||
var lang_edge_invalid_number = "<?= __("Please enter valid numbers for frequency"); ?>";
|
||||
var lang_edge_from_gt_to = "<?= __("The 'From' frequency must be less than the 'To' frequency."); ?>";
|
||||
var lang_edge_overlap = "<?= __("The Frequency overlaps with an existing entry."); ?>";
|
||||
var lang_edge_remove = "<?= __("Are you sure you want to delete this band edge?"); ?>";
|
||||
</script>
|
||||
<div class="container">
|
||||
|
||||
<br>
|
||||
|
||||
@@ -45,7 +45,7 @@ function saveChanges(id) {
|
||||
if (!$.isNumeric(frequencyfrom) || !$.isNumeric(frequencyto)) {
|
||||
BootstrapDialog.alert({
|
||||
title: 'INFO',
|
||||
message: "Please enter valid numbers for frequency.",
|
||||
message: lang_edge_invalid_number,
|
||||
type: BootstrapDialog.TYPE_INFO,
|
||||
closable: true,
|
||||
draggable: true,
|
||||
@@ -59,7 +59,7 @@ function saveChanges(id) {
|
||||
if (frequencyfrom >= frequencyto) {
|
||||
BootstrapDialog.alert({
|
||||
title: 'INFO',
|
||||
message: "The 'From' frequency must be less than the 'To' frequency.",
|
||||
message: lang_edge_from_gt_to,
|
||||
type: BootstrapDialog.TYPE_INFO,
|
||||
closable: true,
|
||||
draggable: true,
|
||||
@@ -81,11 +81,24 @@ function saveChanges(id) {
|
||||
'mode': mode,
|
||||
},
|
||||
success: function (data) {
|
||||
|
||||
response=JSON.parse(data);
|
||||
console.log(response);
|
||||
if ((response.message ?? '') !== 'OK') {
|
||||
BootstrapDialog.alert({
|
||||
title: 'INFO',
|
||||
message: lang_edge_overlap,
|
||||
type: BootstrapDialog.TYPE_INFO,
|
||||
closable: true,
|
||||
draggable: true,
|
||||
btnOKClass: 'btn-info',
|
||||
callback: function (result) {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
restoreLine(id);
|
||||
restoreLine(id);
|
||||
}
|
||||
|
||||
function cancelChanges(id) {
|
||||
@@ -119,7 +132,7 @@ function restoreLine(id) {
|
||||
function deleteBandEdge(id) {
|
||||
BootstrapDialog.confirm({
|
||||
title: lang_general_word_danger,
|
||||
message: 'Are you sure you want to delete this band edge?',
|
||||
message: lang_edge_remove,
|
||||
type: BootstrapDialog.TYPE_DANGER,
|
||||
closable: true,
|
||||
draggable: true,
|
||||
@@ -169,14 +182,14 @@ function addBandEdgeRow() {
|
||||
}
|
||||
|
||||
function saveNewBandEdgeRow() {
|
||||
var frequencyfrom = $('#new_frequencyfrom').val();
|
||||
var frequencyto = $('#new_frequencyto').val();
|
||||
var mode = $('#new_mode').val();
|
||||
var frequencyfrom = $('#new_frequencyfrom').val();
|
||||
var frequencyto = $('#new_frequencyto').val();
|
||||
var mode = $('#new_mode').val();
|
||||
|
||||
if (!$.isNumeric(frequencyfrom) || !$.isNumeric(frequencyto)) {
|
||||
BootstrapDialog.alert({
|
||||
title: 'INFO',
|
||||
message: "Please enter valid numbers for frequency.",
|
||||
message: lang_edge_invalid_number,
|
||||
type: BootstrapDialog.TYPE_INFO,
|
||||
closable: true,
|
||||
draggable: true,
|
||||
@@ -190,7 +203,7 @@ function saveNewBandEdgeRow() {
|
||||
if (frequencyfrom >= frequencyto) {
|
||||
BootstrapDialog.alert({
|
||||
title: 'INFO',
|
||||
message: "The 'From' frequency must be less than the 'To' frequency.",
|
||||
message: lang_edge_from_gt_to,
|
||||
type: BootstrapDialog.TYPE_INFO,
|
||||
closable: true,
|
||||
draggable: true,
|
||||
@@ -203,17 +216,33 @@ function saveNewBandEdgeRow() {
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: base_url + 'index.php/band/savebandedge',
|
||||
type: 'post',
|
||||
data: {
|
||||
'frequencyfrom': frequencyfrom,
|
||||
'frequencyto': frequencyto,
|
||||
'mode': mode,
|
||||
url: base_url + 'index.php/band/saveBandEdge',
|
||||
type: 'post',
|
||||
data: {
|
||||
'frequencyfrom': frequencyfrom,
|
||||
'frequencyto': frequencyto,
|
||||
'mode': mode,
|
||||
},
|
||||
success: function (html) {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
success: function (data) {
|
||||
response=JSON.parse(data);
|
||||
console.log(response);
|
||||
if ((response.message ?? '') !== 'OK') {
|
||||
BootstrapDialog.alert({
|
||||
title: 'INFO',
|
||||
message: lang_edge_overlap,
|
||||
type: BootstrapDialog.TYPE_INFO,
|
||||
closable: true,
|
||||
draggable: true,
|
||||
btnOKClass: 'btn-info',
|
||||
callback: function (result) {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function cancelNewBandEdgeRow() {
|
||||
|
||||
Reference in New Issue
Block a user