Merge pull request #40 from apuc/sum_and_calendar

Sum and calendar
This commit is contained in:
kavalar 2020-02-06 12:04:11 +03:00 committed by GitHub
commit 88212626a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 165 additions and 41 deletions

View File

@ -48,6 +48,11 @@ class ReportsSearch extends Reports
$dataProvider = new ActiveDataProvider([
'query' => $query,
'sort' => [
'defaultOrder' => [
'created_at' => SORT_DESC,
]
],
]);
$this->load($params);

View File

@ -3,9 +3,11 @@
use yii\grid\GridView;
/* @var $dataProvider yii\data\ActiveDataProvider */
/* @var $pages */
echo GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
['class' => 'yii\grid\SerialColumn'],

View File

@ -1,5 +1,7 @@
<?php
use kartik\date\DatePicker;
use kartik\datetime\DateTimePicker;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
@ -10,18 +12,27 @@ use yii\widgets\ActiveForm;
<div class="reports-form">
<?php $form = ActiveForm::begin(); ?>
<?php $form = ActiveForm::begin();
<?= $form->field($model, 'created_at')->input(
'date',
[
'placeholder' => 'Zadejte svůj Datum narození',
'language' => 'en',
"data-format" => "DD MMMM YYYY",
'class' => 'form-control report-date'
$now = time();
$day = idate('d', $now);
$month = idate('m', $now);
$year = idate('Y', $now);
$date = $year."-".$month."-".$day;
if(!$model->created_at)
$model->created_at = $date;
echo '<b>Дата заполнения отчета:</b>';
echo DatePicker::widget([
'model' => $model,
'attribute' => 'created_at',
'options' => [],
'pluginOptions' => [
'autoclose' => true,
'format' => 'yyyy-mm-dd'
]
) ?>
]).'<br>';
?>
<?= $form->field($model, 'today')->textarea(['maxlength' => true]) ?>

View File

@ -2,6 +2,7 @@
use backend\modules\reports\models\ReportsSearch;
use kartik\grid\GridView;
use yii\data\Pagination;
use yii\helpers\Html;
/* @var $this yii\web\View */
@ -38,6 +39,7 @@ $this->params['breadcrumbs'][] = $this->title;
$searchReports = new ReportsSearch();
$providerReports = $searchReports->search(Yii::$app->request->queryParams);
$providerReports->query->andWhere(['user_card.id_user' => $model->id_user]);
$providerReports->pagination->pageSize = 10;
return Yii::$app->controller->renderPartial('_expand-row-details', ['dataProvider' => $providerReports]);
},

View File

@ -5,9 +5,9 @@ use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\Reports */
$this->title = 'Редактировать отчет';
$this->title = 'Редактировать отчет ' . $model->created_at;
$this->params['breadcrumbs'][] = ['label' => 'Отчеты', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = ['label' => $model->created_at, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = 'Редактировать';
?>
<div class="reports-update">

View File

@ -6,7 +6,7 @@ use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model common\models\Reports */
$this->title = 'Отчет';
$this->title = $model->created_at;
$this->params['breadcrumbs'][] = ['label' => 'Отчеты', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
\yii\web\YiiAsset::register($this);

View File

@ -28,7 +28,8 @@
"mirocow/yii2-eav": "*",
"kartik-v/yii2-widget-fileinput": "^1.0",
"2amigos/yii2-file-upload-widget": "~1.0",
"kartik-v/yii2-grid": "dev-master"
"kartik-v/yii2-grid": "dev-master",
"kartik-v/yii2-widget-datetimepicker": "dev-master"
},
"require-dev": {
"yiisoft/yii2-debug": "~2.0.0",

63
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "27fb15c02f7c345930818f5f2b532cf8",
"content-hash": "fa1395e986b21ee60c85db006a32bcc9",
"packages": [
{
"name": "2amigos/yii2-file-upload-widget",
@ -257,7 +257,7 @@
"version": "v3.4.1",
"source": {
"type": "git",
"url": "git@github.com:twbs/bootstrap.git",
"url": "https://github.com/twbs/bootstrap.git",
"reference": "68b0d231a13201eb14acd3dc84e51543d16e5f7e"
},
"dist": {
@ -317,7 +317,7 @@
"version": "1.12.1",
"source": {
"type": "git",
"url": "https://github.com/components/jqueryui.git",
"url": "git@github.com:components/jqueryui.git",
"reference": "44ecf3794cc56b65954cc19737234a3119d036cc"
},
"dist": {
@ -1049,6 +1049,60 @@
],
"time": "2019-08-23T17:23:20+00:00"
},
{
"name": "kartik-v/yii2-widget-datetimepicker",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/kartik-v/yii2-widget-datetimepicker.git",
"reference": "c201f98d3b8e41dcce2c70678ae31008246fc430"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/kartik-v/yii2-widget-datetimepicker/zipball/c201f98d3b8e41dcce2c70678ae31008246fc430",
"reference": "c201f98d3b8e41dcce2c70678ae31008246fc430",
"shasum": ""
},
"require": {
"kartik-v/yii2-krajee-base": ">=2.0.0"
},
"type": "yii2-extension",
"extra": {
"branch-alias": {
"dev-master": "1.4.x-dev"
}
},
"autoload": {
"psr-4": {
"kartik\\datetime\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Kartik Visweswaran",
"email": "kartikv2@gmail.com",
"homepage": "http://www.krajee.com/"
}
],
"description": "Enhanced Yii2 wrapper for the bootstrap datetimepicker plugin (sub repo split from yii2-widgets)",
"homepage": "https://github.com/kartik-v/yii2-widget-datetimepicker",
"keywords": [
"datetime",
"extension",
"form",
"jquery",
"picker",
"plugin",
"select2",
"widget",
"yii2"
],
"time": "2019-12-16T09:37:15+00:00"
},
{
"name": "kartik-v/yii2-widget-fileinput",
"version": "v1.0.9",
@ -4945,7 +4999,8 @@
"kartik-v/yii2-widget-select2": 20,
"kavalar/hhapi": 20,
"kartik-v/yii2-widget-datepicker": 20,
"kartik-v/yii2-grid": 20
"kartik-v/yii2-grid": 20,
"kartik-v/yii2-widget-datetimepicker": 20
},
"prefer-stable": false,
"prefer-lowest": false,

View File

@ -4,8 +4,8 @@ namespace frontend\modules\access\controllers;
use Yii;
use common\models\Accesses;
use frontend\modules\access\models\AccessSearch;
use yii\data\ActiveDataProvider;
use yii\filters\AccessControl;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
@ -27,6 +27,15 @@ class AccessController extends Controller
'delete' => ['POST'],
],
],
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['@'],
],
],
],
];
}

