source: trunk/Modules/Task/Task.php

Last change on this file was 914, checked in by chronos, 3 years ago
  • Added: Made IS dashboard numbers as links with filters.
File size: 5.8 KB
Line 
1<?php
2
3class ModuleTask extends Module
4{
5 function __construct(System $System)
6 {
7 parent::__construct($System);
8 $this->Name = 'Task';
9 $this->Version = '1.0';
10 $this->Creator = 'Chronos';
11 $this->License = 'GNU/GPLv3';
12 $this->Description = 'Work and task management';
13 $this->Dependencies = array(ModuleUser::GetName());
14 $this->Models = array(TaskGroup::GetClassName(), Task::GetClassName(), Work::GetClassName());
15 }
16
17 function DoStart(): void
18 {
19 $this->System->FormManager->RegisterClass('Task', array(
20 'Title' => 'Úkoly',
21 'Table' => 'Task',
22 'DefaultSortColumn' => 'TimeCreate',
23 'DefaultSortOrder' => 1,
24 'Items' => array(
25 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => '', 'Required' => true),
26 'TimeCreate' => array('Type' => 'Date', 'Caption' => 'Datum zadání', 'Default' => '', 'Required' => true),
27 'TimeDue' => array('Type' => 'Date', 'Caption' => 'Termín', 'Default' => '', 'Null' => true),
28 'TimeClose' => array('Type' => 'Date', 'Caption' => 'Datum uzavření', 'Default' => '', 'Null' => true),
29 'Priority' => array('Type' => 'TPriority', 'Caption' => 'Důležitost', 'Default' => 1),
30 'Public' => array('Type' => 'Boolean', 'Caption' => 'Veřejné', 'Default' => '0'),
31 'Progress' => array('Type' => 'Integer', 'Caption' => 'Průběh', 'Default' => '0', 'Suffix' => '%'),
32 'Group' => array('Type' => 'TTaskGroup', 'Caption' => 'Kategorie', 'Default' => '', 'Null' => true),
33 'Description' => array('Type' => 'Text', 'Caption' => 'Popis', 'Default' => '', 'NotInList' => true),
34 'Conclusion' => array('Type' => 'Text', 'Caption' => 'Vyhodnocení', 'Default' => '', 'NotInList' => true),
35 'AssignedTo' => array('Type' => 'TUser', 'Caption' => 'Přiřazeno', 'Default' => '', 'Null' => true),
36 'Work' => array('Type' => 'TWorkListTask', 'Caption' => 'Práce', 'Default' => ''),
37 ),
38 ));
39 $this->System->FormManager->RegisterClass('TaskGroup', array(
40 'Title' => 'Kategorie úkolu',
41 'Table' => 'TaskGroup',
42 'DefaultSortColumn' => 'Name',
43 'Items' => array(
44 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
45 'Description' => array('Type' => 'Text', 'Caption' => 'Popis', 'Default' => ''),
46 'Parent' => array('Type' => 'TTaskGroup', 'Caption' => 'Kategorie', 'Default' => '', 'Null' => true),
47 'Tasks' => array('Type' => 'TTaskList', 'Caption' => 'Úkoly', 'Default' => ''),
48 ),
49 ));
50 $this->System->FormManager->RegisterClass('Work', array(
51 'Title' => 'Práce',
52 'Table' => 'Work',
53 'DefaultSortColumn' => 'TimeStart',
54 'Items' => array(
55 'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => ''),
56 'Description' => array('Type' => 'Text', 'Caption' => 'Popis', 'Default' => ''),
57 'TimeStart' => array('Type' => 'DateTime', 'Caption' => 'Čas začátku', 'Default' => ''),
58 'Duration' => array('Type' => 'Float', 'Caption' => 'Trvání', 'Default' => '1', 'Suffix' => 'hodin'),
59 'User' => array('Type' => 'TUser', 'Caption' => 'Uživatel', 'Default' => '1', 'Null' => true),
60 'Task' => array('Type' => 'TTask', 'Caption' => 'Úkol', 'Default' => '', 'Null' => true),
61 ),
62 ));
63 $this->System->FormManager->RegisterFormType('TTask', array(
64 'Type' => 'Reference',
65 'Table' => 'Task',
66 'Id' => 'Id',
67 'Name' => 'Name',
68 'Filter' => '1',
69 ));
70 $this->System->FormManager->RegisterFormType('TWorkListTask', array(
71 'Type' => 'ManyToOne',
72 'Table' => 'Work',
73 'Id' => 'Id',
74 'Ref' => 'Task',
75 'Filter' => '1',
76 ));
77 $this->System->FormManager->RegisterFormType('TTaskList', array(
78 'Type' => 'ManyToOne',
79 'Table' => 'Task',
80 'Id' => 'Id',
81 'Ref' => 'Group',
82 'Filter' => '1',
83 ));
84 $this->System->FormManager->RegisterFormType('TTaskGroup', array(
85 'Type' => 'Reference',
86 'Table' => 'TaskGroup',
87 'Id' => 'Id',
88 'Name' => 'Name',
89 'Filter' => '1',
90 ));
91
92 ModuleIS::Cast($this->System->GetModule('IS'))->RegisterDashboardItem('Task',
93 array($this, 'ShowDashboardItem'));
94 }
95
96 function ShowDashboardItem(): string
97 {
98 $DbResult = $this->Database->select('Task', 'COUNT(*)', '`Progress` < 100');
99 $DbRow = $DbResult->fetch_row();
100 $Output = 'Nedokončených úkolů: <a href="'.$this->System->Link('/is/?a=list&amp;t=Task&amp;filter=1&amp;FilterProgress=100&amp;FilterOpProgress=less').'">'.$DbRow['0'].'</a><br/>';
101 return $Output;
102 }
103}
104
105class Task extends Model
106{
107 static function GetModelDesc(): ModelDesc
108 {
109 $Desc = new ModelDesc(self::GetClassName());
110 $Desc->AddString('Name');
111 $Desc->AddDate('TimeCreate');
112 $Desc->AddDate('TimeDue');
113 $Desc->AddDate('TimeClose');
114 $Desc->AddEnum('Priority', array('Nízká', 'Střední', 'Vysoká'));
115 $Desc->AddBoolean('Public');
116 $Desc->AddInteger('Progress');
117 $Desc->AddReference('Group', TaskGroup::GetClassName());
118 $Desc->AddString('Description');
119 $Desc->AddText('Conclusion');
120 $Desc->AddReference('AssignedTo', User::GetClassName());
121 return $Desc;
122 }
123}
124
125class TaskGroup extends Model
126{
127 static function GetModelDesc(): ModelDesc
128 {
129 $Desc = new ModelDesc(self::GetClassName());
130 $Desc->AddString('Name');
131 $Desc->AddText('Description');
132 $Desc->AddReference('Parent', TaskGroup::GetClassName());
133 return $Desc;
134 }
135}
136
137class Work extends Model
138{
139 static function GetModelDesc(): ModelDesc
140 {
141 $Desc = new ModelDesc(self::GetClassName());
142 $Desc->AddString('Name');
143 $Desc->AddText('Description');
144 $Desc->AddDateTime('TimeStart');
145 $Desc->AddFloat('Duration');
146 $Desc->AddReference('User', User::GetClassName());
147 $Desc->AddReference('Task', Task::GetClassName());
148 return $Desc;
149 }
150}
Note: See TracBrowser for help on using the repository browser.