add history of changes to all entitys
This commit is contained in:
parent
812bb2b23a
commit
6aff5567c4
@ -73,9 +73,17 @@ class BalanceController extends Controller
|
||||
],
|
||||
]);
|
||||
|
||||
$changeDataProvider = new ActiveDataProvider([
|
||||
'query' => \common\models\ChangeHistory::find()->where(['type_id' => $this->findModel($id)->id]),
|
||||
'pagination' => [
|
||||
'pageSize' => 200,
|
||||
]
|
||||
]);
|
||||
|
||||
return $this->render('view',[
|
||||
'model' => $this->findModel($id),
|
||||
'dataProviderF' => $dataProviderF
|
||||
'dataProviderF' => $dataProviderF,
|
||||
'changeDataProvider' => $changeDataProvider,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -20,5 +20,12 @@ use yii\helpers\ArrayHelper;
|
||||
*/
|
||||
class Balance extends \common\models\Balance
|
||||
{
|
||||
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'log' => [
|
||||
'class' => \common\behaviors\LogBehavior::class,
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
@ -54,4 +54,16 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
],
|
||||
]); ?>
|
||||
|
||||
<h2>История изменений</h2>
|
||||
|
||||
<?= GridView::widget([
|
||||
'dataProvider' => $changeDataProvider,
|
||||
'columns' => [
|
||||
'label',
|
||||
'old_value',
|
||||
'new_value',
|
||||
'created_at',
|
||||
],
|
||||
]); ?>
|
||||
|
||||
</div>
|
||||
|
@ -38,6 +38,9 @@ class CompanyController extends Controller
|
||||
],
|
||||
],
|
||||
],
|
||||
'log' => [
|
||||
'class' => \common\behaviors\LogBehavior::class,
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
@ -72,9 +75,18 @@ class CompanyController extends Controller
|
||||
'pageSize' => 200,
|
||||
],
|
||||
]);
|
||||
|
||||
$changeDataProvider = new ActiveDataProvider([
|
||||
'query' => \common\models\ChangeHistory::find()->where(['type_id' => $this->findModel($id)->id]),
|
||||
'pagination' => [
|
||||
'pageSize' => 200,
|
||||
]
|
||||
]);
|
||||
|
||||
return $this->render('view', [
|
||||
'model' => $this->findModel($id),
|
||||
'dataProviderF' => $dataProviderF
|
||||
'dataProviderF' => $dataProviderF,
|
||||
'changeDataProvider' => $changeDataProvider,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -43,6 +43,15 @@ class Company extends \common\models\Company
|
||||
}
|
||||
}
|
||||
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'log' => [
|
||||
'class' => \common\behaviors\LogBehavior::class,
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function afterSave($insert, $changedAttributes)
|
||||
{
|
||||
$post = \Yii::$app->request->post('Company');
|
||||
|
@ -50,4 +50,16 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
],
|
||||
]); ?>
|
||||
|
||||
<h2>История изменений</h2>
|
||||
|
||||
<?= GridView::widget([
|
||||
'dataProvider' => $changeDataProvider,
|
||||
'columns' => [
|
||||
'label',
|
||||
'old_value',
|
||||
'new_value',
|
||||
'created_at',
|
||||
],
|
||||
]); ?>
|
||||
|
||||
</div>
|
||||
|
@ -6,6 +6,7 @@ use backend\modules\holiday\models\Holiday;
|
||||
use backend\modules\holiday\models\HolidaySearch;
|
||||
use common\classes\Debug;
|
||||
use Yii;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use yii\filters\AccessControl;
|
||||
use yii\filters\VerbFilter;
|
||||
use yii\web\Controller;
|
||||
@ -52,8 +53,16 @@ class HolidayController extends Controller
|
||||
{
|
||||
$model = $this->findModel($id);
|
||||
|
||||
$changeDataProvider = new ActiveDataProvider([
|
||||
'query' => \common\models\ChangeHistory::find()->where(['type_id' => $this->findModel($id)->id]),
|
||||
'pagination' => [
|
||||
'pageSize' => 200,
|
||||
]
|
||||
]);
|
||||
|
||||
return $this->render('view', [
|
||||
'model' => $model,
|
||||
'changeDataProvider' => $changeDataProvider,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -4,5 +4,12 @@ namespace backend\modules\holiday\models;
|
||||
|
||||
class Holiday extends \common\models\Holiday
|
||||
{
|
||||
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'log' => [
|
||||
'class' => \common\behaviors\LogBehavior::class,
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@ $this->title = 'Отпуск №' . $model->id;
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Список отпусков', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="balance-view">
|
||||
<div class="balance-view">
|
||||
<p>
|
||||
<?= Html::a('Список', ['index'], ['class' => 'btn btn-primary']) ?>
|
||||
<?= Html::a('Редактировать', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
|
||||
@ -20,17 +20,28 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
]) ?>
|
||||
</p>
|
||||
|
||||
<?= DetailView::widget([
|
||||
'model' => $model,
|
||||
'attributes' => [
|
||||
[
|
||||
'label' => 'ФИО',
|
||||
'value' => function($model)
|
||||
{
|
||||
return $model->users->fio;
|
||||
},
|
||||
<?= DetailView::widget([
|
||||
'model' => $model,
|
||||
'attributes' => [
|
||||
[
|
||||
'label' => 'ФИО',
|
||||
'value' => function ($model) {
|
||||
return $model->users->fio;
|
||||
},
|
||||
],
|
||||
'dt_start',
|
||||
'dt_end'
|
||||
],
|
||||
'dt_start',
|
||||
'dt_end'
|
||||
],
|
||||
]) ?>
|
||||
]) ?>
|
||||
<h2>История изменений</h2>
|
||||
|
||||
<?= \yii\grid\GridView::widget([
|
||||
'dataProvider' => $changeDataProvider,
|
||||
'columns' => [
|
||||
'label',
|
||||
'old_value',
|
||||
'new_value',
|
||||
'created_at',
|
||||
],
|
||||
]);
|
||||
?>
|
||||
|
@ -91,9 +91,17 @@ class NotesController extends Controller
|
||||
],
|
||||
]);
|
||||
|
||||
$changeDataProvider = new ActiveDataProvider([
|
||||
'query' => \common\models\ChangeHistory::find()->where(['type_id' => $this->findModel($id)->id]),
|
||||
'pagination' => [
|
||||
'pageSize' => 200,
|
||||
]
|
||||
]);
|
||||
|
||||
return $this->render('view', [
|
||||
'model' => Note::findOne($id),
|
||||
'additionalDataProvider' => $additionalDataProvider
|
||||
'additionalDataProvider' => $additionalDataProvider,
|
||||
'changeDataProvider' => $changeDataProvider,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,15 @@ class Note extends \common\models\Note
|
||||
}
|
||||
}
|
||||
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'log' => [
|
||||
'class' => \common\behaviors\LogBehavior::class,
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function afterSave($insert, $changedAttributes)
|
||||
{
|
||||
$post = \Yii::$app->request->post('Note');
|
||||
|
@ -52,4 +52,16 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
],
|
||||
]); ?>
|
||||
|
||||
<h2>История изменений</h2>
|
||||
|
||||
<?= GridView::widget([
|
||||
'dataProvider' => $changeDataProvider,
|
||||
'columns' => [
|
||||
'label',
|
||||
'old_value',
|
||||
'new_value',
|
||||
'created_at',
|
||||
],
|
||||
]); ?>
|
||||
|
||||
</div>
|
||||
|
@ -98,11 +98,19 @@ class ProjectController extends Controller
|
||||
],
|
||||
]);
|
||||
|
||||
$changeDataProvider = new ActiveDataProvider([
|
||||
'query' => \common\models\ChangeHistory::find()->where(['type_id' => $this->findModel($id)->id]),
|
||||
'pagination' => [
|
||||
'pageSize' => 200,
|
||||
]
|
||||
]);
|
||||
|
||||
return $this->render('view', [
|
||||
'model' => $model,
|
||||
'modelFildValue' => $dataProvider,
|
||||
'modelUser' => $dataProviderUser,
|
||||
'jobsProvider' => $jobsProvider,
|
||||
'changeDataProvider' => $changeDataProvider,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,15 @@ class Project extends \common\models\Project
|
||||
}
|
||||
}
|
||||
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'log' => [
|
||||
'class' => \common\behaviors\LogBehavior::class,
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function afterSave($insert, $changedAttributes)
|
||||
{
|
||||
$post = \Yii::$app->request->post('Project');
|
||||
|
@ -104,4 +104,16 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
],
|
||||
]); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<h2>История изменений</h2>
|
||||
|
||||
<?= GridView::widget([
|
||||
'dataProvider' => $changeDataProvider,
|
||||
'columns' => [
|
||||
'label',
|
||||
'old_value',
|
||||
'new_value',
|
||||
'created_at',
|
||||
],
|
||||
]); ?>
|
||||
</div>
|
||||
|
@ -25,4 +25,14 @@ class ChangeHistory extends \yii\db\ActiveRecord
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function afterFind()
|
||||
{
|
||||
parent::afterFind(); // TODO: Change the autogenerated stub
|
||||
//milliseconds to date
|
||||
if ($this->field_name == 'dt_start' || $this->field_name == 'dt_end' || $this->field_name == 'dt_add') {
|
||||
$this->old_value = date('d-m-Y', $this->old_value);
|
||||
$this->new_value = date('d-m-Y', $this->new_value);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user