Merge branch 'add_minutes' of https://github.com/q6q9/guild into add_minutes

This commit is contained in:
andrey 2021-11-23 16:16:09 +03:00
commit 8e490ce518
11 changed files with 56 additions and 8 deletions

View File

@ -19,7 +19,7 @@ echo GridView::widget([
if ($model->task) { if ($model->task) {
$i = 1; $i = 1;
foreach ($model->task as $task) { foreach ($model->task as $task) {
$text .= "<p>$i. ($task->hours_spent ч.) $task->task</p>"; $text .= "<p>$i. ($task->hours_spent ч., $task->minutes_spent мин.) $task->task</p>";
$i++; $i++;
} }
} }

View File

@ -20,7 +20,7 @@ echo GridView::widget([
if ($model->task) { if ($model->task) {
$i = 1; $i = 1;
foreach ($model->task as $task) { foreach ($model->task as $task) {
$text .= "<p>$i. ($task->hours_spent ч.) $task->task</p>"; $text .= "<p>$i. ($task->hours_spent ч., $task->minutes_spent мин.) $task->task</p>";
$i++; $i++;
} }
} }

View File

@ -10,6 +10,8 @@ use yii\widgets\ActiveForm;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model common\models\Reports */ /* @var $model common\models\Reports */
/* @var $form yii\widgets\ActiveForm */ /* @var $form yii\widgets\ActiveForm */
$this->registerCss('.list-cell__task{width:73%}')
?> ?>
<div class="reports-form"> <div class="reports-form">
@ -52,6 +54,13 @@ use yii\widgets\ActiveForm;
'style' => 'width:100px' 'style' => 'width:100px'
], ],
], ],
[
'name' => 'minutes_spent',
'title' => 'Кол-во минут',
'options' => [
'type' => 'number',
],
],
], ],
])->label('Какие задачаи были выполнены:'); ?> ])->label('Какие задачаи были выполнены:'); ?>

View File

@ -37,7 +37,7 @@ $this->params['breadcrumbs'][] = $this->title;
if ($model->task) { if ($model->task) {
$i = 1; $i = 1;
foreach ($model->task as $task) { foreach ($model->task as $task) {
$text .= "<p>$i. ($task->hours_spent ч.) $task->task</p>"; $text .= "<p>$i. ($task->hours_spent ч., $task->minutes_spent мин.) $task->task</p>";
$i++; $i++;
} }
} }

View File

@ -68,7 +68,7 @@ class DateHelper {
static dateToString(date) { static dateToString(date) {
let year = date.getFullYear() let year = date.getFullYear()
let day = this.intToDate(date.getDate()) let day = this.intToDate(date.getDate())
let month = this.intToDate(this.isDecember(date) ? 0 : date.getMonth() + 1) let month = this.intToDate(date.getMonth() + 1)
return year + '-' + month + '-' + day return year + '-' + month + '-' + day
} }

View File

@ -102,6 +102,7 @@ class Reports extends \yii\db\ActiveRecord
$taskModel->report_id = $this->id; $taskModel->report_id = $this->id;
$taskModel->task = $task['task']; $taskModel->task = $task['task'];
$taskModel->hours_spent = (float)$task['hours_spent']; $taskModel->hours_spent = (float)$task['hours_spent'];
$taskModel->minutes_spent = (int) $task['minutes_spent'];
$taskModel->status = 1; $taskModel->status = 1;
$taskModel->created_at = time(); $taskModel->created_at = time();
$taskModel->save(); $taskModel->save();

View File

@ -12,6 +12,7 @@ use Yii;
* @property string $task * @property string $task
* @property int $created_at * @property int $created_at
* @property int $status * @property int $status
* @property int $minutes_spent
* @property float $hours_spent * @property float $hours_spent
* *
* @property Reports $report * @property Reports $report
@ -33,8 +34,9 @@ class ReportsTask extends \yii\db\ActiveRecord
{ {
return [ return [
[['report_id'], 'required'], [['report_id'], 'required'],
[['report_id', 'created_at', 'status'], 'integer'], [['report_id', 'created_at', 'status', 'minutes_spent'], 'integer'],
[['hours_spent'], 'number'], [['hours_spent'], 'number'],
['minutes_spent', 'compare', 'compareValue' => 60, 'operator' => '<'],
[['task'], 'string'], [['task'], 'string'],
[['report_id'], 'exist', 'skipOnError' => true, 'targetClass' => Reports::className(), 'targetAttribute' => ['report_id' => 'id']], [['report_id'], 'exist', 'skipOnError' => true, 'targetClass' => Reports::className(), 'targetAttribute' => ['report_id' => 'id']],
]; ];

View File

@ -0,0 +1,25 @@
<?php
use yii\db\Migration;
/**
* Handles adding columns to table `{{%reports_task}}`.
*/
class m211122_144548_add_column_to_reports_task_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->addColumn('reports_task', 'minutes_spent', $this->integer()->defaultValue(0)->notNull());
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropColumn('reports_task', 'minutes_spent' );
}
}

View File

@ -8,6 +8,8 @@ use yii\widgets\ActiveForm;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model common\models\Reports */ /* @var $model common\models\Reports */
/* @var $form yii\widgets\ActiveForm */ /* @var $form yii\widgets\ActiveForm */
$this->registerCss('.list-cell__task{width:73%}')
?> ?>
<div class="reports-form"> <div class="reports-form">
@ -48,7 +50,16 @@ use yii\widgets\ActiveForm;
'title' => 'Кол-во часов', 'title' => 'Кол-во часов',
'options' => [ 'options' => [
'type' => 'number', 'type' => 'number',
'style' => 'width:100px' 'min' => '0'
],
],
[
'name' => 'minutes_spent',
'title' => 'Кол-во минут',
'options' => [
'type' => 'number',
'min' => '0',
'max' => '59'
], ],
], ],
], ],

View File

@ -34,7 +34,7 @@ $this->params['breadcrumbs'][] = $this->title;
if ($model->task) { if ($model->task) {
$i = 1; $i = 1;
foreach ($model->task as $task) { foreach ($model->task as $task) {
$text .= "<p>$i. ($task->hours_spent ч.) $task->task</p>"; $text .= "<p>$i. ($task->hours_spent ч., $task->minutes_spent мин.) $task->task</p>";
$i++; $i++;
} }
} }

View File

@ -39,7 +39,7 @@ $this->params['breadcrumbs'][] = $this->title;
if ($model->task) { if ($model->task) {
$i = 1; $i = 1;
foreach ($model->task as $task) { foreach ($model->task as $task) {
$text .= "<p>$i. ($task->hours_spent ч.) $task->task</p>"; $text .= "<p>$i. ($task->hours_spent ч., $task->minutes_spent мин.) $task->task</p>";
$i++; $i++;
} }
} }