public function afterSave() { parent::afterSave(); if (count($this->data) == 0) { foreach (Metric::model()->findAll() as $metric) { $data = new Data(); $data->metric_id = $metric->id; $data->sector_id = $this->id; $data->save(); } } }
<h3>Редактирование метрики</h3> </div> <div class="modal-body"> <form class="form-vertical"> Формула: <br/> <textarea id="metric_formula" class="input-xlarge" rows="4" style="font: monospace;"></textarea><br/> Минимум:<br/> <textarea id="metric_min" class="input-xlarge" rows="4" style="font: monospace;"></textarea><br/> Норма:<br/> <textarea id="metric_norma" class="input-xlarge" rows="4" style="font: monospace;"></textarea><br/> Максимум:<br/> <textarea id="metric_max" class="input-xlarge" rows="4" style="font: monospace;"></textarea><br/> </form> <div> <?php foreach (Metric::model()->findAll() as $item) { echo '<li>' . $item->title . ' - ' . $item->name . '</li>'; } ?> </div> </div> <div class="modal-footer"> <a href="#" class="btn" data-dismiss="modal">Отмена</a> <a href="#" id="formula_save" class="btn btn-primary">Сохранить</a> </div> </div> <div style="z-index: 101; position: absolute; top: 60px; right: 10px; text-align: right;" class="right-toolbar"> <div id="edit_metric"> <a data-toggle="modal" href="#metric_form"><img src="/img/formula.png" width="40" height="40"/></a> </div> </div>
public function actions() { return array('nested.' => array('class' => 'regions.portlets.NestedTree', 'sort' => array('model' => Metric::model(), 'forwardRoute' => '/regions/index/actualData'))); }
<?php foreach (CHtml::listData(Metric::model()->findAll('t.type=1'), 'name', 'title') as $name => $title) { $link = CHtml::link($title, '#' . $name); echo CHtml::tag('li', array(), $link); } ?> </ul> </li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"> По кварталам <b class="caret"></b> </a> <ul class="dropdown-menu" data-type="squares"> <?php foreach (CHtml::listData(Metric::model()->findAll('t.type=2'), 'name', 'title') as $name => $title) { $link = CHtml::link($title, '#' . $name); echo CHtml::tag('li', array(), $link); } ?> </ul> </li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"> Настройки <b class="caret"></b> </a> <ul class="dropdown-menu settings"> <?php $link = CHtml::link('Сортировка метрик', '/regions/save/nested.sort', array('id' => 'metrics-sortable-toggle', 'data-fancybox-type ' => "iframe", 'class' => "fancy")); echo CHtml::tag('li', array(), $link);