154 lines
4.8 KiB
PHP
Raw Normal View History

2020-02-05 12:08:01 +03:00
<?php
2021-09-07 15:24:24 +03:00
2020-02-05 12:08:01 +03:00
use yii\helpers\Html;
use yii\grid\GridView;
2021-09-07 15:24:24 +03:00
2020-02-05 12:08:01 +03:00
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\reports\models\ReportsSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
2021-09-07 15:24:24 +03:00
/* @var $user_id__fio */
2020-02-05 12:08:01 +03:00
$this->title = 'Отчеты';
$this->params['breadcrumbs'][] = $this->title;
2021-09-06 10:29:50 +03:00
define('TODAY', date('Y-m-d'));
define('WEEK_AGO', date('Y-m-d', time() - 3600 * 24 * 7));
function next_day($date, $number)
{
return date('Y-m-d', strtotime($date) + 3600 * 24 * $number);
}
2021-09-07 17:05:10 +03:00
2020-02-05 12:08:01 +03:00
?>
<div class="reports-index">
<p>
<?= Html::a('Добавить', ['create'], ['class' => 'btn btn-success']) ?>
<?= Html::a('Сгрупированный по пользователям вид', ['group'], ['class' => 'btn btn-success']) ?>
</p>
2021-09-06 10:29:50 +03:00
<p>
2021-09-07 15:24:24 +03:00
<?php
2021-09-07 17:05:10 +03:00
if (!$_GET) {
$url = '../..' . Yii::$app->request->url . '?ReportsSearch[created_at]=';
} else {
$url = '../..' . Yii::$app->request->url . '&ReportsSearch[created_at]=';
2021-09-07 15:24:24 +03:00
}
for ($date = TODAY;
$date != WEEK_AGO;
$date = next_day($date, -1)): ?>
2021-09-07 17:05:10 +03:00
<?= Html::a($date, ['index', 'ReportsSearch[created_at]' => $date], ['class' => 'btn btn-primary']) ?>
2021-09-07 15:24:24 +03:00
<?php endfor; ?></div>
2021-09-06 10:29:50 +03:00
<div class="row">
<div class="col-xs-6">
2021-09-07 17:05:10 +03:00
<?php $form = \yii\widgets\ActiveForm::begin() ?>
<?= $form->field($searchModel, 'today')->hiddenInput()->label(false) ?>
<?php \yii\widgets\ActiveForm::end() ?>
2021-09-06 10:29:50 +03:00
<form method="get" style="display: inline-flex;">
2021-09-07 17:05:10 +03:00
<?php if (isset($_GET['ReportsSearch'])): ?>
<input name="ReportsSearch[today]" type="hidden" value="<?= $searchModel->today ?>">
<input name="ReportsSearch[difficulties]" type="hidden" value="<?= $searchModel->difficulties ?>">
<input name="ReportsSearch[tomorrow]" type="hidden" value="<?= $searchModel->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 . '">';
}
?>
2021-09-07 15:24:24 +03:00
<?php endif;
?>
<?= Html::input('date', 'ReportsSearch[created_at]',
isset($_GET['ReportsSearch']['created_at']) ? $_GET['ReportsSearch']['created_at'] : date('Y-m-d'), [
'class' => 'form-control',
'style' => 'display:',
'id' => 'date'
]) ?>
2021-09-06 10:29:50 +03:00
2020-02-05 12:08:01 +03:00
2021-09-06 10:29:50 +03:00
<?= Html::button('Сортировка по дате', ['class' => 'btn btn-danger sort_by_date', 'type' => 'submit']) ?>
2021-09-07 17:05:10 +03:00
<?= Html::a('Все дни', ['index'], ['class' => 'btn btn-primary']) ?>
2021-09-06 10:29:50 +03:00
</form>
</div>
</div>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
2021-09-07 15:24:24 +03:00
[
'format' => 'raw',
'attribute' => 'created_at',
2021-09-07 17:05:10 +03:00
'filter' => Html::input('date', 'ReportsSearch[created_at]',
2021-09-07 15:24:24 +03:00
null, [
'class' => 'form-control',
'style' => 'display:',
'id' => 'date'
2021-09-07 17:05:10 +03:00
]),
2021-09-07 15:24:24 +03:00
'value' => 'created_at',
],
2021-09-07 17:05:10 +03:00
// [
// 'attribute' => 'today',
// 'format' => 'raw',
// 'value' => function ($model) {
//
// $text = '';
// if ($model->task) {
// $i = 1;
// foreach ($model->task as $task) {
// $text .= "<p>$i. ($task->hours_spent ч.) $task->task</p>";
// $i++;
// }
// }
// return $text;
// }
// ],
//'difficulties',
//'tomorrow',
2021-09-06 10:29:50 +03:00
[
'format' => 'raw',
2021-09-07 15:24:24 +03:00
'attribute' => 'user_card_id',
'filter' => kartik\select2\Select2::widget([
'model' => $searchModel,
'attribute' => 'user_card_id',
'data' => $user_id__fio,
'options' => ['multiple' => true, 'class' => 'form-control'],
'pluginOptions' => [
'multiple' => true,
],
]),
2021-09-06 10:29:50 +03:00
'value' => function ($data) {
2021-09-07 17:05:10 +03:00
return '<a href="' . Yii::getAlias('@web') . '/reports/reports/user?id=' . $data['user_card_id'] . '">' . \common\models\Reports::getFio($data) . '</a>';
2021-09-06 10:29:50 +03:00
},
2020-02-05 12:08:01 +03:00
],
2021-09-06 10:29:50 +03:00
['class' => 'yii\grid\ActionColumn'],
],
]);
$this->registerCssFile('../../css/site.css');
?>
2020-02-05 12:08:01 +03:00
</div>
2021-09-06 10:29:50 +03:00
<style>
.row * {
margin-right: 10px;
}
</style>