'. $Subject['AddressStreet'].'
'. $Subject['AddressPSC'].' '.$Subject['AddressTown'].'
'; if (($Subject['IC'] != '') and ($Subject['IC'] != 0)) $Output .= 'IČ: '.$Subject['IC'].'
'; if ($Subject['DIC'] != '') $Output .= 'DIČ: '.$Subject['DIC'].'
'; if ($Subject['Account'] != '') $Output .= 'Účet: '.$Subject['Account'].'
'; if ($Subject['PayVAT'] != '') $Output .= 'Plátce DPH: '.$BooleanText[$Subject['PayVAT']].'
'; return $Output; } function GenerateHTML(): string { $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance; $Finance->LoadMonthParameters(0); $DbResult = $this->Database->query('SELECT `FinanceInvoice`.*, `FinanceInvoiceGroup`.`Direction`, `DocumentLineCode`.`Name` AS `BillName` FROM `FinanceInvoice` '. 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id`=`FinanceInvoice`.`Group` '. 'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id`=`FinanceInvoice`.`BillCode` '. 'WHERE `FinanceInvoice`.`Id`='.$this->InvoiceId); $Invoice = $DbResult->fetch_assoc(); $DbResult = $this->Database->select('Subject', '*', '`Id`='.$Invoice['Subject']); $SubjectTo = $DbResult->fetch_assoc(); $SubjectTo['Account'] = ''; $SubjectTo['PayVAT'] = ''; $VarSym = $SubjectTo['Id']; $DbResult = $this->Database->select('Subject', '*', '`Id`='.$this->System->Config['Finance']['MainSubjectId']); $SubjectFrom = $DbResult->fetch_assoc(); $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(); $SubjectFrom['Account'] = $SubjectFromAccount['NumberFull']; $InvoiceItems = array(); $DbResult = $this->Database->select('FinanceInvoiceItem', '*, ROUND(`Price` * `Quantity`, '.$Finance->Rounding.') AS `Total`', '`FinanceInvoice`='.$this->InvoiceId); while ($Item = $DbResult->fetch_assoc()) { $InvoiceItems[$Item['Id']] = $Item; } // If direction is in => switch sides if ($Invoice['Direction'] == FINANCE_DIRECTION_OUT) { } else if ($Invoice['Direction'] == FINANCE_DIRECTION_IN) { $Subject = $SubjectTo; $SubjectTo = $SubjectFrom; $SubjectFrom = $Subject; } else throw new Exception('Wrong finance direction'); $PaymentType = array('převodem', 'hotově'); $BooleanText = array('Ne', 'Ano'); $Output = ''. ''. ''. ''. ''. ''. '
'. '
Faktura - daňový doklad
'. '
Dodavatel:
'. $this->ShowSubjectInfo($SubjectFrom). '
'. 'Odběratel:
'. $this->ShowSubjectInfo($SubjectTo); $Output .= '

'. 'Platební podmínky:
'. 'Číslo dokladu: '.$Invoice['BillName'].'
'. 'Variabilní symbol: '.$VarSym.'
'. 'Specifický symbol: '.$this->SpecificSymbol.'
'. 'Konstantní symbol:
'. 'Způsob úhrady: '.$PaymentType[$Invoice['Cash']]. '
'. '
'. 'Datum vystavení: '.HumanDate($Invoice['Time']).'
'. 'Datum zdanitel. plnění: '.HumanDate($Invoice['Time']).'
'. 'Datum splatnosti: '.HumanDate($Invoice['TimeDue']).'
'; if (($Invoice['PeriodFrom'] != '') and ($Invoice['PeriodTo'] != '')) $Output .= 'Fakturované období: '.HumanDate($Invoice['PeriodFrom']).' - '. HumanDate($Invoice['PeriodTo']).'
'; $Output .= '
'. '
'. '
'. ''. ''. ''; $Total = 0; foreach ($InvoiceItems as $Item) { $Output .= ''; $Total += $Item['Total']; } $Output .= ''; $Output .= '
DodávkaMnožstvíCena/MJCelkem

'.$Item['Description'].''. $Item['Quantity'].''.$Item['Price']. ' Kč'.$Item['Total'].' Kč
Celkem'.$Total.' Kč
'. '

'; return $Output; } } class BillOperation extends Bill { public string $OperationId; function GenerateHTML(): string { $DbResult = $this->Database->query('SELECT `FinanceOperation`.*, `FinanceOperationGroup`.`Direction`, `DocumentLineCode`.`Name` AS `BillName` FROM `FinanceOperation` '. 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id`=`FinanceOperation`.`Group` '. 'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id`=`FinanceOperation`.`BillCode` '. 'WHERE `FinanceOperation`.`Id`='.$this->OperationId); $Operation = $DbResult->fetch_assoc(); $DbResult = $this->Database->select('Subject', '*', '`Id`='.$Operation['Subject']); $Subject = $DbResult->fetch_assoc(); $DbResult = $this->Database->select('Subject', '*', '`Id`='.$this->System->Config['Finance']['MainSubjectId']); $MainSubject = $DbResult->fetch_assoc(); $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)'); $MainSubjectAccount = $DbResult->fetch_assoc(); $BooleanText = array('Ne', 'Ano'); if ($Operation['Direction'] == FINANCE_DIRECTION_OUT) $Desc = array( 'Type' => 'VÝDAJOVÝ', 'Signature' => 'Vydal', 'Target' => 'Vydáno komu', ); else if ($Operation['Direction'] == FINANCE_DIRECTION_IN) $Desc = array( 'Type' => 'PŘÍJMOVÝ', 'Signature' => 'Přijal', 'Target' => 'Přijato od', ); else throw new Exception('Wrong finance direction'); $Output = ''. ''. ''. ''. ''; $Output .= '
'. 'Firma:
'. $MainSubject['Name'].'
'. $MainSubject['AddressStreet'].'
'. $MainSubject['AddressPSC'].' '.$MainSubject['AddressTown'].'
'. 'IČ: '.$MainSubject['IC'].'
'. 'DIČ: '.$MainSubject['DIC'].'
'. 'Účet: '.$MainSubjectAccount['NumberFull'].'
'. 'Plátce DPH: '.$BooleanText[$MainSubject['PayVAT']]. '
'. ''.$Desc['Type'].' POKLADNÍ DOKLAD

'. 'Číslo dokladu: '.$Operation['BillName'].'
'. 'Datum vystavení: '.HumanDate($Operation['Time']).'
'. '
'.$Desc['Target'].':
'. $Subject['Name'].'
'. $Subject['AddressStreet'].'
'. $Subject['AddressPSC'].' '.$Subject['AddressTown'].'
'; if ($Subject['IC'] != 0) $Output .= 'IČ: '.$Subject['IC'].'
'; if ($Subject['DIC'] != '') $Output .= 'DIČ: '.$Subject['DIC'].'
'; $Description = $Operation['Text']; $Output .= '
Částka: '.$Operation['Value'].' Kč

'. '
Účel platby:
'.$Description.'
 

'.$Desc['Signature'].':
'; return $Output; } }