/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = EventGroup::find(); $this->load($params); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['attributes' => ['Name', 'MinPrice', 'CategoryId', 'TicketCount']]]); $className = explode('\\', EventGroup::className()); $className = $className[count($className) - 1]; $query->where(['maxPrice' => isset($params[$className]['maxPrice']) ? $params[$className]['maxPrice'] : '']); return $dataProvider; }
protected static function load_event_group($group_id, $id = null) { if (isset($_GET['id'])) { $id = $_GET['id']; } $group_id = mysql_real_escape_string($group_id); $id = mysql_real_escape_string($id); $group = EventGroup::find("event_groups.id = '{$id}' AND groups.id = '{$group_id}'"); if ($group) { return $group; } Error404(); }
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 }
/** * 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])); }
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'); }
<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']; ?>
public function event_groups($reload = false) { if ($reload or !$this->event_groups_cache) { $id = mysql_real_escape_string($this->id); $this->event_groups_cache = EventGroup::find_all("event_groups.event_id = '{$id}'"); } return $this->event_groups_cache; }
public function event_groups($sort = "", $reload = false) { if ($reload or !$this->event_groups_cache) { $this->event_groups_cache = array(); $id = mysql_real_escape_string($this->id); $this->event_groups_cache = EventGroup::find_all("groups.id = '{$id}'", $sort); } return $this->event_groups_cache; }