Returns the static model of the specified AR class.
public static model ( $className = __CLASS__ ) : Benefit | ||
리턴 | Benefit | the static model class |
/** * Edits or adds a Procedure. * * @param bool|int $id * * @throws CHttpException */ public function actionEdit($id = false) { $admin = new Admin(Procedure::model(), $this); if ($id) { $admin->setModelId($id); } $admin->setEditFields(array('term' => 'text', 'short_format' => 'text', 'default_duration' => 'text', 'snomed_code' => 'text', 'snomed_term' => 'text', 'aliases' => 'text', 'unbooked' => 'checkbox', 'active' => 'checkbox', 'opcsCodes' => array('widget' => 'MultiSelectList', 'relation_field_id' => 'id', 'label' => 'OPCS Code', 'options' => CHtml::encodeArray(CHtml::listData(OPCSCode::model()->findAll(), 'id', function ($model) { return $model->name . ': ' . $model->description; }))), 'benefits' => array('widget' => 'MultiSelectList', 'relation_field_id' => 'id', 'label' => 'Benefit', 'options' => CHtml::encodeArray(CHtml::listData(Benefit::model()->findAll(), 'id', 'name'))), 'complications' => array('widget' => 'MultiSelectList', 'relation_field_id' => 'id', 'label' => 'Complication', 'options' => CHtml::encodeArray(CHtml::listData(Complication::model()->findAll(), 'id', 'name'))))); if (isset($admin->getModel()->operationNotes)) { $admin->setEditFields(array_merge($admin->getEditFields(), array('operationNotes' => array('widget' => 'MultiSelectList', 'relation_field_id' => 'id', 'label' => 'Operation Note Element', 'options' => CHtml::encodeArray(CHtml::listData(ElementType::model()->findAllByAttributes(array(), 'event_type_id in (select id from event_type where name = "Operation Note")'), 'id', 'name')))))); } $admin->editModel(); }
public static function DropDown($groupid = 0) { $res = array(); if ($groupid == 0) { foreach (Benefit::model()->findAll("visible = :visible", array(":visible" => 1)) as $record) { $res[$record->idBenefit] = $record->BenefitName; } } else { foreach (Benefit::model()->findAll("visible = :visible and BenefitGroupID = {$groupid}", array(":visible" => 1)) as $record) { $res[$record->idBenefit] = $record->BenefitName; } } return $res; }
* @var $form */ $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'benefit-form-modal', 'enableAjaxValidation' => false, 'htmlOptions' => array("class" => "form"))); //$form = new TbActiveForm(); ?> <div class="row-fluid"> <?php echo $form->errorSummary($model); ?> <?php echo $form->hiddenField($model, 'PersonID', array('class' => 'span5')); ?> <?php echo $form->dropDownListRow($model, 'BenefitID', CHtml::listData(Benefit::model()->findAll(), "idBenefit", "BenefitName"), array('class' => 'span12')); ?> </div> <div class="row-fluid"> <div class ="span1"> <?php echo $form->labelEx($model, 'Series'); ?> <?php echo $form->textField($model, 'Series', array('class' => 'span12', 'maxlength' => 50)); ?> </div> <div class ="span2"> <?php echo $form->labelEx($model, 'Numbers'); ?>
/** * Метод асинхронно повертає список типів пільг */ public function actionBenefitgroups() { $models = Benefit::model()->findAll('1 ORDER BY BenefitName ASC'); $result = array(); foreach ($models as $model) { /* @var $model Benefit */ $result[] = array('text' => str_replace('"', "'", $model->BenefitName), 'id' => $model->idBenefit); } echo CJSON::encode($result); }
/** * @covers Benefit::model * @todo Implement testModel(). */ public function testModel() { $this->assertEquals('Benefit', get_class(Benefit::model()), 'Class name should match model.'); }
/** * Deletes rows for the model. */ public function actionDelete() { $admin = new Admin(Benefit::model(), $this); $admin->deleteModel(); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = Benefit::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }