Changeset 755


Ignore:
Timestamp:
Oct 25, 2015, 9:51:51 PM (9 years ago)
Author:
chronos
Message:
  • Modified: Now IS Dashboard is not dependent on other modules. They need to register their view to IS dashboard.
  • Fixed: Wrong sign of created finance operations from bank import.
  • Added: Storno invoices now have special groups in FinanceInvoiceGroup table.

Both Storno and previous storned documents should be linked together using new table FinanceInvoiceStorno.
Also they should be marked as not visible to user.

Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/FormClasses.php

    r747 r755  
    356356    'Filter' => '1',
    357357  ),
     358  'TFinanceInvoiceStornoListBy' => array(
     359    'Type' => 'ManyToOne',
     360    'Table' => 'FinanceInvoiceStorno',
     361    'Id' => 'Id',
     362    'Ref' => 'StornoBy',
     363    'Filter' => '1',
     364  ),
     365  'TFinanceInvoiceStornoListOf' => array(
     366    'Type' => 'ManyToOne',
     367    'Table' => 'FinanceInvoiceStorno',
     368    'Id' => 'Id',
     369    'Ref' => 'StornoOf',
     370    'Filter' => '1',
     371  ),
     372  'TFinanceInvoiceListGroup' => array(
     373    'Type' => 'ManyToOne',
     374    'Table' => 'FinanceInvoice',
     375    'Id' => 'Id',
     376    'Ref' => 'Group',
     377    'Filter' => '1',
     378  ),
    358379  'TFinanceOperationListAccount' => array(
    359380    'Type' => 'ManyToOne',
  • trunk/Application/Version.php

    r754 r755  
    11<?php
    22
    3 $Revision = 752; // Subversion revision
    4 $DatabaseRevision = 752; // SQL structure revision
    5 $ReleaseTime = strtotime('2015-10-21');
     3$Revision = 755; // Subversion revision
     4$DatabaseRevision = 755; // SQL structure revision
     5$ReleaseTime = strtotime('2015-10-25');
  • trunk/Common/Setup/Updates.php

    r754 r755  
    15231523    'VALUES (NULL, "Kontrola změn stavů", "SchedulerNotifyCheck");');
    15241524
    1525   $this->Database->query('
     1525  $Manager->Database->query('
    15261526  CREATE TABLE IF NOT EXISTS `NotifyUser` (
    15271527  `Id` int(11) NOT NULL AUTO_INCREMENT,
     
    15331533  KEY `Contact` (`Contact`)
    15341534    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;');
    1535   $this->Database->query('ALTER TABLE `NotifyUser`
     1535  $Manager->Database->query('ALTER TABLE `NotifyUser`
    15361536ADD CONSTRAINT `NotifyUser_ibfk_1` FOREIGN KEY (`User`) REFERENCES `User` (`Id`),
    15371537ADD CONSTRAINT `NotifyUser_ibfk_2` FOREIGN KEY (`Contact`) REFERENCES `Contact` (`Id`);');
    15381538
    1539   $this->Database->query('CREATE TABLE IF NOT EXISTS `NotifyCategory` (
     1539  $Manager->Database->query('CREATE TABLE IF NOT EXISTS `NotifyCategory` (
    15401540      `Id` int(11) NOT NULL AUTO_INCREMENT,
    15411541      `Name` varchar(255) NOT NULL,
     
    15441544    ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;');
    15451545
    1546   $this->Database->query("INSERT INTO `NotifyCategory` (`Id`, `Name`, `SysName`) VALUES
     1546  $Manager->Database->query("INSERT INTO `NotifyCategory` (`Id`, `Name`, `SysName`) VALUES
    15471547    (1, 'Dostupnost zařízení (ping)', 'NetworkReachability'),
    15481548    (2, 'Dostupnost URL', 'URL'),
     
    15531553}
    15541554
     1555function UpdateTo755($Manager)
     1556{
     1557  $Manager->Execute("INSERT INTO `FinanceInvoiceGroup` (`Id`, `Name`, `DocumentLine`, `ValueSign`, `Direction`) '.
     1558    'VALUES (NULL, 'Přijaté faktury - storno', '5', '1', '0'), (NULL, 'Vydané faktury - storno', '6', '-1', '1')");
     1559  $Manager->Execute("ALTER TABLE `FinanceInvoice` ADD `VisibleToUser` INT NOT NULL DEFAULT '1' AFTER `Generate`;ALTER TABLE `FinanceInvoice` ADD `VisibleToUser` INT NOT NULL DEFAULT '1' AFTER `Generate`;");
     1560
     1561  $Manager->Execute("CREATE TABLE IF NOT EXISTS `FinanceInvoiceStorno` (
     1562    `Id` int(11) NOT NULL AUTO_INCREMENT,
     1563    `StornoBy` int(11) NOT NULL,
     1564    `StornoOf` int(11) NOT NULL,
     1565    PRIMARY KEY (`Id`),
     1566    KEY `StornoBy` (`StornoBy`),
     1567    KEY `StornoOf` (`StornoOf`)
     1568  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
     1569
     1570  $Manager->Execute("ALTER TABLE `FinanceInvoiceStorno`
     1571  ADD CONSTRAINT `FinanceInvoiceStorno_ibfk_1` FOREIGN KEY (`StornoBy`) REFERENCES `FinanceInvoice` (`Id`),
     1572  ADD CONSTRAINT `FinanceInvoiceStorno_ibfk_2` FOREIGN KEY (`StornoOf`) REFERENCES `FinanceInvoice` (`Id`);
     1573  ");
     1574}
    15551575
    15561576class Updates
     
    16271647      747 => array('Revision' => 748, 'Function' => 'UpdateTo748'),
    16281648      748 => array('Revision' => 752, 'Function' => 'UpdateTo752'),
     1649      752 => array('Revision' => 755, 'Function' => 'UpdateTo755'),
    16291650    ));
    16301651  }
  • trunk/Modules/Customer/Customer.php

    r738 r755  
    148148      'Filter' => '1',
    149149    ));
     150
     151    $this->System->ModuleManager->Modules['IS']->RegisterDashboardItem('Customer',
     152      array('ModuleCustomer', 'ShowDashboardItem'));
    150153  }
     154
     155  function ShowDashboardItem()
     156  {
     157    $DbResult = $this->Database->select('Member', 'COUNT(*)', '1');
     158    $DbRow = $DbResult->fetch_row();
     159    $Output = 'Zákazníků: registrovaných:'.$DbRow['0'];
     160
     161    $DbResult = $this->Database->select('Member', 'COUNT(*)', '`Blocked`=0 AND `BillingPeriod`<>1');
     162    $DbRow = $DbResult->fetch_row();
     163    $Output .= ' platících:'.$DbRow['0'].'<br/>';
     164
     165    return($Output);
     166  }
     167
    151168}
  • trunk/Modules/Finance/Finance.php

    r750 r755  
    333333        'PeriodTo' => array('Type' => 'Date', 'Caption' => 'Období do', 'Default' => '', 'Null' => true),
    334334        'Cash' => array('Type' => 'Boolean', 'Caption' => 'Platit hotově', 'Default' => ''),
     335        'VisibleToUser' => array('Type' => 'Boolean', 'Caption' => 'Viditelné uživatelům', 'Default' => '1'),
    335336        'Items' => array('Type' => 'TFinanceInvoiceItemListInvoice', 'Caption' => 'Položky', 'Default' => ''),
     337        'StornoBy' => array('Type' => 'TFinanceInvoiceStornoListBy', 'Caption' => 'Storno doklady', 'Default' => ''),
     338        'StornoOf' => array('Type' => 'TFinanceInvoiceStornoListOf', 'Caption' => 'Původní doklady', 'Default' => ''),
    336339        'OperationRel' => array('Type' => 'TFinanceInvoiceOperationRelListInvoice', 'Caption' => 'Platba', 'Default' => ''),
    337340        'OperationRelCount' => array('Type' => 'Integer', 'Caption' => 'Plateb',
     
    365368        'ValueSign' => array('Type' => 'TFinanceValueSign', 'Caption' => 'Znaménko hodnoty', 'Default' => '0'),
    366369        'Direction' => array('Type' => 'TFinanceDirection', 'Caption' => 'Směr', 'Default' => '0'),
     370        'Items' => array('Type' => 'TFinanceInvoiceListGroup', 'Caption' => 'Faktury', 'Default' => ''),
     371      ),
     372    ));
     373
     374    $this->System->FormManager->RegisterClass('FinanceInvoiceStorno', array(
     375      'Title' => 'Storno faktur',
     376      'Table' => 'FinanceInvoiceStorno',
     377      'Items' => array(
     378        'StornoBy' => array('Type' => 'TFinanceInvoice', 'Caption' => 'Storno doklad', 'Default' => ''),
     379        'StornoOf' => array('Type' => 'TFinanceInvoice', 'Caption' => 'Původní doklad', 'Default' => ''),
    367380      ),
    368381    ));
     
    557570    ));
    558571
     572
    559573    $this->System->AddModule(new Bill($this->System));
    560574    $this->System->AddModule(new Finance($this->System));
    561575    $this->System->Modules['Finance']->MainSubject = $Config['Finance']['MainSubjectId'];
    562576    $this->System->Modules['Finance']->DirectoryId = $Config['Finance']['DirectoryId'];
     577
     578    $this->System->ModuleManager->Modules['IS']->RegisterDashboardItem('Finance',
     579      array('ModuleFinance', 'ShowDashboardItem'));
     580  }
     581
     582  function ShowDashboardItem()
     583  {
     584    $DbResult = $this->Database->select('FinanceOperation', 'ROUND(SUM(`Value`))', '1');
     585    $DbRow = $DbResult->fetch_row();
     586    $Output = 'Stav placení: '.$DbRow['0'].' Kč<br/>';
     587    return $Output;
    563588  }
    564589
  • trunk/Modules/FinanceBankAPI/FileImport.php

    r747 r755  
    4242          $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($FinanceGroup['DocumentLine'], $Year);
    4343          $DbResult3 = $this->Database->insert('FinanceOperation', array('Subject' => $DbRow2['Id'], 'Cash' => 0,
    44             'Value' => Abs($DbRow['Value']), 'Taxable' => 1, 'BankAccount' => $DbRow['BankAccount'], 'Network' => 1,
     44            'ValueUser' => Abs($DbRow['Value']), 'Taxable' => 1, 'BankAccount' => $DbRow['BankAccount'], 'Network' => 1,
    4545            'Time' => $DbRow['Time'], 'Text' => $DbRow['Description'], 'BillCode' => $BillCode, 'Group' => $FinanceGroup['Id']));
    46           $this->Database->update('FinanceBankImport', 'Id='.$DbRow['Id'], array('FinanceOperation' => $this->Database->insert_id));
     46          $Id = $this->Database->insert_id;
     47          $this->Database->update('FinanceBankImport', 'Id='.$DbRow['Id'], array('FinanceOperation' => $Id));
     48
     49          // Execute after insert event
     50          $Form = new Form($this->System->FormManager);
     51          $Form->SetClass('FinanceOperation');
     52          $Form->LoadValuesFromDatabase($Id);
     53          if(array_key_exists('AfterInsert', $Form->Definition))
     54          {
     55            $Class = $Form->Definition['AfterInsert'][0];
     56            $Method = $Form->Definition['AfterInsert'][1];
     57            $Form->Values = $Class->$Method($Form, $Id);
     58          }
    4759        }
    4860      }
  • trunk/Modules/FinanceBankAPI/FinanceBankAPI.php

    r740 r755  
    6060    $this->System->RegisterPage(array('finance', 'import-api'), 'PageImportAPI');
    6161    $this->System->RegisterPage(array('finance', 'import-soubor'), 'PageImportFile');
     62
     63    $this->System->ModuleManager->Modules['IS']->RegisterDashboardItem('FinanceBankAPI',
     64      array('ModuleFinanceBankAPI', 'ShowDashboardItem'));
    6265  }
    6366
    6467  function DoStop()
    6568  {
     69  }
     70
     71  function ShowDashboardItem()
     72  {
     73    $DbResult = $this->Database->select('FinanceBankImport', 'COUNT(*)', '`FinanceOperation` IS NULL');
     74    $DbRow = $DbResult->fetch_row();
     75    $Output = 'Nezpárovaných plateb: '.$DbRow['0'].'<br/>';
     76    return($Output);
    6677  }
    6778
  • trunk/Modules/IS/IS.php

    r747 r755  
    8181  {
    8282    $Output = '<strong>Nástěnka:</strong><br/>';
    83     $DbResult = $this->Database->select('Task', 'COUNT(*)', '`Progress` < 100');
    84     $DbRow = $DbResult->fetch_row();
    85     $Output .= 'Nedokončených úkolů: '.$DbRow['0'].'<br/>';
    86 
    87     $DbResult = $this->Database->select('Member', 'COUNT(*)', '1');
    88     $DbRow = $DbResult->fetch_row();
    89     $Output .= 'Zákazníků: '.$DbRow['0'].'<br/>';
    90 
    91     $DbResult = $this->Database->select('Subject', 'COUNT(*)', '1');
    92     $DbRow = $DbResult->fetch_row();
    93     $Output .= 'Subjektů: '.$DbRow['0'].'<br/>';
    94 
    95     $DbResult = $this->Database->select('User', 'COUNT(*)', '1');
    96     $DbRow = $DbResult->fetch_row();
    97     $Output .= 'Uživatelů: '.$DbRow['0'].'<br/>';
    98 
    99     $DbResult = $this->Database->select('NetworkDevice', 'COUNT(*)', '1');
    100     $DbRow = $DbResult->fetch_row();
    101     $Output .= 'Registrovaných zařízení: '.$DbRow['0'].'<br/>';
    102 
    103     $DbResult = $this->Database->select('FinanceOperation', 'SUM(`Value`)', '1');
    104     $DbRow = $DbResult->fetch_row();
    105     $Output .= 'Stav placení: '.$DbRow['0'].'<br/>';
    106 
    107     $DbResult = $this->Database->select('FinanceBankImport', 'COUNT(*)', '`FinanceOperation` IS NULL');
    108     $DbRow = $DbResult->fetch_row();
    109     $Output .= 'Nezpárovaných plateb: '.$DbRow['0'].'<br/>';
    110     return($Output);
     83    foreach($this->System->ModuleManager->Modules['IS']->DashboardItems as $Item)
     84    {
     85      if(is_string($Item['Callback'][0]))
     86      {
     87        $Class = new $Item['Callback'][0]($this->System);
     88        $Output .= $Class->$Item['Callback'][1]();
     89      } else $Output .= call_user_func($Item['Callback']);
     90    }
     91    return $Output;
    11192  }
    11293
     
    780761class ModuleIS extends AppModule
    781762{
     763  var $DashboardItems;
     764
    782765  function __construct($System)
    783766  {
     
    790773    $this->Description = 'User interface for generic information system';
    791774    $this->Dependencies = array();
     775
     776    $this->DashboardItems = array();
    792777  }
    793778
     
    849834  {
    850835  }
     836
     837  function RegisterDashboardItem($Name, $Callback)
     838  {
     839    $this->DashboardItems[$Name] = array('Callback' => $Callback);
     840  }
     841
     842  function UnregisterDashboardItem($Name)
     843  {
     844    unset($this->DashboardItems[$Name]);
     845  }
    851846}
  • trunk/Modules/Network/Network.php

    r739 r755  
    490490    ));
    491491
     492    $this->System->ModuleManager->Modules['IS']->RegisterDashboardItem('Network',
     493      array('ModuleNetwork', 'ShowDashboardItem'));
     494  }
     495
     496  function ShowDashboardItem()
     497  {
     498    $Output = '';
     499    $DbResult = $this->Database->select('NetworkDevice', 'COUNT(*)', '1');
     500    $DbRow = $DbResult->fetch_row();
     501    $Output .= 'Síťových zařízení: registrovaných:'.$DbRow['0'];
     502
     503    $DbResult = $this->Database->select('NetworkDevice', 'COUNT(*)', '`Used`=1');
     504    $DbRow = $DbResult->fetch_row();
     505    $Output .= ' použitých:'.$DbRow['0'].'<br>';
     506
     507    $DbResult = $this->Database->select('NetworkInterface', 'COUNT(*)', '1');
     508    $DbRow = $DbResult->fetch_row();
     509    $Output .= 'Síťových rozhraní: '.$DbRow['0'].'<br>';
     510
     511    $DbResult = $this->Database->select('NetworkSubnet', 'COUNT(*)', '1');
     512    $DbRow = $DbResult->fetch_row();
     513    $Output .= 'Síťových podsítí: '.$DbRow['0'].'<br/>';
     514    return $Output;
    492515  }
    493516
  • trunk/Modules/Subject/Subject.php

    r754 r755  
    126126      'Filter' => '1',
    127127    ));
     128    $this->System->ModuleManager->Modules['IS']->RegisterDashboardItem('Subject',
     129      array('ModuleSubject', 'ShowDashboardItem'));
    128130  }
    129131
     
    176178    $this->Database->query('DROP TABLE `Subject`');
    177179  }
     180
     181  function ShowDashboardItem()
     182  {
     183    $DbResult = $this->Database->select('Subject', 'COUNT(*)', '1');
     184    $DbRow = $DbResult->fetch_row();
     185    $Output = 'Subjektů: '.$DbRow['0'].'<br/>';
     186    return($Output);
     187  }
    178188}
  • trunk/Modules/Task/Task.php

    r746 r755  
    8888      'Filter' => '1',
    8989    ));
     90
     91    $this->System->ModuleManager->Modules['IS']->RegisterDashboardItem('Task',
     92      array('ModuleTask', 'ShowDashboardItem'));
    9093  }
    9194
     
    9497
    9598  }
     99
     100  function ShowDashboardItem()
     101  {
     102    $DbResult = $this->Database->select('Task', 'COUNT(*)', '`Progress` < 100');
     103    $DbRow = $DbResult->fetch_row();
     104    $Output = 'Nedokončených úkolů: '.$DbRow['0'].'<br/>';
     105    return $Output;
     106  }
    96107}
  • trunk/Modules/User/User.php

    r746 r755  
    270270      'Filter' => '1',
    271271    ));
    272 
     272    $this->System->ModuleManager->Modules['IS']->RegisterDashboardItem('User',
     273        array('ModuleUser', 'ShowDashboardItem'));
     274  }
     275
     276  function ShowDashboardItem()
     277  {
     278    $DbResult = $this->Database->select('User', 'COUNT(*)', '1');
     279    $DbRow = $DbResult->fetch_row();
     280    $Output = 'Uživatelů: '.$DbRow['0'].'<br/>';
     281    return $Output;
    273282  }
    274283
Note: See TracChangeset for help on using the changeset viewer.