Title = 'Daňová evidence'; $this->ParentClass = 'PageFinance'; } function GetTimePeriodBalance(int $StartTime, int $EndTime): array { $Balance = array(); $DbResult = $this->Database->query('SELECT SUM(`Value`) FROM `FinanceOperation` '. 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `FinanceOperation`.`Group` '. 'WHERE (`Time` < "'.TimeToMysqlDateTime($StartTime).'") AND (`Time` >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (`Taxable` = 1) AND (`FinanceOperationGroup`.`ValueSign` = 1)'); $Row = $DbResult->fetch_array(); $Balance['Income']['Start'] = $Row[0] + 0; $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceOperation '. 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `FinanceOperation`.`Group` '. 'WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (`FinanceOperationGroup`.`ValueSign` = 1)'); $Row = $DbResult->fetch_array(); $Balance['Income']['End'] = $Row[0] + 0; $DbResult = $this->Database->query('SELECT SUM(Value*ValueSign) FROM FinanceOperation '. 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `FinanceOperation`.`Group` '. 'WHERE (`Time` < "'.TimeToMysqlDateTime($StartTime).'") AND (`Time` >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (`Taxable` = 1) AND (`FinanceOperationGroup`.`ValueSign` = -1)'); $Row = $DbResult->fetch_array(); $Balance['Spend']['Start'] = $Row[0] + 0; $DbResult = $this->Database->query('SELECT SUM(Value*ValueSign) FROM FinanceOperation '. 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `FinanceOperation`.`Group` '. 'WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (`FinanceOperationGroup`.`ValueSign` = -1)'); $Row = $DbResult->fetch_array(); $Balance['Spend']['End'] = $Row[0] + 0; $DbResult = $this->Database->query('SELECT SUM(Value*ValueSign) FROM FinanceInvoice '. 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `FinanceInvoice`.`Group` '. 'WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (`FinanceInvoiceGroup`.`ValueSign` = 1)'); $Row = $DbResult->fetch_array(); $Balance['Claims']['Start'] = $Row[0] + 0; $DbResult = $this->Database->query('SELECT SUM(Value*ValueSign) FROM FinanceInvoice '. 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `FinanceInvoice`.`Group` '. 'WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (`FinanceInvoiceGroup`.`ValueSign` = 1)'); $Row = $DbResult->fetch_array(); $Balance['Claims']['End'] = $Row[0] + 0; $DbResult = $this->Database->query('SELECT SUM(Value*ValueSign) FROM FinanceInvoice '. 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `FinanceInvoice`.`Group` '. 'WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (`FinanceInvoiceGroup`.`ValueSign` = -1)'); $Row = $DbResult->fetch_array(); $Balance['Liabilities']['Start'] = $Row[0] + 0; $DbResult = $this->Database->query('SELECT SUM(Value*ValueSign) FROM FinanceInvoice '. 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `FinanceInvoice`.`Group` '. 'WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (`FinanceInvoiceGroup`.`ValueSign` = -1)'); $Row = $DbResult->fetch_array(); $Balance['Liabilities']['End'] = $Row[0] + 0; // SmallAssets $DbResult = $this->Database->query('SELECT SUM(SellPrice) FROM StockSerialNumber WHERE (TimeEnlistment < "'.TimeToMysqlDateTime($StartTime).'") AND (TimeEnlistment != 0) AND ((TimeElimination > "'.TimeToMysqlDateTime($StartTime).'") OR (TimeElimination IS NULL))'); //$Output .= $Database->error; $Row = $DbResult->fetch_array(); $Balance['SmallAssets']['Start'] = $Row[0] + 0; $DbResult = $this->Database->query('SELECT SUM(SellPrice) FROM StockSerialNumber WHERE (TimeEnlistment < "'.TimeToMysqlDateTime($EndTime).'") AND (TimeEnlistment != 0) AND ((TimeElimination > "'.TimeToMysqlDateTime($EndTime).'") OR (TimeElimination IS NULL))'); $Row = $DbResult->fetch_array(); $Balance['SmallAssets']['End'] = $Row[0] + 0; return $Balance; } function ShowAnnualBalance(): string { $Output = ''; $Output .= ''. ''; $this->StartEvidence = mktime(0, 0, 0, 12, 1, 2007); $StartYear = date('Y', $this->StartEvidence); $EndYear = date('Y', time()); for ($Year = $StartYear; $Year <= $EndYear; $Year++) { $EndTime = mktime(0, 0, 0, 12, 31, $Year); //$Year = date('Y', $EndTime); $StartTime = mktime(0, 0, 0, 1, 1, $Year); if ($StartTime < $this->StartEvidence) $StartTime = $this->StartEvidence; $Balance = $this->GetTimePeriodBalance($StartTime, $EndTime); $Output .= ''; $Output .= ''; $Output .= ''; $Output .= ''; $Output .= ''; $Output .= ''; $Output .= ''; $Output .= ''; $Output .= ''; $Output .= ''; $Output .= ''; $Output .= ''; } $Output .= '
Účetní obdobíNa konciBěhem
RokOdDoPříjmyVýdajePohledávkyZávazkyDrobný majetekPříjmyVýdajePohledávkyZávazkyDrobný majetekZáklad daně
'.$Year.''.date(HumanDate(TimeToMysqlDateTime($StartTime))).''.date(HumanDate(TimeToMysqlDateTime($EndTime))).''.round($Balance['Income']['End']).''.round($Balance['Spend']['End']).''.round($Balance['Claims']['End']).''.round($Balance['Liabilities']['End']).''.round($Balance['SmallAssets']['End']).''.round($Balance['Income']['End'] - $Balance['Income']['Start']).''.round($Balance['Spend']['End'] - $Balance['Spend']['Start']).''.round($Balance['Claims']['End'] - $Balance['Claims']['Start']).''.round($Balance['Liabilities']['End'] - $Balance['Liabilities']['Start']).''.round($Balance['SmallAssets']['End'] - $Balance['SmallAssets']['Start']).''.round(($Balance['Income']['End'] - $Balance['Income']['Start']) - ($Balance['Spend']['End'] - $Balance['Spend']['Start'])).'
'; return $Output; } function ShowMonthlyBalance(): string { $Output = ''; $Output .= ''. ''; $this->StartEvidence = mktime(0, 0, 0, 12, 1, 2007); $StartYear = date('Y', $this->StartEvidence); $EndYear = date('Y', time()); for ($Year = $StartYear; $Year <= $EndYear; $Year++) { for ($Month = 1; $Month <= 12; $Month++) { $EndTime = mktime(0, 0, 0, $Month, 31, $Year); //$Year = date('Y', $EndTime); $StartTime = mktime(0, 0, 0, $Month, 1, $Year); if (($StartTime < time()) and ($EndTime > $this->StartEvidence)) { if ($StartTime < $this->StartEvidence) $StartTime = $this->StartEvidence; $Balance = $this->GetTimePeriodBalance($StartTime, $EndTime); $Output .= ''; $Output .= ''; $Output .= ''; $Output .= ''; $Output .= ''; $Output .= ''; $Output .= ''; $Output .= ''; $Output .= ''; $Output .= ''; $Output .= ''; $Output .= ''; } } } $Output .= '
Účetní obdobíNa konciBěhem
RokMěsícOdDoPříjmyVýdajePohledávkyZávazkyDrobný majetekPříjmyVýdajePohledávkyZávazkyDrobný majetekZáklad daně
'.$Year.''.$Month.''.date(HumanDate(TimeToMysqlDateTime($StartTime))).''.date(HumanDate(TimeToMysqlDateTime($EndTime))).''.round($Balance['Income']['End']).''.round($Balance['Spend']['End']).''.round($Balance['Claims']['End']).''.round($Balance['Liabilities']['End']).''.round($Balance['SmallAssets']['End']).''.round($Balance['Income']['End'] - $Balance['Income']['Start']).''.round($Balance['Spend']['End'] - $Balance['Spend']['Start']).''.round($Balance['Claims']['End'] - $Balance['Claims']['Start']).''.round($Balance['Liabilities']['End'] - $Balance['Liabilities']['Start']).''.round($Balance['SmallAssets']['End'] - $Balance['SmallAssets']['Start']).''.round(($Balance['Income']['End'] - $Balance['Income']['Start']) - ($Balance['Spend']['End'] - $Balance['Spend']['Start'])).'
'; return $Output; } function ShowIncomes(): string { $Table = array('Ne', 'Ano'); $DbResult = $this->Database->select('FinanceYear', '*', 'Id='.$_GET['year']); $Year = $DbResult->fetch_assoc(); $Total = 0; $TotalTax = array(0, 0); $TotalCash = array(0, 0); $Output = 'Příjmy za rok '.$Year['Year'].''; $Output .= ''; $Output .= ''; $DbResult = $this->Database->query('SELECT `FinanceOperation`.*, `DocumentLineCode`.`Name` AS `BillName`, `Subject`.`Name` AS `Name` FROM `FinanceOperation` '. 'LEFT JOIN `Subject` ON `Subject`.`Id` = `FinanceOperation`.`Subject` '. 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `FinanceOperation`.`Group` '. 'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id` = `FinanceOperation`.`BillCode` '. 'WHERE (`ValueSign` = 1) AND (`FinanceOperation`.`Time` >= "'.$Year['DateStart'].'") '. 'AND (`FinanceOperation`.`Time` <= "'.$Year['DateEnd'].'") ORDER BY `Time`'); while ($Row = $DbResult->fetch_array()) { $Row['Time'] = explode(' ', $Row['Time']); $Row['Time'] = $Row['Time'][0]; $Output .= ''; $Total += $Row['Value']; $TotalTax[$Row['Taxable']] += $Row['Value']; $TotalCash[$Row['Cash']] += $Row['Value']; } $Output .= '
ČasKódSubjektTextHodnota [Kč]DaňovýHotovost
'.HumanDate($Row['Time']).''.$Row['BillName']. ''.$Row['Name'].''.$Row['Text'].''.$Row['Value']. ''.$Table[$Row['Taxable']].''.$Table[$Row['Cash']].'

'; $Output .= 'Souhrn
'; $Output .= 'Celkem: '.$Total.' Kč
'; $Output .= ' Daňové: '.$TotalTax[1].' Kč
'; $Output .= ' Nedaňové: '.$TotalTax[0].' Kč
'; $Output .= ' Hotovostní: '.$TotalCash[1].' Kč
'; $Output .= ' Bezhotovostní: '.$TotalCash[0].' Kč
'; return $Output; } function ShowExpenses(): string { $Table = array('Ne', 'Ano'); $DbResult = $this->Database->select('FinanceYear', '*', 'Id='.$_GET['year']); $Year = $DbResult->fetch_assoc(); $Total = 0; $TotalTax = array(0, 0); $TotalCash = array(0, 0); $Output = 'Výdaje za rok '.$Year['Year'].''; $Output .= ''; $Output .= ''; $DbResult = $this->Database->query('SELECT `FinanceOperation`.*, `DocumentLineCode`.`Name` AS `BillName`, '. '`Subject`.`Name` AS `SubjectName`, `FinanceOperationGroup`.`ValueSign` AS `ValueSign` FROM `FinanceOperation` '. 'LEFT JOIN `Subject` ON `Subject`.`Id` = `FinanceOperation`.`Subject` '. 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `FinanceOperation`.`Group` '. 'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id` = `FinanceOperation`.`BillCode` '. 'WHERE (`FinanceOperationGroup`.`ValueSign` = -1) AND (`FinanceOperation`.`Time` >= "'.$Year['DateStart'].'") '. 'AND (`FinanceOperation`.`Time` <= "'.$Year['DateEnd'].'") ORDER BY `Time`'); while ($Row = $DbResult->fetch_array()) { $Row['Time'] = explode(' ', $Row['Time']); $Row['Time'] = $Row['Time'][0]; $Row['Value'] = $Row['Value'] * $Row['ValueSign']; $Output .= ''; $Total += $Row['Value']; $TotalTax[$Row['Taxable']] += $Row['Value']; $TotalCash[$Row['Cash']] += $Row['Value']; } $Output .= '
ČasKódSubjektTextHodnota [Kč]DaňovýHotovost
'.HumanDate($Row['Time']).''.$Row['BillName']. ''.$Row['SubjectName'].''.$Row['Text'].''.$Row['Value']. ''.$Table[$Row['Taxable']].''.$Table[$Row['Cash']].'

'; $Output .= 'Souhrn
'; $Output .= 'Celkem: '.$Total.' Kč
'; $Output .= ' Daňové: '.$TotalTax[1].' Kč
'; $Output .= ' Nedaňové: '.$TotalTax[0].' Kč
'; $Output .= ' Hotovostní: '.$TotalCash[1].' Kč
'; $Output .= ' Bezhotovostní: '.$TotalCash[0].' Kč
'; return $Output; } function ShowClaims(): string { $Table = array('Ne', 'Ano'); $DbResult = $this->Database->select('FinanceYear', '*', 'Id='.$_GET['year']); $Year = $DbResult->fetch_assoc(); $Total = 0; $Output = 'Pohledávky za rok '.$Year['Year'].''; $Output .= ''; $Output .= ''; $DbResult = $this->Database->query('SELECT `FinanceInvoice`.*, '. '`DocumentLineCode`.`Name` AS `BillName`, `Subject`.`Name` AS `SubjectName`, '. '(SELECT GROUP_CONCAT(`Description` SEPARATOR ",") '. 'FROM `FinanceInvoiceItem` WHERE `FinanceInvoiceItem`.`FinanceInvoice` = `FinanceInvoice`.`Id`) AS `Text` FROM `FinanceInvoice`'. 'LEFT JOIN `Subject` ON `Subject`.`Id` = `FinanceInvoice`.`Subject` '. 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `FinanceInvoice`.`Group` '. 'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id` = `FinanceInvoice`.`BillCode` '. 'WHERE (`FinanceInvoiceGroup`.`ValueSign` = 1) AND (`FinanceInvoice`.`Time` >= "'.$Year['DateStart']. '") AND (`FinanceInvoice`.`Time` <= "'.$Year['DateEnd'].'") ORDER BY `Time`'); while ($Row = $DbResult->fetch_array()) { if ($Row['TimePayment'] == '0000-00-00 00:00:00') $Row['TimePayment'] = ' '; $Output .= ''; $Total += $Row['Value']; } $Output .= '
Čas vystaveníKódSubjektTextHodnota [Kč]
'.HumanDate($Row['Time']).''.$Row['BillName']. ''.$Row['SubjectName'].''.$Row['Text'].''.$Row['Value'].'

