diff --git a/backend/modules/accesses/views/accesses/create.php b/backend/modules/accesses/views/accesses/create.php index be6b7d6..552caff 100644 --- a/backend/modules/accesses/views/accesses/create.php +++ b/backend/modules/accesses/views/accesses/create.php @@ -6,7 +6,7 @@ use yii\helpers\Html; /* @var $model common\models\Accesses */ $this->title = 'Добавить доступ'; -$this->params['breadcrumbs'][] = ['label' => 'Accesses', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => 'Доступы', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?>
diff --git a/backend/modules/accesses/views/accesses/update.php b/backend/modules/accesses/views/accesses/update.php index f28ec72..1ac2001 100644 --- a/backend/modules/accesses/views/accesses/update.php +++ b/backend/modules/accesses/views/accesses/update.php @@ -6,9 +6,9 @@ use yii\helpers\Html; /* @var $model common\models\Accesses */ $this->title = 'Редактировать доступ: ' . $model->name; -$this->params['breadcrumbs'][] = ['label' => 'Accesses', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => 'Доступы', 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]]; -$this->params['breadcrumbs'][] = 'Update'; +$this->params['breadcrumbs'][] = 'Редактировать'; ?>
diff --git a/backend/modules/accesses/views/accesses/view.php b/backend/modules/accesses/views/accesses/view.php index 2ea10ea..7310ef2 100644 --- a/backend/modules/accesses/views/accesses/view.php +++ b/backend/modules/accesses/views/accesses/view.php @@ -7,7 +7,7 @@ use yii\widgets\DetailView; /* @var $model common\models\Accesses */ $this->title = $model->name; -$this->params['breadcrumbs'][] = ['label' => 'Accesses', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => 'Доступы', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; \yii\web\YiiAsset::register($this); ?> @@ -19,7 +19,7 @@ $this->params['breadcrumbs'][] = $this->title; $model->id], [ 'class' => 'btn btn-danger', 'data' => [ - 'confirm' => 'Вы уверены, что хотите удалить эот элемент?', + 'confirm' => 'Вы уверены, что хотите удалить этот элемент?', 'method' => 'post', ], ]) ?> diff --git a/backend/modules/card/views/user-card/index.php b/backend/modules/card/views/user-card/index.php index 207a537..c4b2494 100755 --- a/backend/modules/card/views/user-card/index.php +++ b/backend/modules/card/views/user-card/index.php @@ -27,7 +27,7 @@ $this->params['breadcrumbs'][] = $this->title; //'id', [ - 'label' => 'photo', + 'label' => 'Фото', 'format' => 'raw', 'value' => function ($model) { return Html::img(Url::to($model->photo), [ diff --git a/backend/modules/card/views/user-card/view.php b/backend/modules/card/views/user-card/view.php index 9cf3277..4ec95e2 100755 --- a/backend/modules/card/views/user-card/view.php +++ b/backend/modules/card/views/user-card/view.php @@ -78,10 +78,7 @@ $this->params['breadcrumbs'][] = $this->title; 'attribute' => 'value', 'format' => 'raw', 'value' => function ($model) { - if ($model->type_file == 'file') { - return $model->value . ' (' . Html::a('Скачать', $model->value, ['target' => '_blank', 'download' => 'download']) . ')'; - } - return $model->value; + return $model->getValue(); } ], ], diff --git a/backend/modules/notes/views/notes/_form.php b/backend/modules/notes/views/notes/_form.php index e339fd2..5ca7a08 100755 --- a/backend/modules/notes/views/notes/_form.php +++ b/backend/modules/notes/views/notes/_form.php @@ -22,7 +22,7 @@ use yii\widgets\ActiveForm;
field($model, 'fields')->widget(MultipleInput::class, [ - + 'cloneButton' => true, 'columns' => [ [ 'name' => 'field_id', diff --git a/backend/modules/notes/views/notes/view.php b/backend/modules/notes/views/notes/view.php index 20388d7..dc27b37 100755 --- a/backend/modules/notes/views/notes/view.php +++ b/backend/modules/notes/views/notes/view.php @@ -46,10 +46,7 @@ $this->params['breadcrumbs'][] = $this->title; 'attribute' => 'value', 'format' => 'raw', 'value' => function ($model) { - if ($model->type_file == 'file') { - return $model->value . ' (' . Html::a('Скачать', $model->value, ['target' => '_blank', 'download' => 'download']) . ')'; - } - return $model->value; + return $model->getValue(); } ], ], diff --git a/backend/modules/settings/views/additional-fields/_form.php b/backend/modules/settings/views/additional-fields/_form.php index d89afe1..9b600c2 100755 --- a/backend/modules/settings/views/additional-fields/_form.php +++ b/backend/modules/settings/views/additional-fields/_form.php @@ -17,7 +17,7 @@ use yii\widgets\ActiveForm; field($model, 'use')->checkboxList((new \common\models\UseField())->statuses); ?>
- 'btn btn-success']) ?> + 'btn btn-success']) ?>
diff --git a/backend/modules/settings/views/additional-fields/view.php b/backend/modules/settings/views/additional-fields/view.php index 9d43ddf..6f3081b 100755 --- a/backend/modules/settings/views/additional-fields/view.php +++ b/backend/modules/settings/views/additional-fields/view.php @@ -7,22 +7,22 @@ use yii\widgets\DetailView; /* @var $model backend\modules\card\models\AdditionalFields */ $this->title = $model->name; -$this->params['breadcrumbs'][] = ['label' => 'Additional Fields', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => 'Дополнительные поля', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?>
-

title) ?>

