commit
47c13f9bf0
@ -2,9 +2,11 @@
|
||||
|
||||
namespace backend\modules\company\controllers;
|
||||
|
||||
use common\models\FieldsValueNew;
|
||||
use Yii;
|
||||
use backend\modules\company\models\Company;
|
||||
use backend\modules\company\models\CompanySearch;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
@ -52,8 +54,17 @@ class CompanyController extends Controller
|
||||
*/
|
||||
public function actionView($id)
|
||||
{
|
||||
$dataProviderF = new ActiveDataProvider([
|
||||
'query' => FieldsValueNew::find()
|
||||
->where(['item_id' => $id, 'item_type' => FieldsValueNew::TYPE_COMPANY])
|
||||
->orderBy('order'),
|
||||
'pagination' => [
|
||||
'pageSize' => 200,
|
||||
],
|
||||
]);
|
||||
return $this->render('view', [
|
||||
'model' => $this->findModel($id),
|
||||
'dataProviderF' => $dataProviderF
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace backend\modules\company\models;
|
||||
|
||||
use common\models\FieldsValue;
|
||||
use common\models\FieldsValueNew;
|
||||
|
||||
class Company extends \common\models\Company
|
||||
{
|
||||
@ -12,17 +13,21 @@ class Company extends \common\models\Company
|
||||
{
|
||||
parent::init();
|
||||
|
||||
$fieldValue = FieldsValue::find()->where(
|
||||
$fieldValue = FieldsValueNew::find()
|
||||
->where(
|
||||
[
|
||||
'company_id' => \Yii::$app->request->get('id'),
|
||||
'project_id' => null,
|
||||
'card_id' => null,
|
||||
'item_id' => \Yii::$app->request->get('id'),
|
||||
'item_type' => FieldsValueNew::TYPE_COMPANY,
|
||||
])
|
||||
->all();
|
||||
$array = [];
|
||||
if(!empty($fieldValue)){
|
||||
foreach ($fieldValue as $item){
|
||||
array_push($array, ['field_id' => $item->field_id, 'value' => $item->value, 'order' => $item->order]);
|
||||
array_push($array,
|
||||
['field_id' => $item->field_id,
|
||||
'value' => $item->value,
|
||||
'order' => $item->order,
|
||||
'field_name' => $item->field->name]);
|
||||
}
|
||||
$this->fields = $array;
|
||||
}
|
||||
@ -32,6 +37,7 @@ class Company extends \common\models\Company
|
||||
'field_id' => null,
|
||||
'value' => null,
|
||||
'order' => null,
|
||||
'field_name' => null,
|
||||
],
|
||||
];
|
||||
}
|
||||
@ -44,11 +50,12 @@ class Company extends \common\models\Company
|
||||
FieldsValue::deleteAll(['company_id' => $this->id]);
|
||||
|
||||
foreach ( $post['fields'] as $item) {
|
||||
$fildsValue = new FieldsValue();
|
||||
$fildsValue = new FieldsValueNew();
|
||||
$fildsValue->field_id = $item['field_id'];
|
||||
$fildsValue->value = $item['value'];
|
||||
$fildsValue->order = $item['order'];
|
||||
$fildsValue->company_id = $this->id;
|
||||
$fildsValue->item_id = $this->id;
|
||||
$fildsValue->item_type = FieldsValueNew::TYPE_COMPANY;
|
||||
|
||||
$fildsValue->save();
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
<?php
|
||||
|
||||
use yii\grid\GridView;
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\DetailView;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $dataProviderF \yii\data\ActiveDataProvider
|
||||
/* @var $model backend\modules\company\models\Company */
|
||||
|
||||
$this->title = $model->name;
|
||||
@ -12,6 +14,7 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="company-view">
|
||||
<p>
|
||||
<?= Html::a('Список', ['index'], ['class' => 'btn btn-primary']) ?>
|
||||
<?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
|
||||
<?= Html::a('Delete', ['delete', 'id' => $model->id], [
|
||||
'class' => 'btn btn-danger',
|
||||
@ -34,4 +37,17 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
],
|
||||
]) ?>
|
||||
|
||||
<h2>Дополнительные сведения</h2>
|
||||
<?= GridView::widget([
|
||||
'dataProvider' => $dataProviderF,
|
||||
'layout' => "{items}",
|
||||
'columns' => [
|
||||
'field.name:text:Поле',
|
||||
[
|
||||
'attribute' => 'value',
|
||||
'label' => 'Значение'
|
||||
],
|
||||
],
|
||||
]); ?>
|
||||
|
||||
</div>
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace backend\modules\settings\models;
|
||||
|
||||
use common\classes\Debug;
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
@ -62,7 +63,7 @@ class AdditionalFieldsSearch extends AdditionalFields
|
||||
]);
|
||||
|
||||
$query->andFilterWhere(['like', 'name', $this->name]);
|
||||
|
||||
// Debug::dd($query->createCommand()->rawSql);
|
||||
return $dataProvider;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @var $model \yii\db\ActiveRecord
|
||||
*/
|
||||
|
||||
echo \common\models\UseField::getStatusesTextById($model->use);
|
@ -1,7 +1,9 @@
|
||||
<?php
|
||||
|
||||
use yii\data\ActiveDataProvider;
|
||||
use yii\helpers\Html;
|
||||
use yii\grid\GridView;
|
||||
use yii\widgets\ListView;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $searchModel backend\modules\card\models\AdditionalFieldsSearch */
|
||||
@ -23,10 +25,23 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
'filterModel' => $searchModel,
|
||||
'columns' => [
|
||||
['class' => 'yii\grid\SerialColumn'],
|
||||
|
||||
'id',
|
||||
'name',
|
||||
[
|
||||
'label' => 'Доп. информация',
|
||||
'format' => 'raw',
|
||||
'value' => function ($model) {
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => $model->getUseFields(),
|
||||
]);
|
||||
return ListView::widget([
|
||||
'dataProvider' => $dataProvider,
|
||||
'itemView' => '_additional',
|
||||
'layout' => "{items}",
|
||||
|
||||
]);
|
||||
},
|
||||
'headerOptions' => ['width' => '300'],
|
||||
],
|
||||
['class' => 'yii\grid\ActionColumn'],
|
||||
],
|
||||
]); ?>
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use common\classes\Debug;
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
@ -53,7 +54,12 @@ class AdditionalFields extends \yii\db\ActiveRecord
|
||||
*/
|
||||
public function getFieldsValues()
|
||||
{
|
||||
return $this->hasMany(FieldsValue::className(), ['field_id' => 'id']);
|
||||
return $this->hasMany(FieldsValueNew::className(), ['field_id' => 'id']);
|
||||
}
|
||||
|
||||
public function getObjectValue()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,8 +63,4 @@ class FieldsValueNew extends \yii\db\ActiveRecord
|
||||
return $this->hasOne(AdditionalFields::class, ['id' => 'field_id']);
|
||||
}
|
||||
|
||||
// public function getadditional_fields()
|
||||
// {
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
@ -81,4 +81,13 @@ class UseField extends \yii\db\ActiveRecord
|
||||
{
|
||||
return $this->statuses[$this->status_id];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string status text label
|
||||
*/
|
||||
public static function getStatusesTextById($id)
|
||||
{
|
||||
$model = new self();
|
||||
return $model->statuses[$id];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user