1 | <?php
|
---|
2 | include_once('../global.php');
|
---|
3 |
|
---|
4 | class FinanceTaxFilingPage extends Page
|
---|
5 | {
|
---|
6 | var $FullTitle = 'Daňová evidence';
|
---|
7 | var $ShortTitle = 'Daňová evidence';
|
---|
8 | var $ExternalSubject = 96;
|
---|
9 | var $MainSubject = 71;
|
---|
10 | var $StartEvidence = 0;
|
---|
11 |
|
---|
12 | /*function TransformFinance()
|
---|
13 | {
|
---|
14 | //$Database->Query('SELECT user as Subject, date as TimeCreation, date as TimeDue, date as TimePayment, -money as Value, bill_id as Bill, comment as Text FROM `finance_operations` WHERE Comment LIKE "Poplatek za měsíc%" AND date >= "2007-12-01"');
|
---|
15 | //'TRUNCATE TABLE FinanceCashFlow; INSERT INTO FinanceCashFlow (SELECT '' as Id, user as Subject, comment as Text, date as Time, 1 as Taxable, 0 as Cash, money as Value, bill_id as Bill FROM `finance_operations` WHERE comment NOT LIKE "Poplatek za měsíc%" AND date >= "2007-12-01")'
|
---|
16 | // 'UPDATE finance_operations SET date="2007-11-24" WHERE comment="Jednorázový poplatek za společné zařízení"'
|
---|
17 |
|
---|
18 | $DbResult = $this->Database->query('SELECT * FROM users WHERE role=2');
|
---|
19 | while($User = $DbResult->fetch_array())
|
---|
20 | {
|
---|
21 | $DbResult2 = $this->Database->query('SELECT SUM(money) FROM finance_operations WHERE user='.$User['id'].' AND date < "2007-12-01"');
|
---|
22 | $Row = $DbResult2->fetch_array();
|
---|
23 | echo($User['second_name'].' '.$User['first_name'].' '.$Row[0].'<br />');
|
---|
24 | // if($Row[0] > 0) $Database->insert('FinanceCashFlow', array('Text' => 'Přijatá záloha (z období před účetnictvím)', 'Subject' => $User['id'], 'Time' => '2007-01-01', 'Taxable' => 1, 'Cash' => 0, 'Value' => $Row[0], 'Bill' => 0));
|
---|
25 | if($Row[0] < 0)
|
---|
26 | {
|
---|
27 | $this->Database->insert('FinanceClaimsLiabilities', array('Text' => 'Připojení k síti (z období před účetnictvím)', 'Subject' => $User['id'], 'TimeCreation' => '2007-12-01', 'TimeDue' => '2007-12-14', 'TimePayment' => '', 'Value' => (-$Row[0]), 'Bill' => 0));
|
---|
28 | //echo($Database->LastQuery.'<br />');
|
---|
29 | }
|
---|
30 | }
|
---|
31 | }*/
|
---|
32 | function GetTimePeriodBalance($StartTime, $EndTime)
|
---|
33 | {
|
---|
34 | $Balance = array();
|
---|
35 | $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceOperation WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (Value > 0)');
|
---|
36 | $Row = $DbResult->fetch_array();
|
---|
37 | $Balance['Income']['Start'] = $Row[0] + 0;
|
---|
38 | $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceOperation WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (Value > 0)');
|
---|
39 | //echo('SELECT SUM(Value) FROM FinanceCashFlow WHERE Time <= "'.TimeToMysqlDateTime($EndTime).'" AND Value > 0 AND Taxable = 1'.'<br />');
|
---|
40 | $Row = $DbResult->fetch_array();
|
---|
41 | $Balance['Income']['End'] = $Row[0] + 0;
|
---|
42 |
|
---|
43 | $DbResult = $this->Database->query('SELECT SUM(-Value) FROM FinanceOperation WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (Value < 0)');
|
---|
44 | $Row = $DbResult->fetch_array();
|
---|
45 | $Balance['Spend']['Start'] = $Row[0] + 0;
|
---|
46 | $DbResult = $this->Database->query('SELECT SUM(-Value) FROM FinanceOperation WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (Value < 0)');
|
---|
47 | //echo('SELECT -SUM(Value) FROM FinanceCashFlow WHERE Time <= "'.TimeToMysqlDateTime($EndTime).'" AND Value < 0 AND Taxable = 1'.'<br />');
|
---|
48 | $Row = $DbResult->fetch_array();
|
---|
49 | $Balance['Spend']['End'] = $Row[0] + 0;
|
---|
50 |
|
---|
51 | $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceClaimsLiabilities WHERE (TimeCreation < "'.TimeToMysqlDateTime($StartTime).'") AND (TimeCreation >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Value > 0)');
|
---|
52 | $Row = $DbResult->fetch_array();
|
---|
53 | $Balance['Claims']['Start'] = $Row[0] + 0;
|
---|
54 | $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceClaimsLiabilities WHERE (TimeCreation <= "'.TimeToMysqlDateTime($EndTime).'") AND (TimeCreation >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Value > 0)');
|
---|
55 | $Row = $DbResult->fetch_array();
|
---|
56 | $Balance['Claims']['End'] = $Row[0] + 0;
|
---|
57 |
|
---|
58 | $DbResult = $this->Database->query('SELECT SUM(-Value) FROM FinanceClaimsLiabilities WHERE (TimeCreation < "'.TimeToMysqlDateTime($StartTime).'") AND (TimeCreation >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Value < 0)');
|
---|
59 | $Row = $DbResult->fetch_array();
|
---|
60 | $Balance['Liabilities']['Start'] = $Row[0] + 0;
|
---|
61 | $DbResult = $this->Database->query('SELECT SUM(-Value) FROM FinanceClaimsLiabilities WHERE (TimeCreation <= "'.TimeToMysqlDateTime($EndTime).'") AND (TimeCreation >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Value < 0)');
|
---|
62 | $Row = $DbResult->fetch_array();
|
---|
63 | $Balance['Liabilities']['End'] = $Row[0] + 0;
|
---|
64 |
|
---|
65 | // SmallAssets
|
---|
66 | $DbResult = $this->Database->query('SELECT SUM(price) FROM network_devices WHERE (TimeEnlistment < "'.TimeToMysqlDateTime($StartTime).'") AND (TimeEnlistment != 0) AND ((TimeElimination > "'.TimeToMysqlDateTime($StartTime).'") OR (TimeElimination = 0))');
|
---|
67 | //$Output .= $Database->error;
|
---|
68 | $Row = $DbResult->fetch_array();
|
---|
69 | $Balance['SmallAssets']['Start'] = $Row[0] + 0;
|
---|
70 | $DbResult = $this->Database->query('SELECT SUM(price) FROM network_devices WHERE (TimeEnlistment < "'.TimeToMysqlDateTime($EndTime).'") AND (TimeEnlistment != 0) AND ((TimeElimination > "'.TimeToMysqlDateTime($EndTime).'") OR (TimeElimination = 0))');
|
---|
71 | $Row = $DbResult->fetch_array();
|
---|
72 | $Balance['SmallAssets']['End'] = $Row[0] + 0;
|
---|
73 | return($Balance);
|
---|
74 | }
|
---|
75 |
|
---|
76 | function Show()
|
---|
77 | {
|
---|
78 | if(!$this->System->Models['User']->CheckPermission('Finance', 'TradingStatus')) return('Nemáte oprávnění');
|
---|
79 | $this->System->Modules['Finance']->LoadTariffs(1);
|
---|
80 | //TransformFinance();
|
---|
81 |
|
---|
82 | $Output = '';
|
---|
83 | if(!array_key_exists('table', $_GET)) $_GET['table'] = '';
|
---|
84 | switch($_GET['table'])
|
---|
85 | {
|
---|
86 | case 'AnnualBalance':
|
---|
87 | $Output = '<table style="font-size: smaller;" class="WideTable">';
|
---|
88 | $Output .= '<tr><th colspan="3">Účetní období</th><th colspan="5">Na konci</th><th colspan="6">Během</th></tr>'.
|
---|
89 | '<tr><th>Rok</th><th>Od</th><th>Do</th><th>Příjmy</th><th>Výdaje</th><th>Pohledávky</th><th>Závazky</th><th>Drobný majetek</th><th>Příjmy</th><th>Výdaje</th><th>Pohledávky</th><th>Závazky</th><th>Drobný majetek</th><th>Základ daně</th></tr>';
|
---|
90 |
|
---|
91 | $this->StartEvidence = mktime(0, 0, 0, 12, 1, 2007);
|
---|
92 | $StartYear = date('Y', $this->StartEvidence);
|
---|
93 | $EndYear = date('Y', time());
|
---|
94 | for($Year = $StartYear; $Year <= $EndYear; $Year++)
|
---|
95 | {
|
---|
96 | $EndTime = mktime(0, 0, 0, 12, 31, $Year);
|
---|
97 | //$Year = date('Y', $EndTime);
|
---|
98 | $StartTime = mktime(0, 0, 0, 1, 1, $Year);
|
---|
99 | if($StartTime < $this->StartEvidence) $StartTime = $this->StartEvidence;
|
---|
100 |
|
---|
101 | $Balance = $this->GetTimePeriodBalance($StartTime, $EndTime);
|
---|
102 |
|
---|
103 | $Output .= '<tr><td>'.$Year.'</td><td>'.date(HumanDate(TimeToMysqlDateTime($StartTime))).'</td><td>'.date(HumanDate(TimeToMysqlDateTime($EndTime))).'</td>';
|
---|
104 | $Output .= '<td>'.round($Balance['Income']['End']).'</td>';
|
---|
105 | $Output .= '<td>'.round($Balance['Spend']['End']).'</td>';
|
---|
106 | $Output .= '<td>'.round($Balance['Claims']['End']).'</td>';
|
---|
107 | $Output .= '<td>'.round($Balance['Liabilities']['End']).'</td>';
|
---|
108 | $Output .= '<td>'.round($Balance['SmallAssets']['End']).'</td>';
|
---|
109 |
|
---|
110 | $Output .= '<td>'.round($Balance['Income']['End'] - $Balance['Income']['Start']).'</td>';
|
---|
111 | $Output .= '<td>'.round($Balance['Spend']['End'] - $Balance['Spend']['Start']).'</td>';
|
---|
112 | $Output .= '<td>'.round($Balance['Claims']['End'] - $Balance['Claims']['Start']).'</td>';
|
---|
113 | $Output .= '<td>'.round($Balance['Liabilities']['End'] - $Balance['Liabilities']['Start']).'</td>';
|
---|
114 | $Output .= '<td>'.round($Balance['SmallAssets']['End'] - $Balance['SmallAssets']['Start']).'</td>';
|
---|
115 | $Output .= '<td>'.round(($Balance['Income']['End'] - $Balance['Income']['Start']) - ($Balance['Spend']['End'] - $Balance['Spend']['Start'])).'</td></tr>';
|
---|
116 | }
|
---|
117 | $Output .= '</table>';
|
---|
118 | break;
|
---|
119 | case 'MonthlyBalance':
|
---|
120 | $Output = '<table class="WideTable" style="font-size: smaller;">';
|
---|
121 | $Output .= '<tr><th colspan="4">Účetní období</th><th colspan="5">Na konci</th><th colspan="6">Během</th></tr>'.
|
---|
122 | '<tr><th>Rok</th><th>Měsíc</th></th><th>Od</th><th>Do</th><th>Příjmy</th><th>Výdaje</th><th>Pohledávky</th><th>Závazky</th><th>Drobný majetek</th><th>Příjmy</th><th>Výdaje</th><th>Pohledávky</th><th>Závazky</th><th>Drobný majetek</th><th>Základ daně</th></tr>';
|
---|
123 |
|
---|
124 | $this->StartEvidence = mktime(0, 0, 0, 12, 1, 2007);
|
---|
125 | $StartYear = date('Y', $this->StartEvidence);
|
---|
126 | $EndYear = date('Y', time());
|
---|
127 | for($Year = $StartYear; $Year <= $EndYear; $Year++)
|
---|
128 | {
|
---|
129 | for($Month = 1; $Month <= 12; $Month++)
|
---|
130 | {
|
---|
131 | $EndTime = mktime(0, 0, 0, $Month, 31, $Year);
|
---|
132 | //$Year = date('Y', $EndTime);
|
---|
133 | $StartTime = mktime(0, 0, 0, $Month, 1, $Year);
|
---|
134 | if(($StartTime < time()) and ($EndTime > $this->StartEvidence))
|
---|
135 | {
|
---|
136 | if($StartTime < $this->StartEvidence) $StartTime = $this->StartEvidence;
|
---|
137 |
|
---|
138 | $Balance = $this->GetTimePeriodBalance($StartTime, $EndTime);
|
---|
139 |
|
---|
140 | $Output .= '<tr><td>'.$Year.'</td><td>'.$Month.'</td><td>'.date(HumanDate(TimeToMysqlDateTime($StartTime))).'</td><td>'.date(HumanDate(TimeToMysqlDateTime($EndTime))).'</td>';
|
---|
141 | $Output .= '<td>'.round($Balance['Income']['End']).'</td>';
|
---|
142 | $Output .= '<td>'.round($Balance['Spend']['End']).'</td>';
|
---|
143 | $Output .= '<td>'.round($Balance['Claims']['End']).'</td>';
|
---|
144 | $Output .= '<td>'.round($Balance['Liabilities']['End']).'</td>';
|
---|
145 | $Output .= '<td>'.round($Balance['SmallAssets']['End']).'</td>';
|
---|
146 |
|
---|
147 | $Output .= '<td>'.round($Balance['Income']['End'] - $Balance['Income']['Start']).'</td>';
|
---|
148 | $Output .= '<td>'.round($Balance['Spend']['End'] - $Balance['Spend']['Start']).'</td>';
|
---|
149 | $Output .= '<td>'.round($Balance['Claims']['End'] - $Balance['Claims']['Start']).'</td>';
|
---|
150 | $Output .= '<td>'.round($Balance['Liabilities']['End'] - $Balance['Liabilities']['Start']).'</td>';
|
---|
151 | $Output .= '<td>'.round($Balance['SmallAssets']['End'] - $Balance['SmallAssets']['Start']).'</td>';
|
---|
152 | $Output .= '<td>'.round(($Balance['Income']['End'] - $Balance['Income']['Start']) - ($Balance['Spend']['End'] - $Balance['Spend']['Start'])).'</td></tr>';
|
---|
153 | }
|
---|
154 | }
|
---|
155 | }
|
---|
156 | $Output .= '</table>';
|
---|
157 | break;
|
---|
158 | case 'CashFlow':
|
---|
159 | $Table = array('Ne', 'Ano');
|
---|
160 | $Output .= '<table style="font-size: smaller;" class="WideTable">';
|
---|
161 | $Output .= '<tr><th>Čas</th><th>Subjekt</th><th>Text</th><th>Hodnota [Kč]</th><th>Daňový</th><th>Hotovost</th></tr>';
|
---|
162 | $DbResult = $this->Database->query('SELECT * FROM FinanceOperation LEFT JOIN Subject ON Subject.Id = FinanceOperation.Subject ORDER BY Time');
|
---|
163 | while($Row = $DbResult->fetch_array())
|
---|
164 | {
|
---|
165 | $Row['Time'] = explode(' ', $Row['Time']);
|
---|
166 | $Row['Time'] = $Row['Time'][0];
|
---|
167 | $Output .= '<tr><td>'.$Row['Time'].'</td><td>'.$Row['Name'].'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value'].'</td><td>'.$Table[$Row['Taxable']].'</td><td>'.$Table[$Row['Cash']].'</td></tr>';
|
---|
168 | }
|
---|
169 | $Output .= '</table>';
|
---|
170 | break;
|
---|
171 | case 'ClaimsLiabilities':
|
---|
172 | $Output .= '<table width="100%"><tr><td valign="top">';
|
---|
173 | $Output .= '<strong>Pohledávky</strong>';
|
---|
174 | $Output .= '<table style="font-size: smaller;" class="WideTable">';
|
---|
175 | $Output .= '<tr><th>Subjekt</th><th>Text</th><th>Hodnota [Kč]</th><th>Čas vystavení</th><th>Čas splatnosti</th><th>Čas uhrazení</th></tr>';
|
---|
176 | $DbResult = $this->Database->query('SELECT * FROM FinanceClaimsLiabilities JOIN Subject ON Subject.Id = FinanceClaimsLiabilities.Subject WHERE Value > 0 ORDER BY TimeCreation');
|
---|
177 | while($Row = $DbResult->fetch_array())
|
---|
178 | {
|
---|
179 | if($Row['TimePayment'] == '0000-00-00 00:00:00') $Row['TimePayment'] = ' ';
|
---|
180 | $Output .= '<tr><td>'.$Row['Name'].'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value'].'</td><td>'.$Row['TimeCreation'].'</td><td>'.$Row['TimeDue'].'</td><td>'.$Row['TimePayment'].'</td></tr>';
|
---|
181 | }
|
---|
182 | $Output .= '</table></td><td valign="top">';
|
---|
183 |
|
---|
184 | $Output .= '<strong>Závazky</strong>';
|
---|
185 | $Output .= '<table style="font-size: smaller;" class="WideTable">';
|
---|
186 | $Output .= '<tr><th>Subjekt</th><th>Text</th><th>Hodnota [Kč]</th><th>Čas vystavení</th><th>Čas splatnosti</th><th>Čas uhrazení</th></tr>';
|
---|
187 | $DbResult = $this->Database->query('SELECT * FROM FinanceClaimsLiabilities JOIN Subject ON Subject.Id = FinanceClaimsLiabilities.Subject WHERE Value < 0 ORDER BY TimeCreation');
|
---|
188 | while($Row = $DbResult->fetch_array())
|
---|
189 | {
|
---|
190 | if($Row['TimePayment'] == '0000-00-00 00:00:00') $Row['TimePayment'] = ' ';
|
---|
191 | $Output .= '<tr><td>'.$Row['Name'].'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value'].'</td><td>'.$Row['TimeCreation'].'</td><td>'.$Row['TimeDue'].'</td><td>'.$Row['TimePayment'].'</td></tr>';
|
---|
192 | }
|
---|
193 | $Output .= '</table></td></tr></table>';
|
---|
194 | break;
|
---|
195 | case 'SubjectList':
|
---|
196 | $Output .= '<strong>Seznam subjektů</strong>';
|
---|
197 | $Output .= '<table style="font-size: smaller;" class="WideTable">';
|
---|
198 | $Output .= '<tr><th>Jméno</th><th>Závazky [Kč]</th><th>Pohledávky [Kč]</th><th>Příjmy [Kč]</th><th>Výdaje [Kč]</th><th>Stav účtu</th><th>Starý systém</th></tr>';
|
---|
199 | $DbResult = $this->Database->query('SELECT Id, Name, 0 AS Cash, '.
|
---|
200 | '(SELECT SUM(T1.Value) FROM FinanceClaimsLiabilities AS T1 WHERE (T1.Subject = Subject.Id) AND (T1.Value > 0)) as Claims, '.
|
---|
201 | '(SELECT SUM(T2.Value) FROM FinanceClaimsLiabilities AS T2 WHERE (T2.Subject = Subject.Id) AND (T2.Value > 0) AND (TimePayment IS NULL)) as OpenedClaims, '.
|
---|
202 | '(SELECT -SUM(T3.Value) FROM FinanceClaimsLiabilities AS T3 WHERE (T3.Subject = Subject.Id) AND (T3.Value < 0)) as Liabilities, '.
|
---|
203 | '(SELECT -SUM(T4.Value) FROM FinanceClaimsLiabilities AS T4 WHERE (T4.Subject = Subject.Id) AND (T4.Value < 0) AND (TimePayment IS NULL)) AS OpenedLiabilities, '.
|
---|
204 | '(SELECT SUM(T5.Value) FROM FinanceOperation AS T5 WHERE (T5.Subject = Subject.Id) AND (T5.Value > 0)) AS Gains, '.
|
---|
205 | '(SELECT -SUM(T6.Value) FROM FinanceOperation AS T6 WHERE (T6.Subject = Subject.Id) AND (T6.Value < 0)) AS Spends '.
|
---|
206 | 'FROM Subject ORDER BY Name');
|
---|
207 | while($Row = $DbResult->fetch_assoc())
|
---|
208 | {
|
---|
209 | $Output .= '<tr><td style="text-align: left;"><a href="?table=SubjectAccount&Id='.$Row['Id'].'">'.$Row['Name'].'</a></td><td>'.$Row['Liabilities'].' / '.$Row['OpenedLiabilities'].'</td><td>'.$Row['Claims'].' / '.$Row['OpenedClaims'].'</td><td>'.$Row['Gains'].'</td><td>'.$Row['Spends'].'</td><td>'.($Row['Gains'] - $Row['Spends'] - $Row['Claims'] + $Row['Liabilities']).'</td><td>'.$Row['Cash'].'</td></tr>';
|
---|
210 | }
|
---|
211 | $Output .= '</table>';
|
---|
212 | break;
|
---|
213 | case 'SmallAssets':
|
---|
214 | $Output .= '<strong>Drobný majetek</strong>';
|
---|
215 | $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">';
|
---|
216 | $Output .= '<tr><th>Název</th><th>Hodnota [Kč]</th><th>Datum zakoupení</th><th>Datum vyřezení</th></tr>';
|
---|
217 | $DbResult = $this->Database->query('SELECT * FROM network_devices WHERE used != 0');
|
---|
218 | while($Row = $DbResult->fetch_array())
|
---|
219 | {
|
---|
220 | $Output .= '<tr><td>'.$Row['name'].'</td><td>'.$Row['price'].'</td><td>'.$Row['TimeEnlistment'].'</td><td>'.$Row['TimeElimination'].'</td></tr>';
|
---|
221 | }
|
---|
222 | $Output .= '</table>';
|
---|
223 | break;
|
---|
224 | case 'SubjectAccount':
|
---|
225 | $Output .= '<strong>Výpis příjmů/výdajů</strong>';
|
---|
226 | $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">';
|
---|
227 | $Output .= '<tr><th>Datum</th><th>Název</th><th>Hodnota [Kč]</th></tr>';
|
---|
228 | $DbResult = $this->Database->select('FinanceCashFlow', '*', 'Subject='.$_GET['Id']);
|
---|
229 | while($Row = $DbResult->fetch_array())
|
---|
230 | {
|
---|
231 | $Output .= '<tr><td>'.$Row['Time'].'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value'].'</td><td>'.$Row['Bill'].'</td></tr>';
|
---|
232 | }
|
---|
233 | $Output .= '</table><br />';
|
---|
234 |
|
---|
235 | $Output .= '<strong>Výpis závazků/pohledávek</strong>';
|
---|
236 | $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">';
|
---|
237 | $Output .= '<tr><th>Datum vytvoření</th><th>Datum zaplacení</th><th>Název</th><th>Hodnota [Kč]</th></tr>';
|
---|
238 | $DbResult = $this->Database->select('FinanceClaimsLiabilities', '*', 'Subject='.$_GET['Id']);
|
---|
239 | while($Row = $DbResult->fetch_array())
|
---|
240 | {
|
---|
241 | $Output .= '<tr><td>'.$Row['TimeCreation'].'</td><td>'.$Row['TimePayment'].'</td><td>'.$Row['Text'].'</td><td>'.(-$Row['Value']).'</td><td>'.$Row['Bill'].'</td></tr>';
|
---|
242 | }
|
---|
243 | $Output .= '</table><br />';
|
---|
244 |
|
---|
245 | $Output .= '<strong>Výpis záloh</strong>';
|
---|
246 | $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">';
|
---|
247 | $Output .= '<tr><th>Datum vytvoření</th><th>Datum zaplacení</th><th>Název</th><th>Hodnota [Kč]</th></tr>';
|
---|
248 | $DbResult = $this->Database->select('FinanceAdvances', '*', 'Subject='.$_GET['Id']);
|
---|
249 | while($Row = $DbResult->fetch_array())
|
---|
250 | {
|
---|
251 | $Output .= '<tr><td>'.$Row['TimeCreation'].'</td><td>'.$Row['TimePass'].'</td><td>'.$Row['Direction'].'</td><td>'.($Row['Value']).'</td><td>'.$Row['CashFlowId'].'</td></tr>';
|
---|
252 | }
|
---|
253 | $Output .= '</table>';
|
---|
254 |
|
---|
255 | $DbResult = $this->Database->query('SELECT Id, 0 AS Cash, (SELECT SUM(FinanceClaimsLiabilities.Value) FROM FinanceClaimsLiabilities WHERE FinanceClaimsLiabilities.Subject = Subject.Id AND FinanceClaimsLiabilities.Value > 0) as Claims, (SELECT SUM(FinanceClaimsLiabilities.Value) FROM FinanceClaimsLiabilities WHERE FinanceClaimsLiabilities.Subject = Subject.Id AND FinanceClaimsLiabilities.Value > 0 AND TimePayment IS NULL) as OpenedClaims, (SELECT SUM(FinanceClaimsLiabilities.Value) FROM FinanceClaimsLiabilities WHERE FinanceClaimsLiabilities.Subject = Subject.Id AND FinanceClaimsLiabilities.Value < 0) as Liabilities, (SELECT SUM(FinanceClaimsLiabilities.Value) FROM FinanceClaimsLiabilities WHERE FinanceClaimsLiabilities.Subject = Subject.Id AND FinanceClaimsLiabilities.Value < 0 AND TimePayment IS NULL) as OpenedLiabilities, (SELECT SUM(FinanceCashFlow.Value) FROM FinanceCashFlow WHERE FinanceCashFlow.Subject = Subject.Id AND FinanceCashFlow.Value > 0) as Gains, (SELECT SUM(FinanceCashFlow.Value) FROM FinanceCashFlow WHERE FinanceCashFlow.Subject = Subject.Id AND FinanceCashFlow.Value < 0) as Spends, (SELECT SUM(FinanceAdvances.Value) FROM FinanceAdvances WHERE FinanceAdvances.Subject = Subject.Id AND FinanceAdvances.Direction="In") as AdvancesIn, (SELECT SUM(FinanceAdvances.Value) FROM FinanceAdvances WHERE FinanceAdvances.Subject = Subject.Id AND FinanceAdvances.Direction="Out") as AdvancesOut FROM Subject WHERE Id='.$_GET['Id']);
|
---|
256 | $Row = $DbResult->fetch_array();
|
---|
257 | $Output .= 'Stav placení: '.($Row['AdvancesIn'] - $Row['AdvancesOut'] - $Row['OpenedClaims'] + Abs($Row['OpenedLiabilities']));
|
---|
258 | break;
|
---|
259 | case 'PrintMonthOperations':
|
---|
260 | $Output .= '<table><tr><th>Datum</th><th>Subjekt</th><td></td></tr></table>';
|
---|
261 | break;
|
---|
262 | case 'PrintMonthOperations':
|
---|
263 | $Output .= 'Výpis operací od '.$_GET['TimeFrom'].' do '.$_GET['TimeTo'];
|
---|
264 | $Output .= '<table><tr><th>Datum</th><th>Subjekt</th><th>Suma [Kč]</th><td></td></tr></table>';
|
---|
265 | break;
|
---|
266 | default:
|
---|
267 | $Output .= '<a href="?table=AnnualBalance">Účetní závěrka</a><br />';
|
---|
268 | $Output .= '<a href="?table=MonthlyBalance">Měsíční přehledy</a><br />';
|
---|
269 | $Output .= '<a href="?table=CashFlow">Příjmy a výdaje</a><br />';
|
---|
270 | $Output .= '<a href="?table=ClaimsLiabilities">Závazky a pohledávky</a><br />';
|
---|
271 | $Output .= '<a href="?table=Advantages">Zálohy</a><br />';
|
---|
272 | $Output .= '<a href="?table=SmallAssets">Drobný majetek</a><br />';
|
---|
273 | $Output .= '<a href="?table=SubjectList">Seznam subjektů</a><br />';
|
---|
274 | }
|
---|
275 | return($Output);
|
---|
276 | }
|
---|
277 |
|
---|
278 | function AddMoney($Subject, $Value, $Text, $Time)
|
---|
279 | {
|
---|
280 | $TimeDue = $Time + 15 * 24 * 3600; // 15 dnů
|
---|
281 |
|
---|
282 | }
|
---|
283 |
|
---|
284 | function AddInvoice($Subject, $Value, $Text, $Time)
|
---|
285 | {
|
---|
286 | $TimeDue = $Time + 15 * 24 * 3600; // 15 dnů
|
---|
287 |
|
---|
288 | }
|
---|
289 | }
|
---|
290 |
|
---|
291 | $System->AddModule(new FinanceTaxFilingPage());
|
---|
292 | $System->Modules['FinanceTaxFilingPage']->GetOutput();
|
---|
293 |
|
---|
294 | ?>
|
---|