'; $Output .= 'Celkem: '.$Total.' Kč
'; return $Output; } function ShowLiabilities(): string { $Table = array('Ne', 'Ano'); $DbResult = $this->Database->select('FinanceYear', '*', 'Id='.$_GET['year']); $Year = $DbResult->fetch_assoc(); $Total = 0; $Output = 'Závazky za rok '.$Year['Year'].''; $Output .= ''; $Output .= ''; $DbResult = $this->Database->query('SELECT *, `DocumentLineCode`.`Name` AS `BillName`, `Subject`.`Name` AS `SubjectName`, '. '(SELECT GROUP_CONCAT(Description SEPARATOR ",") '. 'FROM `FinanceInvoiceItem` WHERE `FinanceInvoiceItem`.`FinanceInvoice` = `FinanceInvoice`.`Id`) AS `Text` '. 'FROM `FinanceInvoice` '. 'LEFT JOIN `Subject` ON `Subject`.`Id` = `FinanceInvoice`.`Subject` '. 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `FinanceInvoice`.`Group` '. 'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id` = `FinanceInvoice`.`BillCode` '. 'WHERE (`FinanceInvoiceGroup`.`ValueSign` = -1) AND (`FinanceInvoice`.`Time` >= "'.$Year['DateStart']. '") AND (FinanceInvoice.Time <= "'.$Year['DateEnd'].'") ORDER BY Time'); while ($Row = $DbResult->fetch_array()) { if ($Row['TimePayment'] == '0000-00-00 00:00:00') $Row['TimePayment'] = ' '; $Row['Value'] = $Row['Value'] * $Row['ValueSign']; $Output .= ''; $Total += $Row['Value']; } $Output .= '
Čas vystaveníKódSubjektTextHodnota [Kč]
'.HumanDate($Row['Time']).''.$Row['BillName']. ''.$Row['SubjectName'].''.$Row['Text'].''.$Row['Value'].'

