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; ?>
- = Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?> - = Html::a('Delete', ['delete', 'id' => $model->id], [ + = Html::a('Список', ['index', 'id' => $model->id], ['class' => 'btn btn-primary']) ?> + = Html::a('Редактировать', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?> + = Html::a('Удалить', ['delete', 'id' => $model->id], [ 'class' => 'btn btn-danger', 'data' => [ - 'confirm' => 'Are you sure you want to delete this item?', + 'confirm' => 'Вы действительно хотите удалить поле?', 'method' => 'post', ], ]) ?> + = Html::a('Создать', ['create', 'id' => $model->id], ['class' => 'btn btn-success']) ?>
= DetailView::widget([ diff --git a/backend/modules/settings/views/status/index.php b/backend/modules/settings/views/status/index.php index 7637a77..b9a4427 100755 --- a/backend/modules/settings/views/status/index.php +++ b/backend/modules/settings/views/status/index.php @@ -17,7 +17,7 @@ $this->params['breadcrumbs'][] = $this->title; render('_search', ['model' => $searchModel]); ?>- = Html::a('Create Status', ['create'], ['class' => 'btn btn-success']) ?> + = Html::a('Добавить', ['create'], ['class' => 'btn btn-success']) ?>
= GridView::widget([ diff --git a/backend/views/layouts/left.php b/backend/views/layouts/left.php index fe2f1d8..7dea35c 100755 --- a/backend/views/layouts/left.php +++ b/backend/views/layouts/left.php @@ -8,7 +8,7 @@ $menuItems[] = ['label' => $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'); + } +}