Наследование: extends AuditTrail
Пример #1
0
 /**
  * @inheritdoc
  */
 public function getDetail()
 {
     $searchModel = new AuditTrailSearch();
     $params = \Yii::$app->request->getQueryParams();
     $params['AuditTrailSearch']['entry_id'] = $params['id'];
     $dataProvider = $searchModel->search($params);
     return \Yii::$app->view->render('panels/trail/detail', ['panel' => $this, 'dataProvider' => $dataProvider, 'searchModel' => $searchModel]);
 }
Пример #2
0
<?php

use bedezign\yii2\audit\models\AuditTrailSearch;
use yii\db\BaseActiveRecord;
use yii\grid\GridView;
use yii\web\View;
use yii\widgets\Pjax;
/**
 * @var View $this
 * @var BaseActiveRecord $model
 * @var yii\bootstrap\ActiveForm $form
 * @var array $params
 */
$params = !empty($params) ? $params : Yii::$app->request->get();
$auditTrailSearch = new AuditTrailSearch();
$auditTrailDataProvider = $auditTrailSearch->search($params, $model->getAuditTrails());
$auditTrailDataProvider->pagination = ['pageSize' => 20, 'pageParam' => 'page-auditTrails'];
$auditTrailDataProvider->sort = ['defaultOrder' => ['id' => SORT_DESC]];
Pjax::begin(['id' => 'pjax-AuditTrails', 'enableReplaceState' => false, 'linkSelector' => '#pjax-AuditTrails ul.pagination a, th a']);
echo '<div class="table-responsive">' . GridView::widget(['layout' => '{summary}{pager}<br/>{items}{pager}', 'dataProvider' => $auditTrailDataProvider, 'filterModel' => $auditTrailSearch, 'columns' => [['attribute' => 'user_id'], ['attribute' => 'audit_id'], 'action', ['attribute' => 'model'], 'model_id', 'field', 'old_value:ntext', 'new_value:ntext', 'stamp']]) . '</div>';
?>

<?php 
// row grouping
ob_start();
?>
    <script>
        var gridview_id = "#pjax-AuditTrails .grid-view"; // specific gridview
        var columns = [1, 2]; // index column that will grouping, (user_id, audit_id)

        var column_data = [];
Пример #3
0
 /**
  * Lists all AuditTrail models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new AuditTrailSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->get());
     return $this->render('index', ['dataProvider' => $dataProvider, 'searchModel' => $searchModel]);
 }
Пример #4
0
 /**
  * History lists all Preferences models.
  * @return mixed
  */
 public function actionHistory()
 {
     $searchModel = new AuditTrailSearch();
     $searchFilter = ['AuditTrailSearch' => ['action' => 'DELETE', 'model' => 'common\\populac\\models\\Preferences']];
     $dataProvider = $searchModel->search(\yii\helpers\ArrayHelper::merge(Yii::$app->request->get(), $searchFilter));
     //$message = "<ol>恢复操作指引<li><删除内容>中输入内容筛选</li><li>点击复选框选中需要恢复的记录</li><li>点击<恢复记录>按钮</li></ol>";
     //Yii::$app->session->setFlash('info', $message);
     return $this->render('history', ['dataProvider' => $dataProvider, 'searchModel' => $searchModel]);
 }
Пример #5
0
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('audit', 'Trails');
$this->params['breadcrumbs'][] = ['label' => Yii::t('audit', 'Audit'), 'url' => ['default/index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="box box-primary">
    <div class="box-header" style="cursor: pointer;">
        <i class="fa fa-th-list"></i>
        <h3 class="box-title"><?php 
echo Html::encode($this->title);
?>
</h3>
    </div>
    <div class="box-body">
        <div class="audit-trail">


            <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\ActionColumn', 'template' => '{view}'], 'id', ['attribute' => 'entry_id', 'class' => 'yii\\grid\\DataColumn', 'value' => function ($data) {
    return $data->entry_id ? Html::a($data->entry_id, ['entry/view', 'id' => $data->entry_id]) : '';
}, 'format' => 'raw'], ['attribute' => 'user_id', 'label' => Yii::t('audit', 'User ID'), 'class' => 'yii\\grid\\DataColumn', 'value' => function ($data) {
    return Audit::getInstance()->getUserIdentifier($data->user_id);
}, 'format' => 'raw'], ['attribute' => 'action', 'filter' => AuditTrailSearch::actionFilter()], 'model', 'model_id', 'field', ['label' => Yii::t('audit', 'Diff'), 'value' => function ($model) {
    return $model->getDiffHtml();
}, 'format' => 'raw'], ['attribute' => 'created', 'options' => ['width' => '150px']]]]);
?>
        </div>
    </div>
</div>

Пример #6
0
<?php

/* @var $panel yii\debug\panels\LogPanel */
/* @var $searchModel yii\debug\models\search\Log */
/* @var $dataProvider yii\data\ArrayDataProvider */
use bedezign\yii2\audit\Audit;
use bedezign\yii2\audit\models\AuditTrailSearch;
use yii\helpers\Html;
use yii\grid\GridView;
echo Html::tag('h1', $panel->name);
echo GridView::widget(['dataProvider' => $dataProvider, 'id' => 'log-panel-detailed-grid', 'options' => ['class' => 'detail-grid-view table-responsive'], 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\ActionColumn', 'template' => '{view}', 'buttons' => ['view' => function ($url, $model) {
    return Html::a(Html::tag('span', '', ['class' => 'glyphicon glyphicon-eye-open']), ['trail/view', 'id' => $model->id]);
}], 'options' => ['width' => '30px']], ['attribute' => 'id', 'options' => ['width' => '80px']], ['attribute' => 'user_id', 'label' => Yii::t('audit', 'User ID'), 'class' => 'yii\\grid\\DataColumn', 'value' => function ($data) {
    return Audit::getInstance()->getUserIdentifier($data->user_id);
}, 'options' => ['width' => '150px'], 'format' => 'raw'], ['attribute' => 'action', 'filter' => AuditTrailSearch::actionFilter(), 'options' => ['width' => '150px']], ['attribute' => 'model', 'options' => ['width' => '150px']], ['attribute' => 'model_id', 'options' => ['width' => '80px']], ['attribute' => 'field', 'options' => ['width' => '100px']], ['label' => Yii::t('audit', 'Diff'), 'value' => function ($data) {
    return $data->getDiffHtml();
}, 'format' => 'raw']]]);
Пример #7
0
 /**
  * History lists all Event models.
  * @return mixed
  */
 public function actionHistory()
 {
     /*$auditdata = AuditTrailSearch::find()
       ->select(['entry_id', 'model_id', 'user_id', 'created', 'old_value'])
       ->where([
       'action' => 'DELETE',
       'model' => 'backend\models\Event',
       ])
       ->andFilterWhere(['>', 'old_value', "''"])
       ->orderBy(['model_id' => SORT_DESC])
       ->all();*/
     //        $historyData = \yii\helpers\ArrayHelper::map($auditdata, 'model_id', 'old_value');
     //        \yii\helpers\VarDumper::dump($historyData);
     $searchModel = new AuditTrailSearch();
     $searchFilter = ['AuditTrailSearch' => ['action' => 'DELETE', 'model' => 'backend\\models\\Event']];
     $dataProvider = $searchModel->search(\yii\helpers\ArrayHelper::merge(Yii::$app->request->get(), $searchFilter));
     //var_dump(Yii::$app->request->get());
     //\yii\helpers\VarDumper::dump($searchModel);
     $message = "<ol>恢复操作指引<li><删除内容>中输入内容筛选</li><li>点击复选框选中需要恢复的记录</li><li>点击<恢复记录>按钮</li></ol>";
     Yii::$app->session->setFlash('info', $message);
     return $this->render('history', ['dataProvider' => $dataProvider, 'searchModel' => $searchModel]);
 }
Пример #8
0
use yii\helpers\Html;
use yii\web\View;
use yii\widgets\Pjax;
/**
 * @var View $this
 * @var bool $filter
 * @var array $params
 * @var ActiveQuery $query
 * @var array $columns
 */
$params = isset($params) ? $params : Yii::$app->request->get();
$query = isset($query) ? $query : null;
$columns = isset($columns) ? $columns : [];
$filter = isset($filter) ? $filter : true;
$this->registerAssetBundle(AuditAsset::className());
$auditTrailSearch = new AuditTrailSearch();
$auditTrailDataProvider = $auditTrailSearch->search($params, $query);
$auditTrailDataProvider->pagination = ['pageSize' => 20, 'pageParam' => 'page-auditTrails'];
$auditTrailDataProvider->sort = ['defaultOrder' => ['id' => SORT_DESC]];
$_columns = [];
if (empty($columns) || in_array('user_id', $columns)) {
    $_columns[] = ['attribute' => 'user_id', 'value' => function ($data) {
        return Audit::getInstance()->getUserIdentifier($data->user_id);
    }, 'format' => 'raw'];
}
if (empty($columns) || in_array('entry_id', $columns)) {
    $_columns[] = ['attribute' => 'entry_id', 'value' => function ($model) {
        /** @var AuditTrail $model */
        if (Access::checkAccess()) {
            return Html::a($model->entry_id, ['/audit/entry/view', 'id' => $model->entry_id]);
        }
Пример #9
0
use bedezign\yii2\audit\Audit;
use yii\helpers\Html;
use yii\grid\GridView;
use bedezign\yii2\audit\models\AuditTrailSearch;
use bedezign\yii2\audit\models\AuditEntrySearch;
use yii\helpers\ArrayHelper;
/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('audit', 'Entradas');
$this->params['breadcrumbs'][] = ['label' => Yii::t('audit', 'Configuracion'), 'url' => ['/site/configuracion']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="audit-entry-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['attribute' => 'user_id', 'filter' => AuditEntrySearch::userFilter(), 'label' => 'Usuarios', 'class' => 'yii\\grid\\DataColumn', 'value' => function ($data) {
    return $data->obtener_nombre($data->user_id);
}, 'format' => 'raw'], 'ip', ['class' => 'yii\\grid\\DataColumn', 'attribute' => 'route', 'label' => 'Lugar De Entrada', 'filter' => AuditEntrySearch::routeFilter(), 'format' => 'html', 'value' => function ($data) {
    return HTML::tag('span', '', ['title' => \yii\helpers\Url::to([$data->route]), 'class' => 'glyphicon glyphicon-link']) . ' ' . $data->route;
}], ['attribute' => 'trails', 'label' => 'Accion BD', 'filter' => AuditTrailSearch::actionFilter(), 'value' => function ($data) {
    return $data->trails ? $data->trails[0]['action'] : '';
}, 'contentOptions' => ['class' => 'text-right']], ['attribute' => 'created', 'label' => 'Fecha', 'options' => ['width' => '150px']]]]);
?>
</div>