Ignore:
Timestamp:
Feb 5, 2016, 11:47:36 PM (8 years ago)
Author:
chronos
Message:
  • Fixed: Do not allow to regenerate multipletimes already running export task.
  • Modified: Progress reimplemented as Page class extension with virtual URL to avoid execution of any scripts with path to Modules subdirectory.
  • Added: Show estimated time to complete export task.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Export/Export.php

    r859 r864  
    715715  {
    716716    $this->System->RegisterPage('export', 'PageExport');
     717    $this->System->RegisterPage(array('export', 'progress'), 'PageExportProgress');
    717718    $this->System->RegisterMenuItem(array(
    718719      'Title' => 'Exporty',
     
    723724    ), 2);
    724725  }
     726
     727  function GetTaskProgress($TaskId)
     728  {
     729    $Output = '';
     730    $DbResult = $this->Database->query('SELECT * FROM `ExportTask` '.
     731      'LEFT JOIN `Export` ON `Export`.`Id` = `ExportTask`.`Export` WHERE '.
     732      '((`Export`.`OutputType` = 9) OR (`Export`.`OutputType` = 10)) AND '.
     733      '(`TimeFinish` IS NULL) OR (`Export` ='.$TaskId.') ORDER BY `Progress` DESC'); // `Export`='.$Export->Id
     734    while($Task = $DbResult->fetch_assoc())
     735    {
     736      $Export = '<a href="'.$this->System->Link('/export/?Action=View&amp;ExportId='.$Task['Export']).'">'.$Task['Export'].'</a>';
     737      if ($TaskId == $Task['Export'])
     738        $Export = ''.$Export.' (tento)';
     739
     740      // Show progress bar
     741      $Output .= ' <strong>Export '.$Export.': <div id="progress'.$Task['Export'].'">'.
     742        ProgressBar(300, $Task['Progress']).'</div></strong>';
     743
     744      // Show estimated time to complete
     745      $PrefixMultiplier = new PrefixMultiplier();
     746      $EstimatedTime = (time() - MysqlDateTimeToTime($Task['TimeStart'])) / $Task['Progress'] * (100 - $Task['Progress']);
     747      $Output .= 'Zbývající odhadovaný čas: '.$PrefixMultiplier->Add($EstimatedTime, '', 4, 'Time').'<br/>';
     748
     749      if($Task['Progress'] > 99)
     750        $Output .= '<script type="text/javascript" language="JavaScript" charset="utf-8">'.
     751        'setTimeout("parent.location.href=\''.$this->System->Link('/export/?Action=View&amp;Tab=7&amp;ExportId='.$TaskId).'\'", 500)'.
     752        '</script>';
     753    }
     754    return($Output);
     755  }
    725756}
    726 
Note: See TracChangeset for help on using the changeset viewer.