commit
b27a033802
@ -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;
|
||||
?>
|
||||
<div class="accesses-create">
|
||||
|
@ -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'][] = 'Редактировать';
|
||||
?>
|
||||
<div class="accesses-update">
|
||||
|
||||
|
@ -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;
|
||||
<?= Html::a('Удалить', ['delete', 'id' => $model->id], [
|
||||
'class' => 'btn btn-danger',
|
||||
'data' => [
|
||||
'confirm' => 'Вы уверены, что хотите удалить эот элемент?',
|
||||
'confirm' => 'Вы уверены, что хотите удалить этот элемент?',
|
||||
'method' => 'post',
|
||||
],
|
||||
]) ?>
|
||||
|
@ -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), [
|
||||
|
@ -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();
|
||||
}
|
||||
],
|
||||
],
|
||||
|
@ -22,7 +22,7 @@ use yii\widgets\ActiveForm;
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<?= $form->field($model, 'fields')->widget(MultipleInput::class, [
|
||||
|
||||
'cloneButton' => true,
|
||||
'columns' => [
|
||||
[
|
||||
'name' => 'field_id',
|
||||
|
@ -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();
|
||||
}
|
||||
],
|
||||
],
|
||||
|
@ -17,7 +17,7 @@ use yii\widgets\ActiveForm;
|
||||
<?= $form->field($model, 'use')->checkboxList((new \common\models\UseField())->statuses); ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
|
||||
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
@ -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;
|
||||
?>
|
||||
<div class="additional-fields-view">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<p>
|
||||
<?= 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']) ?>
|
||||
</p>
|
||||
|
||||
<?= DetailView::widget([
|
||||
|
@ -17,7 +17,7 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
|
||||
|
||||
<p>
|
||||
<?= Html::a('Create Status', ['create'], ['class' => 'btn btn-success']) ?>
|
||||
<?= Html::a('Добавить', ['create'], ['class' => 'btn btn-success']) ?>
|
||||
</p>
|
||||
|
||||
<?= GridView::widget([
|
||||
|
@ -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']],
|
||||
|
@ -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'],
|
||||
];
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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' => 'Обновлено',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Class m191206_100300_accesses_table_access_field_to_text_type
|
||||
*/
|
||||
class m191206_100300_accesses_table_access_field_to_text_type extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->alterColumn('accesses', 'access', 'text');
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user