Start working on tasks feature

This commit is contained in:
Bernd Bestel
2018-09-22 22:01:32 +02:00
parent bcb359e317
commit 6fe0100927
13 changed files with 477 additions and 2 deletions

View File

@@ -87,6 +87,12 @@ class DemoDataGeneratorService extends BaseService
INSERT INTO batteries (name, description, used_in, charge_interval_days) VALUES ('{$localizationService->Localize('Battery')}3', '{$localizationService->Localize('Warranty ends')} 2022', '{$localizationService->Localize('Heat remote control')}', 60); --3
INSERT INTO batteries (name, description, used_in, charge_interval_days) VALUES ('{$localizationService->Localize('Battery')}4', '{$localizationService->Localize('Warranty ends')} 2028', '{$localizationService->Localize('Heat remote control')}', 60); --4
INSERT INTO task_categories (name) VALUES ('{$localizationService->Localize('Home')}'); --1
INSERT INTO task_categories (name) VALUES ('{$localizationService->Localize('Life')}'); --2
INSERT INTO task_categories (name) VALUES ('{$localizationService->Localize('Projects')}'); --3
INSERT INTO tasks (name, category_id, due) VALUES ('{$localizationService->Localize('Repair the garage door')}', 1, date(datetime('now', 'localtime'), '+14 day'));
INSERT INTO migrations (migration) VALUES (-1);
";

18
services/TasksService.php Normal file
View File

@@ -0,0 +1,18 @@
<?php
namespace Grocy\Services;
class TasksService extends BaseService
{
public function GetCurrent()
{
$sql = 'SELECT * from tasks_current';
return $this->DatabaseService->ExecuteDbQuery($sql)->fetchAll(\PDO::FETCH_OBJ);
}
private function TaskExists($taskId)
{
$taskRow = $this->Database->tasks()->where('id = :1', $taskId)->fetch();
return $taskRow !== null;
}
}