<?php

// TODO: Split all form class definitions to modules

function RegisterFormClasses(FormManager $FormManager): void
{
  $FormManager->Classes = array(
  'UserCustomerRel' => array(
    'Title' => 'Vztahy uživatel - zákazník',
    'Table' => 'UserCustomerRel',
    'Items' => array(
      'User' => array('Type' => 'TUser', 'Caption' => 'Uživatel', 'Default' => ''),
      'Customer' => array('Type' => 'TMember', 'Caption' => 'Zákazník', 'Default' => ''),
    ),
  ),
  'FinanceInvoiceOperationRel' => array(
    'Title' => 'Zaplacení faktůr',
    'Table' => 'FinanceInvoiceOperationRel',
    'Items' => array(
      'Invoice' => array('Type' => 'TFinanceInvoice', 'Caption' => 'Faktura', 'Default' => ''),
      'Operation' => array('Type' => 'TFinanceOperation', 'Caption' => 'Platba', 'Default' => ''),
    ),
  ),
  'DocumentLine' => array(
    'Title' => 'Dokladové řady',
    'Table' => 'DocumentLine',
    'DefaultSortColumn' => 'Name',
    'Items' => array(
      'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
      'Shortcut' => array('Type' => 'String', 'Caption' => 'Kód', 'Default' => ''),
      'Yearly' => array('Type' => 'Boolean', 'Caption' => 'Ročně', 'Default' => 0),
      'Sequence' => array('Type' => 'TDocumentLineSequenceListLine', 'Caption' => 'Čísleníky', 'Default' => ''),
      'Codes' => array('Type' => 'TDocumentLineCodeList', 'Caption' => 'Kódy', 'Default' => ''),
      'Operations' => array('Type' => 'TFinanceOperationGroupListDocumentLine', 'Caption' => 'Skupiny finančních operací', 'Default' => ''),
      'Invoices' => array('Type' => 'TFinanceInvoiceGroupListDocumentLine', 'Caption' => 'Skupiny faktur', 'Default' => ''),
    ),
  ),
  'DocumentLineSequence' => array(
    'Title' => 'Čísleníky dokladových řad',
    'Table' => 'DocumentLineSequence',
    'DefaultSortColumn' => 'Id',
    'Items' => array(
      'DocumentLine' => array('Type' => 'TDocumentLine', 'Caption' => 'Dokladová řada', 'Default' => ''),
      'FinanceYear' => array('Type' => 'TFinanceYear', 'Caption' => 'Účetní rok', 'Default' => ''),
      'NextNumber' => array('Type' => 'Integer', 'Caption' => 'Další číslo', 'Default' => '1'),
      'YearPrefix' => array('Type' => 'Boolean', 'Caption' => 'Rok jako přípona', 'Default' => '1'),
    ),
  ),
  'DocumentLineCode' => array(
    'Title' => 'Kód dokladových řad',
    'Table' => 'DocumentLineCode',
    'DefaultSortColumn' => 'Name',
    'Items' => array(
      'DocumentLine' => array('Type' => 'TDocumentLine', 'Caption' => 'Dokladová řada', 'Default' => ''),
      'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => ''),
    ),
  ),
  'FinanceYear' => array(
    'Title' => 'Účetní roky',
    'Table' => 'FinanceYear',
    'DefaultSortColumn' => 'Year',
    'DefaultSortOrder' => 1,
    'Items' => array(
      'Year' => array('Type' => 'Integer', 'Caption' => 'Rok', 'Default' => ''),
      'DateStart' => array('Type' => 'Date', 'Caption' => 'První den', 'Default' => ''),
      'DateEnd' => array('Type' => 'Date', 'Caption' => 'Poslední den', 'Default' => ''),
      'Closed' => array('Type' => 'Boolean', 'Caption' => 'Uzavřen', 'Default' => 0),
      'Sequence' => array('Type' => 'TDocumentLineSequenceListYear', 'Caption' => 'Čísleníky', 'Default' => ''),
    ),
    //'AfterInsert' => array($this, 'AfterInsertFinanceYear'),
  ),
  'FinanceYearReport' => array(
    'Title' => 'Roční výkaz',
    'Table' => 'FinanceYearReport',
    'SQL' => 'SELECT Id, DateEnd, DateStart FROM FinanceYear',
    'DefaultSortColumn' => 'Id',
    'Items' => array(
      'Id' => array('Type' => 'TFinanceYear', 'Caption' => 'Rok', 'Default' => '',
        'ReadOnly' => true),
      'Income' => array('Type' => 'Integer', 'Caption' => 'Příjmy', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
        'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '.
        'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id`=`FinanceOperation`.`Group` '.
        'WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.
        'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperationGroup`.`ValueSign` = 1))'),
      'Spending' => array('Type' => 'Integer', 'Caption' => 'Výdaje', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
        'SQL' => '(SELECT -ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '.
        'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id`=`FinanceOperation`.`Group` '.
        'WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.
        'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperationGroup`.`ValueSign` = -1))'),
      'OperationBalance' => array('Type' => 'Integer', 'Caption' => 'Zisk', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
        'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '.
        'WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.
        'AND (`FinanceOperation`.`Time` >= `DateStart`))'),
      'TaxIncome' => array('Type' => 'Integer', 'Caption' => 'Daňové příjmy', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
        'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '.
        'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id`=`FinanceOperation`.`Group` '.
        'WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.
        'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperation`.`Taxable` = 1) AND (`FinanceOperationGroup`.`ValueSign` = 1))'),
      'TaxSpending' => array('Type' => 'Integer', 'Caption' => 'Daňové výdaje', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
        'SQL' => '(SELECT -ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '.
        'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id`=`FinanceOperation`.`Group` '.
        'WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.
        'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperation`.`Taxable` = 1) AND (`FinanceOperationGroup`.`ValueSign` = -1))'),
      'TaxBase' => array('Type' => 'Integer', 'Caption' => 'Základ daně', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
        'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '.
        'WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.
        'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperation`.`Taxable` = 1))'),
      'Claims' => array('Type' => 'Integer', 'Caption' => 'Pohledávky', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
        'SQL' => '(SELECT ROUND(SUM(`FinanceInvoice`.`Value`)) FROM `FinanceInvoice` '.
        'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id`=`FinanceInvoice`.`Group` '.
        'WHERE (`FinanceInvoice`.`Time` <= `DateEnd`) '.
        'AND (`FinanceInvoice`.`Time` >= `DateStart`) AND (`FinanceInvoiceGroup`.`ValueSign` = 1))'),
      'Liabilities' => array('Type' => 'Integer', 'Caption' => 'Závazky', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
        'SQL' => '(SELECT -ROUND(SUM(`FinanceInvoice`.`Value`)) FROM `FinanceInvoice` '.
        'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id`=`FinanceInvoice`.`Group` '.
        'WHERE (`FinanceInvoice`.`Time` <= `DateEnd`) '.
        'AND (`FinanceInvoice`.`Time` >= `DateStart`) AND (`FinanceInvoiceGroup`.`ValueSign` = -1))'),
      'InvoiceBalance' => array('Type' => 'Integer', 'Caption' => 'Fakturační rozdíl', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
        'SQL' => '(SELECT ROUND(SUM(`FinanceInvoice`.`Value`)) FROM `FinanceInvoice` WHERE (`FinanceInvoice`.`Time` <= `DateEnd`) '.
        'AND (`FinanceInvoice`.`Time` >= `DateStart`))'),
    ),
    //'AfterInsert' => array($this, 'AfterInsertFinanceYear'),
  ),
  'FinanceBillingPeriod' => array(
    'Title' => 'Platební období',
    'Table' => 'FinanceBillingPeriod',
    'DefaultSortColumn' => 'Name',
    'Items' => array(
      'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
      'MonthCount' => array('Type' => 'Integer', 'Caption' => 'Počet měsíců', 'Default' => '0', 'Suffix' => 'měsíců'),
      'Customers' => array('Type' => 'TCustomerListBillingPeriod', 'Caption' => 'Zákazníci', 'Default' => ''),
    ),
  ),
);

$FormManager->FormTypes = array
(
  'TPriority' => array(
    'Type' => 'Enumeration',
    'States' => array('Nízká', 'Střední', 'Vysoká'),
  ),
  'TOnlineState' => array(
    'Type' => 'Enumeration',
    'States' => array('<span style="color:red;">Nedostupný</span>', '<span style="color:green;">Dostupný</span>'),
  ),
  'TAntennaPolarity' => array(
    'Type' => 'Enumeration',
    'States' => array('Vertikální', 'Horizontální', 'Kruhová', 'Vertikální i horizontální'),
  ),
  'TNetworkDeviceState' => array(
    'Type' => 'Enumeration',
    'States' => array('Vyřazeno', 'Použito', 'Na skladě'),
  ),
  'TNetworkDeviceAction' => array(
    'Type' => 'Enumeration',
    'States' => array('Zakoupeno', 'Prodáno', 'Zařazeno do použití', 'Vyřazeno z použití', 'Zasláno do reklamace', 'Přijato z reklamace'),
  ),
  'TActionEnum' => array(
    'Type' => 'Enumeration',
    'States' => array('add' => 'Přidat', 'modify' => 'Upravit', 'remove' => 'Odstranit'),
  ),
  'TWirelessMode' => array(
    'Type' => 'Enumeration',
    'States' => array('Přístupový bod (AP)', 'Klient'),
  ),
  'TFinanceBillingPeriod' => array(
    'Type' => 'Reference',
    'Table' => 'FinanceBillingPeriod',
    'Id' => 'Id',
    'Name' => 'Name',
    'Filter' => '1',
  ),
  'TMemberListSubject' => array(
    'Type' => 'ManyToOne',
    'Table' => 'Member',
    'Id' => 'Id',
    'Ref' => 'Subject',
    'Filter' => '1',
  ),
  'TDocumentLine' => array(
    'Type' => 'Reference',
    'Table' => 'DocumentLine',
    'Id' => 'Id',
    'Name' => 'Name',
    'Filter' => '1',
  ),
  'TDocumentLineCode' => array(
    'Type' => 'Reference',
    'Table' => 'DocumentLineCode',
    'Id' => 'Id',
    'Name' => 'Name',
    'Filter' => '1',
  ),
	'TStockSerialNumberListStock' => array(
    'Type' => 'ManyToOne',
    'Table' => 'StockSerialNumber',
    'Id' => 'Id',
    'Ref' => 'Stock',
    'Filter' => '1',
  ),
  'TStockSerialNumberListProduct' => array(
    'Type' => 'ManyToOne',
    'Table' => 'StockSerialNumber',
    'Id' => 'Id',
    'Ref' => 'Product',
    'Filter' => '1',
  ),
  'TNetworkDeviceListProduct' => array(
    'Type' => 'ManyToOne',
    'Table' => 'NetworkDevice',
    'Id' => 'Id',
    'Ref' => 'Product',
    'Filter' => '1',
  ),
  'TDocumentLine' => array(
    'Type' => 'Reference',
    'Table' => 'DocumentLine',
    'Id' => 'Id',
    'Name' => 'Name',
    'Filter' => '1',
  ),
  'TFinanceYear' => array(
    'Type' => 'Reference',
    'Table' => 'FinanceYear',
    'Id' => 'Id',
    'Name' => 'Year',
    'Filter' => '1',
  ),
  'TCurrency' => array(
    'Type' => 'Reference',
    'Table' => 'Currency',
    'Id' => 'Id',
    'Name' => 'Code',
    'Filter' => '1',
  ),
  'TFinanceInvoice' => array(
    'Type' => 'Reference',
    'Table' => 'FinanceInvoice',
    'Id' => 'Id',
    'Name' => '(SELECT `DocumentLineCode`.`Name` FROM `DocumentLineCode` WHERE `Id`=`FinanceInvoice`.`BillCode`)',
    'Filter' => '1',
  ),
  'TFinanceOperation' => array(
    'Type' => 'Reference',
    'Table' => 'FinanceOperation',
    'Id' => 'Id',
    'Name' => '(SELECT `DocumentLineCode`.`Name` FROM `DocumentLineCode` WHERE `Id`=`FinanceOperation`.`BillCode`)',
    'Filter' => '1',
  ),
  'TFinanceCharge' => array(
    'Type' => 'Reference',
    'Table' => 'FinanceCharge',
    'Id' => 'Id',
    'Name' => 'Id',
    'Filter' => '1',
  ),
  'TDocumentLineSequenceListYear' => array(
    'Type' => 'ManyToOne',
    'Table' => 'DocumentLineSequence',
    'Id' => 'Id',
    'Ref' => 'FinanceYear',
    'Filter' => '1',
  ),
  'TDocumentLineSequenceListLine' => array(
    'Type' => 'ManyToOne',
    'Table' => 'DocumentLineSequence',
    'Id' => 'Id',
    'Ref' => 'DocumentLine',
    'Filter' => '1',
  ),
  'TDocumentLineCodeList' => array(
    'Type' => 'ManyToOne',
    'Table' => 'DocumentLineCode',
    'Id' => 'Id',
    'Ref' => 'DocumentLine',
    'Filter' => '1',
  ),
	'TUserCustomerRelListUser' => array(
    'Type' => 'ManyToOne',
    'Table' => 'UserCustomerRel',
    'Id' => 'Id',
    'Ref' => 'User',
    'Filter' => '1',
  ),
  'TUserCustomerRelListCustomer' => array(
    'Type' => 'ManyToOne',
    'Table' => 'UserCustomerRel',
    'Id' => 'Id',
    'Ref' => 'Customer',
    'Filter' => '1',
  ),
  'TFinanceInvoiceOperationRelListInvoice' => array(
    'Type' => 'ManyToOne',
    'Table' => 'FinanceInvoiceOperationRel',
    'Id' => 'Id',
    'Ref' => 'Invoice',
    'Filter' => '1',
  ),
  'TFinanceInvoiceOperationRelListOperation' => array(
    'Type' => 'ManyToOne',
    'Table' => 'FinanceInvoiceOperationRel',
    'Id' => 'Id',
    'Ref' => 'Operation',
    'Filter' => '1',
  ),
  'TCustomerStockSerialNumber' => array(
    'Type' => 'ManyToOne',
    'Table' => 'StockSerialNumber',
    'Id' => 'Id',
    'Ref' => 'Location',
    'Filter' => '1',
  ),
  'TPermissionUserAssignmentListUser' => array(
    'Type' => 'ManyToOne',
    'Table' => 'PermissionUserAssignment',
    'Id' => 'Id',
    'Ref' => 'User',
    'Filter' => '1',
  ),
  'TPermissionGroupAssignmentListGroup' => array(
    'Type' => 'ManyToOne',
    'Table' => 'PermissionGroupAssignment',
    'Id' => 'Id',
    'Ref' => 'Group',
    'Filter' => '1',
  ),
  'TPermissionGroupAssignmentListOperation' => array(
    'Type' => 'ManyToOne',
    'Table' => 'PermissionGroupAssignment',
    'Id' => 'Id',
    'Ref' => 'AssignedOperation',
    'Filter' => '1',
  ),
  'TPermissionGroupAssignmentListAssignedGroup' => array(
    'Type' => 'ManyToOne',
    'Table' => 'PermissionGroupAssignment',
    'Id' => 'Id',
    'Ref' => 'AssignedGroup',
    'Filter' => '1',
  ),
  'TNetworkSignalListInterface' => array(
    'Type' => 'ManyToOne',
    'Table' => 'NetworkSignal',
    'Id' => 'Id',
    'Ref' => 'Interface',
    'Filter' => '1',
  ),
  'TFinanceInvoiceItemListInvoice' => array(
    'Type' => 'ManyToOne',
    'Table' => 'FinanceInvoiceItem',
    'Id' => 'Id',
    'Ref' => 'FinanceInvoice',
    'Filter' => '1',
  ),
  'TFinanceInvoiceStornoListBy' => array(
    'Type' => 'ManyToOne',
    'Table' => 'FinanceInvoiceStorno',
    'Id' => 'Id',
    'Ref' => 'StornoBy',
    'Filter' => '1',
  ),
  'TFinanceInvoiceStornoListOf' => array(
    'Type' => 'ManyToOne',
    'Table' => 'FinanceInvoiceStorno',
    'Id' => 'Id',
    'Ref' => 'StornoOf',
    'Filter' => '1',
  ),
  'TFinanceInvoiceListGroup' => array(
    'Type' => 'ManyToOne',
    'Table' => 'FinanceInvoice',
    'Id' => 'Id',
    'Ref' => 'Group',
    'Filter' => '1',
  ),
  'TFinanceOperationListGroup' => array(
    'Type' => 'ManyToOne',
    'Table' => 'FinanceOperation',
    'Id' => 'Id',
    'Ref' => 'Group',
    'Filter' => '1',
  ),
    'TFinanceOperationListAccount' => array(
    'Type' => 'ManyToOne',
    'Table' => 'FinanceOperation',
    'Id' => 'Id',
    'Ref' => 'BankAccount',
    'Filter' => '1',
  ),
  'TFinanceOperationListSubject' => array(
    'Type' => 'ManyToOne',
    'Table' => 'FinanceOperation',
    'Id' => 'Id',
    'Ref' => 'Subject',
    'Filter' => '1',
  ),
  'TFinanceInvoiceListSubject' => array(
    'Type' => 'ManyToOne',
    'Table' => 'FinanceInvoice',
    'Id' => 'Id',
    'Ref' => 'Subject',
    'Filter' => '1',
  ),
  'TMenuItemListMenu' => array(
    'Type' => 'ManyToOne',
    'Table' => 'MenuItem',
    'Id' => 'Id',
    'Ref' => 'Menu',
    'Filter' => '1',
  ),
  'TMenuItemListParent' => array(
    'Type' => 'ManyToOne',
    'Table' => 'MenuItem',
    'Id' => 'Id',
    'Ref' => 'Parent',
    'Filter' => '1',
  ),
  'TActionListGroup' => array(
    'Type' => 'ManyToOne',
    'Table' => 'Action',
    'Id' => 'Id',
    'Ref' => 'Group',
    'Filter' => '1',
  ),
  'TFinanceOperationListTreasury' => array(
    'Type' => 'ManyToOne',
    'Table' => 'FinanceOperation',
    'Id' => 'Id',
    'Ref' => 'Treasury',
    'Filter' => '1',
  ),
  'TActionListIcon' => array(
    'Type' => 'ManyToOne',
    'Table' => 'Action',
    'Id' => 'Id',
    'Ref' => 'Icon',
    'Filter' => '1',
  ),
  'TActionListType' => array(
    'Type' => 'ManyToOne',
    'Table' => 'Action',
    'Id' => 'Id',
    'Ref' => 'Type',
    'Filter' => '1',
  ),
  'TStockSerialNumberListStockSerialNumber' => array(
    'Type' => 'ManyToOne',
    'Table' => 'StockSerialNumber',
    'Id' => 'Id',
    'Ref' => 'Esemble',
    'Filter' => '1',
  ),
  'TCustomerListBillingPeriod' => array(
    'Type' => 'ManyToOne',
    'Table' => 'Member',
    'Id' => 'Id',
    'Ref' => 'BillingPeriod',
    'Filter' => '1',
  ),
  'TFinanceOperationGroupListDocumentLine' => array(
    'Type' => 'ManyToOne',
    'Table' => 'FinanceOperationGroup',
    'Id' => 'Id',
    'Ref' => 'DocumentLine',
    'Filter' => '1',
  ),
  'TFinanceInvoiceGroupListDocumentLine' => array(
    'Type' => 'ManyToOne',
    'Table' => 'FinanceInvoiceGroup',
    'Id' => 'Id',
    'Ref' => 'DocumentLine',
    'Filter' => '1',
  ),
);
}
