<?php

include_once(dirname(__FILE__).'/../../includes/global.php');

$System = new Core();
$System->DoNotShowPage = true;
$System->Run();

$Output = '';
if(!array_key_exists('RedirectId', $_GET)) exit;

$DbResult = $System->Database->query('SELECT * FROM `ExportTask` '.
 'LEFT JOIN `Export` ON `Export`.`Id` = `ExportTask`.`Export` WHERE '.
 '((`Export`.`OutputType` = 9) OR (`Export`.`OutputType` = 10)) AND '.
 '(`TimeFinish` IS NULL) OR (`Export` ='.($_GET['RedirectId'] * 1).') ORDER BY `Progress` DESC'); // `Export`='.$Export->Id
while($Task = $DbResult->fetch_assoc())
{
  $Export = '<a href="'.$System->Link('/export/?Action=View&ExportId='.$Task['Export']).'">'.$Task['Export'].'</a>';
  if ($_GET['RedirectId'] == $Task['Export'])
    $Export = ''.$Export.' (tento)';
  $Output .= ' <strong>Export '.$Export.': <div id="progress'.$Task['Export'].'">'.ProgressBar(300, $Task['Progress']).'</div></strong><br />';
  if($Task['Progress'] > 99)
    echo('<script type="text/javascript" language="JavaScript" charset="utf-8">'.
      'setTimeout("parent.location.href=\''.$System->Link('/export/?Action=View&Tab=7&ExportId='.$_GET['RedirectId']).'\'", 500)'.
      '</script>');
}

echo($Output);
//echo ''.ProgressBar(300, $Task['Progress']).'';
