Changeset 433


Ignore:
Timestamp:
Oct 12, 2012, 8:27:30 AM (12 years ago)
Author:
chronos
Message:
  • Přidáno: Možnost mazat položky.
  • Přidáno: Přidávání a změna hodnot položek.
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • branches/Modular/Modules/System/System.php

    r425 r433  
    118118class ModuleSystem extends Module
    119119{
     120  var $InstalledChecked;
     121       
    120122  function __construct($Database, $System)
    121123  {
     
    216218  function IsInstalled()
    217219  {
    218     $DbResult = $this->Database->query('SELECT table_name FROM information_schema.tables
     220    if($this->InstalledChecked == false)
     221    {
     222      $DbResult = $this->Database->query('SELECT table_name FROM information_schema.tables
    219223WHERE table_schema = "'.$this->Database->Database.'" AND table_name = "SystemVersion";');   
    220     if($DbResult->num_rows > 0) return(true);
    221       else return(false);
     224      if($DbResult->num_rows > 0) $this->Installed = true;
     225        else $this->Installed = false;
     226      $this->InstalledChecked = true;
     227    }
     228    return($this->Installed);
    222229  }
    223230 
  • trunk/form_classes.php

    r432 r433  
    22
    33$FormClasses = array(
     4  'FinanceTreasury' => array(
     5    'Title' => 'Pokladny',
     6    'Table' => 'FinanceTreasury',
     7    'DefaultSortColumn' => 'Name',
     8    'Items' => array(
     9      'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
     10      'TimeCreate' => array('Type' => 'Date', 'Caption' => 'Čas vytvoření', 'Default' => ''),
     11    ),
     12  ),
     13  'FinanceBankAccount' => array(
     14    'Title' => 'Účty',
     15    'Table' => 'FinanceBankAccount',
     16    'DefaultSortColumn' => 'Comment',
     17    'Items' => array(
     18      'Comment' => array('Type' => 'String', 'Caption' => 'Komentář', 'Default' => ''),
     19      'Number' => array('Type' => 'String', 'Caption' => 'Číslo', 'Default' => ''),
     20      'TimeCreate' => array('Type' => 'Date', 'Caption' => 'Čas vytvoření', 'Default' => ''),
     21    ),
     22  ),
    423  'Country' => array(
    524    'Title' => 'Země',
     
    1938      'Password' => array('Type' => 'Password', 'Caption' => 'Heslo', 'Default' => ''),
    2039      'Email' => array('Type' => 'String', 'Caption' => 'E-mail', 'Default' => ''),
    21       'LastIP' => array('Type' => 'String', 'Caption' => 'Poslední IP adresy', 'Default' => ''),
     40      'LastIpAddress' => array('Type' => 'String', 'Caption' => 'Poslední IP adresy', 'Default' => ''),
    2241      'LastLoginTime' => array('Type' => 'DateTime', 'Caption' => 'Poslední čas přihlášení', 'Default' => ''),
    2342      'RegistrationTime' => array('Type' => 'DateTime', 'Caption' => 'Čas registrace', 'Default' => ''),
  • trunk/forms.php

    r431 r433  
    193193    {
    194194      $this->Values['Id'] = $Id;
    195       $DbResult = $Database->replace($this->Definition['Table'], $this->Values);
     195      $DbResult = $Database->insert($this->Definition['Table'], $this->Values);
    196196    } else
    197197    $DbResult = $Database->update($this->Definition['Table'], 'Id='.$Id, $this->Values);
  • trunk/is/index.php

    r431 r433  
    3030    if(array_key_exists('a', $_GET)) $_SESSION['Action'] = $_GET['a'];
    3131    if(array_key_exists('id', $_GET)) $_SESSION['Id'] = $_GET['id'];
    32    
    33     if($_SESSION['Action'] == 'list')
    34     {
    35       if(array_key_exists('Table', $_SESSION))
    36         $Output .= $this->ShowList($FormClasses[$_SESSION['Table']]);
    37     } else
    38     if($_SESSION['Action'] == 'edit') $Output .= $this->ShowEdit();
     32       
     33    if(!array_key_exists('Action', $_SESSION)) $_SESSION['Action'] = 'list';
     34   
     35    if($_SESSION['Action'] == 'list') $Output .= $this->ShowList();
     36    else if($_SESSION['Action'] == 'edit') $Output .= $this->ShowEdit();
    3937    else if($_SESSION['Action'] == 'add') $Output .= $this->ShowAdd();
    4038    else if($_SESSION['Action'] == 'view') $Output .= $this->ShowView();
     
    4745  function ShowEdit()
    4846  {
    49     $Form = new Form($_SESSION['Table']);
    50     $Form->LoadValuesFromDatabase($_SESSION['Id']);
    51     $Form->OnSubmit = '?a=view';
    52     $Output = $Form->ShowEditForm();
     47    $Output = '';
     48    if(array_key_exists('o', $_GET))
     49    {
     50      if($_GET['o'] == 'save')
     51      {
     52        $Form = new Form($_SESSION['Table']);
     53        $Form->LoadValuesFromForm();
     54        $Form->SaveValuesToDatabase($_SESSION['Id']);
     55        $Output .= $this->SystemMessage('Úprava položky', 'Položka upravena');
     56        $_SESSION['Action'] = 'view';
     57        $Output .= $this->ShowView();   
     58      }
     59    } else
     60    {
     61      $Form = new Form($_SESSION['Table']);
     62      $Form->LoadValuesFromDatabase($_SESSION['Id']);
     63      $Form->OnSubmit = '?a=edit&o=save';
     64      $Output .= $Form->ShowEditForm();
     65      $Output .= '<br/><div style="text-align: center;">';
     66      $Output .= '<a href="?a=view"><img alt="Prohlížet" title="Prohlížet" src="'.
     67      $this->System->Link('/images/view.png').'"/></a>';
     68      $Output .= '<a href="?a=list"><img alt="Seznam" title="Seznam" src="'.
     69        $this->System->Link('/images/list.png').'"/></a>';
     70      $Output .= '<a href="?a=delete" ><img alt="Odstranit" title="Odstranit" src="'.
     71        $this->System->Link('/images/delete.png').'" onclick="return confirmAction(\'Opravdu smazat položku?\');"/></a>';
     72      $Output .= '</div>';
     73    }
    5374    return($Output);
    5475  }
     
    5778  {
    5879    $Output = '';
     80    $this->Database->delete($_SESSION['Table'], 'Id='.$_SESSION['Id']);
     81    $Output .= $this->SystemMessage('Odstranění položky', 'Položka odstraněna');
     82    $_SESSION['Action'] = 'list';
     83    $Output .= $this->ShowList();   
    5984    return($Output);
    6085  }
     
    6287  function ShowAdd()
    6388  {
    64     $Form = new Form($_SESSION['Table']);
    65     $Form->OnSubmit = '?a=view';
    66     $Output = $Form->ShowEditForm();
     89    $Output = '';
     90    if(array_key_exists('o', $_GET))
     91    {
     92      if($_GET['o'] == 'save')
     93      {
     94        $Form = new Form($_SESSION['Table']);
     95        $Form->LoadValuesFromForm();
     96        $Form->SaveValuesToDatabase(0);
     97        $Output .= $this->SystemMessage('Přidání položky', 'Nová položka vytvořena');
     98        $_SESSION['Action'] = 'view';
     99        $_SESSION['Id'] = $this->Database->insert_id;
     100        $Output .= $this->ShowView();   
     101      }
     102    } else
     103    {
     104      $Form = new Form($_SESSION['Table']);
     105      $Form->OnSubmit = '?a=add&amp;o=save';
     106      $Output .= $Form->ShowEditForm();
     107      $Output .= '<br/><div style="text-align: center;">';
     108      $Output .= '<a href="?a=list"><img alt="Seznam" title="Seznam" src="'.
     109        $this->System->Link('/images/list.png').'"/></a>';
     110      $Output .= '</div>';
     111    }
    67112    return($Output);
    68113  }
     
    74119    $Form->OnSubmit = '?a=view';
    75120    $Output = $Form->ShowViewForm();
    76     $Output .= '<br/><div style="text-align: center;"><a href="?a=edit"><img alt="Upravit" title="Upravit" src="'.
    77         $this->System->Link('/images/edit.png').'"/></a></div>';
    78     return($Output);
    79   }
    80  
    81   function ShowList($FormClass)
     121    $Output .= '<br/><div style="text-align: center;">';
     122    $Output .= '<a href="?a=edit"><img alt="Upravit" title="Upravit" src="'.
     123      $this->System->Link('/images/edit.png').'"/></a>';
     124    $Output .= '<a href="?a=list"><img alt="Seznam" title="Seznam" src="'.
     125      $this->System->Link('/images/list.png').'"/></a>';
     126    $Output .= '<a href="?a=delete"><img alt="Odstranit" title="Odstranit" src="'.
     127      $this->System->Link('/images/delete.png').'" onclick="return confirmAction(\'Opravdu smazat položku?\');"/></a>';
     128    $Output .= '</div>';
     129    return($Output);
     130  }
     131 
     132  function ShowList()
    82133  {   
    83     global $Type, $FormTypes;
    84    
     134    global $Type, $FormTypes, $FormClasses;
     135   
     136    if(array_key_exists('Table', $_SESSION))
     137      $FormClass = $FormClasses[$_SESSION['Table']];
     138      else return($this->SystemMessage('Chyba', 'Tabulka nenalezena'));
    85139    $DbResult = $this->Database->query('SELECT COUNT(*) FROM `'.$FormClass['Table'].'`');
    86140    $DbRow = $DbResult->fetch_row();
     
    123177        $this->System->Link('/images/edit.png').'"/></a>'.
    124178        '<a href="?a=delete&amp;id='.$Row['Id'].'"><img alt="Smazat" title="Smazat" src="'.
    125         $this->System->Link('/images/delete.png').'"/></a></td>';
     179        $this->System->Link('/images/delete.png').'" onclick="return confirmAction(\'Opravdu smazat položku?\');"/></a></td>';
    126180      $Output .= '</tr>';
    127181    }
    128182    $Output .= '</table>';
    129183    $Output .= $PageList['Output'];
    130     $Output .= '<br/><div style="text-align: center;"><a href="?a=add"><img alt="Přidat" title="Přidat" src="'.
    131         $this->System->Link('/images/add.png').'"/></a></div>';
     184    $Output .= '<br/><div style="text-align: center;">';
     185    $Output .= '<a href="?a=add"><img alt="Přidat" title="Přidat" src="'.
     186        $this->System->Link('/images/add.png').'"/></a>';
     187    $Output .= '</div>';
    132188    return($Output);
    133189  }
  • trunk/style/new/global.js

    r251 r433  
    2424  }
    2525}
     26
     27function confirmAction(theMessage)
     28{
     29  // TODO: Confirmation is not required in the configuration file
     30  // or browser is Opera (crappy js implementation)
     31  if (typeof(window.opera) != 'undefined')
     32  {
     33    return true;
     34  }
     35
     36  var is_confirmed = confirm(theMessage);
     37
     38  return is_confirmed;
     39}
  • trunk/style/simple/global.js

    r251 r433  
    2424  }
    2525}
     26
     27function confirmAction(theMessage)
     28{
     29  // TODO: Confirmation is not required in the configuration file
     30  // or browser is Opera (crappy js implementation)
     31  if (typeof(window.opera) != 'undefined')
     32  {
     33    return true;
     34  }
     35
     36  var is_confirmed = confirm(theMessage);
     37
     38  return is_confirmed;
     39}
Note: See TracChangeset for help on using the changeset viewer.