Changeset 905


Ignore:
Timestamp:
Feb 19, 2021, 12:39:23 PM (3 years ago)
Author:
chronos
Message:
  • Added: New item clone action in IS module.
Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/Version.php

    r904 r905  
    11<?php
    22
    3 $Revision = 904; // Subversion revision
     3$Revision = 905; // Subversion revision
    44$DatabaseRevision = 901; // SQL structure revision
    55$ReleaseTime = strtotime('2021-02-19');
  • trunk/Modules/Contract/Contract.php

    r904 r905  
    274274    $SignDate = HumanDate($Contract['ValidFrom']);
    275275
    276 
    277276    $Output = '<html>
    278277    <head></head>
  • trunk/Modules/IS/IS.php

    r899 r905  
    5353    else if ($Action == 'mapselect') $Content = $this->ShowMapSelect($Table);
    5454    else if ($Action == 'edit') $Content = $this->ShowEdit($Table, $ItemId);
     55    else if ($Action == 'clone') $Content = $this->ShowClone($Table, $ItemId);
    5556    else if ($Action == 'add') $Content = $this->ShowAdd($Table);
    5657    else if ($Action == 'addsub') $Content = $this->ShowAddSub($Table);
     
    200201          $Output .= '<li>'.$this->ShowAction('Prohlížet', '?a=view&amp;t='.$Table.'&amp;i='.$Id,
    201202            $this->System->Link('/images/view.png'));
     203          $Output .= '<li>'.$this->ShowAction('Duplikovat', '?a=clone&amp;t='.$Table.'&amp;i='.$Id,
     204            $this->System->Link('/images/clone.png'));
    202205          $Output .= '<li>'.$this->ShowAction('Seznam', '?a=list&amp;t='.$Table,
    203206            $this->System->Link('/images/list.png'));
     
    218221      $Output .= '<li>'.$this->ShowAction('Prohlížet', '?a=view&amp;t='.$Table.'&amp;i='.$Id,
    219222        $this->System->Link('/images/view.png'));
     223      $Output .= '<li>'.$this->ShowAction('Duplikovat', '?a=clone&amp;t='.$Table.'&amp;i='.$Id,
     224        $this->System->Link('/images/clone.png'));
    220225      $Output .= '<li>'.$this->ShowAction('Seznam', '?a=list&amp;t='.$Table,
    221226        $this->System->Link('/images/list.png'));
     
    224229      $Output .= '</ul>';
    225230    }
     231    return $Output;
     232  }
     233
     234  function ShowClone(string $Table, string $Id, array $Actions = array()): string
     235  {
     236    $Output = '';
     237    if (!array_key_exists($Table, $this->System->FormManager->Classes))
     238      return $this->SystemMessage('Chyba', 'Tabulka '.$Table.' nenalezena');
     239    if (defined('NEW_PERMISSION') and !ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission($this->TableToModule($Table), 'Write'))
     240      return 'Nemáte oprávnění';
     241    if (array_key_exists('o', $_GET))
     242    {
     243      if ($_GET['o'] == 'save')
     244      {
     245        $Form = new Form($this->System->FormManager);
     246        $Form->SetClass($Table);
     247        $Form->LoadValuesFromForm();
     248        $this->ShortTitle .= ' - '.$Form->Definition['Title'].' duplikování';
     249        try
     250        {
     251          $Form->Validate();
     252          if (array_key_exists('BeforeInsert', $Form->Definition))
     253          {
     254            $Class = $Form->Definition['BeforeInsert'][0];
     255            $Method = $Form->Definition['BeforeInsert'][1];
     256            $Form->Values = $Class->$Method($Form);
     257          }
     258          $Form->Validate();
     259          $Form->SaveValuesToDatabase(0);
     260          $Id = $this->Database->insert_id;
     261          $this->LogChange($Form, 'Clone', $Id, 0);
     262          $Output .= $this->SystemMessage('Duplikování položky', 'Nová kopie položky vytvořena');
     263          $Output .= $this->ShowView($Table, $Id, $_GET['a'] == 'addsub');
     264          if (array_key_exists('AfterInsert', $Form->Definition))
     265          {
     266            $Class = $Form->Definition['AfterInsert'][0];
     267            $Method = $Form->Definition['AfterInsert'][1];
     268            $Form->Values = $Class->$Method($Form, $Id);
     269          }
     270
     271        //$this->Database->update($Table, 'Id='.$Id,
     272        //  array('UserCreate' => ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'],
     273        //  'TimeCreate' => 'NOW()'));
     274        } catch (Exception $E)
     275        {
     276          $Output .= $this->SystemMessage('Duplikování položky', 'Položku se nepodařilo duplikovat. Opravte problém a opakujte akci.<br/>'.$E->getMessage());
     277          $Form->OnSubmit = '?a=clone&amp;t='.$Table.'&amp;o=save';
     278          $Output .= $Form->ShowEditForm();
     279          $Actions[] = '<a href="?a=list&amp;t='.$Table.'"><img alt="Seznam" title="Seznam" src="'.
     280            $this->System->Link('/images/list.png').'"/>Seznam</a>';
     281        }
     282      }
     283    } else
     284    {
     285      $Form = new Form($this->System->FormManager);
     286      $Form->SetClass($Table);
     287      $Form->LoadValuesFromDatabase($Id);
     288      $this->ShortTitle .= ' - '.$Form->Definition['Title'].' duplikování';
     289      $Form->OnSubmit = '?a='.$_GET['a'].'&amp;t='.$Table.'&amp;o=save';
     290      $Output .= $Form->ShowEditForm();
     291      $Actions[] = $this->ShowAction('Seznam', '?a=list&amp;t='.$Table,
     292        $this->System->Link('/images/list.png'));
     293    }
     294    $Output .= '<ul class="ActionMenu">';
     295    foreach ($Actions as $Action)
     296    {
     297      $Output .= '<li>'.$Action.'</li>';
     298    }
     299    $Output .= '</ul>';
    226300    return $Output;
    227301  }
     
    412486        $this->ShowAction('Upravit', '?a=edit&amp;t='.$TableModify.'&amp;i='.$Id,
    413487          $this->System->Link('/images/edit.png')),
     488        $this->ShowAction('Duplikovat', '?a=clone&amp;t='.$TableModify.'&amp;i='.$Id,
     489          $this->System->Link('/images/clone.png')),
    414490        $this->ShowAction('Seznam', '?a=list&amp;t='.$Table,
    415491          $this->System->Link('/images/list.png')),
     
    713789      else $TableModify = $Table;
    714790
    715     $RowActions = '<a href="?a=view&amp;t='.$Table.'&amp;i=#RowId"><img alt="Ukázat" title="Ukázat" src="'.
    716       $this->System->Link('/images/view.png').'"/></a>'.
    717       '<a href="?a=edit&amp;t='.$TableModify.'&amp;i=#RowId"><img alt="Upravit" title="Upravit" src="'.
    718       $this->System->Link('/images/edit.png').'"/></a>'.
    719       '<a href="?a=delete&amp;t='.$Table.'&amp;i=#RowId"><img alt="Smazat" title="Smazat" src="'.
    720       $this->System->Link('/images/delete.png').'" onclick="return confirmAction(\'Opravdu smazat položku?\');"/></a>';
     791    $RowActions =
     792      $this->ShowAction('Ukázat', '?a=view&amp;t='.$Table.'&amp;i=#RowId', $this->System->Link('/images/view.png')).
     793      $this->ShowAction('Upravit', '?a=edit&amp;t='.$TableModify.'&amp;i=#RowId', $this->System->Link('/images/edit.png')).
     794      $this->ShowAction('Duplikovat', '?a=clone&amp;t='.$TableModify.'&amp;i=#RowId', $this->System->Link('/images/clone.png')).
     795      $this->ShowAction('Odstranit', '?a=delete&amp;t='.$Table.'&amp;i=#RowId', $this->System->Link('/images/delete.png'), 'Opravdu smazat položku?;');
    721796    if (($Table != '') and (array_key_exists($Table, $this->System->FormManager->Classes)))
    722797      $FormClass = $this->System->FormManager->Classes[$Table];
Note: See TracChangeset for help on using the changeset viewer.