academic_program

Description

Filters the academic program dropdown list.

Parameters

$query (mixed) (required) Query used to generate the dropdown list from the academic program table.

$progCode (string) (optional) Used to check the selected option with the database.

Example

$app = \Liten\Liten::getInstance();

/**
 * This function is used to override the academic_program filter.
 * Our query will retrieve active acad programs from the acad_program
 * table and order the acad programs by schools.
 * 
 * @param mixed $query
 * @param string $progCode
 */
function custom_academic_program_select($query, $progCode)
{
    $app = \Liten\Liten::getInstance();
    
    $prog = $app->db->acad_program()
        ->where('currStatus = "A"')
        ->orderBy('schoolCode');
    
    $query = $prog->find(function ($data) {
        $array = [];
        foreach ($data as $d) {
            $array[] = $d;
        }
        return $array;
    });
    
    foreach ($query as $r) {
        echo '<option value="' . _h($r['acadProgCode']) . '"' . selected($progCode, _h($r['acadProgCode']), false) . '>' . _h($r['acadProgCode']) . ' ' . _h($r['acadProgTitle']) . '</option>' . "\n";
    }
}
$app->hook->add_filter( 'academic_program', 'custom_academic_program_select', 10, 2 );

Change Log

Since 6.2.3

Source File

academic_program hook is located in app/src/functions/hook-function.php.

See Also