diff --git a/backend/modules/company/controllers/CompanyController.php b/backend/modules/company/controllers/CompanyController.php index 3235f73..2ee9ff7 100755 --- a/backend/modules/company/controllers/CompanyController.php +++ b/backend/modules/company/controllers/CompanyController.php @@ -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 ]); } diff --git a/backend/modules/company/models/Company.php b/backend/modules/company/models/Company.php index b023103..fe44a2a 100755 --- a/backend/modules/company/models/Company.php +++ b/backend/modules/company/models/Company.php @@ -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(); } diff --git a/backend/modules/company/views/company/view.php b/backend/modules/company/views/company/view.php index 942c8d0..4ddd155 100755 --- a/backend/modules/company/views/company/view.php +++ b/backend/modules/company/views/company/view.php @@ -1,9 +1,11 @@ title = $model->name; @@ -12,6 +14,7 @@ $this->params['breadcrumbs'][] = $this->title; ?>
+ = 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; ], ]) ?> +