예제 #1
0
파일: log_data.php 프로젝트: sapozhkov/goal
<strong title="<?php 
echo Yii::$app->formatter->asDatetime($log->created_at);
?>
"><?php 
echo Yii::$app->formatter->asRelativeTime($log->created_at);
?>
</strong>
<br />

<?php 
$data = json_decode($log->data, true);
$rows = [];
if ($data) {
    foreach ($data as $fieldName => $fieldData) {
        if ($goalModel->hasAttribute($fieldName)) {
            $fieldLabel = $goalModel->getAttributeLabel($fieldName);
            switch ($fieldName) {
                case 'percent':
                case 'title':
                    $rows[] = sprintf('<strong>%s</strong>: "%s" -> "%s"', $fieldLabel, Html::encode($fieldData[0]), Html::encode($fieldData[1]));
                    break;
                case 'to_be_done_at':
                    $rows[] = sprintf('<strong>%s</strong>: "%s" -> "%s"', $fieldLabel, \Yii::$app->formatter->asDate($fieldData[0]), \Yii::$app->formatter->asDate($fieldData[1]));
                    break;
                case 'status_id':
                    $oldStatus = Status::findOne($fieldData[0]);
                    $newStatus = Status::findOne($fieldData[1]);
                    $rows[] = sprintf('<strong>%s</strong>: "%s" -> "%s"', $fieldLabel, $oldStatus ? Html::encode($oldStatus->title) : $notFound, $newStatus ? Html::encode($newStatus->title) : $notFound);
                    break;
                case 'priority_id':