[538] | 1 | <?php
|
---|
| 2 |
|
---|
[899] | 3 | class ModuleTask extends Module
|
---|
[538] | 4 | {
|
---|
[887] | 5 | function __construct(System $System)
|
---|
[538] | 6 | {
|
---|
[546] | 7 | parent::__construct($System);
|
---|
[538] | 8 | $this->Name = 'Task';
|
---|
| 9 | $this->Version = '1.0';
|
---|
| 10 | $this->Creator = 'Chronos';
|
---|
[899] | 11 | $this->License = 'GNU/GPLv3';
|
---|
[538] | 12 | $this->Description = 'Work and task management';
|
---|
[899] | 13 | $this->Dependencies = array(ModuleUser::GetName());
|
---|
| 14 | $this->Models = array(TaskGroup::GetClassName(), Task::GetClassName(), Work::GetClassName());
|
---|
[538] | 15 | }
|
---|
[660] | 16 |
|
---|
[887] | 17 | function DoStart(): void
|
---|
[538] | 18 | {
|
---|
| 19 | $this->System->FormManager->RegisterClass('Task', array(
|
---|
| 20 | 'Title' => 'Úkoly',
|
---|
| 21 | 'Table' => 'Task',
|
---|
[660] | 22 | 'DefaultSortColumn' => 'TimeCreate',
|
---|
| 23 | 'DefaultSortOrder' => 1,
|
---|
[538] | 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),
|
---|
[660] | 30 | 'Public' => array('Type' => 'Boolean', 'Caption' => 'Veřejné', 'Default' => '0'),
|
---|
[538] | 31 | 'Progress' => array('Type' => 'Integer', 'Caption' => 'Průběh', 'Default' => '0', 'Suffix' => '%'),
|
---|
| 32 | 'Group' => array('Type' => 'TTaskGroup', 'Caption' => 'Kategorie', 'Default' => '', 'Null' => true),
|
---|
[760] | 33 | 'Description' => array('Type' => 'Text', 'Caption' => 'Popis', 'Default' => '', 'NotInList' => true),
|
---|
| 34 | 'Conclusion' => array('Type' => 'Text', 'Caption' => 'Vyhodnocení', 'Default' => '', 'NotInList' => true),
|
---|
[538] | 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 | ));
|
---|
[738] | 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 | ));
|
---|
[712] | 63 | $this->System->FormManager->RegisterFormType('TTask', array(
|
---|
| 64 | 'Type' => 'Reference',
|
---|
| 65 | 'Table' => 'Task',
|
---|
| 66 | 'Id' => 'Id',
|
---|
| 67 | 'Name' => 'Name',
|
---|
| 68 | 'Filter' => '1',
|
---|
| 69 | ));
|
---|
[711] | 70 | $this->System->FormManager->RegisterFormType('TWorkListTask', array(
|
---|
[738] | 71 | 'Type' => 'ManyToOne',
|
---|
| 72 | 'Table' => 'Work',
|
---|
| 73 | 'Id' => 'Id',
|
---|
| 74 | 'Ref' => 'Task',
|
---|
| 75 | 'Filter' => '1',
|
---|
[711] | 76 | ));
|
---|
[712] | 77 | $this->System->FormManager->RegisterFormType('TTaskList', array(
|
---|
[738] | 78 | 'Type' => 'ManyToOne',
|
---|
| 79 | 'Table' => 'Task',
|
---|
| 80 | 'Id' => 'Id',
|
---|
| 81 | 'Ref' => 'Group',
|
---|
| 82 | 'Filter' => '1',
|
---|
[712] | 83 | ));
|
---|
| 84 | $this->System->FormManager->RegisterFormType('TTaskGroup', array(
|
---|
[738] | 85 | 'Type' => 'Reference',
|
---|
| 86 | 'Table' => 'TaskGroup',
|
---|
| 87 | 'Id' => 'Id',
|
---|
| 88 | 'Name' => 'Name',
|
---|
| 89 | 'Filter' => '1',
|
---|
[712] | 90 | ));
|
---|
[755] | 91 |
|
---|
[887] | 92 | ModuleIS::Cast($this->System->GetModule('IS'))->RegisterDashboardItem('Task',
|
---|
| 93 | array($this, 'ShowDashboardItem'));
|
---|
[746] | 94 | }
|
---|
[738] | 95 |
|
---|
[887] | 96 | function ShowDashboardItem(): string
|
---|
[755] | 97 | {
|
---|
| 98 | $DbResult = $this->Database->select('Task', 'COUNT(*)', '`Progress` < 100');
|
---|
| 99 | $DbRow = $DbResult->fetch_row();
|
---|
[914] | 100 | $Output = 'Nedokončených úkolů: <a href="'.$this->System->Link('/is/?a=list&t=Task&filter=1&FilterProgress=100&FilterOpProgress=less').'">'.$DbRow['0'].'</a><br/>';
|
---|
[755] | 101 | return $Output;
|
---|
| 102 | }
|
---|
[538] | 103 | }
|
---|
[893] | 104 |
|
---|
| 105 | class Task extends Model
|
---|
| 106 | {
|
---|
[899] | 107 | static function GetModelDesc(): ModelDesc
|
---|
[893] | 108 | {
|
---|
[894] | 109 | $Desc = new ModelDesc(self::GetClassName());
|
---|
[893] | 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');
|
---|
[894] | 117 | $Desc->AddReference('Group', TaskGroup::GetClassName());
|
---|
[893] | 118 | $Desc->AddString('Description');
|
---|
| 119 | $Desc->AddText('Conclusion');
|
---|
[894] | 120 | $Desc->AddReference('AssignedTo', User::GetClassName());
|
---|
[893] | 121 | return $Desc;
|
---|
| 122 | }
|
---|
| 123 | }
|
---|
| 124 |
|
---|
| 125 | class TaskGroup extends Model
|
---|
| 126 | {
|
---|
[899] | 127 | static function GetModelDesc(): ModelDesc
|
---|
[893] | 128 | {
|
---|
[894] | 129 | $Desc = new ModelDesc(self::GetClassName());
|
---|
[893] | 130 | $Desc->AddString('Name');
|
---|
| 131 | $Desc->AddText('Description');
|
---|
[894] | 132 | $Desc->AddReference('Parent', TaskGroup::GetClassName());
|
---|
[893] | 133 | return $Desc;
|
---|
| 134 | }
|
---|
| 135 | }
|
---|
| 136 |
|
---|
| 137 | class Work extends Model
|
---|
| 138 | {
|
---|
[899] | 139 | static function GetModelDesc(): ModelDesc
|
---|
[893] | 140 | {
|
---|
[894] | 141 | $Desc = new ModelDesc(self::GetClassName());
|
---|
[893] | 142 | $Desc->AddString('Name');
|
---|
| 143 | $Desc->AddText('Description');
|
---|
| 144 | $Desc->AddDateTime('TimeStart');
|
---|
| 145 | $Desc->AddFloat('Duration');
|
---|
[894] | 146 | $Desc->AddReference('User', User::GetClassName());
|
---|
| 147 | $Desc->AddReference('Task', Task::GetClassName());
|
---|
[893] | 148 | return $Desc;
|
---|
| 149 | }
|
---|
| 150 | }
|
---|