View File

@ -26,7 +26,7 @@ class UserCardController extends Controller
return [
'access' => [
'class' => AccessControl::className(),
'only' => ['index', 'update'],
//'only' => ['index', 'update'],
'rules' => [
[
'allow' => true,

View File

@ -2,12 +2,10 @@
namespace frontend\modules\reports\controllers;
use common\classes\Debug;
use common\models\Accesses;
use Yii;
use common\models\Reports;
use frontend\modules\reports\models\ReportsSearch;
use yii\data\ActiveDataProvider;
use yii\filters\AccessControl;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
@ -29,6 +27,15 @@ class ReportsController extends Controller
'delete' => ['POST'],
],
],
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['@'],
],
],
],
];
}

View File

@ -46,6 +46,11 @@ class ReportsSearch extends Reports
$dataProvider = new ActiveDataProvider([
'query' => $query,
'sort' => [
'defaultOrder' => [
'created_at' => SORT_DESC,
]
],
]);
$this->load($params);

View File

@ -1,5 +1,6 @@
<?php
use kartik\date\DatePicker;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
@ -12,22 +13,32 @@ use yii\widgets\ActiveForm;
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'created_at')->input(
'date',
[
'placeholder' => 'Zadejte svůj Datum narození',
'language' => 'en',
"data-format" => "DD MMMM YYYY",
'class' => 'form-control report-date'
<?php
$now = time();
$day = idate('d', $now);
$month = idate('m', $now);
$year = idate('Y', $now);
$date = $year."-".$month."-".$day;
if(!$model->created_at)
$model->created_at = $date;
echo '<b>Дата заполнения отчета:</b>';
echo DatePicker::widget([
'model' => $model,
'attribute' => 'created_at',
'options' => [],
'pluginOptions' => [
'autoclose' => true,
'format' => 'yyyy-mm-dd'
]
) ?>
]).'<br>';
?>
<?= $form->field($model, 'today')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'today')->textarea(['maxlength' => true]) ?>
<?= $form->field($model, 'difficulties')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'difficulties')->textarea(['maxlength' => true]) ?>
<?= $form->field($model, 'tomorrow')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'tomorrow')->textarea(['maxlength' => true]) ?>
<div class="form-group">
<?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>

View File

@ -24,13 +24,25 @@ $this->params['breadcrumbs'][] = $this->title;
'columns' => [
['class' => 'yii\grid\SerialColumn'],
// 'id',
'created_at',
'today',
'difficulties',
'tomorrow',
// 'user_card_id',
//'status',
[
'format' => 'raw',
'attribute' => 'Что было сделано сегодня?',
'filter' => Html::activeTextInput($searchModel, 'today', ['class' => 'form-control']),
'value' => function ($data) { return '<div class="custom-text">'.$data->today.'</div>'; },
],
[
'format' => 'raw',
'attribute' => 'Какие сложности возникли?',
'filter' => Html::activeTextInput($searchModel, 'difficulties', ['class' => 'form-control']),
'value' => function ($data) { return '<div class="custom-text">'.$data->difficulties.'</div>'; },
],
[
'format' => 'raw',
'attribute' => 'Что планируется сделать завтра?',
'filter' => Html::activeTextInput($searchModel, 'tomorrow', ['class' => 'form-control']),
'value' => function ($data) { return '<div class="custom-text">'.$data->tomorrow.'</div>'; },
],
['class' => 'yii\grid\ActionColumn'],
],

View File

@ -7,7 +7,7 @@ use yii\helpers\Html;
$this->title = 'Редактировать отчет';
$this->params['breadcrumbs'][] = ['label' => 'Отчеты', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = ['label' => $model->created_at, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = 'Редактировать';
?>
<div class="reports-update">

View File

@ -6,7 +6,7 @@ use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model common\models\Reports */
$this->title = $model->id;
$this->title = $model->created_at;
$this->params['breadcrumbs'][] = ['label' => 'Отчеты', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
\yii\web\YiiAsset::register($this);

View File

@ -125,4 +125,8 @@ a.desc:after {
.report-date {
width: 155px;
}
.custom-text {
white-space: normal;
}