create_update_sttr_record ( object $sacd )

Creates a new student sttr record is none exists or updates the attCreds if the student registers for a new course in the same term.

Source file: app/functions/student-function.php

View source


Parameters

$sacd

(object) (Required) Object holding the last insert into stac.


Used by


Source

function create_update_sttr_record($sacd)
{
    $app = \Liten\Liten::getInstance();
    try {
        $sttr = $app->db->sttr()
            ->where('stuID = ?', _h($sacd->stuID))->_and_()
            ->where('termCode = ?', _h($sacd->termCode))
            ->count('id');

        if ($sttr <= 0) {
            $insert = $app->db->sttr();
            $insert->insert([
                'stuID' => _h($sacd->stuID),
                'termCode' => _h($sacd->termCode),
                'acadLevelCode' => _h($sacd->acadLevelCode),
                'attCred' => _h($sacd->attCred)
            ]);
        } else {
            $upd = $app->db->sttr()
                ->where('stuID = ?', _h($sacd->stuID))->_and_()
                ->where('termCode = ?', _h($sacd->termCode))
                ->findOne();
            $upd->set([
                    'attCred' => _h($upd->attCred) + _h($sacd->attCred)
                ])
                ->update();
        }
    } catch (NotFoundException $e) {
        Cascade::getLogger('error')->error($e->getMessage());
        _etsis_flash()->error(_etsis_flash()->notice(409));
    } catch (ORMException $e) {
        Cascade::getLogger('error')->error($e->getMessage());
        _etsis_flash()->error(_etsis_flash()->notice(409));
    } catch (Exception $e) {
        Cascade::getLogger('error')->error($e->getMessage());
        _etsis_flash()->error(_etsis_flash()->notice(409));
    }
}


Changelog

  • Since: eduTrac SIS 6.3.0

User Contributed Notes

You must log in before being able to contribute a note.