Ignore:
Timestamp:
Feb 22, 2015, 11:20:50 PM (9 years ago)
Author:
chronos
Message:
  • Modified: Tabs converted to spaces.
  • Modified: Remove spaces from end of lines.
  • Added: Code format script.
File:
1 edited

Legend:

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

    r809 r816  
    1414class PageExport extends Page
    1515{
    16         function ExportList()
    17         {
    18                 $Output = '<a href="?Action=ViewList">'.T('All').'</a>';
    19                 if($this->System->User->Licence(LICENCE_USER))
    20                 {
    21                         $Output .= ' <a href="?Action=ViewList&amp;Filter=Others">Ostatních</a>'.
    22                                         ' <a href="?Action=ViewList&amp;Filter=My">'.T('Mine').'</a>';
    23                 }
    24        
    25                 if($this->System->User->Licence(LICENCE_USER))
    26                         $Output .= '<br/><div style="text-align: center;"><a href="?Action=Create">'.T('Create new export').'</a></div><br/>';
    27                
    28                 $Filter = '';
    29                 if(array_key_exists('Filter', $_GET))
    30                 {
    31                         if($_GET['Filter'] == 'My') $Filter = ' WHERE `Export`.`User` = '.$this->System->User->Id;
    32                         if($_GET['Filter'] == 'Others') $Filter = ' WHERE `Export`.`User` != '.$this->System->User->Id;
    33                 }
    34        
    35                 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Export` '.$Filter);
    36                 $DbRow = $DbResult->fetch_row();
    37                 $PageList = GetPageList($DbRow[0]);
    38        
    39                 $Output .= '<h3>'.T('List of export').'</h3>'.
    40                                 $PageList['Output'];
    41        
    42                 $TableColumns = array(
    43                                 array('Name' => 'TimeCreate', 'Title' => T('Time made')),
    44                                 array('Name' => 'UserName', 'Title' => T('Translator')),
    45                                 array('Name' => 'Title', 'Title' => T('Name od export')),
    46                                 //  array('Name' => 'UserCount', 'Title' => 'Vybraných překladatelů'),
    47                                 //  array('Name' => 'GroupCount', 'Title' => 'Překladových skupin'),
    48                                 array('Name' => 'OutputType', 'Title' => T('Type of output')),
    49                                 array('Name' => 'ClientVersion', 'Title' => T('Client version')),
    50                                 array('Name' => 'UsedCount', 'Title' => T('Viewed count')),
    51                                 array('Name' => '', 'Title' => T('Action')),
    52                 );
    53                 $Order = GetOrderTableHeader($TableColumns, 'TimeCreate', 1);
    54                 $Output .= '<table class="BaseTable">'.
    55                                 $Order['Output'];
    56        
    57                 $DbResult = $this->System->Database->query('SELECT `User`.`Name` AS `UserName`, `Export`.`Id`, `Export`.`TimeCreate`, `Export`.`Title`, `Export`.`User`, `Export`.`UsedCount`, '.
     16  function ExportList()
     17  {
     18    $Output = '<a href="?Action=ViewList">'.T('All').'</a>';
     19    if($this->System->User->Licence(LICENCE_USER))
     20    {
     21      $Output .= ' <a href="?Action=ViewList&amp;Filter=Others">Ostatních</a>'.
     22          ' <a href="?Action=ViewList&amp;Filter=My">'.T('Mine').'</a>';
     23    }
     24
     25    if($this->System->User->Licence(LICENCE_USER))
     26      $Output .= '<br/><div style="text-align: center;"><a href="?Action=Create">'.T('Create new export').'</a></div><br/>';
     27
     28    $Filter = '';
     29    if(array_key_exists('Filter', $_GET))
     30    {
     31      if($_GET['Filter'] == 'My') $Filter = ' WHERE `Export`.`User` = '.$this->System->User->Id;
     32      if($_GET['Filter'] == 'Others') $Filter = ' WHERE `Export`.`User` != '.$this->System->User->Id;
     33    }
     34
     35    $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Export` '.$Filter);
     36    $DbRow = $DbResult->fetch_row();
     37    $PageList = GetPageList($DbRow[0]);
     38
     39    $Output .= '<h3>'.T('List of export').'</h3>'.
     40        $PageList['Output'];
     41
     42    $TableColumns = array(
     43        array('Name' => 'TimeCreate', 'Title' => T('Time made')),
     44        array('Name' => 'UserName', 'Title' => T('Translator')),
     45        array('Name' => 'Title', 'Title' => T('Name od export')),
     46        //  array('Name' => 'UserCount', 'Title' => 'Vybraných překladatelů'),
     47        //  array('Name' => 'GroupCount', 'Title' => 'Překladových skupin'),
     48        array('Name' => 'OutputType', 'Title' => T('Type of output')),
     49        array('Name' => 'ClientVersion', 'Title' => T('Client version')),
     50        array('Name' => 'UsedCount', 'Title' => T('Viewed count')),
     51        array('Name' => '', 'Title' => T('Action')),
     52    );
     53    $Order = GetOrderTableHeader($TableColumns, 'TimeCreate', 1);
     54    $Output .= '<table class="BaseTable">'.
     55        $Order['Output'];
     56
     57    $DbResult = $this->System->Database->query('SELECT `User`.`Name` AS `UserName`, `Export`.`Id`, `Export`.`TimeCreate`, `Export`.`Title`, `Export`.`User`, `Export`.`UsedCount`, '.
    5858      '(SELECT Version FROM `ClientVersion` WHERE `ClientVersion`.`Id`=`Export`.`ClientVersion`) AS `ClientVersion`, '.
    5959      '(SELECT Id FROM `ClientVersion` WHERE `ClientVersion`.`Id`=`Export`.`ClientVersion`) AS `ClientVersionId`, '.
     
    6262      '(SELECT COUNT(*) FROM `ExportUser` WHERE `ExportUser`.`Export`=`Export`.`Id`) AS `UserCount` FROM `Export` '.
    6363      'LEFT JOIN `User` ON `User`.`ID`=`Export`.`User` '.$Filter.$Order['SQL'].$PageList['SQLLimit']);
    64                 while($Export = $DbResult->fetch_assoc())
    65                 {
    66                         $Action = '<a href="?Action=View&amp;ExportId='.$Export['Id'].'&amp;Tab=0">'.T('View').'</a> '.
    67                           '<a href="?Action=View&amp;ExportId='.$Export['Id'].'&amp;Tab=7">'.T('Make export').'</a>';
    68                         if($Export['User'] == $this->System->User->Id) $Action .= ' <a href="?Action=Delete&amp;ExportId='.$Export['Id'].'" onclick="return confirmAction(\''.T('Realy delete item?').'\');">'.T('Delete').'</a>';
    69                         if($this->System->User->Id != null) $Action .= ' <a href="?Action=Clone&amp;ExportId='.$Export['Id'].'" onclick="return confirmAction(\''.T('Realy clone item?').'\');">'.T('Clone').'</a>';
    70                         $Output .= '<tr><td>'.HumanDate($Export['TimeCreate']).'</td>'.
    71                                         '<td><a href="'.$this->System->Link('/user.php?user='.$Export['User']).'">'.$Export['UserName'].'</a></td>'.
    72                                         '<td>'.$Export['Title'].'</td>'.
    73                                         '<td>'.$Export['OutputType'].'</td>'.
    74                                         '<td><a href="'.$this->System->Link('/client-version/?action=item&amp;id='.$Export['ClientVersionId']).'">'.$Export['ClientVersion'].'</a></td>'.
    75                                         '<td>'.$Export['UsedCount'].'</td>'.
    76                                         '<td>'.$Action.'</td></tr>';
    77                 }
    78                 $Output .= '</table>'.
    79                                 $PageList['Output'];
    80        
    81                 return($Output);
    82         }
    83        
    84         function ExportCreate()
    85         {
    86                 if($this->System->User->Licence(LICENCE_USER))
    87                 {
    88                         $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Export` WHERE `User`='.$this->System->User->Id);
    89                         $DbRow = $DbResult->fetch_row();
    90                         if($DbRow[0] < $this->System->Config['MaxExportPerUser'])
    91                         {
    92                                 $Output = '<form action="?Action=CreateFinish" method="post">'.
    93                                                 '<fieldset><legend>'.T('Creation of new export').'</legend>'.
    94                                                 '<table><tr><td>'.T('Identification').':</td><td><input type="text" name="Title" /></td></tr>'.
    95                                                 '<tr><td>'.T('Description').':</td><td><textarea name="Description" cols="54" rows="10"></textarea></td></tr>'.
    96                                                 '<tr><td colspan="2"><input type="submit" value="'.T('Create').'" /></td></tr>'.
    97                                                 '</table></fieldset></form>';
    98                         } else $Output = ShowMessage(T('You can\'t create another export. Max for one user is').$this->System->Config['MaxExportPerUser'].'.', MESSAGE_CRITICAL);
    99                 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
    100                 return($Output);
    101         }
    102        
    103         function ExportCreateFinish()
    104         {
    105                 if($this->System->User->Licence(LICENCE_USER))
    106                 {
    107                         if(array_key_exists('Title', $_POST) and array_key_exists('Description', $_POST))
    108                         {
    109                                 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Export` WHERE `User`='.$this->System->User->Id);
    110                                 $DbRow = $DbResult->fetch_row();
    111                                 if($DbRow[0] < $this->System->Config['MaxExportPerUser'])
    112                                 {
    113                                         $this->System->Database->query('INSERT INTO `Export` (`Title`, `User`, `TimeCreate`, `WithDiacritic`, `Description`) VALUES ("'.$_POST['Title'].'", '.$this->System->User->Id.', NOW(), 1, "'.$_POST['Description'].'")');
    114                                         $ExportId = $this->System->Database->insert_id;
    115                                         $Output = ShowMessage(T('New export created.<br />Direct link to export').': <a href="?Action=View&amp;ExportId='.$ExportId.'">'.T('here').'</a>');
    116                                         $this->System->ModuleManager->Modules['Log']->WriteLog(T('New export created').' <a href="'.$this->System->Link('/export/?Action=View&amp;ExportId='.$ExportId).'">'.$ExportId.'</a>.', LOG_TYPE_EXPORT);
    117                                         $_GET['Filter'] = 'my';
    118                                         $this->ExportList();
    119                                 } else $Output = ShowMessage(T('You can\'t create another export. Max for one user is').' '.$this->System->Config['MaxExportPerUser'].'.', MESSAGE_CRITICAL);
    120                         } else $Output = ShowMessage(T('Missing data in form.'), MESSAGE_CRITICAL);
    121                 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
    122                 return($Output);
    123         }
    124        
    125         function ExportDelete()
    126         {
    127                 if($this->System->User->Licence(LICENCE_USER))
    128                 {
    129                         $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE (`Id`='.($_GET['ExportId'] * 1).') AND (`User`='.$this->System->User->Id.')');
    130                         if($DbResult->num_rows > 0)
    131                         {
    132                                 $this->System->Database->query('DELETE FROM `ExportGroup` WHERE `Export`='.$_GET['ExportId']);
    133                                 $this->System->Database->query('DELETE FROM `ExportGroupItem` WHERE `Export`='.$_GET['ExportId']);
    134                                 $this->System->Database->query('DELETE FROM `ExportLanguage` WHERE `Export`='.$_GET['ExportId']);
    135                                 $this->System->Database->query('DELETE FROM `ExportTask` WHERE `Export`='.$_GET['ExportId']);
    136                                 $this->System->Database->query('DELETE FROM `ExportUser` WHERE `Export`='.$_GET['ExportId']);
    137                                 $this->System->Database->query('DELETE FROM `Export` WHERE `Id`='.$_GET['ExportId']);
    138                                 DeleteDirectory('../tmp/Export/'.$_GET['ExportId'].'/');
    139                                 $Output = ShowMessage(T('Export deleted.'));
    140                                 $_GET['Filter'] = 'my';
    141                                 $this->System->ModuleManager->Modules['Log']->WriteLog('Smazán export '.$_GET['ExportId'], LOG_TYPE_EXPORT);
    142                                 $Output .= $this->ExportList();
    143                         } else $Output = ShowMessage(T('Export not found.'), MESSAGE_CRITICAL);
    144                 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
    145                 return($Output);
    146         }
    147        
    148         function SaveAllUsers()
    149         {
    150         global $System;
    151             $Export = new Export($System);
     64    while($Export = $DbResult->fetch_assoc())
     65    {
     66      $Action = '<a href="?Action=View&amp;ExportId='.$Export['Id'].'&amp;Tab=0">'.T('View').'</a> '.
     67        '<a href="?Action=View&amp;ExportId='.$Export['Id'].'&amp;Tab=7">'.T('Make export').'</a>';
     68      if($Export['User'] == $this->System->User->Id) $Action .= ' <a href="?Action=Delete&amp;ExportId='.$Export['Id'].'" onclick="return confirmAction(\''.T('Realy delete item?').'\');">'.T('Delete').'</a>';
     69      if($this->System->User->Id != null) $Action .= ' <a href="?Action=Clone&amp;ExportId='.$Export['Id'].'" onclick="return confirmAction(\''.T('Realy clone item?').'\');">'.T('Clone').'</a>';
     70      $Output .= '<tr><td>'.HumanDate($Export['TimeCreate']).'</td>'.
     71          '<td><a href="'.$this->System->Link('/user.php?user='.$Export['User']).'">'.$Export['UserName'].'</a></td>'.
     72          '<td>'.$Export['Title'].'</td>'.
     73          '<td>'.$Export['OutputType'].'</td>'.
     74          '<td><a href="'.$this->System->Link('/client-version/?action=item&amp;id='.$Export['ClientVersionId']).'">'.$Export['ClientVersion'].'</a></td>'.
     75          '<td>'.$Export['UsedCount'].'</td>'.
     76          '<td>'.$Action.'</td></tr>';
     77    }
     78    $Output .= '</table>'.
     79        $PageList['Output'];
     80
     81    return($Output);
     82  }
     83
     84  function ExportCreate()
     85  {
     86    if($this->System->User->Licence(LICENCE_USER))
     87    {
     88      $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Export` WHERE `User`='.$this->System->User->Id);
     89      $DbRow = $DbResult->fetch_row();
     90      if($DbRow[0] < $this->System->Config['MaxExportPerUser'])
     91      {
     92        $Output = '<form action="?Action=CreateFinish" method="post">'.
     93            '<fieldset><legend>'.T('Creation of new export').'</legend>'.
     94            '<table><tr><td>'.T('Identification').':</td><td><input type="text" name="Title" /></td></tr>'.
     95            '<tr><td>'.T('Description').':</td><td><textarea name="Description" cols="54" rows="10"></textarea></td></tr>'.
     96            '<tr><td colspan="2"><input type="submit" value="'.T('Create').'" /></td></tr>'.
     97            '</table></fieldset></form>';
     98      } else $Output = ShowMessage(T('You can\'t create another export. Max for one user is').$this->System->Config['MaxExportPerUser'].'.', MESSAGE_CRITICAL);
     99    } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
     100    return($Output);
     101  }
     102
     103  function ExportCreateFinish()
     104  {
     105    if($this->System->User->Licence(LICENCE_USER))
     106    {
     107      if(array_key_exists('Title', $_POST) and array_key_exists('Description', $_POST))
     108      {
     109        $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Export` WHERE `User`='.$this->System->User->Id);
     110        $DbRow = $DbResult->fetch_row();
     111        if($DbRow[0] < $this->System->Config['MaxExportPerUser'])
     112        {
     113          $this->System->Database->query('INSERT INTO `Export` (`Title`, `User`, `TimeCreate`, `WithDiacritic`, `Description`) VALUES ("'.$_POST['Title'].'", '.$this->System->User->Id.', NOW(), 1, "'.$_POST['Description'].'")');
     114          $ExportId = $this->System->Database->insert_id;
     115          $Output = ShowMessage(T('New export created.<br />Direct link to export').': <a href="?Action=View&amp;ExportId='.$ExportId.'">'.T('here').'</a>');
     116          $this->System->ModuleManager->Modules['Log']->WriteLog(T('New export created').' <a href="'.$this->System->Link('/export/?Action=View&amp;ExportId='.$ExportId).'">'.$ExportId.'</a>.', LOG_TYPE_EXPORT);
     117          $_GET['Filter'] = 'my';
     118          $this->ExportList();
     119        } else $Output = ShowMessage(T('You can\'t create another export. Max for one user is').' '.$this->System->Config['MaxExportPerUser'].'.', MESSAGE_CRITICAL);
     120      } else $Output = ShowMessage(T('Missing data in form.'), MESSAGE_CRITICAL);
     121    } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
     122    return($Output);
     123  }
     124
     125  function ExportDelete()
     126  {
     127    if($this->System->User->Licence(LICENCE_USER))
     128    {
     129      $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE (`Id`='.($_GET['ExportId'] * 1).') AND (`User`='.$this->System->User->Id.')');
     130      if($DbResult->num_rows > 0)
     131      {
     132        $this->System->Database->query('DELETE FROM `ExportGroup` WHERE `Export`='.$_GET['ExportId']);
     133        $this->System->Database->query('DELETE FROM `ExportGroupItem` WHERE `Export`='.$_GET['ExportId']);
     134        $this->System->Database->query('DELETE FROM `ExportLanguage` WHERE `Export`='.$_GET['ExportId']);
     135        $this->System->Database->query('DELETE FROM `ExportTask` WHERE `Export`='.$_GET['ExportId']);
     136        $this->System->Database->query('DELETE FROM `ExportUser` WHERE `Export`='.$_GET['ExportId']);
     137        $this->System->Database->query('DELETE FROM `Export` WHERE `Id`='.$_GET['ExportId']);
     138        DeleteDirectory('../tmp/Export/'.$_GET['ExportId'].'/');
     139        $Output = ShowMessage(T('Export deleted.'));
     140        $_GET['Filter'] = 'my';
     141        $this->System->ModuleManager->Modules['Log']->WriteLog('Smazán export '.$_GET['ExportId'], LOG_TYPE_EXPORT);
     142        $Output .= $this->ExportList();
     143      } else $Output = ShowMessage(T('Export not found.'), MESSAGE_CRITICAL);
     144    } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
     145    return($Output);
     146  }
     147
     148  function SaveAllUsers()
     149  {
     150  global $System;
     151      $Export = new Export($System);
    152152      $Export->Id = $_GET['ExportId'];
    153153      $Export->SaveAllUsers();
    154      
    155   }
    156        
    157         function ExportViewTranslators()
    158         {
    159                 global $TranslationTree;
    160        
    161                 $Output = '';
    162                 $DisabledInput = array(false => ' disabled="disabled"', true => '');
    163                 $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
    164                 $Export = $DbResult->fetch_assoc();
    165                 if($this->System->User->Licence(LICENCE_USER) and ($this->System->User->Id == $Export['User'])) $Editable = true;
    166                 else $Editable = false;
    167        
    168                 if(array_key_exists('Operation', $_POST))
    169                 {
    170                         if($_POST['Operation'] == 'Save')
    171                         {
    172                                 //print_r($_POST);
    173                                 // Update user selection page
    174                                 foreach($_POST as $Index => $Value)
    175                                 {
    176                                         if(substr($Index, 0, 3) == 'seq')
    177                                         {
    178                                                 $UserId = substr($Index, 3) * 1;
    179                                                 if(array_key_exists('sel'.$UserId, $_POST)) $Selected = true;
    180                                                 else $Selected = false;
    181                                                 $Condition = ' WHERE `Export`='.$_GET['ExportId'].' AND `User`='.$UserId;
    182                                                 $DbResult = $this->System->Database->query('SELECT * FROM `ExportUser` '.$Condition);
    183                                                 if($DbResult->num_rows > 0)
    184                                                 {
    185                                                         if(!$Selected) $this->System->Database->query('DELETE FROM `ExportUser` '.$Condition);
    186                                                         else $this->System->Database->query('UPDATE `ExportUser` SET `Sequence`='.$Value.$Condition);
    187                                                 } else
    188                                                 {
    189                                                         if($Selected) $this->System->Database->query('INSERT INTO `ExportUser` (`Export`, `User`, `Sequence`) VALUES ('.$_GET['ExportId'].', '.$UserId.', '.$Value.')');
    190                                                 }
    191                                         }
    192                                 }
    193        
    194                           if (array_key_exists('AllUsers', $_POST)) {
     154
     155  }
     156
     157  function ExportViewTranslators()
     158  {
     159    global $TranslationTree;
     160
     161    $Output = '';
     162    $DisabledInput = array(false => ' disabled="disabled"', true => '');
     163    $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
     164    $Export = $DbResult->fetch_assoc();
     165    if($this->System->User->Licence(LICENCE_USER) and ($this->System->User->Id == $Export['User'])) $Editable = true;
     166    else $Editable = false;
     167
     168    if(array_key_exists('Operation', $_POST))
     169    {
     170      if($_POST['Operation'] == 'Save')
     171      {
     172        //print_r($_POST);
     173        // Update user selection page
     174        foreach($_POST as $Index => $Value)
     175        {
     176          if(substr($Index, 0, 3) == 'seq')
     177          {
     178            $UserId = substr($Index, 3) * 1;
     179            if(array_key_exists('sel'.$UserId, $_POST)) $Selected = true;
     180            else $Selected = false;
     181            $Condition = ' WHERE `Export`='.$_GET['ExportId'].' AND `User`='.$UserId;
     182            $DbResult = $this->System->Database->query('SELECT * FROM `ExportUser` '.$Condition);
     183            if($DbResult->num_rows > 0)
     184            {
     185              if(!$Selected) $this->System->Database->query('DELETE FROM `ExportUser` '.$Condition);
     186              else $this->System->Database->query('UPDATE `ExportUser` SET `Sequence`='.$Value.$Condition);
     187            } else
     188            {
     189              if($Selected) $this->System->Database->query('INSERT INTO `ExportUser` (`Export`, `User`, `Sequence`) VALUES ('.$_GET['ExportId'].', '.$UserId.', '.$Value.')');
     190            }
     191          }
     192        }
     193
     194        if (array_key_exists('AllUsers', $_POST)) {
    195195            //add allusers to export
    196                                                 $this->System->Database->query('UPDATE `Export` SET `AllUsers`=1 WHERE `Id`='.$_GET['ExportId']);
    197            
    198                   //update export stat
     196            $this->System->Database->query('UPDATE `Export` SET `AllUsers`=1 WHERE `Id`='.$_GET['ExportId']);
     197
     198            //update export stat
    199199            $Export['AllUsers'] = 1;
    200200            $this->SaveAllUsers();
    201201          } else {
    202                   //update export stat
     202            //update export stat
    203203            $Export['AllUsers'] = 0;
    204                                                 $this->System->Database->query('UPDATE `Export` SET `AllUsers`=0 WHERE `Id`='.$_GET['ExportId']);
     204            $this->System->Database->query('UPDATE `Export` SET `AllUsers`=0 WHERE `Id`='.$_GET['ExportId']);
    205205          }
    206206
    207                                 // Recalculate sequence number
    208                                 $this->System->Database->query('SET @I = 0');
    209                                 $this->System->Database->query('UPDATE `ExportUser` SET `Sequence` = (@I := @I + 1) WHERE `Export`='.$_GET['ExportId'].' ORDER BY `Sequence`;');
    210                                 $Output .= ShowMessage(T('Select saved.'));
    211                         }
    212                 }
    213        
    214                 $TableColumns = array(
    215                                 array('Name' => 'Name', 'Title' => T('Name')),
    216                                 array('Name' => 'TranslatedCount', 'Title' => T('Translated count')),
    217                                 array('Name' => 'XP', 'Title' => T('Level')),
    218                                 array('Name' => 'XP', 'Title' => T('Experience')),
    219                                 array('Name' => '', 'Title' => T('Select')),
    220                                 array('Name' => 'Sequence2', 'Title' => T('Order')),
    221                 );
    222                 $Order = GetOrderTableHeader($TableColumns, 'TranslatedCount', 1);
    223                 if($Order['Column'] != 'Sequence2') $InitialOrder = ', '.substr($Order['SQL'], 10);
    224                 else $InitialOrder = '';
    225        
    226                 $Query = 'SELECT (@I := @I + 1) AS `Sequence2`, `TT`.* FROM (SELECT `ExportUser`.`Sequence`, `T`.`ID`, `T`.`TranslatedCount`, `T`.`Name`, `T`.`XP` FROM (SELECT `User`.`ID`, `User`.`Name`, `User`.`XP`, `TranslatedCount` FROM `User`) AS T';
    227                 $Query .=' LEFT JOIN `ExportUser` ON `ExportUser`.`Export` = '.$_GET['ExportId'].' AND `ExportUser`.`User`=`T`.`ID`';
    228                 $Query .=' WHERE `T`.`TranslatedCount` > 0 ORDER BY COALESCE(`ExportUser`.`Sequence`, 100000000)'.$InitialOrder.') AS `TT`';
    229        
    230                 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS `X`');
    231                 $DbRow = $DbResult->fetch_row();
    232                 $PageList = GetPageList($DbRow[0]);
    233        
    234                 $Output .= '<form name="Translators" action="?Action=View&amp;ExportId='.$_GET['ExportId'].'" method="post">'.
    235                                 '<h3>'.T('Translators').'</h3>';
    236                 if($Editable)
    237                 {
    238                         $Output .= '<input type="submit" value="'.T('Save').'" '.$DisabledInput[$Editable].'/>'.
    239                                         '<input type="hidden" name="Operation" value="Save"/><br />'.
    240                                         ' <span onclick="CheckAllCheckbox();">'.CheckBox('CheckAll', False, 'CheckAll').' '.T('Select all on page').'</span> <br />'.
    241                                         ' <span>'.CheckBox('AllUsers', $Export['AllUsers']).' '.T('Export allways from all users').'</span> '.
    242                                         '<br />'.
    243                                         T('Select users from list which you want to export from. And edit their order.').'<br />'.
    244                                         T('Order is done by numeric value which is can be edit to desirable order. Lines with same number will be renumbered in ascending order.');
    245                 }
    246        
    247                 $Output .= $PageList['Output'].
    248                 '<table class="BaseTable">'.
    249                 $Order['Output'];
    250        
    251                 $Query = 'SELECT * FROM ('.$Query.') AS `TX` '.$Order['SQL'].$PageList['SQLLimit'];
    252                 $this->System->Database->query('SET @I = 0');
    253                 $DbResult = $this->System->Database->query($Query);
    254                 while($UserLine = $DbResult->fetch_assoc())
    255                 {
    256                         $XP = GetLevelMinMax($UserLine['XP']);
    257                         $Checked = $UserLine['Sequence'] != '';
    258                         $Selection = CheckBox('sel'.$UserLine['ID'], $Checked, '', 'CheckBox', ((!$Editable) or ($Export['AllUsers'])));
    259                         $Sequence = '<input type="text" name="seq'.$UserLine['ID'].'" style="text-align: center; width: 40px;" value="'.$UserLine['Sequence2'].'"'.$DisabledInput[$Editable].'/>';
    260                         $Output .= '<tr>'.
    261                                         '<td><a href="'.$this->System->Link('/TranslationList.php?user='.$UserLine['ID'].'&amp;state=2&amp;group=0').'" title="Zobrazit všechny jeho přeložené texty">'.$UserLine['Name'].'</a></td>'.
    262                                         '<td>'.$UserLine['TranslatedCount'].'</td>'.
    263                                         '<td>'.$XP['Level'].'</td>'.
    264                                         '<td>'.ProgressBar(150, round($XP['XP'] / $XP['MaxXP'] * 100, 2), $XP['XP'].' / '.$XP['MaxXP']).'</td>'.
    265                                         '<td>'.$Selection.'</td><td>'.$Sequence.'</td></tr>';
    266                 }
    267                 $Output .= '</table>'.
    268                                 '</form>'.
    269                                 $PageList['Output'];
    270                 return($Output);
    271         }
    272        
    273         function ExportViewGeneral()
    274         {
    275                 $DisabledInput = array(false => ' disabled="disabled"', true => '');
    276                 $DisabledTextArea = array(false => ' readonly="yes"', true => '');
    277                 $Output = '<h3>Obecná nastavení</h3>';
    278                 $DbRows = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
    279                 $Export = $DbRows->fetch_assoc();
    280                 if($this->System->User->Licence(LICENCE_USER) and ($this->System->User->Id == $Export['User'])) $Editable = true;
    281                 else $Editable = false;
    282        
    283                 if(array_key_exists('Operation', $_POST))
    284                         if($_POST['Operation'] == 'Save')  if($Editable and array_key_exists('Title', $_POST) and array_key_exists('Description', $_POST))
    285                         {
    286                                 if(array_key_exists('WithDiacritic', $_POST)) $WithDiacritic = 1;
    287                                 else $WithDiacritic = 0;
    288                                 if (array_key_exists('Featured', $_POST)) $Export['Featured'] = 1;
    289                                 $this->System->Database->query('UPDATE `Export` SET `Title`="'.$_POST['Title'].'", `Featured`='.$Export['Featured'].', `Description`="'.$_POST['Description'].'", `WithDiacritic`='.$WithDiacritic.' WHERE Id='.$Export['Id']);
    290                                 $Export['Title'] = $_POST['Title'];
    291                                 $Export['Description'] = $_POST['Description'];
    292                                 $Export['WithDiacritic'] = $WithDiacritic;
    293                                 $Output .= ShowMessage('Nastavení uloženo.');
    294                         }
    295        
    296                         if($Export['WithDiacritic'] == 1) $WithDiacritic = ' checked="checked"';
    297                         else $WithDiacritic = '';
    298                         $Output .= '<form action="?Action=View&amp;Tab=0&amp;ExportId='.$Export['Id'].'" method="post">'.
    299                                         '<table>';
    300                         if($this->System->User->Id != null)
    301                         {
    302                                 $Output .= '<input type="hidden" name="Operation" value="Save"/>'.
    303                                                 '<tr><td colspan="2">';
     207        // Recalculate sequence number
     208        $this->System->Database->query('SET @I = 0');
     209        $this->System->Database->query('UPDATE `ExportUser` SET `Sequence` = (@I := @I + 1) WHERE `Export`='.$_GET['ExportId'].' ORDER BY `Sequence`;');
     210        $Output .= ShowMessage(T('Select saved.'));
     211      }
     212    }
     213
     214    $TableColumns = array(
     215        array('Name' => 'Name', 'Title' => T('Name')),
     216        array('Name' => 'TranslatedCount', 'Title' => T('Translated count')),
     217        array('Name' => 'XP', 'Title' => T('Level')),
     218        array('Name' => 'XP', 'Title' => T('Experience')),
     219        array('Name' => '', 'Title' => T('Select')),
     220        array('Name' => 'Sequence2', 'Title' => T('Order')),
     221    );
     222    $Order = GetOrderTableHeader($TableColumns, 'TranslatedCount', 1);
     223    if($Order['Column'] != 'Sequence2') $InitialOrder = ', '.substr($Order['SQL'], 10);
     224    else $InitialOrder = '';
     225
     226    $Query = 'SELECT (@I := @I + 1) AS `Sequence2`, `TT`.* FROM (SELECT `ExportUser`.`Sequence`, `T`.`ID`, `T`.`TranslatedCount`, `T`.`Name`, `T`.`XP` FROM (SELECT `User`.`ID`, `User`.`Name`, `User`.`XP`, `TranslatedCount` FROM `User`) AS T';
     227    $Query .=' LEFT JOIN `ExportUser` ON `ExportUser`.`Export` = '.$_GET['ExportId'].' AND `ExportUser`.`User`=`T`.`ID`';
     228    $Query .=' WHERE `T`.`TranslatedCount` > 0 ORDER BY COALESCE(`ExportUser`.`Sequence`, 100000000)'.$InitialOrder.') AS `TT`';
     229
     230    $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS `X`');
     231    $DbRow = $DbResult->fetch_row();
     232    $PageList = GetPageList($DbRow[0]);
     233
     234    $Output .= '<form name="Translators" action="?Action=View&amp;ExportId='.$_GET['ExportId'].'" method="post">'.
     235        '<h3>'.T('Translators').'</h3>';
     236    if($Editable)
     237    {
     238      $Output .= '<input type="submit" value="'.T('Save').'" '.$DisabledInput[$Editable].'/>'.
     239          '<input type="hidden" name="Operation" value="Save"/><br />'.
     240          ' <span onclick="CheckAllCheckbox();">'.CheckBox('CheckAll', False, 'CheckAll').' '.T('Select all on page').'</span> <br />'.
     241          ' <span>'.CheckBox('AllUsers', $Export['AllUsers']).' '.T('Export allways from all users').'</span> '.
     242          '<br />'.
     243          T('Select users from list which you want to export from. And edit their order.').'<br />'.
     244          T('Order is done by numeric value which is can be edit to desirable order. Lines with same number will be renumbered in ascending order.');
     245    }
     246
     247    $Output .= $PageList['Output'].
     248    '<table class="BaseTable">'.
     249    $Order['Output'];
     250
     251    $Query = 'SELECT * FROM ('.$Query.') AS `TX` '.$Order['SQL'].$PageList['SQLLimit'];
     252    $this->System->Database->query('SET @I = 0');
     253    $DbResult = $this->System->Database->query($Query);
     254    while($UserLine = $DbResult->fetch_assoc())
     255    {
     256      $XP = GetLevelMinMax($UserLine['XP']);
     257      $Checked = $UserLine['Sequence'] != '';
     258      $Selection = CheckBox('sel'.$UserLine['ID'], $Checked, '', 'CheckBox', ((!$Editable) or ($Export['AllUsers'])));
     259      $Sequence = '<input type="text" name="seq'.$UserLine['ID'].'" style="text-align: center; width: 40px;" value="'.$UserLine['Sequence2'].'"'.$DisabledInput[$Editable].'/>';
     260      $Output .= '<tr>'.
     261          '<td><a href="'.$this->System->Link('/TranslationList.php?user='.$UserLine['ID'].'&amp;state=2&amp;group=0').'" title="Zobrazit všechny jeho přeložené texty">'.$UserLine['Name'].'</a></td>'.
     262          '<td>'.$UserLine['TranslatedCount'].'</td>'.
     263          '<td>'.$XP['Level'].'</td>'.
     264          '<td>'.ProgressBar(150, round($XP['XP'] / $XP['MaxXP'] * 100, 2), $XP['XP'].' / '.$XP['MaxXP']).'</td>'.
     265          '<td>'.$Selection.'</td><td>'.$Sequence.'</td></tr>';
     266    }
     267    $Output .= '</table>'.
     268        '</form>'.
     269        $PageList['Output'];
     270    return($Output);
     271  }
     272
     273  function ExportViewGeneral()
     274  {
     275    $DisabledInput = array(false => ' disabled="disabled"', true => '');
     276    $DisabledTextArea = array(false => ' readonly="yes"', true => '');
     277    $Output = '<h3>Obecná nastavení</h3>';
     278    $DbRows = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
     279    $Export = $DbRows->fetch_assoc();
     280    if($this->System->User->Licence(LICENCE_USER) and ($this->System->User->Id == $Export['User'])) $Editable = true;
     281    else $Editable = false;
     282
     283    if(array_key_exists('Operation', $_POST))
     284      if($_POST['Operation'] == 'Save')  if($Editable and array_key_exists('Title', $_POST) and array_key_exists('Description', $_POST))
     285      {
     286        if(array_key_exists('WithDiacritic', $_POST)) $WithDiacritic = 1;
     287        else $WithDiacritic = 0;
     288        if (array_key_exists('Featured', $_POST)) $Export['Featured'] = 1;
     289        $this->System->Database->query('UPDATE `Export` SET `Title`="'.$_POST['Title'].'", `Featured`='.$Export['Featured'].', `Description`="'.$_POST['Description'].'", `WithDiacritic`='.$WithDiacritic.' WHERE Id='.$Export['Id']);
     290        $Export['Title'] = $_POST['Title'];
     291        $Export['Description'] = $_POST['Description'];
     292        $Export['WithDiacritic'] = $WithDiacritic;
     293        $Output .= ShowMessage('Nastavení uloženo.');
     294      }
     295
     296      if($Export['WithDiacritic'] == 1) $WithDiacritic = ' checked="checked"';
     297      else $WithDiacritic = '';
     298      $Output .= '<form action="?Action=View&amp;Tab=0&amp;ExportId='.$Export['Id'].'" method="post">'.
     299          '<table>';
     300      if($this->System->User->Id != null)
     301      {
     302        $Output .= '<input type="hidden" name="Operation" value="Save"/>'.
     303            '<tr><td colspan="2">';
    304304        if($Editable) $Output .= ' <input type="submit" value="Uložit" '.$DisabledInput[$Editable].'/>';
    305         $Output .= ' <a href="?Action=Clone&amp;ExportId='.$Export['Id'].'" onclick="return confirmAction(\''.T('Realy clone item?').'\');">'.T('Clone').'</a> ';
     305        $Output .= ' <a href="?Action=Clone&amp;ExportId='.$Export['Id'].'" onclick="return confirmAction(\''.T('Realy clone item?').'\');">'.T('Clone').'</a> ';
    306306        if($this->System->User->Licence(LICENCE_ADMIN))
    307307          $Output .= CheckBox('Featured', $Export['Featured'], '', 'CheckBox', !$Editable). ' '.T('Recommended').' ';
    308308        $Output .= '</td></tr>';
    309                         }
    310                         $Output .= '<tr><td>'.T('Identification').':</td><td><input type="text" style="width: 400px" name="Title" value="'.$Export['Title'].'"'.$DisabledInput[$Editable].'/></td></tr>'.
    311                                         '<tr><td>Popis:</td><td><textarea name="Description" cols="54" rows="10"'.$DisabledTextArea[$Editable].'>'.$Export['Description'].'</textarea></td></tr>'.
    312                                         '<tr><td>'.T('With diacritics').'</td><td><input type="checkbox" name="WithDiacritic" '.$WithDiacritic.''.$DisabledInput[$Editable].'/></td></tr>'.
    313                                         '</table></form>';
    314                         return($Output);
    315         }
    316        
    317         function ExportViewLanguages()
    318         {
    319                 global $TranslationTree;
    320        
    321                 $Output = '';
    322                 $DisabledInput = array(false => ' disabled="disabled"', true => '');
    323                 $DbRows = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
    324                 $Export = $DbRows->fetch_assoc();
    325                 if($this->System->User->Licence(LICENCE_USER) and ($this->System->User->Id == $Export['User'])) $Editable = true;
    326                 else $Editable = false;
    327        
    328                 if(array_key_exists('Operation', $_POST))
    329                 {
    330                         if($_POST['Operation'] == 'Save')
    331                         {
    332                                 //print_r($_POST);
    333                                 // Update user selection page
    334                                 foreach($_POST as $Index => $Value)
    335                                 {
    336                                         if(substr($Index, 0, 3) == 'seq')
    337                                         {
    338                                                 $LanguageId = substr($Index, 3) * 1;
    339                                                 if(array_key_exists('sel'.$LanguageId, $_POST)) $Selected = true;
    340                                                 else $Selected = false;
    341                                                 $Condition = ' WHERE Export='.$_GET['ExportId'].' AND `Language`='.$LanguageId;
    342                                                 $DbResult = $this->System->Database->query('SELECT * FROM `ExportLanguage` '.$Condition);
    343                                                 if($DbResult->num_rows > 0)
    344                                                 {
    345                                                         if(!$Selected) $this->System->Database->query('DELETE FROM `ExportLanguage` '.$Condition);
    346                                                         else $this->System->Database->query('UPDATE `ExportLanguage` SET `Sequence`='.$Value.$Condition);
    347                                                 } else
    348                                                 {
    349                                                         if($Selected) $this->System->Database->query('INSERT INTO `ExportLanguage` (`Export`, `Language`, `Sequence`) VALUES ('.$_GET['ExportId'].', '.$LanguageId.', '.$Value.')');
    350                                                 }
    351                                         }
    352                                 }
    353        
    354                                 // Recalculate sequence number
    355                                 $this->System->Database->query('SET @I = 0');
    356                                 $this->System->Database->query('UPDATE `ExportLanguage` SET `Sequence` = (@I := @I + 1) WHERE `Export`='.$_GET['ExportId'].' ORDER BY `Sequence`;');
    357                                 $Output .= ShowMessage('Výběr uložen.');
    358                         }
    359                 }
    360        
    361                 $Query = 'SELECT (@I := @I + 1) AS `Sequence2`, `Sequence`, `Language`.`Id`, `Name` FROM `Language`';
    362                 $Query .=' LEFT JOIN `ExportLanguage` ON `ExportLanguage`.`Export` = '.$_GET['ExportId'].' AND `ExportLanguage`.`Language`=`Language`.`Id`';
    363                 $Query .=' WHERE `Language`.`Enabled` = 1 ORDER BY COALESCE(`Sequence`, 100)';
    364        
    365                 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS X');
    366                 $DbRow = $DbResult->fetch_row();
    367                 $PageList = GetPageList($DbRow[0]);
    368        
    369                 $TableColumns = array(
    370                                 array('Name' => 'Name', 'Title' => T('Name')),
    371                                 array('Name' => '', 'Title' => T('Select')),
    372                                 array('Name' => 'Sequence2', 'Title' => T('Order')),
    373                 );
    374                 $Order = GetOrderTableHeader($TableColumns, 'Sequence2');
    375                 $Output .= '<form action="?Action=View&amp;ExportId='.$_GET['ExportId'].'" method="post">'.
    376                                 '<h3>'.T('Languages').'</h3>';
    377                 if($Editable)
    378                 {
    379                         $Output .= '<input type="submit" value="'.T('Save').'" '.$DisabledInput[$Editable].'/>'.
    380                                         '<input type="hidden" name="Operation" value="Save"/>'.
    381                                         '<br />'.
    382                                         T('Select languades from list witch you want to export from. And edit theirs order.').'<br />'.
    383                                         T('Order is done by numeric value which is can be edit to desirable order. Lines with same number will be renumbered in ascending order.');
    384                 }
    385        
    386                 $Output .= $PageList['Output'].
    387                 '<table class="BaseTable">'.
    388                 $Order['Output'];
    389        
    390                 $Query = 'SELECT * FROM ('.$Query.') AS TX '.$Order['SQL'].$PageList['SQLLimit'];
    391                 $this->System->Database->query('SET @I = 0');
    392                 $DbResult = $this->System->Database->query($Query);
    393                 while($Langugage = $DbResult->fetch_assoc())
    394                 {
    395                         $Checked = $Langugage['Sequence'] != '';
    396                         $Selection = CheckBox('sel'.$Langugage['Id'], $Checked, '', 'CheckBox', !$Editable);
    397                         $Sequence = '<input type="text" name="seq'.$Langugage['Id'].'" style="text-align: center; width: 40px;" value="'.$Langugage['Sequence2'].'"'.$DisabledInput[$Editable].'/>';
    398                         $Output .= '<tr>
    399                         <td>'.$Langugage['Name'].'</td>
    400                         <td>'.$Selection.'</td><td>'.$Sequence.'</td></tr>';
    401                 }
    402                 $Output .= '</table>'.
    403                                 '</form>'.
    404                                 $PageList['Output'];
    405                 return($Output);
    406         }
    407        
    408         function ExportViewGroups()
    409         {
    410                 global $TranslationTree;
    411        
    412                 $Output = '';
    413                 $DisabledInput = array(false => ' disabled="disabled"', true => '');
    414                 $DbRows = $this->System->Database->query('SELECT * FROM Export WHERE Id='.$_GET['ExportId']);
    415                 $Export = $DbRows->fetch_assoc();
    416                 if($this->System->User->Licence(LICENCE_USER) and ($this->System->User->Id == $Export['User'])) $Editable = true;
    417                 else $Editable = false;
    418        
    419                 if(array_key_exists('Operation', $_POST))
    420                 {
    421                         if($_POST['Operation'] == 'Save')
    422                         {
    423                                 //print_r($_POST);
    424                                 // Update user selection page
    425                                 foreach($_POST as $Index => $Value)
    426                                 {
    427                                         if(substr($Index, 0, 3) == 'seq')
    428                                         {
    429                                                 $GroupId = substr($Index, 3) * 1;
    430                                                 if(array_key_exists('sel'.$GroupId, $_POST)) $Selected = true;
    431                                                 else $Selected = false;
    432                                                 $Condition = ' WHERE `Export`='.$_GET['ExportId'].' AND `Group`='.$GroupId;
    433                                                 $DbResult = $this->System->Database->query('SELECT * FROM `ExportGroup` '.$Condition);
    434                                                 if($DbResult->num_rows > 0)
    435                                                 {
    436                                                         if(!$Selected) $this->System->Database->query('DELETE FROM `ExportGroup` '.$Condition);
    437                                                 } else
    438                                                 {
    439                                                         if($Selected) $this->System->Database->query('INSERT INTO `ExportGroup` (`Export`, `Group`) VALUES ('.$_GET['ExportId'].', '.$GroupId.')');
    440                                                 }
    441                                         }
    442                                 }
    443                                 $Output .= ShowMessage(T('Select saved.'));
    444                         }
    445           //items
    446       foreach($TranslationTree as $Group) 
    447                 {
    448                 //  echo $Group['Id'].' ';
     309      }
     310      $Output .= '<tr><td>'.T('Identification').':</td><td><input type="text" style="width: 400px" name="Title" value="'.$Export['Title'].'"'.$DisabledInput[$Editable].'/></td></tr>'.
     311          '<tr><td>Popis:</td><td><textarea name="Description" cols="54" rows="10"'.$DisabledTextArea[$Editable].'>'.$Export['Description'].'</textarea></td></tr>'.
     312          '<tr><td>'.T('With diacritics').'</td><td><input type="checkbox" name="WithDiacritic" '.$WithDiacritic.''.$DisabledInput[$Editable].'/></td></tr>'.
     313          '</table></form>';
     314      return($Output);
     315  }
     316
     317  function ExportViewLanguages()
     318  {
     319    global $TranslationTree;
     320
     321    $Output = '';
     322    $DisabledInput = array(false => ' disabled="disabled"', true => '');
     323    $DbRows = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
     324    $Export = $DbRows->fetch_assoc();
     325    if($this->System->User->Licence(LICENCE_USER) and ($this->System->User->Id == $Export['User'])) $Editable = true;
     326    else $Editable = false;
     327
     328    if(array_key_exists('Operation', $_POST))
     329    {
     330      if($_POST['Operation'] == 'Save')
     331      {
     332        //print_r($_POST);
     333        // Update user selection page
     334        foreach($_POST as $Index => $Value)
     335        {
     336          if(substr($Index, 0, 3) == 'seq')
     337          {
     338            $LanguageId = substr($Index, 3) * 1;
     339            if(array_key_exists('sel'.$LanguageId, $_POST)) $Selected = true;
     340            else $Selected = false;
     341            $Condition = ' WHERE Export='.$_GET['ExportId'].' AND `Language`='.$LanguageId;
     342            $DbResult = $this->System->Database->query('SELECT * FROM `ExportLanguage` '.$Condition);
     343            if($DbResult->num_rows > 0)
     344            {
     345              if(!$Selected) $this->System->Database->query('DELETE FROM `ExportLanguage` '.$Condition);
     346              else $this->System->Database->query('UPDATE `ExportLanguage` SET `Sequence`='.$Value.$Condition);
     347            } else
     348            {
     349              if($Selected) $this->System->Database->query('INSERT INTO `ExportLanguage` (`Export`, `Language`, `Sequence`) VALUES ('.$_GET['ExportId'].', '.$LanguageId.', '.$Value.')');
     350            }
     351          }
     352        }
     353
     354        // Recalculate sequence number
     355        $this->System->Database->query('SET @I = 0');
     356        $this->System->Database->query('UPDATE `ExportLanguage` SET `Sequence` = (@I := @I + 1) WHERE `Export`='.$_GET['ExportId'].' ORDER BY `Sequence`;');
     357        $Output .= ShowMessage('Výběr uložen.');
     358      }
     359    }
     360
     361    $Query = 'SELECT (@I := @I + 1) AS `Sequence2`, `Sequence`, `Language`.`Id`, `Name` FROM `Language`';
     362    $Query .=' LEFT JOIN `ExportLanguage` ON `ExportLanguage`.`Export` = '.$_GET['ExportId'].' AND `ExportLanguage`.`Language`=`Language`.`Id`';
     363    $Query .=' WHERE `Language`.`Enabled` = 1 ORDER BY COALESCE(`Sequence`, 100)';
     364
     365    $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS X');
     366    $DbRow = $DbResult->fetch_row();
     367    $PageList = GetPageList($DbRow[0]);
     368
     369    $TableColumns = array(
     370        array('Name' => 'Name', 'Title' => T('Name')),
     371        array('Name' => '', 'Title' => T('Select')),
     372        array('Name' => 'Sequence2', 'Title' => T('Order')),
     373    );
     374    $Order = GetOrderTableHeader($TableColumns, 'Sequence2');
     375    $Output .= '<form action="?Action=View&amp;ExportId='.$_GET['ExportId'].'" method="post">'.
     376        '<h3>'.T('Languages').'</h3>';
     377    if($Editable)
     378    {
     379      $Output .= '<input type="submit" value="'.T('Save').'" '.$DisabledInput[$Editable].'/>'.
     380          '<input type="hidden" name="Operation" value="Save"/>'.
     381          '<br />'.
     382          T('Select languades from list witch you want to export from. And edit theirs order.').'<br />'.
     383          T('Order is done by numeric value which is can be edit to desirable order. Lines with same number will be renumbered in ascending order.');
     384    }
     385
     386    $Output .= $PageList['Output'].
     387    '<table class="BaseTable">'.
     388    $Order['Output'];
     389
     390    $Query = 'SELECT * FROM ('.$Query.') AS TX '.$Order['SQL'].$PageList['SQLLimit'];
     391    $this->System->Database->query('SET @I = 0');
     392    $DbResult = $this->System->Database->query($Query);
     393    while($Langugage = $DbResult->fetch_assoc())
     394    {
     395      $Checked = $Langugage['Sequence'] != '';
     396      $Selection = CheckBox('sel'.$Langugage['Id'], $Checked, '', 'CheckBox', !$Editable);
     397      $Sequence = '<input type="text" name="seq'.$Langugage['Id'].'" style="text-align: center; width: 40px;" value="'.$Langugage['Sequence2'].'"'.$DisabledInput[$Editable].'/>';
     398      $Output .= '<tr>
     399      <td>'.$Langugage['Name'].'</td>
     400      <td>'.$Selection.'</td><td>'.$Sequence.'</td></tr>';
     401    }
     402    $Output .= '</table>'.
     403        '</form>'.
     404        $PageList['Output'];
     405    return($Output);
     406  }
     407
     408  function ExportViewGroups()
     409  {
     410    global $TranslationTree;
     411
     412    $Output = '';
     413    $DisabledInput = array(false => ' disabled="disabled"', true => '');
     414    $DbRows = $this->System->Database->query('SELECT * FROM Export WHERE Id='.$_GET['ExportId']);
     415    $Export = $DbRows->fetch_assoc();
     416    if($this->System->User->Licence(LICENCE_USER) and ($this->System->User->Id == $Export['User'])) $Editable = true;
     417    else $Editable = false;
     418
     419    if(array_key_exists('Operation', $_POST))
     420    {
     421      if($_POST['Operation'] == 'Save')
     422      {
     423        //print_r($_POST);
     424        // Update user selection page
     425        foreach($_POST as $Index => $Value)
     426        {
     427          if(substr($Index, 0, 3) == 'seq')
     428          {
     429            $GroupId = substr($Index, 3) * 1;
     430            if(array_key_exists('sel'.$GroupId, $_POST)) $Selected = true;
     431            else $Selected = false;
     432            $Condition = ' WHERE `Export`='.$_GET['ExportId'].' AND `Group`='.$GroupId;
     433            $DbResult = $this->System->Database->query('SELECT * FROM `ExportGroup` '.$Condition);
     434            if($DbResult->num_rows > 0)
     435            {
     436              if(!$Selected) $this->System->Database->query('DELETE FROM `ExportGroup` '.$Condition);
     437            } else
     438            {
     439              if($Selected) $this->System->Database->query('INSERT INTO `ExportGroup` (`Export`, `Group`) VALUES ('.$_GET['ExportId'].', '.$GroupId.')');
     440            }
     441          }
     442        }
     443        $Output .= ShowMessage(T('Select saved.'));
     444      }
     445      //items
     446      foreach($TranslationTree as $Group)
     447      {
     448      //  echo $Group['Id'].' ';
    449449        foreach($TranslationTree[$Group['Id']]['Items'] as $Column) {
    450450          if(array_key_exists('item'.$Column['Id'], $_POST)) $Selected = true;
     
    452452          //we will save only forbitten collums and need to be visible
    453453          $Selected = !$Selected;
    454           if (!$Column['Visible']) $Selected = false; 
    455 
    456                                                 $Condition = ' WHERE `Export`='.$_GET['ExportId'].' AND `GroupItem`='.$Column['Id'];
    457                                                 $DbResult = $this->System->Database->query('SELECT * FROM `ExportGroupItem` '.$Condition);
    458                                                 if($DbResult->num_rows > 0)
    459                                                 {
    460                                                         if(!$Selected) $this->System->Database->query('DELETE FROM `ExportGroupItem` '.$Condition);
    461                                                 } else
    462                                                 {
    463                                                         if($Selected) $this->System->Database->query('INSERT INTO `ExportGroupItem` (`Export`, `GroupItem`) VALUES ('.$_GET['ExportId'].', '.$Column['Id'].')');
    464                                                 }
     454          if (!$Column['Visible']) $Selected = false;
     455
     456            $Condition = ' WHERE `Export`='.$_GET['ExportId'].' AND `GroupItem`='.$Column['Id'];
     457            $DbResult = $this->System->Database->query('SELECT * FROM `ExportGroupItem` '.$Condition);
     458            if($DbResult->num_rows > 0)
     459            {
     460              if(!$Selected) $this->System->Database->query('DELETE FROM `ExportGroupItem` '.$Condition);
     461            } else
     462            {
     463              if($Selected) $this->System->Database->query('INSERT INTO `ExportGroupItem` (`Export`, `GroupItem`) VALUES ('.$_GET['ExportId'].', '.$Column['Id'].')');
     464            }
    465465
    466466        }
    467467      }
    468                 }
    469        
    470                 $Query = 'SELECT `Group`.*, `ExportGroup`.`Id` AS `ExportGroupId` FROM `Group` LEFT JOIN `ExportGroup` ON `ExportGroup`.`Export`='.$_GET['ExportId'].' AND `Group`=`Group`.`Id`';
    471        
    472                 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS X');
    473                 $DbRow = $DbResult->fetch_row();
    474                 $PageList = GetPageList($DbRow[0]);
    475        
    476                 $TableColumns = array(
    477                                 array('Name' => '', 'Title' => T('Select')),
    478                                 array('Name' => 'Name', 'Title' => T('Name')),
    479                                 array('Name' => 'MangosTable', 'Title' => 'Mangos/DBC/Lua'),
    480                 //              array('Name' => 'DBCFileName', 'Title' => 'DBC soubor'),
    481                 //              array('Name' => 'LuaFileName', 'Title' => 'Lua soubor'),
    482                                 array('Name' => '', 'Title' => T('Items of tranlation')),
    483                 );
    484                 $Order = GetOrderTableHeader($TableColumns, 'Name');
    485                 $Output .= '<form action="?Action=View&amp;ExportId='.$_GET['ExportId'].'" method="post">'.
    486                                 '<h3>Překladové skupiny</h3>';
    487                 if($Editable)
    488                 {
    489                         $Output .= '<input type="submit" value="'.T('Save').'" '.$DisabledInput[$Editable].'/>'.
    490                                         '<input type="hidden" name="Operation" value="Save"/>'.
    491                                         ' <span onclick="CheckAllCheckbox();">'.CheckBox('CheckAll', False, 'CheckAll').' '.T('Select all').'</span> '.
    492                                         '<br />'.
    493                                         T('Select translation groups witch you want to export.').'<br />';
    494                 }
    495        
    496                 $Output .= $PageList['Output'].
    497                 '<table class="BaseTable">'.
    498                 $Order['Output'];
    499 
    500           $DbResultItem = $this->System->Database->query('SELECT * FROM `ExportGroupItem` WHERE `Export`='.$_GET['ExportId']);
    501                 while($GroupItem = $DbResultItem->fetch_assoc())
    502                 {
    503                   $GroupItems[$GroupItem['GroupItem']] = 1;
    504     }
    505        
    506                 $Query = 'SELECT * FROM ('.$Query.') AS TX '.$Order['SQL'].$PageList['SQLLimit'];
    507                 $DbResult = $this->System->Database->query($Query);
    508                 while($Group = $DbResult->fetch_assoc())
    509                 {
     468    }
     469
     470    $Query = 'SELECT `Group`.*, `ExportGroup`.`Id` AS `ExportGroupId` FROM `Group` LEFT JOIN `ExportGroup` ON `ExportGroup`.`Export`='.$_GET['ExportId'].' AND `Group`=`Group`.`Id`';
     471
     472    $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS X');
     473    $DbRow = $DbResult->fetch_row();
     474    $PageList = GetPageList($DbRow[0]);
     475
     476    $TableColumns = array(
     477        array('Name' => '', 'Title' => T('Select')),
     478        array('Name' => 'Name', 'Title' => T('Name')),
     479        array('Name' => 'MangosTable', 'Title' => 'Mangos/DBC/Lua'),
     480    //    array('Name' => 'DBCFileName', 'Title' => 'DBC soubor'),
     481    //    array('Name' => 'LuaFileName', 'Title' => 'Lua soubor'),
     482        array('Name' => '', 'Title' => T('Items of tranlation')),
     483    );
     484    $Order = GetOrderTableHeader($TableColumns, 'Name');
     485    $Output .= '<form action="?Action=View&amp;ExportId='.$_GET['ExportId'].'" method="post">'.
     486        '<h3>Překladové skupiny</h3>';
     487    if($Editable)
     488    {
     489      $Output .= '<input type="submit" value="'.T('Save').'" '.$DisabledInput[$Editable].'/>'.
     490          '<input type="hidden" name="Operation" value="Save"/>'.
     491          ' <span onclick="CheckAllCheckbox();">'.CheckBox('CheckAll', False, 'CheckAll').' '.T('Select all').'</span> '.
     492          '<br />'.
     493          T('Select translation groups witch you want to export.').'<br />';
     494    }
     495
     496    $Output .= $PageList['Output'].
     497    '<table class="BaseTable">'.
     498    $Order['Output'];
     499
     500    $DbResultItem = $this->System->Database->query('SELECT * FROM `ExportGroupItem` WHERE `Export`='.$_GET['ExportId']);
     501    while($GroupItem = $DbResultItem->fetch_assoc())
     502    {
     503      $GroupItems[$GroupItem['GroupItem']] = 1;
     504    }
     505
     506    $Query = 'SELECT * FROM ('.$Query.') AS TX '.$Order['SQL'].$PageList['SQLLimit'];
     507    $DbResult = $this->System->Database->query($Query);
     508    while($Group = $DbResult->fetch_assoc())
     509    {
    510510      $Columns = '';
    511511      foreach($TranslationTree[$Group['Id']]['Items'] as $Column) {
    512512        if ($Column['Visible'])  $Columns .= CheckBox('item'.$Column['Id'], !isset($GroupItems[$Column['Id']]), '', 'CheckBox', !$Editable).' '.$Column['Name'].' <br />';
    513513      }
    514                         $Checked = $Group['ExportGroupId'] != '';
    515                         $Selection = CheckBox('sel'.$Group['Id'], $Checked, '', 'CheckBox', !$Editable);
    516                         $Output .= '<tr>'.
    517                                         '<td>'.$Selection.'<input type="hidden" name="seq'.$Group['Id'].'"/></td>'.
    518                                         '<td>'.$Group['Name'].'</td><td>';
    519                                         if ($Group['MangosTable'] <> '')
    520                                           $Output .= $Group['MangosTable'].'.sql ';
    521                                         if ($Group['LuaFileName'] <> '')
    522                                           $Output .= $Group['LuaFileName'].'.lua ';
    523                                         if ($Group['DBCFileName'] <> '')
    524                                           $Output .= $Group['DBCFileName'].'.dbc ';
    525      
    526       $Output .=                '</td><td>';
    527       $Output .=        $Columns.       '</td>';
     514      $Checked = $Group['ExportGroupId'] != '';
     515      $Selection = CheckBox('sel'.$Group['Id'], $Checked, '', 'CheckBox', !$Editable);
     516      $Output .= '<tr>'.
     517          '<td>'.$Selection.'<input type="hidden" name="seq'.$Group['Id'].'"/></td>'.
     518          '<td>'.$Group['Name'].'</td><td>';
     519          if ($Group['MangosTable'] <> '')
     520            $Output .= $Group['MangosTable'].'.sql ';
     521          if ($Group['LuaFileName'] <> '')
     522            $Output .= $Group['LuaFileName'].'.lua ';
     523          if ($Group['DBCFileName'] <> '')
     524            $Output .= $Group['DBCFileName'].'.dbc ';
     525
     526      $Output .=    '</td><td>';
     527      $Output .=  $Columns. '</td>';
    528528      $Output .=     '</tr>';
    529                 }
    530                 $Output .= '</table>'.
    531                                 '</form>'.
    532                                 $PageList['Output'];
    533                 return($Output);
    534         }
    535        
    536         function ExportViewOutputFormat()
    537         {
    538                 $Output = '';
    539                 $DisabledInput = array(false => ' disabled="disabled"', true => '');
    540                 if(array_key_exists('ExportId', $_GET))
    541                 {
    542                         $DbRows = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
    543                         if($DbRows->num_rows > 0)
    544                         {
    545                                 $Export = $DbRows->fetch_assoc();
    546                                 if($this->System->User->Licence(LICENCE_USER) and ($this->System->User->Id == $Export['User'])) $Editable = true;
    547                                 else $Editable = false;
    548        
    549                                 if(array_key_exists('Operation', $_POST))
    550                                         if($_POST['Operation'] == 'Save')
    551                                         {
    552                                                 if(array_key_exists('OutputType', $_POST) and ($_POST['OutputType'] * 1 > 0))
    553                                                 {
    554                                                   $this->System->Database->query('UPDATE Export SET OutputType='.$_POST['OutputType'].' WHERE Id='.$_GET['ExportId']);
    555                                                   $Output .= ShowMessage(T('Select saved.'));
    556                                           } else $Output .= ShowMessage(T('Format wasn\'t selected'), MESSAGE_CRITICAL);
    557                                         }
    558        
    559                                         $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
    560                                         $Export = $DbResult->fetch_assoc();
    561        
    562                                         $Output .= '<h3>'.T('Format the generated output').'</h3>'.
    563                                                         '<form action="?Action=View&amp;ExportId='.$_GET['ExportId'].'" method="post">';
    564                                         if($Editable)
    565                                         {
    566                                                 $Output .= '<input type="submit" value="'.T('Save').'" '.$DisabledInput[$Editable].'/>'.
    567                                                                 '<input type="hidden" name="Operation" value="Save"/>'.
    568                                                                 '<br />';
    569                                         }
    570                                         $DbResult = $this->System->Database->query('SELECT * FROM `ExportOutputType` ORDER BY `Name`');
    571                                         while($ExportFormat = $DbResult->fetch_assoc())
    572                                         {
    573                                                 $Output .= RadioButton('OutputType', $ExportFormat['Id'], $Export['OutputType'] == $ExportFormat['Id'], '', !$Editable).' '.$ExportFormat['Name'].'<br/>';
    574                                         }
    575                                         $Output .= '</form>';
    576                         } else $Output .= ShowMessage(T('Item not found'), MESSAGE_CRITICAL);
    577                 } else $Output .= ShowMessage(T('Is isn\'t select'), MESSAGE_CRITICAL);
    578                 return($Output);
    579         }
    580        
    581         function ExportViewVersion()
    582         {
    583                 $Output = '';
    584                 $DisabledInput = array(false => ' disabled="disabled"', true => '');
    585                 $DbRows = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
    586                 $Export = $DbRows->fetch_assoc();
    587                 if($this->System->User->Licence(LICENCE_USER) and ($this->System->User->Id == $Export['User'])) $Editable = true;
    588                 else $Editable = false;
    589        
    590                 if(array_key_exists('Operation', $_POST))
    591                         if(($_POST['Operation'] == 'Save') and (array_key_exists('ClientVersion', $_POST)))
    592                         {
    593                                 $this->System->Database->query('UPDATE `Export` SET `ClientVersion`='.$_POST['ClientVersion'].' WHERE `Id`='.$_GET['ExportId']);
    594                                 $Output .= ShowMessage(T('Select saved.'));
    595                         }
    596        
    597                         $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
    598                         $Export = $DbResult->fetch_assoc();
    599        
    600                         if($Export['OutputType'] == '') $Output .= ShowMessage('Nevybrán typ exportu', MESSAGE_CRITICAL);
    601                         else {
    602                                 $Query = 'SELECT `ClientVersion`.* FROM `ExportVersion` '.
    603                                   'LEFT JOIN `ClientVersion` ON `ClientVersion`.`Id`=`ExportVersion`.`ClientVersion` WHERE `ExportType`='.$Export['OutputType'];
    604        
    605                                 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS `X`');
    606                                 $DbRow = $DbResult->fetch_row();
    607                                 $PageList = GetPageList($DbRow[0]);
    608        
    609                                 $TableColumns = array(
    610                                                 array('Name' => 'Version', 'Title' => T('Version')),
    611                                                 array('Name' => 'BuildNumber', 'Title' => T('Build')),
    612                                                 array('Name' => 'ReleaseDate', 'Title' => T('Release date')),
    613                                                 array('Name' => 'Title', 'Title' => T('Name2')),
    614                                                 array('Name' => '', 'Title' => T('Select')),
    615                                 );
    616                                 $Order = GetOrderTableHeader($TableColumns, 'BuildNumber', 1);
    617                                 $Output .= '<form action="?Action=View&amp;ExportId='.$_GET['ExportId'].'" method="post">'.
    618                                                 '<h3>'.T('Client version').'</h3>';
    619        
    620                                 if($Editable)
    621                                 {
    622                                         $Output .= '<input type="submit" value="'.T('Save').'" '.$DisabledInput[$Editable].'/>'.
    623                                                         '<input type="hidden" name="Operation" value="Save"/>'.
    624                                                         '<br />'.
    625                                                         T('Select version of game client witch you want to export.').'<br />';
    626                                 }
    627                                 $Output .= $PageList['Output'].
    628                                 '<table class="BaseTable">'.
    629                                 $Order['Output'];
    630        
    631                                 $Query = 'SELECT * FROM ('.$Query.') AS `TX` '.$Order['SQL'].$PageList['SQLLimit'];
    632                                 $DbResult = $this->System->Database->query($Query);
    633                                 while($Version = $DbResult->fetch_assoc())
    634                                 {
    635                                         $Output .= '<tr><td><a href="'.$this->System->Link('/client-version/?action=item&amp;id='.$Version['Id']).'">'.
    636                                                         $Version['Version'].'</a></td><td>'.$Version['BuildNumber'].'</td><td>'.
    637                                                         HumanDate($Version['ReleaseDate']).'</td><td>'.$Version['Title'].'</td><td>'.
    638                                                         RadioButton('ClientVersion', $Version['Id'], $Export['ClientVersion'] == $Version['Id'], '', !$Editable
    639                                                         ).'</td></tr>';
    640        
    641                                 }
    642                                 $Output .= '</table>'.
    643                                                 '</form>'.
    644                                                 $PageList['Output'];
    645                         }
    646                         return($Output);
    647         }
    648        
    649         function ExportViewOutput()
    650         {
    651                 $Output = '';
    652                 $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
    653                 $Export = $DbResult->fetch_assoc();
    654                 if($Export['OutputType'] == '') $Output .= ShowMessage('Nevybrán typ exportu', MESSAGE_CRITICAL);
    655                 else if($Export['ClientVersion'] == '') $Output .= ShowMessage(T('Export don\'t have selected version of client'), MESSAGE_CRITICAL);
    656                 else {
    657                         $DbResult = $this->System->Database->query('SELECT * FROM `ExportOutputType` WHERE `Id`='.$Export['OutputType']);
    658                         if($DbResult->num_rows > 0)
    659                         {
    660                                 $DbResult = $this->System->Database->query('SELECT * FROM `ExportVersion` WHERE (`ExportType`='.$Export['OutputType'].') AND (`ClientVersion`='.$Export['ClientVersion'].')');
    661                                 if($DbResult->num_rows > 0)
    662                                 {
    663                                   if (array_key_exists('Auto', $_GET) == false) 
    664                                           $this->System->Database->query('UPDATE `Export` SET `UsedCount` = `UsedCount` + 1 WHERE `Id`='.$Export['Id']);
    665                                         $Output = ExportOutput($Export['Id'], $Export['OutputType']);
    666                                 } else $Output = ShowMessage(T('Export don\'t have selected version of client'), MESSAGE_CRITICAL);
    667                         } else $Output = ShowMessage(T('Format output isn\'t select').'.', MESSAGE_CRITICAL);
    668                 }
    669                 return($Output);
    670         }
    671        
    672         function ExportViewStat($Where = '')
    673         {
    674                 $Export = new Export($this->System);
    675                 $Export->Id = $_GET['ExportId'];
    676                 $Export->Init();
    677                 $Export->LoadFilters();
    678        
    679                 if(($Export->Export['ClientVersion'] == '') or ($Export->ClientVersion['BuildNumber'] == ''))
    680                         $Output = ShowMessage(T('Export don\'t have selected version of client'), MESSAGE_CRITICAL);
    681                 else {
    682                         $GroupListQuery = 'SELECT `Group`.* FROM `Group` '.
    683                                         ' JOIN `ExportGroup` ON (`ExportGroup`.`Export`='.$Export->Id.') AND (`ExportGroup`.`Group`=`Group`.`Id`)';
    684                         $Query = '';
    685                         $UnionItems = array();
    686                         $DbResult = $this->System->Database->query($GroupListQuery.$Where);
    687                         while($DbRow = $DbResult->fetch_assoc())
    688                         {
    689                                 $UnionItems[] = 'SELECT (SELECT COUNT(DISTINCT(`Entry`)) FROM ('.
    690                                                 ' SELECT `T`.* FROM `'.$DbRow['TablePrefix'].'` AS `T`'.
    691                                                 ' JOIN `ExportUser` ON (`ExportUser`.`User`=`T`.`User`) AND (`ExportUser`.`Export`='.$Export->Id.') '.
    692                                                 ' JOIN `ExportLanguage` ON (`ExportLanguage`.`Export`='.$Export->Id.')'.
    693                                                 ' WHERE (`Complete` = 1) AND (`VersionStart` <= '.$Export->ClientVersion['BuildNumber'].') AND (`VersionEnd` >= '.$Export->ClientVersion['BuildNumber'].')'.
    694                                                 ') AS `C1`) AS `Translated`, '.
    695                                                 '(SELECT COUNT(DISTINCT(`Entry`)) FROM ('.
    696                                                 ' SELECT `T`.* FROM `'.$DbRow['TablePrefix'].'` AS `T`'.
    697                                                 ' WHERE (`Language` = '.$this->System->Config['OriginalLanguage'].') AND (`VersionStart` <= '.$Export->ClientVersion['BuildNumber'].') AND (`VersionEnd` >= '.$Export->ClientVersion['BuildNumber'].')'.
    698                                                 ') AS `C2`) AS `Total`, "'.$DbRow['Name'].'" AS `Name`';
    699                         }
    700                         $Query = substr($Query, 0, - 6);
    701        
    702                         $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM ('.$GroupListQuery.') AS `T`');
    703                         $DbRow = $DbResult->fetch_row();
    704                         $PageList = GetPageList($DbRow[0]);
    705                         $Output = '<h3>'.T('Statistic of coplection selected groups').'</h3>'.
    706                                 $PageList['Output'];
    707        
    708                         $Output .= '<table class="BaseTable">';
    709                         $TableColumns = array(
    710                                 array('Name' => 'Name', 'Title' => T('Name')),
    711                                 array('Name' => 'Translated', 'Title' => T('Translated count')),
    712                                 array('Name' => 'Total', 'Title' => T('English')),
    713                                 array('Name' => 'Percent', 'Title' => T('Percent')),
    714                         );
    715        
    716                         $Order = GetOrderTableHeader($TableColumns, 'Name', 0);
    717                         $Output .= $Order['Output'];
    718        
    719                         $Translated = 0;
    720                         $Total = 0;
    721                         if(count($UnionItems) > 0)
    722                         {
    723                                 $ID = $this->System->Database->query('SELECT *, ROUND(`Translated` / `Total` * 100, 2) AS `Percent` FROM ('.implode(' UNION ALL ', $UnionItems).') AS `C3` '.$Order['SQL'].$PageList['SQLLimit']);
    724                                 while($Group = $ID->fetch_assoc())
    725                                 {
    726                                         $Output .= '<tr><td>'.$Group['Name'].'</td><td>'.$Group['Translated'].'</td><td>'.$Group['Total'].'</td><td>'.ProgressBar(150, $Group['Percent']).'</td></tr>';
    727                                         $Translated += $Group['Translated'];
    728                                         $Total += $Group['Total'];
    729                                 }
    730                         }
    731                         if($Total > 0) $Percent = $Translated / $Total * 100;
    732                         else $Percent = 100;
    733        
    734                         $Output .= '<tr><td><strong>'.T('Altogether').'</strong></td><td><strong>'.$Translated.'</strong></td><td><strong>'.$Total.'</strong></td><td><strong>'.ProgressBar(150, round($Percent, 2)).'</strong></td></tr>';
    735                         $Output .= '</table>';
    736                 }
    737                 return($Output);
    738         }
    739        
    740         function ExportView()
    741         {
    742                 $Output = '';
    743                 if(array_key_exists('ExportId', $_GET) and is_numeric($_GET['ExportId']))
    744                 {
    745                         $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
    746                         if($DbResult->num_rows > 0)
    747                         {
    748                                 $Export = $DbResult->fetch_assoc();
    749        
    750                                 $DbResult = $this->System->Database->query('SELECT * FROM `User` WHERE `ID`='.$Export['User']);
    751                                 $UserLine = $DbResult->fetch_assoc();
    752                                 $Output .= 'Export <strong><a href="?Action=View&amp;Tab=6&amp;ExportId='.$Export['Id'].'">'.$_GET['ExportId'].'</a></strong> překladatele <strong>'.$UserLine['Name'].'</strong> s označením <strong>'.$Export['Title'].'</strong>';
    753                                 $Output .= ShowTabs(array(T('General'), T('Translators'), 'Překlady', T('Languages'), T('Format'), T('Version'), T('Statistic'), T('Output')));
    754                                 $Output .= '<div id="content">';
    755                                 if($_SESSION['Tab'] == TAB_GENERAL) $Output .= $this->ExportViewGeneral();
    756                                 else if($_SESSION['Tab'] == TAB_TRANSLATORS) $Output .= $this->ExportViewTranslators();
    757                                 else if($_SESSION['Tab'] == TAB_GROUPS) $Output .= $this->ExportViewGroups();
    758                                 else if($_SESSION['Tab'] == TAB_LANGUAGES) $Output .= $this->ExportViewLanguages();
    759                                 else if($_SESSION['Tab'] == TAB_OUTPUT_FORMAT) $Output .= $this->ExportViewOutputFormat();
    760                                 else if($_SESSION['Tab'] == TAB_VERSION) $Output .= $this->ExportViewVersion();
    761                                 else if($_SESSION['Tab'] == TAB_STAT) $Output .= $this->ExportViewStat();
    762                                 else if($_SESSION['Tab'] == TAB_OUTPUT) $Output .= $this->ExportViewOutput();
    763                                 else $Output .= $this->ExportViewGeneral();
    764        
    765                                 $Output .= '</div>';
    766                         } else $Output .= ShowMessage(T('Export not found.'), MESSAGE_CRITICAL);
    767                 } else $Output .= ShowMessage(T('Is isn\'t select'), MESSAGE_CRITICAL);
    768                 return($Output);
    769         }
    770        
    771         function ExportClone()
    772         {
    773                 if($this->System->User->Licence(LICENCE_USER))
    774                 {
    775                         if(array_key_exists('ExportId', $_GET) and is_numeric($_GET['ExportId']))
    776                         {
    777                                 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Export` WHERE `User`='.$this->System->User->Id);
    778                                 $DbRow = $DbResult->fetch_row();
    779                                 if($DbRow[0] < $this->System->Config['MaxExportPerUser'])
    780                                 {
    781                                   $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
    782                                   if($DbResult->num_rows > 0)
    783                                   {
    784                                     $DbRow = $DbResult->fetch_assoc();
    785                                     unset($DbRow['Id']);
    786                                     $DbRow['UsedCount'] = '0';
    787                                     $DbRow['User'] = $this->System->User->Id;                             
    788                                     $DbRow['TimeCreate'] = 'NOW()';
    789                                     $DbRow['Title'] .= ' - '.T('clone');
     529    }
     530    $Output .= '</table>'.
     531        '</form>'.
     532        $PageList['Output'];
     533    return($Output);
     534  }
     535
     536  function ExportViewOutputFormat()
     537  {
     538    $Output = '';
     539    $DisabledInput = array(false => ' disabled="disabled"', true => '');
     540    if(array_key_exists('ExportId', $_GET))
     541    {
     542      $DbRows = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
     543      if($DbRows->num_rows > 0)
     544      {
     545        $Export = $DbRows->fetch_assoc();
     546        if($this->System->User->Licence(LICENCE_USER) and ($this->System->User->Id == $Export['User'])) $Editable = true;
     547        else $Editable = false;
     548
     549        if(array_key_exists('Operation', $_POST))
     550          if($_POST['Operation'] == 'Save')
     551          {
     552            if(array_key_exists('OutputType', $_POST) and ($_POST['OutputType'] * 1 > 0))
     553            {
     554              $this->System->Database->query('UPDATE Export SET OutputType='.$_POST['OutputType'].' WHERE Id='.$_GET['ExportId']);
     555              $Output .= ShowMessage(T('Select saved.'));
     556            } else $Output .= ShowMessage(T('Format wasn\'t selected'), MESSAGE_CRITICAL);
     557          }
     558
     559          $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
     560          $Export = $DbResult->fetch_assoc();
     561
     562          $Output .= '<h3>'.T('Format the generated output').'</h3>'.
     563              '<form action="?Action=View&amp;ExportId='.$_GET['ExportId'].'" method="post">';
     564          if($Editable)
     565          {
     566            $Output .= '<input type="submit" value="'.T('Save').'" '.$DisabledInput[$Editable].'/>'.
     567                '<input type="hidden" name="Operation" value="Save"/>'.
     568                '<br />';
     569          }
     570          $DbResult = $this->System->Database->query('SELECT * FROM `ExportOutputType` ORDER BY `Name`');
     571          while($ExportFormat = $DbResult->fetch_assoc())
     572          {
     573            $Output .= RadioButton('OutputType', $ExportFormat['Id'], $Export['OutputType'] == $ExportFormat['Id'], '', !$Editable).' '.$ExportFormat['Name'].'<br/>';
     574          }
     575          $Output .= '</form>';
     576      } else $Output .= ShowMessage(T('Item not found'), MESSAGE_CRITICAL);
     577    } else $Output .= ShowMessage(T('Is isn\'t select'), MESSAGE_CRITICAL);
     578    return($Output);
     579  }
     580
     581  function ExportViewVersion()
     582  {
     583    $Output = '';
     584    $DisabledInput = array(false => ' disabled="disabled"', true => '');
     585    $DbRows = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
     586    $Export = $DbRows->fetch_assoc();
     587    if($this->System->User->Licence(LICENCE_USER) and ($this->System->User->Id == $Export['User'])) $Editable = true;
     588    else $Editable = false;
     589
     590    if(array_key_exists('Operation', $_POST))
     591      if(($_POST['Operation'] == 'Save') and (array_key_exists('ClientVersion', $_POST)))
     592      {
     593        $this->System->Database->query('UPDATE `Export` SET `ClientVersion`='.$_POST['ClientVersion'].' WHERE `Id`='.$_GET['ExportId']);
     594        $Output .= ShowMessage(T('Select saved.'));
     595      }
     596
     597      $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
     598      $Export = $DbResult->fetch_assoc();
     599
     600      if($Export['OutputType'] == '') $Output .= ShowMessage('Nevybrán typ exportu', MESSAGE_CRITICAL);
     601      else {
     602        $Query = 'SELECT `ClientVersion`.* FROM `ExportVersion` '.
     603          'LEFT JOIN `ClientVersion` ON `ClientVersion`.`Id`=`ExportVersion`.`ClientVersion` WHERE `ExportType`='.$Export['OutputType'];
     604
     605        $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS `X`');
     606        $DbRow = $DbResult->fetch_row();
     607        $PageList = GetPageList($DbRow[0]);
     608
     609        $TableColumns = array(
     610            array('Name' => 'Version', 'Title' => T('Version')),
     611            array('Name' => 'BuildNumber', 'Title' => T('Build')),
     612            array('Name' => 'ReleaseDate', 'Title' => T('Release date')),
     613            array('Name' => 'Title', 'Title' => T('Name2')),
     614            array('Name' => '', 'Title' => T('Select')),
     615        );
     616        $Order = GetOrderTableHeader($TableColumns, 'BuildNumber', 1);
     617        $Output .= '<form action="?Action=View&amp;ExportId='.$_GET['ExportId'].'" method="post">'.
     618            '<h3>'.T('Client version').'</h3>';
     619
     620        if($Editable)
     621        {
     622          $Output .= '<input type="submit" value="'.T('Save').'" '.$DisabledInput[$Editable].'/>'.
     623              '<input type="hidden" name="Operation" value="Save"/>'.
     624              '<br />'.
     625              T('Select version of game client witch you want to export.').'<br />';
     626        }
     627        $Output .= $PageList['Output'].
     628        '<table class="BaseTable">'.
     629        $Order['Output'];
     630
     631        $Query = 'SELECT * FROM ('.$Query.') AS `TX` '.$Order['SQL'].$PageList['SQLLimit'];
     632        $DbResult = $this->System->Database->query($Query);
     633        while($Version = $DbResult->fetch_assoc())
     634        {
     635          $Output .= '<tr><td><a href="'.$this->System->Link('/client-version/?action=item&amp;id='.$Version['Id']).'">'.
     636              $Version['Version'].'</a></td><td>'.$Version['BuildNumber'].'</td><td>'.
     637              HumanDate($Version['ReleaseDate']).'</td><td>'.$Version['Title'].'</td><td>'.
     638              RadioButton('ClientVersion', $Version['Id'], $Export['ClientVersion'] == $Version['Id'], '', !$Editable
     639              ).'</td></tr>';
     640
     641        }
     642        $Output .= '</table>'.
     643            '</form>'.
     644            $PageList['Output'];
     645      }
     646      return($Output);
     647  }
     648
     649  function ExportViewOutput()
     650  {
     651    $Output = '';
     652    $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
     653    $Export = $DbResult->fetch_assoc();
     654    if($Export['OutputType'] == '') $Output .= ShowMessage('Nevybrán typ exportu', MESSAGE_CRITICAL);
     655    else if($Export['ClientVersion'] == '') $Output .= ShowMessage(T('Export don\'t have selected version of client'), MESSAGE_CRITICAL);
     656    else {
     657      $DbResult = $this->System->Database->query('SELECT * FROM `ExportOutputType` WHERE `Id`='.$Export['OutputType']);
     658      if($DbResult->num_rows > 0)
     659      {
     660        $DbResult = $this->System->Database->query('SELECT * FROM `ExportVersion` WHERE (`ExportType`='.$Export['OutputType'].') AND (`ClientVersion`='.$Export['ClientVersion'].')');
     661        if($DbResult->num_rows > 0)
     662        {
     663          if (array_key_exists('Auto', $_GET) == false)
     664            $this->System->Database->query('UPDATE `Export` SET `UsedCount` = `UsedCount` + 1 WHERE `Id`='.$Export['Id']);
     665          $Output = ExportOutput($Export['Id'], $Export['OutputType']);
     666        } else $Output = ShowMessage(T('Export don\'t have selected version of client'), MESSAGE_CRITICAL);
     667      } else $Output = ShowMessage(T('Format output isn\'t select').'.', MESSAGE_CRITICAL);
     668    }
     669    return($Output);
     670  }
     671
     672  function ExportViewStat($Where = '')
     673  {
     674    $Export = new Export($this->System);
     675    $Export->Id = $_GET['ExportId'];
     676    $Export->Init();
     677    $Export->LoadFilters();
     678
     679    if(($Export->Export['ClientVersion'] == '') or ($Export->ClientVersion['BuildNumber'] == ''))
     680      $Output = ShowMessage(T('Export don\'t have selected version of client'), MESSAGE_CRITICAL);
     681    else {
     682      $GroupListQuery = 'SELECT `Group`.* FROM `Group` '.
     683          ' JOIN `ExportGroup` ON (`ExportGroup`.`Export`='.$Export->Id.') AND (`ExportGroup`.`Group`=`Group`.`Id`)';
     684      $Query = '';
     685      $UnionItems = array();
     686      $DbResult = $this->System->Database->query($GroupListQuery.$Where);
     687      while($DbRow = $DbResult->fetch_assoc())
     688      {
     689        $UnionItems[] = 'SELECT (SELECT COUNT(DISTINCT(`Entry`)) FROM ('.
     690            ' SELECT `T`.* FROM `'.$DbRow['TablePrefix'].'` AS `T`'.
     691            ' JOIN `ExportUser` ON (`ExportUser`.`User`=`T`.`User`) AND (`ExportUser`.`Export`='.$Export->Id.') '.
     692            ' JOIN `ExportLanguage` ON (`ExportLanguage`.`Export`='.$Export->Id.')'.
     693            ' WHERE (`Complete` = 1) AND (`VersionStart` <= '.$Export->ClientVersion['BuildNumber'].') AND (`VersionEnd` >= '.$Export->ClientVersion['BuildNumber'].')'.
     694            ') AS `C1`) AS `Translated`, '.
     695            '(SELECT COUNT(DISTINCT(`Entry`)) FROM ('.
     696            ' SELECT `T`.* FROM `'.$DbRow['TablePrefix'].'` AS `T`'.
     697            ' WHERE (`Language` = '.$this->System->Config['OriginalLanguage'].') AND (`VersionStart` <= '.$Export->ClientVersion['BuildNumber'].') AND (`VersionEnd` >= '.$Export->ClientVersion['BuildNumber'].')'.
     698            ') AS `C2`) AS `Total`, "'.$DbRow['Name'].'" AS `Name`';
     699      }
     700      $Query = substr($Query, 0, - 6);
     701
     702      $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM ('.$GroupListQuery.') AS `T`');
     703      $DbRow = $DbResult->fetch_row();
     704      $PageList = GetPageList($DbRow[0]);
     705      $Output = '<h3>'.T('Statistic of coplection selected groups').'</h3>'.
     706        $PageList['Output'];
     707
     708      $Output .= '<table class="BaseTable">';
     709      $TableColumns = array(
     710        array('Name' => 'Name', 'Title' => T('Name')),
     711        array('Name' => 'Translated', 'Title' => T('Translated count')),
     712        array('Name' => 'Total', 'Title' => T('English')),
     713        array('Name' => 'Percent', 'Title' => T('Percent')),
     714      );
     715
     716      $Order = GetOrderTableHeader($TableColumns, 'Name', 0);
     717      $Output .= $Order['Output'];
     718
     719      $Translated = 0;
     720      $Total = 0;
     721      if(count($UnionItems) > 0)
     722      {
     723        $ID = $this->System->Database->query('SELECT *, ROUND(`Translated` / `Total` * 100, 2) AS `Percent` FROM ('.implode(' UNION ALL ', $UnionItems).') AS `C3` '.$Order['SQL'].$PageList['SQLLimit']);
     724        while($Group = $ID->fetch_assoc())
     725        {
     726          $Output .= '<tr><td>'.$Group['Name'].'</td><td>'.$Group['Translated'].'</td><td>'.$Group['Total'].'</td><td>'.ProgressBar(150, $Group['Percent']).'</td></tr>';
     727          $Translated += $Group['Translated'];
     728          $Total += $Group['Total'];
     729        }
     730      }
     731      if($Total > 0) $Percent = $Translated / $Total * 100;
     732      else $Percent = 100;
     733
     734      $Output .= '<tr><td><strong>'.T('Altogether').'</strong></td><td><strong>'.$Translated.'</strong></td><td><strong>'.$Total.'</strong></td><td><strong>'.ProgressBar(150, round($Percent, 2)).'</strong></td></tr>';
     735      $Output .= '</table>';
     736    }
     737    return($Output);
     738  }
     739
     740  function ExportView()
     741  {
     742    $Output = '';
     743    if(array_key_exists('ExportId', $_GET) and is_numeric($_GET['ExportId']))
     744    {
     745      $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
     746      if($DbResult->num_rows > 0)
     747      {
     748        $Export = $DbResult->fetch_assoc();
     749
     750        $DbResult = $this->System->Database->query('SELECT * FROM `User` WHERE `ID`='.$Export['User']);
     751        $UserLine = $DbResult->fetch_assoc();
     752        $Output .= 'Export <strong><a href="?Action=View&amp;Tab=6&amp;ExportId='.$Export['Id'].'">'.$_GET['ExportId'].'</a></strong> překladatele <strong>'.$UserLine['Name'].'</strong> s označením <strong>'.$Export['Title'].'</strong>';
     753        $Output .= ShowTabs(array(T('General'), T('Translators'), 'Překlady', T('Languages'), T('Format'), T('Version'), T('Statistic'), T('Output')));
     754        $Output .= '<div id="content">';
     755        if($_SESSION['Tab'] == TAB_GENERAL) $Output .= $this->ExportViewGeneral();
     756        else if($_SESSION['Tab'] == TAB_TRANSLATORS) $Output .= $this->ExportViewTranslators();
     757        else if($_SESSION['Tab'] == TAB_GROUPS) $Output .= $this->ExportViewGroups();
     758        else if($_SESSION['Tab'] == TAB_LANGUAGES) $Output .= $this->ExportViewLanguages();
     759        else if($_SESSION['Tab'] == TAB_OUTPUT_FORMAT) $Output .= $this->ExportViewOutputFormat();
     760        else if($_SESSION['Tab'] == TAB_VERSION) $Output .= $this->ExportViewVersion();
     761        else if($_SESSION['Tab'] == TAB_STAT) $Output .= $this->ExportViewStat();
     762        else if($_SESSION['Tab'] == TAB_OUTPUT) $Output .= $this->ExportViewOutput();
     763        else $Output .= $this->ExportViewGeneral();
     764
     765        $Output .= '</div>';
     766      } else $Output .= ShowMessage(T('Export not found.'), MESSAGE_CRITICAL);
     767    } else $Output .= ShowMessage(T('Is isn\'t select'), MESSAGE_CRITICAL);
     768    return($Output);
     769  }
     770
     771  function ExportClone()
     772  {
     773    if($this->System->User->Licence(LICENCE_USER))
     774    {
     775      if(array_key_exists('ExportId', $_GET) and is_numeric($_GET['ExportId']))
     776      {
     777        $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Export` WHERE `User`='.$this->System->User->Id);
     778        $DbRow = $DbResult->fetch_row();
     779        if($DbRow[0] < $this->System->Config['MaxExportPerUser'])
     780        {
     781          $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
     782          if($DbResult->num_rows > 0)
     783          {
     784            $DbRow = $DbResult->fetch_assoc();
     785            unset($DbRow['Id']);
     786            $DbRow['UsedCount'] = '0';
     787            $DbRow['User'] = $this->System->User->Id;
     788            $DbRow['TimeCreate'] = 'NOW()';
     789            $DbRow['Title'] .= ' - '.T('clone');
    790790            $DbRow['Featured'] = 0;
    791                                           $this->System->Database->insert('Export', $DbRow);
    792                                     $ExportId = $this->System->Database->insert_id;                                     
    793                                     $this->System->Database->query('INSERT INTO `ExportGroup` (SELECT NULL AS `Id`, '.$ExportId.' AS `Export`, `Group` FROM `ExportGroup` WHERE `Export`='.$_GET['ExportId'].')');
    794                                     $this->System->Database->query('INSERT INTO `ExportGroupItem` (SELECT NULL AS `Id`, '.$ExportId.' AS `Export`, `GroupItem` FROM `ExportGroupItem` WHERE `Export`='.$_GET['ExportId'].')');
    795                                     $this->System->Database->query('INSERT INTO `ExportLanguage` (SELECT NULL AS `Id`, '.$ExportId.' AS `Export`, `Language`, `Sequence` FROM `ExportLanguage` WHERE `Export`='.$_GET['ExportId'].')');
    796                                     $this->System->Database->query('INSERT INTO `ExportUser` (SELECT NULL AS `Id`, '.$ExportId.' AS `Export`, `User`, `Sequence` FROM `ExportUser` WHERE `Export`='.$_GET['ExportId'].')');
    797                                           $Output = ShowMessage(T('Clone export created.<br />Direct link to export').': <a href="?Action=View&amp;ExportId='.$ExportId.'">zde</a>');
    798                                           $this->System->ModuleManager->Modules['Log']->WriteLog(T('Clone export created').' <a href="'.$this->System->Link('/export/?Action=View&amp;ExportId='.$ExportId).'">'.$ExportId.'</a>.', LOG_TYPE_EXPORT);
    799                                           $_GET['Filter'] = 'my';
    800                                           $this->ExportList();
    801                                         } else $Output = ShowMessage('Zdrojový export nenalezen', MESSAGE_CRITICAL);
    802                                 } else $Output = ShowMessage('Nemůžete vytvářet další export. Max. počet na uživatele je '.
    803                                         $this->System->Config['MaxExportPerUser'].'.', MESSAGE_CRITICAL);
    804                         } else $Output = ShowMessage(T('Export not found.'), MESSAGE_CRITICAL);
    805                 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
    806                 return($Output);
    807         }
    808        
    809         function Show()
    810   {
    811         $this->Title = T('Export');
     791            $this->System->Database->insert('Export', $DbRow);
     792            $ExportId = $this->System->Database->insert_id;
     793            $this->System->Database->query('INSERT INTO `ExportGroup` (SELECT NULL AS `Id`, '.$ExportId.' AS `Export`, `Group` FROM `ExportGroup` WHERE `Export`='.$_GET['ExportId'].')');
     794            $this->System->Database->query('INSERT INTO `ExportGroupItem` (SELECT NULL AS `Id`, '.$ExportId.' AS `Export`, `GroupItem` FROM `ExportGroupItem` WHERE `Export`='.$_GET['ExportId'].')');
     795            $this->System->Database->query('INSERT INTO `ExportLanguage` (SELECT NULL AS `Id`, '.$ExportId.' AS `Export`, `Language`, `Sequence` FROM `ExportLanguage` WHERE `Export`='.$_GET['ExportId'].')');
     796            $this->System->Database->query('INSERT INTO `ExportUser` (SELECT NULL AS `Id`, '.$ExportId.' AS `Export`, `User`, `Sequence` FROM `ExportUser` WHERE `Export`='.$_GET['ExportId'].')');
     797            $Output = ShowMessage(T('Clone export created.<br />Direct link to export').': <a href="?Action=View&amp;ExportId='.$ExportId.'">zde</a>');
     798            $this->System->ModuleManager->Modules['Log']->WriteLog(T('Clone export created').' <a href="'.$this->System->Link('/export/?Action=View&amp;ExportId='.$ExportId).'">'.$ExportId.'</a>.', LOG_TYPE_EXPORT);
     799            $_GET['Filter'] = 'my';
     800            $this->ExportList();
     801          } else $Output = ShowMessage('Zdrojový export nenalezen', MESSAGE_CRITICAL);
     802        } else $Output = ShowMessage('Nemůžete vytvářet další export. Max. počet na uživatele je '.
     803          $this->System->Config['MaxExportPerUser'].'.', MESSAGE_CRITICAL);
     804      } else $Output = ShowMessage(T('Export not found.'), MESSAGE_CRITICAL);
     805    } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
     806    return($Output);
     807  }
     808
     809  function Show()
     810  {
     811    $this->Title = T('Export');
    812812    if(array_key_exists('Action', $_GET))
    813813    {
     
    820820    } else $Output = $this->ExportList();
    821821    return($Output);
    822   } 
     822  }
    823823}
Note: See TracChangeset for help on using the changeset viewer.