Дебаги
This commit is contained in:
parent
6377b84396
commit
1883039c80
@ -79,7 +79,7 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
'data' => \common\models\UserCard::getNameSkills(),
|
'data' => \common\models\UserCard::getNameSkills(),
|
||||||
'options' => ['multiple' => true, 'placeholder' => 'Выбрать параметр', 'class' => 'form-control'],
|
'options' => ['multiple' => true, 'placeholder' => 'Выбрать параметр', 'class' => 'form-control'],
|
||||||
'pluginOptions' => [
|
'pluginOptions' => [
|
||||||
'allowClear' => true
|
'allowClear' => true,
|
||||||
],
|
],
|
||||||
]),
|
]),
|
||||||
],
|
],
|
||||||
|
@ -48,11 +48,19 @@ class ReportsController extends Controller
|
|||||||
public function actionIndex()
|
public function actionIndex()
|
||||||
{
|
{
|
||||||
$searchModel = new ReportsSearch();
|
$searchModel = new ReportsSearch();
|
||||||
|
$reports = $searchModel->search([])->getModels();
|
||||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||||
|
|
||||||
|
$user_id__fio = [];
|
||||||
|
for ($i=0; $i<count($reports);$i++){
|
||||||
|
$user_id__fio[$reports[$i]->user_card_id] = \common\models\Reports::getFio($reports[$i]);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->render('index', [
|
return $this->render('index', [
|
||||||
'searchModel' => $searchModel,
|
'searchModel' => $searchModel,
|
||||||
'dataProvider' => $dataProvider,
|
'dataProvider' => $dataProvider,
|
||||||
|
'user_id__fio' => $user_id__fio,
|
||||||
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,9 +60,6 @@ class ReportsSearch extends Reports
|
|||||||
$this->load($params);
|
$this->load($params);
|
||||||
|
|
||||||
|
|
||||||
if (isset($params['date']) and preg_match("/^\d{4}\-(0[1-9]|1[012])\-(0[1-9]|[12][0-9]|3[01])$/", $params['date']) and !isset($params['id'])) {
|
|
||||||
$this->created_at = $params['date'];
|
|
||||||
}
|
|
||||||
if (isset($params['year'])) {
|
if (isset($params['year'])) {
|
||||||
$query->andFilterWhere(['=', 'YEAR(reports.created_at)', $params['year']]);
|
$query->andFilterWhere(['=', 'YEAR(reports.created_at)', $params['year']]);
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
use yii\helpers\Html;
|
use yii\helpers\Html;
|
||||||
use yii\grid\GridView;
|
use yii\grid\GridView;
|
||||||
|
|
||||||
|
|
||||||
/* @var $this yii\web\View */
|
/* @var $this yii\web\View */
|
||||||
/* @var $searchModel backend\modules\reports\models\ReportsSearch */
|
/* @var $searchModel backend\modules\reports\models\ReportsSearch */
|
||||||
/* @var $dataProvider yii\data\ActiveDataProvider */
|
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||||
|
/* @var $user_id__fio */
|
||||||
|
|
||||||
$this->title = 'Отчеты';
|
$this->title = 'Отчеты';
|
||||||
$this->params['breadcrumbs'][] = $this->title;
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
@ -16,7 +19,6 @@ function next_day($date, $number)
|
|||||||
{
|
{
|
||||||
return date('Y-m-d', strtotime($date) + 3600 * 24 * $number);
|
return date('Y-m-d', strtotime($date) + 3600 * 24 * $number);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<div class="reports-index">
|
<div class="reports-index">
|
||||||
|
|
||||||
@ -25,21 +27,48 @@ function next_day($date, $number)
|
|||||||
<?= Html::a('Сгрупированный по пользователям вид', ['group'], ['class' => 'btn btn-success']) ?>
|
<?= Html::a('Сгрупированный по пользователям вид', ['group'], ['class' => 'btn btn-success']) ?>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<?php for ($date = TODAY; $date != WEEK_AGO; $date = next_day($date, -1)): ?>
|
<?php
|
||||||
<?= Html::a($date, ['reports/?date=' . $date], ['class' => 'btn btn-primary']) ?>
|
if (!$_GET){
|
||||||
|
$url = '../..'.Yii::$app->request->url .'?ReportsSearch[created_at]=';
|
||||||
|
} else{
|
||||||
|
$url = '../..'.Yii::$app->request->url .'&ReportsSearch[created_at]=';
|
||||||
|
}
|
||||||
|
|
||||||
|
for ($date = TODAY;
|
||||||
|
$date != WEEK_AGO;
|
||||||
|
$date = next_day($date, -1)): ?>
|
||||||
|
|
||||||
|
<?= Html::a($date, [$url. $date], ['class' => 'btn btn-primary']) ?>
|
||||||
<?php endfor; ?></div>
|
<?php endfor; ?></div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-6">
|
<div class="col-xs-6">
|
||||||
|
|
||||||
<form method="get" style="display: inline-flex;">
|
<form method="get" style="display: inline-flex;">
|
||||||
|
<?php if(isset($_GET['ReportsSearch'])):?>
|
||||||
|
<input name="ReportsSearch[today]" type="hidden" value="<?=($_GET['ReportsSearch']['today'])?>">
|
||||||
|
<input name="ReportsSearch[difficulties]" type="hidden" value="<?=($_GET['ReportsSearch']['difficulties'])?>">
|
||||||
|
<input name="ReportsSearch[tomorrow]" type="hidden" value="<?=($_GET['ReportsSearch']['tomorrow'])?>">
|
||||||
|
<input name="ReportsSearch[user_card_id]" type="hidden">
|
||||||
|
<?php if(isset($_GET['ReportsSearch']['user_card_id'])){
|
||||||
|
foreach ($_GET['ReportsSearch']['user_card_id'] as $res)
|
||||||
|
echo
|
||||||
|
'<input name="ReportsSearch[user_card_id][]" type="hidden" value="'.$res.'">';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<?php endif;
|
||||||
|
?>
|
||||||
|
|
||||||
<?= Html::input('date', 'date', isset($_GET['date']) ? $_GET['date'] : date('Y-m-d'), [
|
<?= Html::input('date', 'ReportsSearch[created_at]',
|
||||||
|
isset($_GET['ReportsSearch']['created_at']) ? $_GET['ReportsSearch']['created_at'] : date('Y-m-d'), [
|
||||||
'class' => 'form-control',
|
'class' => 'form-control',
|
||||||
'style' => 'display:',
|
'style' => 'display:',
|
||||||
'id' => 'date'
|
'id' => 'date'
|
||||||
|
|
||||||
]) ?>
|
]) ?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<?= Html::button('Сортировка по дате', ['class' => 'btn btn-danger sort_by_date', 'type' => 'submit']) ?>
|
<?= Html::button('Сортировка по дате', ['class' => 'btn btn-danger sort_by_date', 'type' => 'submit']) ?>
|
||||||
|
|
||||||
<?= Html::a('Все дни', ['index'], ['class' => 'btn btn-dark']) ?>
|
<?= Html::a('Все дни', ['index'], ['class' => 'btn btn-dark']) ?>
|
||||||
@ -49,12 +78,7 @@ function next_day($date, $number)
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<!-- <div class="row" style="margin: 10px 0px 0 5px">-->
|
|
||||||
</p>
|
</p>
|
||||||
<?php
|
|
||||||
//echo '<pre>';
|
|
||||||
//var_dump($dataProvider);
|
|
||||||
//echo '</pre>';?>
|
|
||||||
<?= GridView::widget([
|
<?= GridView::widget([
|
||||||
'dataProvider' => $dataProvider,
|
'dataProvider' => $dataProvider,
|
||||||
'filterModel' => $searchModel,
|
'filterModel' => $searchModel,
|
||||||
@ -62,7 +86,18 @@ function next_day($date, $number)
|
|||||||
'columns' => [
|
'columns' => [
|
||||||
['class' => 'yii\grid\SerialColumn'],
|
['class' => 'yii\grid\SerialColumn'],
|
||||||
|
|
||||||
'created_at',
|
[
|
||||||
|
'format' => 'raw',
|
||||||
|
'attribute' => 'created_at',
|
||||||
|
'filter' => Html::input('date', 'ReportsSearch[created_at]',
|
||||||
|
null, [
|
||||||
|
'class' => 'form-control',
|
||||||
|
'style' => 'display:',
|
||||||
|
'id' => 'date'
|
||||||
|
|
||||||
|
]) ,
|
||||||
|
'value' => 'created_at',
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'attribute' => 'today',
|
'attribute' => 'today',
|
||||||
'format' => 'raw',
|
'format' => 'raw',
|
||||||
@ -83,10 +118,19 @@ function next_day($date, $number)
|
|||||||
'tomorrow',
|
'tomorrow',
|
||||||
[
|
[
|
||||||
'format' => 'raw',
|
'format' => 'raw',
|
||||||
'attribute' => 'ФИО',
|
'attribute' => 'user_card_id',
|
||||||
'filter' => Html::activeTextInput($searchModel, 'fio', ['class' => 'form-control']),
|
'filter' => kartik\select2\Select2::widget([
|
||||||
|
'model' => $searchModel,
|
||||||
|
'attribute' => 'user_card_id',
|
||||||
|
'data' => $user_id__fio,
|
||||||
|
'options' => ['multiple' => true, 'class' => 'form-control'],
|
||||||
|
'pluginOptions' => [
|
||||||
|
|
||||||
|
'multiple' => true,
|
||||||
|
],
|
||||||
|
]),
|
||||||
'value' => function ($data) {
|
'value' => function ($data) {
|
||||||
return '<a href="./reports/user?id='.$data['user_card_id'].'">' . \common\models\Reports::getFio($data) . '</a>';
|
return '<a href="'.Yii::getAlias('@web').'/reports/reports/user?id=' . $data['user_card_id'] . '">' . \common\models\Reports::getFio($data) . '</a>';
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
@ -99,18 +143,9 @@ $this->registerCssFile('../../css/site.css');
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
|
||||||
// let date = document.querySelector('#date')
|
|
||||||
// date.onchange = function (){
|
|
||||||
// window.location.replace(`./?date=${date.value}`);
|
|
||||||
// }
|
|
||||||
</script>
|
|
||||||
<style>
|
<style>
|
||||||
.row * {
|
.row * {
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.row {
|
|
||||||
margin-left: 1px;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
@ -1,4 +1,3 @@
|
|||||||
alert(123);
|
|
||||||
|
|
||||||
$(function(){
|
$(function(){
|
||||||
$('#options').change(function(){
|
$('#options').change(function(){
|
||||||
|
Loading…
Reference in New Issue
Block a user