'; $Output .= 'Celkem: '.$Total.' Kč
'; return $Output; } function ShowSubjectList(): string { $Output = 'Seznam subjektů'; $Output .= ''; $Output .= ''; $DbResult = $this->Database->query('SELECT Id, Name, 0 AS Cash, '. '(SELECT SUM(T1.Value) FROM FinanceInvoice AS T1 '. 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `T1`.`Group` '. 'WHERE (T1.Subject = Subject.Id) AND (`FinanceInvoiceGroup`.ValueSign = 1)) AS `Claims`, '. '(SELECT SUM(T2.Value) FROM FinanceInvoice AS T2 '. 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `T2`.`Group` '. 'WHERE (T2.Subject = Subject.Id) AND (`FinanceInvoiceGroup`.`ValueSign` = 1) AND (TimePayment IS NULL)) AS `OpenedClaims`, '. '(SELECT -SUM(T3.Value) FROM FinanceInvoice AS T3 '. 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `T3`.`Group` '. 'WHERE (T3.Subject = Subject.Id) AND (`FinanceInvoiceGroup`.`ValueSign` = -1)) AS `Liabilities`, '. '(SELECT -SUM(T4.Value) FROM FinanceInvoice AS T4 '. 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `T4`.`Group` '. 'WHERE (T4.Subject = Subject.Id) AND (`FinanceInvoiceGroup`.`ValueSign` = -1) AND (`TimePayment` IS NULL)) AS `OpenedLiabilities`, '. '(SELECT SUM(T5.Value) FROM FinanceOperation AS T5 '. 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `T5`.`Group` '. 'WHERE (T5.Subject = Subject.Id) AND (`FinanceOperationGroup`.`ValueSign` = 1)) AS `Gains`, '. '(SELECT SUM(T6.Value) FROM FinanceOperation AS T6 '. 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `T6`.`Group` '. 'WHERE (T6.Subject = Subject.Id) AND (`FinanceOperationGroup`.`ValueSign` = -1)) AS `Spends` '. 'FROM Subject ORDER BY Name'); while ($Row = $DbResult->fetch_assoc()) { $Output .= ''; } $Output .= '
JménoZávazky [Kč]Pohledávky [Kč]Příjmy [Kč]Výdaje [Kč]Stav účtuStarý systém
'.$Row['Name'].''.$Row['Liabilities'].' / '.$Row['OpenedLiabilities'].''.$Row['Claims'].' / '.$Row['OpenedClaims'].''.$Row['Gains'].''.$Row['Spends'].''.($Row['Gains'] - $Row['Spends'] - $Row['Claims'] + $Row['Liabilities']).''.$Row['Cash'].'
'; return $Output; } function ShowSmallAssets(): string { $Output = 'Drobný majetek'; $Output .= ''; $Output .= ''; $DbResult = $this->Database->query('SELECT Product.Name AS Name, StockSerialNumber.SellPrice AS Price, StockSerialNumber.TimeEnlistment AS TimeEnlistment, StockSerialNumber.TimeElimination AS TimeElimination '. 'FROM StockSerialNumber JOIN Product ON Product.Id = StockSerialNumber.Product '. 'WHERE (TimeElimination IS NOT NULL)'); while ($Row = $DbResult->fetch_array()) { $Output .= ''; } $Output .= '
NázevHodnota [Kč]Datum zakoupeníDatum vyřezení
'.$Row['Name'].''.$Row['Price'].''.$Row['TimeEnlistment'].''.$Row['TimeElimination'].'
'; return $Output; } function ShowSubjectAccount(): string { $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance; $Output = '
'; $Output .= 'Výpis příjmů/výdajů'; $Output .= ''; $Output .= ''; $DbResult = $this->Database->query('SELECT `FinanceOperation`.*, `DocumentLineCode`.`Name` AS `BillName` '. 'FROM `FinanceOperation` '. 'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id` = `FinanceOperation`.`BillCode` '. 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `FinanceOperation`.`Group` '. 'WHERE `Subject`='.$_GET['Id'].' ORDER BY `Time`'); while ($Row = $DbResult->fetch_array()) { $Output .= ''; } $Output .= '
DatumNázevHodnota [Kč]Doklad
'.HumanDate($Row['Time']).''.$Row['Text']. ''.$Row['Value'].''.$Row['BillName'].'
'; $Output .= 'Výpis závazků/pohledávek'; $Output .= ''; $Output .= ''; $DbResult = $this->Database->query('SELECT `FinanceInvoice`.*, (SELECT GROUP_CONCAT(Description SEPARATOR ",") '. 'FROM FinanceInvoiceItem WHERE `FinanceInvoiceItem`.`FinanceInvoice` = `FinanceInvoice`.`Id`) AS `Text`, `DocumentLineCode`.`Name` AS `BillName` '. 'FROM `FinanceInvoice` '. 'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id` = `FinanceInvoice`.`BillCode` '. 'WHERE `Subject`='.$_GET['Id'].' ORDER BY `Time`'); while ($Row = $DbResult->fetch_array()) { $Output .= ''; } $Output .= '
Datum vytvořeníDatum zaplaceníNázevHodnota [Kč]Doklad
'.HumanDate($Row['Time']).''.HumanDate($Row['TimePayment']). ''.$Row['Text'].''.round($Row['Value'], $Finance->Rounding).''.$Row['BillName'].'
'; /*$Output .= 'Výpis záloh'; $Output .= ''; $Output .= ''; $DbResult = $this->Database->select('FinanceAdvances', '*', 'Subject='.$_GET['Id']); while ($Row = $DbResult->fetch_array()) { $Output .= ''; } $Output .= '
Datum vytvořeníDatum zaplaceníNázevHodnota [Kč]
'.$Row['Time'].''.$Row['TimePass'].''.$Row['ValueSign'].''.($Row['Value']).''.$Row['CashFlowId'].'
';*/ $DbResult = $this->Database->query('SELECT Id, 0 AS Cash, (SELECT SUM(FinanceInvoice.Value * FinanceInvoice.ValueSign) '. 'FROM FinanceInvoice WHERE (FinanceInvoice.Subject = Subject.Id) AND '. '(FinanceInvoice.ValueSign = 1)) as Claims, (SELECT SUM(FinanceInvoice.Value * FinanceInvoice.ValueSign) '. 'FROM FinanceInvoice WHERE (FinanceInvoice.Subject = Subject.Id) AND ('. 'FinanceInvoice.ValueSign = 1) AND (TimePayment IS NULL)) as OpenedClaims, '. '(SELECT SUM(FinanceInvoice.Value * FinanceInvoice.ValueSign) FROM FinanceInvoice '. 'WHERE (FinanceInvoice.Subject = Subject.Id) AND (FinanceInvoice.ValueSign = -1)) AS '. 'Liabilities, (SELECT SUM(FinanceInvoice.Value) FROM FinanceInvoice '. 'WHERE (FinanceInvoice.Subject = Subject.Id) AND (FinanceInvoice.ValueSign = -1) '. 'AND (TimePayment IS NULL)) AS OpenedLiabilities, '. '(SELECT SUM(FinanceOperation.Value*FinanceOperation.ValueSign) '. 'FROM FinanceOperation WHERE FinanceOperation.Subject = Subject.Id AND FinanceOperation.ValueSign = 1) '. 'AS Gains, (SELECT SUM(FinanceOperation.Value*FinanceOperation.ValueSign) FROM FinanceOperation WHERE '. 'FinanceOperation.Subject = Subject.Id AND FinanceOperation.ValueSign = -1) as Spends '. 'FROM Subject WHERE Id='.$_GET['Id']); $Row = $DbResult->fetch_array(); $Output .= 'Stav placení: '.(-$Row['OpenedClaims'] + Abs($Row['OpenedLiabilities'])); return $Output; } function ShowDefault(): string { $Output = 'Celkové přehledy
'; $Output .= 'Účetní závěrka
'; $Output .= 'Měsíční přehledy
'; $Output .= 'Seznam subjektů
'; $Output .= 'Drobný majetek
'; $Output .= '
'; $Output .= 'Roční přehledy
'; $Output .= $this->ShowFinanceYears(); if (array_key_exists('year', $_GET)) { $Year = $_GET['year'] * 1; $Output .= 'Příjmy
'; $Output .= 'Výdaje
'; $Output .= 'Pohledávky
'; $Output .= 'Závazky
'; $Output .= 'Zálohy
'; $Output .= 'Souhrný přehled
'; } return $Output; } function Show(): string { if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'TradingStatus')) return 'Nemáte oprávnění'; $Output = ''; if (!array_key_exists('table', $_GET)) $_GET['table'] = ''; switch ($_GET['table']) { case 'AnnualBalance': $Output = $this->ShowAnnualBalance(); break; case 'MonthlyBalance': $Output = $this->ShowMonthlyBalance(); break; case 'YearReport': $Output .= $this->ShowIncomes().'
'; $Output .= $this->ShowExpenses().'
'; $Output .= $this->ShowClaims().'
'; $Output .= $this->ShowLiabilities().'
'; break; case 'Incomes': $Output = $this->ShowIncomes(); break; case 'Expenses': $Output = $this->ShowExpenses(); break; case 'Claims': $Output = $this->ShowClaims(); break; case 'Liabilities': $Output = $this->ShowLiabilities(); break; case 'SubjectList': $Output = $this->ShowSubjectList(); break; case 'SmallAssets': $Output = $this->ShowSmallAssets(); break; case 'SubjectAccount': $Output = $this->ShowSubjectAccount(); break; case 'PrintMonthOperations': $Output .= '
DatumSubjekt
'; break; case 'PrintMonthOperations': $Output .= 'Výpis operací od '.$_GET['TimeFrom'].' do '.$_GET['TimeTo']; $Output .= '
DatumSubjektSuma [Kč]
'; break; default: $Output = $this->ShowDefault(); } return $Output; } function ShowFinanceYears(): string { $Output = 'Roky: '; $DbRows = $this->Database->select('FinanceYear', '*'); while ($DbRow = $DbRows->fetch_assoc()) $Output .= ''.$DbRow['Year'].' '; $Output .= '
'; return $Output; } function AddMoney($Subject, $Value, $Text, $Time) { $TimeDue = $Time + 15 * 24 * 3600; // 15 dnů } function AddInvoice($Subject, $Value, $Text, $Time) { $TimeDue = $Time + 15 * 24 * 3600; // 15 dnů } }