Merge remote-tracking branch 'origin/add_task' into add_task
This commit is contained in:
@ -75,6 +75,7 @@ class Reports extends \yii\db\ActiveRecord
|
||||
foreach ($this->task as $task) {
|
||||
$this->_task[$i]['task'] = $task->task;
|
||||
$this->_task[$i]['hours_spent'] = $task->hours_spent;
|
||||
$this->_task[$i]['minutes_spent'] = $task->minutes_spent;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
@ -102,6 +103,7 @@ class Reports extends \yii\db\ActiveRecord
|
||||
$taskModel->report_id = $this->id;
|
||||
$taskModel->task = $task['task'];
|
||||
$taskModel->hours_spent = (float)$task['hours_spent'];
|
||||
$taskModel->minutes_spent = (int) $task['minutes_spent'];
|
||||
$taskModel->status = 1;
|
||||
$taskModel->created_at = time();
|
||||
$taskModel->save();
|
||||
|
@ -12,12 +12,22 @@ use Yii;
|
||||
* @property string $task
|
||||
* @property int $created_at
|
||||
* @property int $status
|
||||
* @property int $minutes_spent
|
||||
* @property float $hours_spent
|
||||
*
|
||||
* @property Reports $report
|
||||
*/
|
||||
class ReportsTask extends \yii\db\ActiveRecord
|
||||
{
|
||||
const SCENARIO_WITHOUT_REPORT_ID = 'withoutReportID';
|
||||
|
||||
public function scenarios()
|
||||
{
|
||||
$scenarios = parent::scenarios();
|
||||
$scenarios[self::SCENARIO_WITHOUT_REPORT_ID] = self::attributes();
|
||||
return $scenarios;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@ -32,9 +42,10 @@ class ReportsTask extends \yii\db\ActiveRecord
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['report_id'], 'required'],
|
||||
[['report_id', 'created_at', 'status'], 'integer'],
|
||||
[['report_id'], 'required', 'on' => self::SCENARIO_DEFAULT],
|
||||
[['report_id', 'created_at', 'status', 'minutes_spent'], 'integer'],
|
||||
[['hours_spent'], 'number'],
|
||||
['minutes_spent', 'compare', 'compareValue' => 60, 'operator' => '<'],
|
||||
[['task'], 'string'],
|
||||
[['report_id'], 'exist', 'skipOnError' => true, 'targetClass' => Reports::className(), 'targetAttribute' => ['report_id' => 'id']],
|
||||
];
|
||||
|
@ -296,4 +296,5 @@ class UserCard extends \yii\db\ActiveRecord
|
||||
return $userCard['id'];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user