/** * @param Model $model * @param mixed $key * @param int $index * @return string */ public function getDataCellValue($model, $key, $index) { $value = $model->getAttribute($this->attribute); $color = $value === 0 ? 'primary' : 'success'; if ($value < 0) { $color = 'warning'; } if ($value < -($model->getAttribute($this->compare) ?: 0)) { $color = 'danger'; } $url = $this->getUrl($model, $key, $index); $txt = Yii::$app->formatter->format($value, ['currency', $model->currency]); $ops = ['class' => 'text-nowrap text-' . $this->getColor($color)]; return $url ? Html::a($txt, $url, $ops) : Html::tag('span', $txt, $ops); }
public function init() { $possible = []; $field = $this->model->{$this->field}; foreach ($this->defaultValues as $key => $values) { $possible[$key] = ArrayHelper::merge($values, $this->values[$key] ?: []); } $this->values = ArrayHelper::merge($possible, $this->values); foreach ($this->values as $classes => $values) { if (in_array($field, $values, true)) { $class = $classes; break; } } $this->color = isset($class) ? $class : 'warning'; if ($this->model->hasAttribute("{$this->field}_label")) { $label = $this->model->getAttribute("{$this->field}_label"); } else { $label = Inflector::titleize($this->model->{$this->field}); } $this->label = Yii::t($this->i18nDictionary, $label); }
/** {@inheritdoc} */ public function init() { parent::init(); $this->calculation_id = $this->position->getId(); $this->amount = $this->position->getQuantity(); }
public function load($data, $formName = null) { $result = parent::load($data, $formName); $this->prepareSpentTime(); return $result; }
public function setOldAttribute($name, $value) { if ($name !== 'texts') { parent::setOldAttribute($name, $value); } }