Skip to content
Snippets Groups Projects
Select Git revision
  • ed2a6c02c381cf58477564dfbd72447dca31a329
  • main default protected
  • dependabot/go_modules/github.com/gin-contrib/cors-1.6.0
  • master
  • v1.3.2
  • v1.3.1
  • v1.3.0
  • v1.2.0
  • v1.1.1
  • v1.1.0
  • v1.0.3
  • v1.0.2
  • v1.0.1
  • v1.0.0
14 results

renderField.js

Blame
  • CourseCode.php 3.24 KiB
    <?php
    
    class CourseCode extends Nmc_Db_Table_Row
    {
        /**
         * Gets the next course code
         *
         * @return CourseCode
         */
        public function getNextAlphabetically()
        {
            $db = $this->_table->getAdapter();
    
            $order = 'subject, course_number, course_letter';
    
            $where = array();
            $where[] = $db->quoteInto('subject = ?', $this->subject);
            $where[] = $db->quoteInto('course_number = ?', $this->courseNumber);
            $where[] = $db->quoteInto('course_letter > ?', $this->courseLetter);
            $where = implode(' AND ', $where);
    
            $row = $this->_table->fetchRow($where, $order);
            if($row->id) {
                return $row;
            }
    
            $where = array();
            $where[] = $db->quoteInto('subject = ?', $this->subject);
            $where[] = $db->quoteInto('course_number > ?', $this->courseNumber);
            $where = implode(' AND ', $where);
    
            $row = $this->_table->fetchRow($where, $order);
            if($row->id) {
                return $row;
            }
    
            $where = array();
            $where[] = $db->quoteInto('subject > ?', $this->subject);
            $where = implode(' AND ', $where);
    
            $row = $this->_table->fetchRow($where, $order);
            if($row->id) {
                return $row;
            }
    
            return null;
    
        }
    
        /**
         * Returns the previous course code
         *
         * @return CourseCode
         */
        public function getPreviousAlphabetically()
        {
            $db = $this->_table->getAdapter();
    
            $order = 'subject DESC, course_number DESC, course_letter DESC';
    
            $where = array();
            $where[] = $db->quoteInto('subject = ?', $this->subject);
            $where[] = $db->quoteInto('course_number = ?', $this->courseNumber);
            $where[] = $db->quoteInto('course_letter < ?', $this->courseLetter);
            $where = implode(' AND ', $where);
    
            $row = $this->_table->fetchRow($where, $order);
            if($row->id) {
                return $row;
            }
    
            $where = array();
            $where[] = $db->quoteInto('subject = ?', $this->subject);
            $where[] = $db->quoteInto('course_number < ?', $this->courseNumber);
            $where = implode(' AND ', $where);
    
            $row = $this->_table->fetchRow($where, $order);
            if($row->id) {
                return $row;
            }
    
            $where = array();
            $where[] = $db->quoteInto('subject < ?', $this->subject);
            $where = implode(' AND ', $where);
    
            $row = $this->_table->fetchRow($where, $order);
            if($row->id) {
                return $row;
            }
    
            return null;
        }
    
        public function _save()
        {
            if(!$this->integratedStudies) {
                $this->integratedStudies = 'no';
            }
            if(!$this->courseLetter) {
                $this->courseLetter = '';
            }
            return parent::_save();
        }
    
        public function _get($name)
        {
            switch($name) {
                case 'courseNumber':
                    $courseNumber = parent::_get('courseNumber');
                    if(Zend_Filter::isInt($courseNumber) && $courseNumber > 0) {
                        return str_pad($courseNumber, 3, '0', STR_PAD_LEFT);
                    } else {
                        return $courseNumber;
                    }
                    break;
                default:
                    return parent::_get($name);
            }
        }
    }