2023-06-12 11:57:01 +00:00
let station _id ;
2022-11-15 17:29:33 +00:00
function loadStationInfo ( ) {
2023-06-12 11:57:01 +00:00
station _id = $ ( "#station" ) . val ( ) ;
2023-06-12 18:27:18 +00:00
$ ( ".resulttable" ) . empty ( ) ;
2022-11-15 17:29:33 +00:00
$ ( ".searchinfo" ) . empty ( ) ;
$ . ajax ( {
url : base _url + 'index.php/oqrs/get_station_info' ,
type : 'post' ,
2023-06-12 11:57:01 +00:00
data : { 'station_id' : station _id } ,
2022-11-15 17:29:33 +00:00
success : function ( data ) {
if ( data . count > 0 ) {
2023-06-12 18:27:18 +00:00
$ ( ".resulttable" ) . append ( '<br />' + data . count + ' Qsos logged between ' + data . mindate + ' and ' + data . maxdate + '.<br /><br />' ) ;
2023-11-28 20:10:30 +00:00
$ ( ".resulttable" ) . append ( '<form class="d-flex align-items-center" onsubmit="return false;"><label for="oqrssearch">Enter your callsign: </label><input class="form-control m-2 w-auto" id="oqrssearch" type="search" name="callsign" placeholder="Search Callsign" aria-label="Search" required="required"><button onclick="searchOqrs();" class="btn btn-sm btn-primary" id="stationbuttonsubmit" type="button"><i class="fas fa-search"></i> Search</button></form>' ) ;
2022-12-23 22:20:31 +00:00
// Get the input field
var input = document . getElementById ( "oqrssearch" ) ;
// Execute a function when the user presses a key on the keyboard
input . addEventListener ( "keypress" , function ( event ) {
// If the user presses the "Enter" key on the keyboard
if ( event . key === "Enter" ) {
// Cancel the default action, if needed
event . preventDefault ( ) ;
// Trigger the button element with a click
document . getElementById ( "stationbuttonsubmit" ) . click ( ) ;
}
} ) ;
2022-11-15 17:29:33 +00:00
} else {
$ ( ".stationinfo" ) . append ( "No QSOs for this callsign was found!" ) ;
}
}
} ) ;
}
function searchOqrs ( ) {
$ ( ".searchinfo" ) . empty ( ) ;
$ . ajax ( {
url : base _url + 'index.php/oqrs/get_qsos' ,
type : 'post' ,
2023-06-12 11:57:01 +00:00
data : { 'station_id' : station _id , 'callsign' : $ ( "#oqrssearch" ) . val ( ) . toUpperCase ( ) } ,
2022-11-15 17:29:33 +00:00
success : function ( data ) {
$ ( ".searchinfo" ) . append ( data ) ;
}
} ) ;
}
2023-04-25 12:00:30 +00:00
function searchOqrsGrouped ( ) {
$ ( ".searchinfo" ) . empty ( ) ;
$ . ajax ( {
url : base _url + 'index.php/oqrs/get_qsos_grouped' ,
type : 'post' ,
data : { 'callsign' : $ ( "#oqrssearch" ) . val ( ) . toUpperCase ( ) } ,
success : function ( data ) {
$ ( ".searchinfo" ) . append ( data ) ;
2023-04-26 18:33:45 +00:00
$ ( '.qsotime' ) . change ( function ( ) {
var raw _time = $ ( this ) . val ( ) ;
if ( raw _time . match ( /^\d\[0-6]d$/ ) ) {
raw _time = "0" + raw _time ;
}
if ( raw _time . match ( /^[012]\d[0-5]\d$/ ) ) {
raw _time = raw _time . substring ( 0 , 2 ) + ":" + raw _time . substring ( 2 , 4 ) ;
$ ( this ) . val ( raw _time ) ;
}
} ) ;
$ ( '.result-table' ) . DataTable ( {
"pageLength" : 25 ,
responsive : false ,
ordering : false ,
"scrollY" : "410px" ,
"scrollCollapse" : true ,
"paging" : false ,
"scrollX" : true ,
2024-01-04 03:03:11 +00:00
"language" : {
2024-01-04 03:18:20 +00:00
url : getDataTablesLanguageUrl ( ) ,
2024-01-04 03:03:11 +00:00
}
2023-04-26 18:33:45 +00:00
} ) ;
2023-06-13 18:38:29 +00:00
// Get the input field
var input = document . getElementById ( "emailInput" ) ;
// Execute a function when the user presses a key on the keyboard
input . addEventListener ( "keypress" , function ( event ) {
// If the user presses the "Enter" key on the keyboard
if ( event . key === "Enter" ) {
// Cancel the default action, if needed
event . preventDefault ( ) ;
// Trigger the button element with a click
document . getElementById ( "requestGroupedSubmit" ) . click ( ) ;
}
} ) ;
2023-04-25 12:00:30 +00:00
}
} ) ;
}
2022-11-15 17:29:33 +00:00
function notInLog ( ) {
$ . ajax ( {
url : base _url + 'index.php/oqrs/not_in_log' ,
type : 'post' ,
2023-06-12 11:57:01 +00:00
data : { 'station_id' : station _id , 'callsign' : $ ( "#oqrssearch" ) . val ( ) . toUpperCase ( ) } ,
2022-11-15 17:29:33 +00:00
success : function ( html ) {
$ ( ".searchinfo" ) . html ( html ) ;
2022-12-30 22:16:38 +00:00
$ ( '.qsotime' ) . change ( function ( ) {
var raw _time = $ ( this ) . val ( ) ;
if ( raw _time . match ( /^\d\[0-6]d$/ ) ) {
raw _time = "0" + raw _time ;
}
if ( raw _time . match ( /^[012]\d[0-5]\d$/ ) ) {
raw _time = raw _time . substring ( 0 , 2 ) + ":" + raw _time . substring ( 2 , 4 ) ;
$ ( this ) . val ( raw _time ) ;
}
} ) ;
2022-11-15 17:29:33 +00:00
}
2023-11-20 18:03:54 +00:00
} ) ;
2022-11-15 17:29:33 +00:00
}
function saveNotInLogRequest ( ) {
2023-06-12 11:57:01 +00:00
const qsos = [ ] ;
2022-11-15 17:29:33 +00:00
$ ( ".alertinfo" ) . remove ( ) ;
if ( $ ( "#emailInput" ) . val ( ) == '' ) {
$ ( ".searchinfo" ) . prepend ( '<div class="alertinfo"><br /><div class="alert alert-warning"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>You need to fill out an email address!</div></div>' ) ;
} else {
$ ( ".notinlog-table tbody tr" ) . each ( function ( i ) {
var data = [ ] ;
var datecell = $ ( "#date" , this ) . val ( ) ;
var timecell = $ ( "#time" , this ) . val ( ) ;
var bandcell = $ ( "#band" , this ) . val ( ) ;
var modecell = $ ( "#mode" , this ) . val ( ) ;
if ( datecell != "" && timecell != "" && bandcell != "" && modecell != "" ) {
data . push ( datecell ) ;
data . push ( timecell ) ;
data . push ( bandcell ) ;
data . push ( modecell ) ;
qsos . push ( data ) ;
}
} ) ;
if ( qsos . length === 0 ) {
$ ( ".searchinfo" ) . prepend ( '<div class="alertinfo"><br /><div class="alert alert-warning"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>You need to fill the QSO information before submitting a request!</div></div>' ) ;
} else {
$ . ajax ( {
url : base _url + 'index.php/oqrs/save_not_in_log' ,
type : 'post' ,
2023-11-20 18:03:54 +00:00
data : { 'station_id' : station _id ,
2022-12-29 16:35:15 +00:00
'callsign' : $ ( "#oqrssearch" ) . val ( ) . toUpperCase ( ) ,
2022-11-15 17:29:33 +00:00
'email' : $ ( "#emailInput" ) . val ( ) ,
'message' : $ ( "#messageInput" ) . val ( ) ,
'qsos' : qsos
} ,
success : function ( data ) {
$ ( ".stationinfo" ) . empty ( ) ;
$ ( ".searchinfo" ) . empty ( ) ;
$ ( ".stationinfo" ) . append ( '<br /><div class="alert alert-success"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>Your not in log query has been saved!</div>' ) ;
}
} ) ;
}
}
}
function oqrsAddLine ( ) {
var rowCount = $ ( '.notinlog-table tr' ) . length ;
var $myTable = $ ( '.notinlog-table' ) ;
var $row = $ ( '<tr></tr>' ) ;
var $iterator = $ ( '<td></td>' ) . html ( rowCount ) ;
var $date = $ ( '<td></td>' ) . html ( '<input class="form-control" type="date" name="date" value="" id="date" placeholder="YYYY-MM-DD">' ) ;
2023-11-28 20:10:30 +00:00
var $time = $ ( '<td></td>' ) . html ( '<input class="form-control qsotime" type="text" name="time" value="" id="time" maxlength="5" placeholder="hh:mm">' ) ;
2022-11-15 17:29:33 +00:00
var $band = $ ( '<td></td>' ) . html ( '<input class="form-control" type="text" name="band" value="" id="band">' ) ;
var $mode = $ ( '<td></td>' ) . html ( '<input class="form-control" type="text" name="mode" value="" id="mode">' ) ;
$row . append ( $iterator , $date , $time , $band , $mode ) ;
$myTable . append ( $row ) ;
2022-12-30 22:16:38 +00:00
$ ( '.qsotime' ) . change ( function ( ) {
var raw _time = $ ( this ) . val ( ) ;
if ( raw _time . match ( /^\d\[0-6]d$/ ) ) {
raw _time = "0" + raw _time ;
}
if ( raw _time . match ( /^[012]\d[0-5]\d$/ ) ) {
raw _time = raw _time . substring ( 0 , 2 ) + ":" + raw _time . substring ( 2 , 4 ) ;
$ ( this ) . val ( raw _time ) ;
}
} ) ;
2022-11-15 17:29:33 +00:00
}
function requestOqrs ( ) {
$ . ajax ( {
url : base _url + 'index.php/oqrs/request_form' ,
type : 'post' ,
2023-06-12 11:57:01 +00:00
data : { 'station_id' : station _id , 'callsign' : $ ( "#oqrssearch" ) . val ( ) . toUpperCase ( ) } ,
2022-11-15 17:29:33 +00:00
success : function ( html ) {
$ ( ".searchinfo" ) . html ( html ) ;
2022-12-30 22:16:38 +00:00
/* time input shortcut */
$ ( '.qsotime' ) . change ( function ( ) {
var raw _time = $ ( this ) . val ( ) ;
if ( raw _time . match ( /^\d\[0-6]d$/ ) ) {
raw _time = "0" + raw _time ;
}
if ( raw _time . match ( /^[012]\d[0-5]\d$/ ) ) {
raw _time = raw _time . substring ( 0 , 2 ) + ":" + raw _time . substring ( 2 , 4 ) ;
$ ( this ) . val ( raw _time ) ;
}
} ) ;
2022-11-15 17:29:33 +00:00
$ ( '.result-table' ) . DataTable ( {
"pageLength" : 25 ,
responsive : false ,
ordering : false ,
"scrollY" : "410px" ,
"scrollCollapse" : true ,
"paging" : false ,
"scrollX" : true ,
2024-01-04 03:03:11 +00:00
"language" : {
2024-01-04 03:18:20 +00:00
url : getDataTablesLanguageUrl ( ) ,
2024-01-04 03:03:11 +00:00
}
2022-11-15 17:29:33 +00:00
} ) ;
2023-06-13 18:38:29 +00:00
// Get the input field
var input = document . getElementById ( "emailInput" ) ;
// Execute a function when the user presses a key on the keyboard
input . addEventListener ( "keypress" , function ( event ) {
// If the user presses the "Enter" key on the keyboard
if ( event . key === "Enter" ) {
// Cancel the default action, if needed
event . preventDefault ( ) ;
// Trigger the button element with a click
document . getElementById ( "requestSubmit" ) . click ( ) ;
}
} ) ;
2022-11-15 17:29:33 +00:00
}
2023-11-20 18:03:54 +00:00
} ) ;
2022-11-15 17:29:33 +00:00
}
function submitOqrsRequest ( ) {
2023-06-12 11:57:01 +00:00
const qsos = [ ] ;
2022-11-15 17:29:33 +00:00
$ ( ".alertinfo" ) . remove ( ) ;
if ( $ ( "#emailInput" ) . val ( ) == '' ) {
$ ( ".searchinfo" ) . prepend ( '<div class="alertinfo"><br /><div class="alert alert-warning"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>You need to fill out an email address!</div></div>' ) ;
} else {
$ ( ".result-table tbody tr" ) . each ( function ( i ) {
var data = [ ] ;
var datecell = $ ( "#date" , this ) . val ( ) ;
var timecell = $ ( "#time" , this ) . val ( ) ;
var bandcell = $ ( "#band" , this ) . text ( ) ;
var modecell = $ ( "#mode" , this ) . text ( ) ;
if ( datecell != "" && timecell != "" ) {
data . push ( datecell ) ;
data . push ( timecell ) ;
data . push ( bandcell ) ;
data . push ( modecell ) ;
qsos . push ( data ) ;
}
} ) ;
if ( qsos . length === 0 ) {
$ ( ".searchinfo" ) . prepend ( '<div class="alertinfo"><br /><div class="alert alert-warning"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>You need to fill the QSO information before submitting a request!</div></div>' ) ;
} else {
$ . ajax ( {
url : base _url + 'index.php/oqrs/save_oqrs_request' ,
type : 'post' ,
2023-06-12 11:57:01 +00:00
data : { 'station_id' : station _id ,
2022-12-29 16:35:15 +00:00
'callsign' : $ ( "#oqrssearch" ) . val ( ) . toUpperCase ( ) ,
2022-11-15 17:29:33 +00:00
'email' : $ ( "#emailInput" ) . val ( ) ,
'message' : $ ( "#messageInput" ) . val ( ) ,
'qsos' : qsos ,
'qslroute' : $ ( 'input[name="qslroute"]:checked' ) . val ( )
} ,
success : function ( data ) {
2023-06-12 18:27:18 +00:00
$ ( ".resulttable" ) . empty ( ) ;
2022-11-15 17:29:33 +00:00
$ ( ".stationinfo" ) . empty ( ) ;
$ ( ".searchinfo" ) . empty ( ) ;
$ ( ".stationinfo" ) . append ( '<br /><div class="alert alert-success"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>Your QSL request has been saved!</div>' ) ;
}
} ) ;
}
}
}
2023-04-25 12:00:30 +00:00
function submitOqrsRequestGrouped ( ) {
2023-06-12 11:57:01 +00:00
const qsos = [ ] ;
2023-04-25 12:00:30 +00:00
$ ( ".alertinfo" ) . remove ( ) ;
if ( $ ( "#emailInput" ) . val ( ) == '' ) {
$ ( ".searchinfo" ) . prepend ( '<div class="alertinfo"><br /><div class="alert alert-warning"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>You need to fill out an email address!</div></div>' ) ;
} else {
$ ( ".result-table tbody tr" ) . each ( function ( i ) {
var data = [ ] ;
var stationid = this . getAttribute ( 'stationid' ) ; ;
var datecell = $ ( "#date" , this ) . val ( ) ;
var timecell = $ ( "#time" , this ) . val ( ) ;
var bandcell = $ ( "#band" , this ) . text ( ) ;
var modecell = $ ( "#mode" , this ) . text ( ) ;
if ( datecell != "" && timecell != "" ) {
data . push ( datecell ) ;
data . push ( timecell ) ;
data . push ( bandcell ) ;
data . push ( modecell ) ;
data . push ( stationid ) ;
qsos . push ( data ) ;
}
} ) ;
if ( qsos . length === 0 ) {
$ ( ".searchinfo" ) . prepend ( '<div class="alertinfo"><br /><div class="alert alert-warning"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>You need to fill the QSO information before submitting a request!</div></div>' ) ;
} else {
$ . ajax ( {
url : base _url + 'index.php/oqrs/save_oqrs_request_grouped' ,
type : 'post' ,
data : {
'callsign' : $ ( "#oqrssearch" ) . val ( ) . toUpperCase ( ) ,
'email' : $ ( "#emailInput" ) . val ( ) ,
'message' : $ ( "#messageInput" ) . val ( ) ,
'qsos' : qsos ,
'qslroute' : $ ( 'input[name="qslroute"]:checked' ) . val ( )
} ,
success : function ( data ) {
$ ( ".stationinfo" ) . empty ( ) ;
$ ( ".searchinfo" ) . empty ( ) ;
2023-06-12 16:41:03 +00:00
$ ( ".stationinfo" ) . append ( '<br /><div class="alert alert-success"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>Your QSL request has been saved!</div>' ) ;
2023-04-25 12:00:30 +00:00
}
} ) ;
}
}
}
2022-11-15 17:29:33 +00:00
function searchLog ( callsign ) {
$ . ajax ( {
url : base _url + 'index.php/oqrs/search_log' ,
type : 'post' ,
data : { 'callsign' : callsign ,
} ,
success : function ( html ) {
BootstrapDialog . show ( {
title : 'QSO List' ,
size : BootstrapDialog . SIZE _WIDE ,
cssClass : 'qso-dialog' ,
nl2br : false ,
message : html ,
onshown : function ( dialog ) {
2023-11-26 09:00:47 +00:00
$ ( '[data-bs-toggle="tooltip"]' ) . tooltip ( ) ;
2022-11-15 17:29:33 +00:00
} ,
buttons : [ {
2023-11-05 18:38:34 +00:00
label : lang _admin _close ,
2022-11-15 17:29:33 +00:00
action : function ( dialogItself ) {
dialogItself . close ( ) ;
}
} ]
} ) ;
}
} ) ;
}
function searchLogTimeDate ( id ) {
$ . ajax ( {
url : base _url + 'index.php/oqrs/search_log_time_date' ,
type : 'post' ,
2022-12-29 16:14:18 +00:00
data : { 'time' : $ ( '#oqrsID_' + id + ' td:nth-child(4)' ) . text ( ) ,
'date' : $ ( '#oqrsID_' + id + ' td:nth-child(3)' ) . text ( ) ,
'band' : $ ( '#oqrsID_' + id + ' td:nth-child(5)' ) . text ( ) ,
'mode' : $ ( '#oqrsID_' + id + ' td:nth-child(6)' ) . text ( )
2022-11-15 17:29:33 +00:00
} ,
success : function ( html ) {
BootstrapDialog . show ( {
title : 'QSO List' ,
size : BootstrapDialog . SIZE _WIDE ,
cssClass : 'qso-dialog' ,
nl2br : false ,
message : html ,
onshown : function ( dialog ) {
2023-11-26 09:00:47 +00:00
$ ( '[data-bs-toggle="tooltip"]' ) . tooltip ( ) ;
2022-11-15 17:29:33 +00:00
} ,
buttons : [ {
2023-11-05 18:38:34 +00:00
label : lang _admin _close ,
2022-11-15 17:29:33 +00:00
action : function ( dialogItself ) {
dialogItself . close ( ) ;
}
} ]
} ) ;
}
} ) ;
}
2022-12-29 16:14:18 +00:00
function loadOqrsTable ( rows ) {
var uninitialized = $ ( '.oqrstable' ) . filter ( function ( ) {
return ! $ . fn . DataTable . fnIsDataTable ( this ) ;
} ) ;
uninitialized . each ( function ( ) {
$ ( this ) . DataTable ( {
searching : false ,
responsive : false ,
ordering : true ,
"scrollY" : window . innerHeight - $ ( '#searchForm' ) . innerHeight ( ) - 250 ,
"scrollCollapse" : true ,
"paging" : false ,
"scrollX" : true ,
2024-01-04 03:03:11 +00:00
"language" : {
2024-01-04 03:18:20 +00:00
url : getDataTablesLanguageUrl ( ) ,
2024-01-04 03:03:11 +00:00
} ,
2022-12-29 16:14:18 +00:00
"order" : [ 0 , 'asc' ] ,
'white-space' : 'nowrap' ,
} ) ;
} ) ;
var table = $ ( '.oqrstable' ) . DataTable ( ) ;
table . clear ( ) ;
2023-11-20 18:03:54 +00:00
2022-12-29 16:14:18 +00:00
for ( i = 0 ; i < rows . length ; i ++ ) {
let qso = rows [ i ] ;
2023-11-20 18:03:54 +00:00
2022-12-29 16:14:18 +00:00
var data = [
'<div class="form-check"><input class="form-check-input" type="checkbox" /></div>' ,
qso . requesttime ,
qso . date ,
qso . time ,
qso . band ,
qso . mode ,
qso . requestcallsign ,
qso . station _callsign ,
qso . email ,
qso . note ,
echo _qsl _method ( qso . qslroute ) ,
echo _searchlog _button ( qso . requestcallsign , qso . id ) ,
echo _status ( qso . status ) ,
] ;
2023-11-20 18:03:54 +00:00
2022-12-29 16:14:18 +00:00
let createdRow = table . row . add ( data ) . index ( ) ;
table . rows ( createdRow ) . nodes ( ) . to$ ( ) . data ( 'oqrsID' , qso . id ) ;
table . row ( createdRow ) . node ( ) . id = 'oqrsID_' + qso . id ;
}
table . columns . adjust ( ) . draw ( ) ;
}
function echo _status ( status ) {
switch ( status . toUpperCase ( ) ) {
case '0' : return 'Open request' ; break ;
case '1' : return 'Not in log request' ; break ;
case '2' : return 'Request done' ; break ;
default : return '' ;
}
}
function echo _qsl _method ( method ) {
switch ( method . toUpperCase ( ) ) {
case 'B' : return 'Bureau' ; break ;
case 'D' : return 'Direct' ; break ;
case 'E' : return 'Electronic' ; break ;
default : return '' ;
}
}
function echo _searchlog _button ( callsign , id ) {
return '<button class="btn btn-primary btn-sm" type="button" onclick="searchLog(\'' + callsign + '\');"><i class="fas fa-search"></i> Call</button> ' +
'<button class="btn btn-primary btn-sm" type="button" onclick="searchLogTimeDate(' + id + ');"><i class="fas fa-search"></i> Date/Time</button>' ;
}
$ ( document ) . ready ( function ( ) {
$ ( '#searchForm' ) . submit ( function ( e ) {
$ ( '#searchButton' ) . prop ( "disabled" , true ) ;
$ . ajax ( {
url : this . action ,
type : 'post' ,
data : {
de : this . de . value ,
dx : this . dx . value ,
status : this . status . value ,
oqrsResults : this . oqrsResults . value
} ,
dataType : 'json' ,
success : function ( data ) {
$ ( '#searchButton' ) . prop ( "disabled" , false ) ;
loadOqrsTable ( data ) ;
} ,
error : function ( data ) {
$ ( '#searchButton' ) . prop ( "disabled" , false ) ;
BootstrapDialog . alert ( {
title : 'ERROR' ,
message : 'An error ocurred while making the request' ,
type : BootstrapDialog . TYPE _DANGER ,
closable : false ,
draggable : false ,
callback : function ( result ) {
}
} ) ;
} ,
} ) ;
return false ;
} ) ;
$ ( '.oqrstable' ) . on ( 'click' , 'input[type="checkbox"]' , function ( ) {
if ( $ ( this ) . is ( ":checked" ) ) {
2023-04-30 11:31:50 +00:00
$ ( this ) . closest ( 'tr' ) . addClass ( 'activeRow' ) ;
2022-12-29 16:14:18 +00:00
} else {
2023-04-30 11:31:50 +00:00
$ ( this ) . closest ( 'tr' ) . removeClass ( 'activeRow' ) ;
2022-12-29 16:14:18 +00:00
}
} ) ;
$ ( '#deleteOqrs' ) . click ( function ( event ) {
var elements = $ ( '.oqrstable tbody input:checked' ) ;
var nElements = elements . length ;
if ( nElements == 0 ) {
return ;
}
$ ( '#deleteOqrs' ) . prop ( "disabled" , true ) ;
var table = $ ( '.oqrstable' ) . DataTable ( ) ;
BootstrapDialog . confirm ( {
title : 'DANGER' ,
message : 'Warning! Are you sure you want to delete the marked OQRS request(s)?' ,
type : BootstrapDialog . TYPE _DANGER ,
closable : true ,
draggable : true ,
btnOKClass : 'btn-danger' ,
callback : function ( result ) {
if ( result ) {
elements . each ( function ( ) {
2022-12-29 16:59:10 +00:00
let id = $ ( this ) . first ( ) . closest ( 'tr' ) . data ( 'oqrsID' )
2022-12-29 16:14:18 +00:00
$ . ajax ( {
2022-12-29 16:59:10 +00:00
url : base _url + 'index.php/oqrs/delete_oqrs_line' ,
2022-12-29 16:14:18 +00:00
type : 'post' ,
data : { 'id' : id
} ,
success : function ( data ) {
2022-12-29 16:59:10 +00:00
var row = $ ( "#oqrsID_" + id ) ;
2022-12-29 16:14:18 +00:00
table . row ( row ) . remove ( ) . draw ( false ) ;
}
} ) ;
$ ( '#deleteOqrs' ) . prop ( "disabled" , false ) ;
} )
}
}
} ) ;
} ) ;
$ ( '#markOqrs' ) . click ( function ( event ) {
var elements = $ ( '.oqrstable tbody input:checked' ) ;
var nElements = elements . length ;
if ( nElements == 0 ) {
return ;
}
$ ( '#markOqrs' ) . prop ( "disabled" , true ) ;
var table = $ ( '.oqrstable' ) . DataTable ( ) ;
BootstrapDialog . confirm ( {
title : 'DANGER' ,
2022-12-29 16:59:10 +00:00
message : 'Warning! Are you sure you want to mark OQRS request(s) as done?' ,
2022-12-29 16:14:18 +00:00
type : BootstrapDialog . TYPE _DANGER ,
closable : true ,
draggable : true ,
btnOKClass : 'btn-danger' ,
callback : function ( result ) {
if ( result ) {
elements . each ( function ( ) {
2022-12-29 16:59:10 +00:00
let id = $ ( this ) . first ( ) . closest ( 'tr' ) . data ( 'oqrsID' )
2022-12-29 16:14:18 +00:00
$ . ajax ( {
2022-12-29 16:59:10 +00:00
url : base _url + 'index.php/oqrs/mark_oqrs_line_as_done' ,
2022-12-29 16:14:18 +00:00
type : 'post' ,
data : { 'id' : id
} ,
success : function ( data ) {
2022-12-29 16:59:10 +00:00
$ ( '#searchForm' ) . submit ( ) ;
2022-12-29 16:14:18 +00:00
}
} ) ;
$ ( '#markOqrs' ) . prop ( "disabled" , false ) ;
} )
}
}
} ) ;
} ) ;
$ ( '#checkBoxAll' ) . change ( function ( event ) {
if ( this . checked ) {
$ ( '.oqrstable tbody tr' ) . each ( function ( i ) {
selectQsoID ( $ ( this ) . data ( 'oqrsID' ) )
} ) ;
} else {
$ ( '.oqrstable tbody tr' ) . each ( function ( i ) {
unselectQsoID ( $ ( this ) . data ( 'oqrsID' ) )
} ) ;
}
} ) ;
$ ( '#searchForm' ) . submit ( ) ;
$ ( '#searchForm' ) . on ( 'reset' , function ( e ) {
setTimeout ( function ( ) {
$ ( '#searchForm' ) . submit ( ) ;
} ) ;
} ) ;
2022-12-30 22:16:38 +00:00
2022-12-29 16:14:18 +00:00
} ) ;
function selectQsoID ( qsoID ) {
var element = $ ( "#oqrsID_" + qsoID ) ;
element . find ( "input[type=checkbox]" ) . prop ( "checked" , true ) ;
2023-04-30 11:31:50 +00:00
element . addClass ( 'activeRow' ) ;
2022-12-29 16:14:18 +00:00
}
function unselectQsoID ( qsoID ) {
var element = $ ( "#oqrsID_" + qsoID ) ;
element . find ( "input[type=checkbox]" ) . prop ( "checked" , false ) ;
2023-04-30 11:31:50 +00:00
element . removeClass ( 'activeRow' ) ;
2022-12-29 16:14:18 +00:00
$ ( '#checkBoxAll' ) . prop ( "checked" , false ) ;
}
2023-11-20 18:03:54 +00:00
function addQsoToPrintQueue ( id ) {
$ . ajax ( {
url : base _url + 'index.php/qslprint/add_qso_to_print_queue' ,
type : 'post' ,
data : { 'id' : id } ,
success : function ( html ) {
$ ( "#qsolist_" + id ) . remove ( ) ; ''
}
} ) ;
}