moved get_plaincall method to model

This commit is contained in:
HB9HIL
2024-07-05 15:21:03 +02:00
parent c28611e62f
commit 0d4291bf8a

View File

@@ -123,7 +123,7 @@ class Logbook extends CI_Controller {
$return['dxcc'] = $this->dxcheck($callsign,$date);
$lookupcall=$this->get_plaincall($callsign);
$lookupcall=$this->logbook_model->get_plaincall($callsign);
$return['partial'] = $this->partial($lookupcall, $band);
@@ -169,24 +169,6 @@ class Logbook extends CI_Controller {
return;
}
function get_plaincall($callsign) {
$split_callsign=explode('/',$callsign);
if (count($split_callsign)==1) { // case F0ABC --> return cel 0 //
$lookupcall = $split_callsign[0];
} else if (count($split_callsign)==3) { // case EA/F0ABC/P --> return cel 1 //
$lookupcall = $split_callsign[1];
} else { // case F0ABC/P --> return cel 0 OR case EA/FOABC --> retunr 1 (normaly not exist) //
if (in_array(strtoupper($split_callsign[1]), array('P','M','MM','QRP','0','1','2','3','4','5','6','7','8','9'))) {
$lookupcall = $split_callsign[0];
} else if (strlen($split_callsign[1])>3) { // Last Element longer than 3 chars? Take that as call
$lookupcall = $split_callsign[1];
} else { // Last Element up to 3 Chars? Take first element as Call
$lookupcall = $split_callsign[0];
}
}
return $lookupcall;
}
// Returns $val2 first if it has value, even if it is null or empty string, if not return $val1.
function nval($val1, $val2) {
return (($val2 ?? "") === "" ? ($val1 ?? "") : ($val2 ?? ""));