source: trunk/www/Module/Task/View.php

Last change on this file was 95, checked in by chronos, 10 years ago
  • Upraveno: Soubory různých logických částí systému odděleny do aplikačních modulů.
File size: 2.9 KB
Line 
1<?php
2
3include_once(dirname(__FILE__).'/../../Base/View.php');
4
5class TaskView extends View
6{
7 var $ItemListFormClass = array(
8 'Title' => 'Seznam úloh',
9 'Table' => 'Task',
10 'DefaultOrderColumn' => 'TimeCreate',
11 'DefaultOrderDirection' => 1,
12 'Items' => array(
13 'TimeCreate' => array('Type' => 'DateTime', 'Caption' => 'Čas vytvoření', 'Default' => ''),
14 'Title' => array('Type' => 'String', 'Caption' => 'Operace', 'Default' => ''),
15 'State' => array('Type' => 'TaskState', 'Caption' => 'Stav', 'Default' => ''),
16 'Duration' => array('Type' => 'String', 'Caption' => 'Trvání', 'Default' => ''),
17 ),
18 );
19
20 function ShowListOnRow($Row)
21 {
22 $Row['Duration'] = $this->System->AddPrefixMultipliers($Row['Duration'], '', 4, 'Time');
23 return($Row);
24 }
25
26 function ItemList()
27 {
28 $Output = '<h4>Fronta úloh</h4>';
29 $Table = new Table($this->ItemListFormClass, $this->System);
30 $Table->OnRow = array($this, 'ShowListOnRow');
31 $Table->Definition['Table'] = '(SELECT Id, (COALESCE(UNIX_TIMESTAMP(TimeEnd), UNIX_TIMESTAMP(NOW())) - UNIX_TIMESTAMP(TimeStart)) AS Duration, TimeCreate, Title, State FROM Task WHERE User='.
32 $this->System->Modules['User']->Data['Id'].' ORDER BY Id DESC)';
33 $Table->Definition['Items']['Id'] = array('Type' => 'Hidden', 'Caption' => '', 'Default' => '');
34 $Table->LoadValuesFromDatabase($this->Database);
35 $Table->Definition['Items']['Actions'] = array('Type' => 'String', 'Caption' => '', 'Default' => '');
36 foreach($Table->Values as $Index => $Item)
37 {
38 $Table->Values[$Index]['Actions'] = '<a href="?Module=Task&amp;Action=ErrorLog&amp;Id='.$Item['Id'].'">Výpis chyb</a> <a href="?Module=Task&amp;Action=StandardLog&amp;Id='.$Item['Id'].'">Výpis výstupu</a> ';
39 unset($Table->Values[$Index]['Id']);
40 }
41 $Output .= $Table->Show();
42 $Output .= '<br /><div style="text-align: center;"><a href="?Module=Task&amp;Action=ItemList">Obnovit pohled</a></dev>';
43 return($Output);
44 }
45
46 function ErrorLog()
47 {
48 $DbResult = $this->Database->select('Task', 'Title, Error, State', 'Id='.$_GET['Id']);
49 $DbRow = $DbResult->fetch_assoc();
50 $Output = '<h4>Chybový výpis úlohy: '.$DbRow['Title'].'</h4>';
51 if($DbRow['State'] == 1) $Output .= '<pre>'.file_get_contents('../temp/wowhosting_script.sh.err').'</pre>';
52 else $Output .= '<pre>'.$DbRow['Error'].'</pre>';
53 return($Output);
54 }
55
56 function StandardLog()
57 {
58 $DbResult = $this->Database->select('Task', 'Title, Output, State', 'Id='.$_GET['Id']);
59 $DbRow = $DbResult->fetch_assoc();
60 $Output = '<h4>Výpis výstupu úlohy: '.$DbRow['Title'].'</h4>';
61 if($DbRow['State'] == 1) $Output .= '<pre>'.file_get_contents('../temp/wowhosting_script.sh.log').'</pre>';
62 $Output .= '<pre>'.$DbRow['Output'].'</pre>';
63 return($Output);
64 }
65}
Note: See TracBrowser for help on using the repository browser.