model() public static method

Returns the static model of the specified AR class.
public static model ( $className = __CLASS__ ) : EventGroup
return EventGroup the static model class
    public static function eventTypeProperties($event_type_id)
    {
        $event_type = EventType::model()->findByPk($event_type_id);
        $event_type_short_name = EventTypeModuleCode::getEventShortName($event_type);
        if (empty($_POST)) {
            if (!preg_match('/^([A-Z][a-z]+)([A-Z][a-z]+)([A-Z][a-zA-Z]+)$/', $event_type->class_name, $m)) {
                die("ERROR: {$event_type->class_name}");
            }
            $specialty_id = Specialty::model()->find('abbreviation=?', array(strtoupper($m[1])))->id;
            $event_group_id = EventGroup::model()->find('code=?', array($m[2]))->id;
            $event_type_name = $event_type->name;
        } else {
            $specialty_id = @$_REQUEST['Specialty']['id'];
            $event_group_id = @$_REQUEST['EventGroup']['id'];
            $event_type_name = @$_REQUEST['EventTypeModuleCode']['moduleSuffix'];
        }
        ?>
		<label>Specialty: </label>
		<?php 
        echo CHtml::dropDownList('Specialty[id]', $specialty_id, CHtml::listData(Specialty::model()->findAll(array('order' => 'name')), 'id', 'name'));
        ?>
<br/>
		<label>Event group: </label><?php 
        echo CHtml::dropDownList('EventGroup[id]', $event_group_id, CHtml::listData(EventGroup::model()->findAll(array('order' => 'name')), 'id', 'name'));
        ?>
<br />
		<label>Name of event type: </label> <?php 
        echo CHtml::textField('EventTypeModuleCode[moduleSuffix]', $event_type_name, array('size' => 65, 'id' => 'moduleSuffix'));
        ?>
<br />
		<label>Event type short name: </label> <?php 
        echo CHtml::textField('EventTypeModuleCode[moduleShortSuffix]', $event_type_short_name, array('size' => 65, 'id' => 'moduleShortSuffix'));
        ?>
<br />
		<?php 
    }
Esempio n. 2
0
 public function getActiveList()
 {
     $legacy = EventGroup::model()->find('name=?', array('Legacy data'));
     $event_types = array_keys(Yii::app()->modules);
     $criteria = new CDbCriteria();
     $criteria->order = 'name asc';
     $criteria->addInCondition('class_name', $event_types);
     $criteria->addCondition('event_group_id != :egi');
     $criteria->params[':egi'] = $legacy->id;
     return CHtml::listData(EventType::model()->findAll($criteria), 'id', 'name');
 }
Esempio n. 3
0
 /**
  * Get the EventGroup for the module of the event type (as defined by the second camelcase section of the module name)
  * @return CActiveRecord
  */
 public function getEvent_group()
 {
     preg_match('/^([A-Z][a-z]+)([A-Z][a-z]+)([A-Z][a-z]+)$/', $this->class_name, $m);
     return EventGroup::model()->find('code=?', array($m[2]));
 }
		<h3>Describe your event type:</h3>
		<label>Specialty:</label>
		<?php 
echo CHtml::dropDownList('Specialty[id]', empty($_REQUEST) ? Specialty::model()->find('code=?', array(130))->id : @$_REQUEST['Specialty']['id'], CHtml::listData(Specialty::model()->findAll(array('order' => 'name')), 'id', 'name'));
?>
<br />
		<label>Event group:</label>
		<?php 
echo CHtml::dropDownList('EventGroup[id]', empty($_REQUEST) ? EventGroup::model()->find('code=?', array('Mi'))->id : @$_REQUEST['EventGroup']['id'], CHtml::listData(EventGroup::model()->findAll(array('order' => 'name')), 'id', 'name'));
?>
<br />
		<label>Name of event type:</label>
		<input type="text" name="EventTypeModuleCode[moduleSuffix]" value="<?php 
echo @$_POST['EventTypeModuleCode']['moduleSuffix'];
?>
" size="65" id="moduleSuffix" /><br/>
		<?php 
if (isset($this->form_errors['EventTypeModuleCode[moduleSuffix]'])) {
    ?>
			<span style="color: #f00; margin-bottom: 10px; display: inline-block;"><?php 
    echo $this->form_errors['EventTypeModuleCode[moduleSuffix]'];
    ?>
</span>
		<?php 
}
?>

		<label>Event type short name:</label>
		<input type="text" name="EventTypeModuleCode[moduleShortSuffix]" value="<?php 
echo @$_POST['EventTypeModuleCode']['moduleShortSuffix'];
?>