<div class="box-actions"> <?php echo EventAction::button('Add', 'add_letter_contact_rule', null, array('class' => 'button small'))->toHtml(); ?> </div> </header> <form id="rulestest" class="panel"> <fieldset> <legend> Test: </legend> <div class="row field-row"> <div class="large-2 column"> <?php echo CHtml::dropDownList('lcr_rule_type_id', '', CHtml::listData(OphTrOperationbooking_Admission_Letter_Warning_Rule_Type::model()->findAll(), 'id', 'name'), array('empty' => '- Rule -')); ?> </div> <div class="large-2 column"> <?php echo CHtml::dropDownList('lcr_site_id', '', Site::model()->getListForCurrentInstitution('name'), array('empty' => '- Site -')); ?> </div> <div class="large-2 column"> <?php echo CHtml::dropDownList('lcr_subspecialty_id', '', CHtml::listData(Subspecialty::model()->findAllByCurrentSpecialty(), 'id', 'name'), array('empty' => '- Subspecialty -')); ?> </div> <div class="large-2 column"> <?php echo CHtml::dropDownList('lcr_firm_id', '', array(), array('empty' => '- Firm -'));
public static function getRule($rule_type_name, $site_id, $is_child, $theatre_id, $subspecialty_id, $firm_id) { if (!($rule_type = OphTrOperationbooking_Admission_Letter_Warning_Rule_Type::model()->find('name=?', array($rule_type_name)))) { throw new Exception("We were asked for a rule type that doesn't exist: {$rule_type_name}"); } $criteria = new CDbCriteria(); $criteria->addCondition("parent_rule_id is null and rule_type_id = {$rule_type->id}"); $criteria->addCondition("rule_type_id = {$rule_type->id}"); $criteria->order = 'rule_order asc'; foreach (self::model()->findAll($criteria) as $rule) { if ($rule->applies($site_id, $is_child, $theatre_id, $subspecialty_id, $firm_id)) { return $rule->parse($site_id, $is_child, $theatre_id, $subspecialty_id, $firm_id); } } }