OphTrOperationbooking_ScheduleOperation_PatientUnavailableReason::afterConstruct PHP Method

afterConstruct() protected method

set a default display order for a new record.
protected afterConstruct ( )
    protected function afterConstruct()
    {
        parent::afterConstruct();
        if (!$this->display_order) {
            $criteria = new CDbCriteria();
            $criteria->order = 'display_order desc';
            $criteria->limit = 1;
            $model = get_class($this);
            $bottom = $model::model()->find($criteria);
            if ($bottom) {
                $this->display_order = $bottom->display_order + 1;
            } else {
                $this->display_order = 1;
            }
        }
    }