Changeset 647


Ignore:
Timestamp:
Mar 25, 2014, 7:09:47 PM (11 years ago)
Author:
chronos
Message:
  • Přidáno: Podpora pro virtuální tabulky.
  • Přidáno: Roční přehledy roků a subjektů.
  • Přidáno: Evidence zaměstnanců a mezd v nabídce v IS.
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/FormClasses.php

    r645 r647  
    8686      'Closed' => array('Type' => 'Boolean', 'Caption' => 'Uzavřen', 'Default' => 0),
    8787      'Sequence' => array('Type' => 'TDocumentLineSequenceListYear', 'Caption' => 'Čísleníky', 'Default' => ''),
     88    ),
     89    //'AfterInsert' => array($this, 'AfterInsertFinanceYear'),
     90  ),
     91  'FinanceYearReport' => array(
     92    'Title' => 'Roční výkaz',
     93    'Table' => 'FinanceYearReport',
     94    'SQL' => 'SELECT Id, DateEnd, DateStart FROM FinanceYear',
     95    'DefaultSortColumn' => 'Id',
     96    'Items' => array(
     97      'Id' => array('Type' => 'TFinanceYear', 'Caption' => 'Rok', 'Default' => '',
     98        'ReadOnly' => true),
    8899      'Income' => array('Type' => 'Integer', 'Caption' => 'Příjmy', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
    89100        'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.
    90         'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperation`.`Taxable` = 1) AND (`FinanceOperation`.`Value` > 0))'),
     101        'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperation`.`Value` > 0))'),
    91102      'Spending' => array('Type' => 'Integer', 'Caption' => 'Výdaje', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
    92103        'SQL' => '(SELECT -ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.
     104        'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperation`.`Value` < 0))'),
     105      'OperationBalance' => array('Type' => 'Integer', 'Caption' => 'Zisk', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
     106        'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.
     107        'AND (`FinanceOperation`.`Time` >= `DateStart`))'),
     108      'TaxIncome' => array('Type' => 'Integer', 'Caption' => 'Daňové příjmy', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
     109        'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.
     110        'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperation`.`Taxable` = 1) AND (`FinanceOperation`.`Value` > 0))'),
     111      'TaxSpending' => array('Type' => 'Integer', 'Caption' => 'Daňové výdaje', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
     112        'SQL' => '(SELECT -ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.
    93113        'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperation`.`Taxable` = 1) AND (`FinanceOperation`.`Value` < 0))'),
    94       'OperationBalance' => array('Type' => 'Integer', 'Caption' => 'Zisk', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
     114      'TaxBase' => array('Type' => 'Integer', 'Caption' => 'Základ daně', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
    95115        'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.
    96116        'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperation`.`Taxable` = 1))'),
     
    233253    'Filter' => '1',
    234254  ),
     255  'TContract' => array(
     256    'Type' => 'Reference',
     257    'Table' => 'Contract',
     258    'Id' => 'Id',
     259    'Name' => 'BillCode',
     260    'Filter' => '1',
     261  ),
     262  'TEmployee' => array(
     263    'Type' => 'Reference',
     264    'Table' => 'Employee',
     265    'Id' => 'Id',
     266    'Name' => 'CONCAT(FirstName, " ", SecondName)',
     267    'Filter' => '1',
     268  ),
     269  'TEmployeeSalaryList' => array(
     270    'Type' => 'ManyToOne',
     271    'Table' => 'EmployeeSalary',
     272    'Id' => 'Id',
     273    'Ref' => 'Employee',
     274    'Filter' => '1',
     275  ),
    235276  'TMemberListSubject' => array(
    236277    'Type' => 'ManyToOne',
  • trunk/Common/Form/Form.php

    r639 r647  
    162162    }
    163163    $Columns = implode(',', $Columns);
    164     $DbResult = $this->Database->query('SELECT '.$Columns.' FROM `'.$this->Definition['Table'].'` AS `T` WHERE `T`.`Id`='.$Id);
     164    if(array_key_exists('SQL', $this->Definition))
     165      $SourceTable = '('.$this->Definition['SQL'].') AS `TX`';
     166      else $SourceTable = '`'.$this->Definition['Table'].'` AS `TX`';
     167    $DbResult = $this->Database->query('SELECT '.$Columns.' FROM '.$SourceTable.' WHERE `TX`.`Id`='.$Id);
    165168    $DbRow = $DbResult->fetch_array();
    166169    foreach($this->Definition['Items'] as $Index => $Item)
  • trunk/Common/Form/Types/OneToMany.php

    r639 r647  
    8080      $Output = '`'.$Item['Name'].'`, (SELECT '.$Type['Parameters']['Name'].''.
    8181        ' AS `Name` FROM '.$Table.' WHERE `'.
    82         $Type['Parameters']['Id'].'`=`'.$Item['Name'].'`) AS `'.$Item['Name'].'_Filter`';
     82        $Type['Parameters']['Id'].'`=`TX`.`'.$Item['Name'].'`) AS `'.$Item['Name'].'_Filter`';
    8383    //} else $Output = '`'.$Item['Name'].'`, `'.$Item['Name'].'` AS `'.$Item['Name'].'_Filter`';
    8484    return($Output);
  • trunk/Common/Setup/Updates.php

    r646 r647  
    612612}
    613613
     614function UpdateTo647($Manager)
     615{
     616        $Manager->Execute('ALTER TABLE `EmployeeSalary` ADD FOREIGN KEY ( `Employee` ) REFERENCES `Employee` (
     617`Id`
     618) ON DELETE RESTRICT ON UPDATE RESTRICT ;');
     619  $Manager->Execute('ALTER TABLE `EmployeeSalary` ADD `Contract` INT NOT NULL ,
     620ADD INDEX ( `Contract` ) ;');
     621 $Manager->Execute('ALTER TABLE `EmployeeSalary` ADD FOREIGN KEY ( `Contract` ) REFERENCES `Contract` (
     622`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;');
     623  $Manager->Execute("INSERT INTO `Action` (
     624`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,`Group` ,`Icon` ,`PermissionOperation` ,
     625`Enable`) VALUES (NULL , '', 'Zaměstnanci', '1', '/is/?t=Employee&a=list', NULL , NULL , NULL , '1'
     626);");
     627  $ActionId = $Manager->Database->insert_id;
     628  $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
     629    "VALUES (NULL , 'Zaměstnanci', '2', '".$ActionId."', '1');");
     630  $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
     631    "VALUES (NULL , 'Roční výkazy', '2', NULL, '1');");
     632  $MenuId = $Manager->Database->insert_id;
     633  $Manager->Execute("INSERT INTO `Action` (
     634`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,`Group` ,`Icon` ,`PermissionOperation` ,
     635`Enable`) VALUES (NULL , '', 'Roční přehled', '1', '/is/?t=FinanceYearReport&a=list', NULL , NULL , NULL , '1'
     636);");
     637  $ActionId = $Manager->Database->insert_id;
     638  $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
     639    "VALUES (NULL , 'Roční přehled', '".$MenuId."', '".$ActionId."', '1');");
     640  $Manager->Execute("INSERT INTO `Action` (
     641`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,`Group` ,`Icon` ,`PermissionOperation` ,
     642`Enable`) VALUES (NULL , '', 'Výkaz subjektů', '1', '/is/?t=SubjectReport&a=list', NULL , NULL , NULL , '1'
     643);");
     644  $ActionId = $Manager->Database->insert_id;
     645  $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
     646    "VALUES (NULL , 'Výkaz subjektů', '".$MenuId."', '".$ActionId."', '1');");
     647}
     648
    614649
    615650class Updates
     
    651686      633 => array('Revision' => 645, 'Function' => 'UpdateTo645'),
    652687      645 => array('Revision' => 646, 'Function' => 'UpdateTo646'),
     688      646 => array('Revision' => 647, 'Function' => 'UpdateTo647'),
    653689    ));
    654690  }
  • trunk/Modules/Finance/Finance.php

    r646 r647  
    502502      'BeforeInsert' => array($this, 'BeforeInsertFinanceOperation'),
    503503    ));
     504    $this->System->FormManager->RegisterClass('Employee', array(
     505      'Title' => 'Zaměstnanci',
     506      'Table' => 'Employee',
     507      'Items' => array(
     508        'FirstName' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
     509        'SecondName' => array('Type' => 'String', 'Caption' => 'Příjmení', 'Default' => ''),
     510        'Salary' => array('Type' => 'Integer', 'Caption' => 'Pevná mzda', 'Default' => '0', 'Suffix' => 'Kč'),
     511        'ValidFrom' => array('Type' => 'Date', 'Caption' => 'Platnost od', 'Default' => ''),
     512        'ValidTo' => array('Type' => 'Date', 'Caption' => 'Platnost do', 'Default' => '', 'Null' => true),
     513        'SalaryList' => array('Type' => 'TEmployeeSalaryList', 'Caption' => 'Mzda', 'Default' => ''),
     514      ),
     515    ));
     516    $this->System->FormManager->RegisterClass('EmployeeSalary', array(
     517      'Title' => 'Výplaty zaměstnanců',
     518      'Table' => 'EmployeeSalary',
     519      'Items' => array(
     520        'Date' => array('Type' => 'Date', 'Caption' => 'Datum', 'Default' => ''),
     521        'Employee' => array('Type' => 'TEmployee', 'Caption' => 'Zaměstnance', 'Default' => ''),
     522        'Amount' => array('Type' => 'Integer', 'Caption' => 'Částka', 'Default' => '0', 'Suffix' => 'Kč'),
     523        'Contract' => array('Type' => 'TContract', 'Caption' => 'Smlouva', 'Default' => ''),
     524      ),
     525      'BeforeInsert' => array($this, 'BeforeInsertFinanceOperation'),
     526    ));
    504527
    505528    $this->System->AddModule(new Bill($this->System));
  • trunk/Modules/IS/IS.php

    r646 r647  
    7474  function ShowEdit($Table, $Id)
    7575  {
     76        $this->ShortTitle .= ' - Úprava '.$Table;
    7677    $Output = '';
    7778    if(defined('NEW_PERMISSION') and !$this->System->User->CheckPermission($this->TableToModule($Table), 'Write'))
     
    8485        $Form->SetClass($Table);
    8586        $Form->LoadValuesFromForm();
     87        $this->ShortTitle .= ' - úprava '.$Form->Definition['Title'];
    8688        try {
    8789          $Form->Validate();
     
    111113      $Form->SetClass($Table);
    112114      $Form->LoadValuesFromDatabase($Id);
     115      $this->ShortTitle .= ' - úprava '.$Form->Definition['Title'];
    113116      $Form->OnSubmit = '?a=edit&amp;t='.$Table.'&amp;i='.$_GET['i'].'&amp;o=save';
    114117      $Output .= $Form->ShowEditForm();
     
    130133    if(defined('NEW_PERMISSION') and !$this->System->User->CheckPermission($this->TableToModule($Table), 'Write'))
    131134      return('Nemáte oprávnění');
     135    $this->ShortTitle .= ' - odstranění '.$Table;
    132136    $DbResult = $this->Database->select($Table, '*', '`Id`='.$Id);
    133137    if($DbResult->num_rows > 0)
     
    160164        $Form->SetClass($Table);
    161165        $Form->LoadValuesFromForm();
     166        $this->ShortTitle .= ' - přidání '.$Form->Definition['Title'];
    162167        try {
    163168          $Form->Validate();
     
    209214      $Form = new Form($this->System->FormManager);
    210215      $Form->SetClass($Table);
     216      $this->ShortTitle .= ' - přidání '.$Form->Definition['Title'];
    211217      // Load presets from URL
    212218      foreach($_GET as $Key => $Value)
     
    252258    $Form = new Form($this->System->FormManager);
    253259    $Form->SetClass($Table);
     260    $this->ShortTitle .= ' - položka '.$Form->Definition['Title'];
    254261    $Form->LoadValuesFromDatabase($Id);
    255262    $Form->OnSubmit = '?a=view';
     
    302309        if($Table != '') $FormClass = $this->System->FormManager->Classes[$Table];
    303310      else return($this->SystemMessage('Chyba', 'Tabulka nenalezena'));
     311     
     312    if(array_key_exists('SQL', $FormClass))
     313      $SourceTable = '('.$FormClass['SQL'].') AS `TX`';
     314      else $SourceTable = '`'.$FormClass['Table'].'` AS `TX`';
    304315
    305316    // Build user filter
     
    359370
    360371        if(!array_key_exists('SQL', $FormItem)) $FormItem['SQL'] = '';
    361           else $FormItem['SQL'] = str_replace('#Id', '`'.$FormClass['Table'].'`.`Id`', $FormItem['SQL']);
     372          else $FormItem['SQL'] = str_replace('#Id', '`TX`.`Id`', $FormItem['SQL']);
    362373        $Columns[] = $this->System->FormManager->Type->ExecuteTypeEvent($UseType, 'OnFilterNameQuery',
    363374          array('Value' => $Value, 'Name' => $ItemIndex,
     
    366377
    367378    // Get total item count in database
    368     $Query = 'SELECT COUNT(*) FROM `'.$FormClass['Table'].'`';
     379    $Query = 'SELECT COUNT(*) FROM '.$SourceTable;
    369380    $DbResult = $this->Database->query($Query);
    370381    $DbRow = $DbResult->fetch_assoc();
     
    375386    if($Filter != '')
    376387    {
    377       $Query = 'SELECT COUNT(*) FROM (SELECT '.$Columns.' FROM `'.$FormClass['Table'].'`) AS `TS` '.$Filter;
     388      $Query = 'SELECT COUNT(*) FROM (SELECT '.$Columns.' FROM '.$SourceTable.') AS `TS` '.$Filter;
    378389      $DbResult = $this->Database->query($Query);
    379390      $DbRow = $DbResult->fetch_row();
     
    410421
    411422    // Load and show items
    412     $Query = 'SELECT * FROM (SELECT '.$Columns.' FROM `'.$FormClass['Table'].'`) AS `TS` '.
     423    $Query = 'SELECT * FROM (SELECT '.$Columns.' FROM '.$SourceTable.') AS `TS` '.
    413424      $Filter.' '.$Order['SQL'].$PageList['SQLLimit'];
    414425    $VisibleItemCount = 0;
  • trunk/Modules/Network/Network.php

    r624 r647  
    155155          'WHERE `FinanceOperation`.`Subject`=#Id) - (SELECT SUM(`FinanceInvoice`.`Value`) FROM `FinanceInvoice` '.
    156156          'WHERE `FinanceInvoice`.`Subject`=#Id)'),
     157      ),
     158    ));
     159    $this->System->FormManager->RegisterClass('SubjectReport', array(
     160      'Title' => 'Přehled subjektů',
     161      'Table' => 'SubjectReport',
     162      'DefaultSortColumn' => 'Id',
     163      'SQL' => '(SELECT Id FROM Subject)',
     164      'Items' => array(
     165        'Id' => array('Type' => 'TSubject', 'Caption' => 'Subjekt', 'Default' => '', 'ReadOnly' => true),
     166        'Income' => array('Type' => 'Integer', 'Caption' => 'Příjmy', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
     167          'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` WHERE (`FinanceOperation`.`Subject` = TX.`Id`) '.
     168          'AND (`FinanceOperation`.`Value` > 0))'),
     169        'Spending' => array('Type' => 'Integer', 'Caption' => 'Výdaje', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
     170          'SQL' => '(SELECT -ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` WHERE (`FinanceOperation`.`Subject` = TX.`Id`) '.
     171          'AND (`FinanceOperation`.`Value` < 0))'),
     172        'OperationBalance' => array('Type' => 'Integer', 'Caption' => 'Zisk', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
     173          'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` WHERE (`FinanceOperation`.`Subject` = TX.`Id`) '.
     174          ')'),
    157175      ),
    158176    ));
Note: See TracChangeset for help on using the changeset viewer.