From 9db4ea8abd4c72b7360a8b0cab1dec0fa6bda9b9 Mon Sep 17 00:00:00 2001 From: Leorne Date: Fri, 6 Dec 2019 11:06:21 +0300 Subject: [PATCH 1/7] addition fields images --- backend/modules/card/views/user-card/view.php | 5 +- backend/modules/notes/views/notes/view.php | 5 +- common/models/FieldsValueNew.php | 61 +++++++++++++++++++ 3 files changed, 63 insertions(+), 8 deletions(-) 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/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/common/models/FieldsValueNew.php b/common/models/FieldsValueNew.php index 6c085f5..7cab619 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,61 @@ class FieldsValueNew extends \yii\db\ActiveRecord return $this->hasOne(AdditionalFields::class, ['id' => 'field_id']); } + + + + + 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; + } + } + + public function getValue() + { + $test = $this->type_file === 'file' ? $this->getFileValue() : $this->getTextValue(); + return $test; + } + + public 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; + } + + public function getTextValue() + { + return $this->value; + } + + public function getFileName(){ + if($this->type_file === 'file'){ + $explode = explode('/', $this->value); + $filename = array_pop($explode); + return $filename; + } + return $this->value; + } } From 75d0b2191e80b0193691de8a7ceda0c03932caf9 Mon Sep 17 00:00:00 2001 From: Leorne Date: Fri, 6 Dec 2019 11:11:31 +0300 Subject: [PATCH 2/7] FieldsValueNew some refactoring --- common/models/FieldsValueNew.php | 86 +++++++++++++++++++------------- 1 file changed, 51 insertions(+), 35 deletions(-) diff --git a/common/models/FieldsValueNew.php b/common/models/FieldsValueNew.php index 7cab619..ffaf54a 100644 --- a/common/models/FieldsValueNew.php +++ b/common/models/FieldsValueNew.php @@ -72,18 +72,67 @@ class FieldsValueNew extends \yii\db\ActiveRecord } + /** + * 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{ + try { $mime = mime_content_type(Yii::getAlias('@frontend/web' . $this->value)); - }catch (ErrorException $e){ + } catch (ErrorException $e) { return false; } @@ -95,37 +144,4 @@ class FieldsValueNew extends \yii\db\ActiveRecord } } - public function getValue() - { - $test = $this->type_file === 'file' ? $this->getFileValue() : $this->getTextValue(); - return $test; - } - - public 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; - } - - public function getTextValue() - { - return $this->value; - } - - public function getFileName(){ - if($this->type_file === 'file'){ - $explode = explode('/', $this->value); - $filename = array_pop($explode); - return $filename; - } - return $this->value; - } } From 48001992ff6e5c455d816df7e030de5a04aaaa2d Mon Sep 17 00:00:00 2001 From: Leorne Date: Fri, 6 Dec 2019 11:30:11 +0300 Subject: [PATCH 3/7] view items translate --- .../settings/views/additional-fields/_form.php | 2 +- .../settings/views/additional-fields/view.php | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) 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..b1a3f97 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-danger', 'data' => [ - 'confirm' => 'Are you sure you want to delete this item?', + 'confirm' => 'Вы действительно хотите удалить поле?', 'method' => 'post', ], ]) ?> + $model->id], ['class' => 'btn btn-success']) ?> + $model->id], ['class' => 'btn btn-primary']) ?>

Date: Fri, 6 Dec 2019 12:05:14 +0300 Subject: [PATCH 4/7] translate buttons and breadcrumbs --- backend/modules/accesses/views/accesses/create.php | 2 +- backend/modules/accesses/views/accesses/update.php | 4 ++-- backend/modules/accesses/views/accesses/view.php | 4 ++-- backend/modules/card/views/user-card/index.php | 2 +- backend/modules/notes/views/notes/_form.php | 2 +- backend/modules/settings/views/additional-fields/view.php | 2 +- backend/modules/settings/views/status/index.php | 2 +- common/models/Note.php | 4 ++-- 8 files changed, 11 insertions(+), 11 deletions(-) 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/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/settings/views/additional-fields/view.php b/backend/modules/settings/views/additional-fields/view.php index b1a3f97..6f3081b 100755 --- a/backend/modules/settings/views/additional-fields/view.php +++ b/backend/modules/settings/views/additional-fields/view.php @@ -13,6 +13,7 @@ $this->params['breadcrumbs'][] = $this->title;

+ $model->id], ['class' => 'btn btn-primary']) ?> $model->id], ['class' => 'btn btn-primary']) ?> $model->id], [ 'class' => 'btn btn-danger', @@ -22,7 +23,6 @@ $this->params['breadcrumbs'][] = $this->title; ], ]) ?> $model->id], ['class' => 'btn btn-success']) ?> - $model->id], ['class' => 'btn btn-primary']) ?>

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

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

'ID', 'name' => 'Название', 'description' => 'Описание', - 'created_at' => 'Created At', - 'updated_at' => 'Updated At', + 'created_at' => 'Создано', + 'updated_at' => 'Обновлено', ]; } } From 325d247006080b1201af7fdbc93351df81336dcd Mon Sep 17 00:00:00 2001 From: Leorne Date: Fri, 6 Dec 2019 12:55:04 +0300 Subject: [PATCH 5/7] left bar company active fix and add icons --- backend/views/layouts/left.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/views/layouts/left.php b/backend/views/layouts/left.php index fe2f1d8..07eb714 100755 --- a/backend/views/layouts/left.php +++ b/backend/views/layouts/left.php @@ -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']], From 888080229abe1222da4e30c26042db315d855e96 Mon Sep 17 00:00:00 2001 From: Leorne Date: Fri, 6 Dec 2019 13:28:22 +0300 Subject: [PATCH 6/7] left bar company active fix and add icons --- backend/views/layouts/left.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/views/layouts/left.php b/backend/views/layouts/left.php index 07eb714..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]]; } From 8c1c2cf5cd0885911950581de355ee536d7c62e7 Mon Sep 17 00:00:00 2001 From: Leorne Date: Fri, 6 Dec 2019 13:46:06 +0300 Subject: [PATCH 7/7] change accesses table access column to text type --- common/models/Accesses.php | 3 ++- ...accesses_table_access_field_to_text_type.php | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 console/migrations/m191206_100300_accesses_table_access_field_to_text_type.php 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/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'); + } +}