| 1 | <?php
|
|---|
| 2 |
|
|---|
| 3 | include_once(dirname(__FILE__).'/../../Base/View.php');
|
|---|
| 4 |
|
|---|
| 5 | class 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&Action=ErrorLog&Id='.$Item['Id'].'">Výpis chyb</a> <a href="?Module=Task&Action=StandardLog&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&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 | }
|
|---|