Title = 'Stav financí'; $this->Description = 'Stav financí účastníka'; $this->ParentClass = 'PageUser'; } function ShowFinanceOperation(int $SubjectId): string { $UserOperationTableQuery = '((SELECT `Text`, `FinanceOperation`.`Time`, `Value`, `File`.`Hash` AS `FileHash`, `BillCode`, NULL AS `PeriodFrom`, NULL AS `PeriodTo`, `DocumentLineCode`.`Name` AS `BillName` '. 'FROM `FinanceOperation` '. 'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id`=`FinanceOperation`.`BillCode` '. 'LEFT JOIN `File` ON `File`.`Id`=`FinanceOperation`.`File` '. 'WHERE (`Subject`='.$SubjectId.') '. ') UNION ALL '. '(SELECT (SELECT GROUP_CONCAT(`Description` SEPARATOR ",") FROM `FinanceInvoiceItem` WHERE `FinanceInvoice`=`FinanceInvoice`.`Id`) AS `Text`, '. '`FinanceInvoice`.`Time`, -`Value`, `File`.`Hash` AS `FileHash`, `BillCode`, `PeriodFrom`, `PeriodTo`, `DocumentLineCode`.`Name` AS `BillName` '. 'FROM `FinanceInvoice` '. 'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id`=`FinanceInvoice`.`BillCode` '. 'LEFT JOIN `File` ON `File`.`Id`=`FinanceInvoice`.`File` '. 'WHERE (`Subject`='.$SubjectId.') AND (`VisibleToUser` = 1)))'; $Output = '
'.HumanDate($Row['Time']).' | '. ''.$Row['Text'].' | '. ''.round($Row['Value'], 2).' | '. ''.$Row['State'].' | '. ''.$Period.' | '. ''.$Invoice.' |
';
// Account state
$UserOperationTableQuery = '((SELECT `Text`, `Time`, `Value`, `File`, `BillCode`, NULL AS `PeriodFrom`, NULL AS `PeriodTo` '.
'FROM `FinanceOperation` WHERE (`Subject`='.$Subject['Id'].')) UNION ALL '.
'(SELECT (SELECT GROUP_CONCAT(`Description` SEPARATOR ",") FROM `FinanceInvoiceItem` WHERE `FinanceInvoice`=`FinanceInvoice`.`Id`) AS `Text`, '.
'`Time`, -`Value`, `File`, `BillCode`, `PeriodFrom`, `PeriodTo` FROM `FinanceInvoice` WHERE (`Subject`='.$Subject['Id'].')) ORDER BY `Time` DESC) AS `T1`';
$DbResult = $this->Database->query('SELECT SUM(`T1`.`Value`) AS `Total` FROM '.$UserOperationTableQuery);
$DbRow = $DbResult->fetch_array();
$Total = $DbRow['Total'];
$Output .= 'Stav účtu: '.round($Total, 2).' Kč '; // Tabulka operaci $Output .= $this->ShowFinanceOperation($Subject['Id']); $Output .= ' | ';
$DbResult = $this->Database->query('SELECT FinanceBankAccount.*, CONCAT(FinanceBankAccount.Number, "/", FinanceBank.Code) AS NumberFull FROM FinanceBankAccount '.
'JOIN FinanceBank ON FinanceBank.Id=FinanceBankAccount.Bank '.
'WHERE (FinanceBankAccount.`Subject`='.$this->System->Config['Finance']['MainSubjectId'].') AND (FinanceBankAccount.`Use`=1)');
$SubjectFromAccount = $DbResult->fetch_assoc();
$Account = $SubjectFromAccount['NumberFull'];
$Output .= 'Účet pro platby: '.$Account.' '; $Output .= 'Variabilní symbol pro platby: '.$Subject['Id'].' '; $Output .= 'Subjekt: '.$Subject['Name'].' '; $Output .= ' '; $Total = 0; $Output .= 'Rozpis měsíčního poplatku:
'); $Output .= ' '; $Output .= ' |