-

- $model->id], ['class' => 'btn btn-primary']) ?> - $model->id], [ + $model->id], ['class' => 'btn btn-primary']) ?> + $model->id], ['class' => 'btn btn-primary']) ?> + $model->id], [ 'class' => 'btn btn-danger', 'data' => [ - 'confirm' => 'Are you sure you want to delete this item?', + 'confirm' => 'Вы действительно хотите удалить поле?', 'method' => 'post', ], ]) ?> + $model->id], ['class' => 'btn btn-success']) ?>

params['breadcrumbs'][] = $this->title; render('_search', ['model' => $searchModel]); ?>

- 'btn btn-success']) ?> + 'btn btn-success']) ?>

$status, 'icon' => 'user', 'url' => ['/card/user-card?UserCardSearch[status]=' . $key]]; } $projectStatuses = \common\models\Status::getStatusesArray(\common\models\UseStatus::USE_PROJECT); - $projectItems = [['label' => 'Все', 'icon' => 'files-o', 'url' => ['/project/project']]]; + $projectItems = [['label' => 'Все', 'icon' => 'cubes', 'url' => ['/project/project']]]; foreach ($projectStatuses as $key => $status) { $projectItems[] = ['label' => $status, 'icon' => 'user', 'url' => ['/project/project?ProjectSearch[status]=' . $key]]; } @@ -32,10 +32,10 @@ 'items' => $menuItems, ], [ - 'label' => 'Проекты', 'icon' => 'files-o', 'url' => ['#'], 'active' => \Yii::$app->controller->id == 'project', + 'label' => 'Проекты', 'icon' => 'cubes', 'url' => ['#'], 'active' => \Yii::$app->controller->id == 'project', 'items' => $projectItems, ], - ['label' => 'Компании', 'icon' => 'files-o', 'url' => ['/company/company']], + ['label' => 'Компании', 'icon' => 'building', 'url' => ['/company/company'], 'active' => \Yii::$app->controller->id == 'company'], [ 'label' => 'Hh.ru', 'icon' => 'user-circle', 'url' => '#', 'items' => [ @@ -45,8 +45,8 @@ ], ['label' => 'Баланс', 'icon' => 'dollar', 'url' => ['/balance/balance'], 'active' => \Yii::$app->controller->id == 'balance'], ['label' => 'Отпуска', 'icon' => 'plane', 'url' => ['/holiday/holiday'], 'active' => \Yii::$app->controller->id == 'holiday'], - ['label' => 'Доступы', 'icon' => '', 'url' => ['/accesses/accesses'], 'active' => \Yii::$app->controller->id == 'accesses'], - ['label' => 'Заметки', 'icon' => '', 'url' => ['/notes/notes'], 'active' => \Yii::$app->controller->id == 'notes'], + ['label' => 'Доступы', 'icon' => 'key', 'url' => ['/accesses/accesses'], 'active' => \Yii::$app->controller->id == 'accesses'], + ['label' => 'Заметки', 'icon' => 'sticky-note', 'url' => ['/notes/notes'], 'active' => \Yii::$app->controller->id == 'notes'], /*['label' => 'Gii', 'icon' => 'file-code-o', 'url' => ['/gii']], ['label' => 'Debug', 'icon' => 'dashboard', 'url' => ['/debug']], diff --git a/common/models/Accesses.php b/common/models/Accesses.php index 42b9386..4d3c6c9 100644 --- a/common/models/Accesses.php +++ b/common/models/Accesses.php @@ -32,7 +32,8 @@ class Accesses extends \yii\db\ActiveRecord public function rules() { return [ - [['name', 'access'], 'string', 'max' => 255], + [['name'], 'string', 'max' => 255], + [['access'], 'string'], [['_projects'], 'safe'], [['_users'], 'safe'], ]; diff --git a/common/models/FieldsValueNew.php b/common/models/FieldsValueNew.php index 6c085f5..ffaf54a 100644 --- a/common/models/FieldsValueNew.php +++ b/common/models/FieldsValueNew.php @@ -3,6 +3,9 @@ namespace common\models; use Yii; +use yii\base\ErrorException; +use yii\base\Exception; +use yii\helpers\Html; /** * This is the model class for table "fields_value_new". @@ -23,6 +26,7 @@ class FieldsValueNew extends \yii\db\ActiveRecord const TYPE_COMPANY = 2; const TYPE_BALANCE = 3; const TYPE_NOTE = 4; + /** * {@inheritdoc} */ @@ -67,4 +71,77 @@ class FieldsValueNew extends \yii\db\ActiveRecord return $this->hasOne(AdditionalFields::class, ['id' => 'field_id']); } + + /** + * get value for view + * @return string + */ + public function getValue() + { + $test = $this->type_file === 'file' ? $this->getFileValue() : $this->getTextValue(); + return $test; + } + + /** + * @return string + */ + private function getFileValue() + { + $filename = $this->getFileName(); + $filePath = Yii::getAlias('@frontend/web' . $this->value); + if ($this->isImage()) { + $imageHTML = Html::img($this->value, ['width' => '200px', 'alt' => $filename]); + $downloadLinkHTML = ' (' . Html::a('Скачать', $this->value, ['target' => '_blank', 'download' => $filename]) . ')'; + $result = $imageHTML . $downloadLinkHTML; + } else { + $result = $filename . ' (' . Html::a('Скачать', $this->value, ['target' => '_blank', 'download' => $filename]) . ')'; + } + return $result; + } + + /** + * @return string + */ + private function getTextValue() + { + return $this->value; + } + + /** + * @return mixed|string + */ + public function getFileName() + { + if ($this->type_file === 'file') { + $explode = explode('/', $this->value); + $filename = array_pop($explode); + return $filename; + } + return $this->value; + } + + /** + * File is image? + * @return bool + */ + public function isImage() + { + if ($this->type_file === 'text') { + return false; + } + + try { + $mime = mime_content_type(Yii::getAlias('@frontend/web' . $this->value)); + } catch (ErrorException $e) { + return false; + } + + $extension = explode('/', $mime)['0']; + if (($extension === 'image') || $extension === 'application') { + return true; + } else { + return false; + } + } + } diff --git a/common/models/Note.php b/common/models/Note.php index 572e8c5..7df1862 100755 --- a/common/models/Note.php +++ b/common/models/Note.php @@ -59,8 +59,8 @@ class Note extends \yii\db\ActiveRecord 'id' => 'ID', 'name' => 'Название', 'description' => 'Описание', - 'created_at' => 'Created At', - 'updated_at' => 'Updated At', + 'created_at' => 'Создано', + 'updated_at' => 'Обновлено', ]; } } diff --git a/console/migrations/m191206_100300_accesses_table_access_field_to_text_type.php b/console/migrations/m191206_100300_accesses_table_access_field_to_text_type.php new file mode 100644 index 0000000..ce27857 --- /dev/null +++ b/console/migrations/m191206_100300_accesses_table_access_field_to_text_type.php @@ -0,0 +1,17 @@ +alterColumn('accesses', 'access', 'text'); + } +}