Changeset 847 for trunk/Modules/Finance/Trade.php
- Timestamp:
- May 1, 2017, 4:52:01 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Finance/Trade.php
r810 r847 68 68 } 69 69 70 function Show() 71 { 72 if(!$this->System->User->CheckPermission('Finance', 'TradingStatus')) 73 return('Nemáte oprávnění'); 74 75 $Finance = &$this->System->Modules['Finance']; 76 77 $Output = ''; 78 if(!array_key_exists('table', $_GET)) $_GET['table'] = ''; 79 switch($_GET['table']) 80 { 81 case 'AnnualBalance': 82 $Output = '<table style="font-size: smaller;" class="WideTable">'; 83 $Output .= '<tr><th colspan="3">Účetní období</th><th colspan="5">Na konci</th><th colspan="6">Během</th></tr>'. 70 function ShowAnnualBalance() 71 { 72 $Output = '<table style="font-size: smaller;" class="WideTable">'; 73 $Output .= '<tr><th colspan="3">Účetní období</th><th colspan="5">Na konci</th><th colspan="6">Během</th></tr>'. 84 74 '<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>'; 85 75 86 $this->StartEvidence = mktime(0, 0, 0, 12, 1, 2007); 87 $StartYear = date('Y', $this->StartEvidence); 88 $EndYear = date('Y', time()); 89 for($Year = $StartYear; $Year <= $EndYear; $Year++) 76 $this->StartEvidence = mktime(0, 0, 0, 12, 1, 2007); 77 $StartYear = date('Y', $this->StartEvidence); 78 $EndYear = date('Y', time()); 79 for($Year = $StartYear; $Year <= $EndYear; $Year++) 80 { 81 $EndTime = mktime(0, 0, 0, 12, 31, $Year); 82 //$Year = date('Y', $EndTime); 83 $StartTime = mktime(0, 0, 0, 1, 1, $Year); 84 if($StartTime < $this->StartEvidence) $StartTime = $this->StartEvidence; 85 86 $Balance = $this->GetTimePeriodBalance($StartTime, $EndTime); 87 88 $Output .= '<tr><td>'.$Year.'</td><td>'.date(HumanDate(TimeToMysqlDateTime($StartTime))).'</td><td>'.date(HumanDate(TimeToMysqlDateTime($EndTime))).'</td>'; 89 $Output .= '<td>'.round($Balance['Income']['End']).'</td>'; 90 $Output .= '<td>'.round($Balance['Spend']['End']).'</td>'; 91 $Output .= '<td>'.round($Balance['Claims']['End']).'</td>'; 92 $Output .= '<td>'.round($Balance['Liabilities']['End']).'</td>'; 93 $Output .= '<td>'.round($Balance['SmallAssets']['End']).'</td>'; 94 95 $Output .= '<td>'.round($Balance['Income']['End'] - $Balance['Income']['Start']).'</td>'; 96 $Output .= '<td>'.round($Balance['Spend']['End'] - $Balance['Spend']['Start']).'</td>'; 97 $Output .= '<td>'.round($Balance['Claims']['End'] - $Balance['Claims']['Start']).'</td>'; 98 $Output .= '<td>'.round($Balance['Liabilities']['End'] - $Balance['Liabilities']['Start']).'</td>'; 99 $Output .= '<td>'.round($Balance['SmallAssets']['End'] - $Balance['SmallAssets']['Start']).'</td>'; 100 $Output .= '<td>'.round(($Balance['Income']['End'] - $Balance['Income']['Start']) - ($Balance['Spend']['End'] - $Balance['Spend']['Start'])).'</td></tr>'; 101 } 102 $Output .= '</table>'; 103 return $Output; 104 } 105 106 function ShowMonthlyBalance() 107 { 108 $Output = '<table class="WideTable" style="font-size: smaller;">'; 109 $Output .= '<tr><th colspan="4">Účetní období</th><th colspan="5">Na konci</th><th colspan="6">Během</th></tr>'. 110 '<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>'; 111 112 $this->StartEvidence = mktime(0, 0, 0, 12, 1, 2007); 113 $StartYear = date('Y', $this->StartEvidence); 114 $EndYear = date('Y', time()); 115 for($Year = $StartYear; $Year <= $EndYear; $Year++) 116 { 117 for($Month = 1; $Month <= 12; $Month++) 118 { 119 $EndTime = mktime(0, 0, 0, $Month, 31, $Year); 120 //$Year = date('Y', $EndTime); 121 $StartTime = mktime(0, 0, 0, $Month, 1, $Year); 122 if(($StartTime < time()) and ($EndTime > $this->StartEvidence)) 90 123 { 91 $EndTime = mktime(0, 0, 0, 12, 31, $Year);92 //$Year = date('Y', $EndTime);93 $StartTime = mktime(0, 0, 0, 1, 1, $Year);94 124 if($StartTime < $this->StartEvidence) $StartTime = $this->StartEvidence; 95 125 96 $Balance = $this->GetTimePeriodBalance($StartTime, $EndTime);97 98 $Output .= '<tr><td>'.$Year.'</td><td>'. date(HumanDate(TimeToMysqlDateTime($StartTime))).'</td><td>'.date(HumanDate(TimeToMysqlDateTime($EndTime))).'</td>';126 $Balance = $this->GetTimePeriodBalance($StartTime, $EndTime); 127 128 $Output .= '<tr><td>'.$Year.'</td><td>'.$Month.'</td><td>'.date(HumanDate(TimeToMysqlDateTime($StartTime))).'</td><td>'.date(HumanDate(TimeToMysqlDateTime($EndTime))).'</td>'; 99 129 $Output .= '<td>'.round($Balance['Income']['End']).'</td>'; 100 130 $Output .= '<td>'.round($Balance['Spend']['End']).'</td>'; … … 110 140 $Output .= '<td>'.round(($Balance['Income']['End'] - $Balance['Income']['Start']) - ($Balance['Spend']['End'] - $Balance['Spend']['Start'])).'</td></tr>'; 111 141 } 112 $Output .= '</table>'; 142 } 143 } 144 $Output .= '</table>'; 145 return $Output; 146 } 147 148 function ShowIncomes() 149 { 150 $Table = array('Ne', 'Ano'); 151 $DbResult = $this->Database->select('FinanceYear', '*', 'Id='.$_GET['year']); 152 $Year = $DbResult->fetch_assoc(); 153 154 $Total = 0; 155 $TotalTax = array(0, 0); 156 $TotalCash = array(0, 0); 157 $Output = '<strong>Příjmy za rok '.$Year['Year'].'</strong>'; 158 $Output .= '<table style="font-size: smaller;" class="WideTable">'; 159 $Output .= '<tr><th>Čas</th><th>Kód</th><th>Subjekt</th><th>Text</th><th>Hodnota [Kč]</th><th>Daňový</th><th>Hotovost</th></tr>'; 160 $DbResult = $this->Database->query('SELECT `FinanceOperation`.*, `DocumentLineCode`.`Name` AS `BillName`, `Subject`.`Name` AS `Name` FROM `FinanceOperation` '. 161 'LEFT JOIN `Subject` ON `Subject`.`Id` = `FinanceOperation`.`Subject` '. 162 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `FinanceOperation`.`Group` '. 163 'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id` = `FinanceOperation`.`BillCode` '. 164 'WHERE (`ValueSign` = 1) AND (`FinanceOperation`.`Time` >= "'.$Year['DateStart'].'") '. 165 'AND (`FinanceOperation`.`Time` <= "'.$Year['DateEnd'].'") ORDER BY `Time`'); 166 while($Row = $DbResult->fetch_array()) 167 { 168 $Row['Time'] = explode(' ', $Row['Time']); 169 $Row['Time'] = $Row['Time'][0]; 170 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['BillName']. 171 '</td><td>'.$Row['Name'].'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value']. 172 '</td><td>'.$Table[$Row['Taxable']].'</td><td>'.$Table[$Row['Cash']].'</td></tr>'; 173 $Total += $Row['Value']; 174 $TotalTax[$Row['Taxable']] += $Row['Value']; 175 $TotalCash[$Row['Cash']] += $Row['Value']; 176 } 177 $Output .= '</table><br/>'; 178 $Output .= '<strong>Souhrn</strong><br/>'; 179 $Output .= 'Celkem: '.$Total.' Kč<br/>'; 180 $Output .= ' Daňové: '.$TotalTax[1].' Kč<br/>'; 181 $Output .= ' Nedaňové: '.$TotalTax[0].' Kč<br/>'; 182 $Output .= ' Hotovostní: '.$TotalCash[1].' Kč<br/>'; 183 $Output .= ' Bezhotovostní: '.$TotalCash[0].' Kč<br/>'; 184 return $Output; 185 } 186 187 function ShowExpenses() 188 { 189 $Table = array('Ne', 'Ano'); 190 $DbResult = $this->Database->select('FinanceYear', '*', 'Id='.$_GET['year']); 191 $Year = $DbResult->fetch_assoc(); 192 193 $Total = 0; 194 $TotalTax = array(0, 0); 195 $TotalCash = array(0, 0); 196 $Output = '<strong>Výdaje za rok '.$Year['Year'].'</strong>'; 197 $Output .= '<table style="font-size: smaller;" class="WideTable">'; 198 $Output .= '<tr><th>Čas</th><th>Kód</th><th>Subjekt</th><th>Text</th><th>Hodnota [Kč]</th><th>Daňový</th><th>Hotovost</th></tr>'; 199 $DbResult = $this->Database->query('SELECT `FinanceOperation`.*, `DocumentLineCode`.`Name` AS `BillName`, '. 200 '`Subject`.`Name` AS `SubjectName`, `FinanceOperationGroup`.`ValueSign` AS `ValueSign` FROM `FinanceOperation` '. 201 'LEFT JOIN `Subject` ON `Subject`.`Id` = `FinanceOperation`.`Subject` '. 202 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `FinanceOperation`.`Group` '. 203 'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id` = `FinanceOperation`.`BillCode` '. 204 'WHERE (`FinanceOperationGroup`.`ValueSign` = -1) AND (`FinanceOperation`.`Time` >= "'.$Year['DateStart'].'") '. 205 'AND (`FinanceOperation`.`Time` <= "'.$Year['DateEnd'].'") ORDER BY `Time`'); 206 while($Row = $DbResult->fetch_array()) 207 { 208 $Row['Time'] = explode(' ', $Row['Time']); 209 $Row['Time'] = $Row['Time'][0]; 210 $Row['Value'] = $Row['Value'] * $Row['ValueSign']; 211 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['BillName']. 212 '</td><td>'.$Row['SubjectName'].'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value']. 213 '</td><td>'.$Table[$Row['Taxable']].'</td><td>'.$Table[$Row['Cash']].'</td></tr>'; 214 $Total += $Row['Value']; 215 $TotalTax[$Row['Taxable']] += $Row['Value']; 216 $TotalCash[$Row['Cash']] += $Row['Value']; 217 } 218 $Output .= '</table><br/>'; 219 $Output .= '<strong>Souhrn</strong><br/>'; 220 $Output .= 'Celkem: '.$Total.' Kč<br/>'; 221 $Output .= ' Daňové: '.$TotalTax[1].' Kč<br/>'; 222 $Output .= ' Nedaňové: '.$TotalTax[0].' Kč<br/>'; 223 $Output .= ' Hotovostní: '.$TotalCash[1].' Kč<br/>'; 224 $Output .= ' Bezhotovostní: '.$TotalCash[0].' Kč<br/>'; 225 return $Output; 226 } 227 228 function ShowClaims() 229 { 230 $Table = array('Ne', 'Ano'); 231 $DbResult = $this->Database->select('FinanceYear', '*', 'Id='.$_GET['year']); 232 $Year = $DbResult->fetch_assoc(); 233 234 $Total = 0; 235 $Output = '<strong>Pohledávky za rok '.$Year['Year'].'</strong>'; 236 $Output .= '<table style="font-size: smaller;" class="WideTable">'; 237 $Output .= '<tr><th>Čas vystavení</th><th>Kód</th><th>Subjekt</th><th>Text</th><th>Hodnota [Kč]</th></tr>'; 238 $DbResult = $this->Database->query('SELECT `FinanceInvoice`.*, '. 239 '`DocumentLineCode`.`Name` AS `BillName`, `Subject`.`Name` AS `SubjectName`, '. 240 '(SELECT GROUP_CONCAT(`Description` SEPARATOR ",") '. 241 'FROM `FinanceInvoiceItem` WHERE `FinanceInvoiceItem`.`FinanceInvoice` = `FinanceInvoice`.`Id`) AS `Text` FROM `FinanceInvoice`'. 242 'LEFT JOIN `Subject` ON `Subject`.`Id` = `FinanceInvoice`.`Subject` '. 243 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `FinanceInvoice`.`Group` '. 244 'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id` = `FinanceInvoice`.`BillCode` '. 245 'WHERE (`FinanceInvoiceGroup`.`ValueSign` = 1) AND (`FinanceInvoice`.`Time` >= "'.$Year['DateStart']. 246 '") AND (`FinanceInvoice`.`Time` <= "'.$Year['DateEnd'].'") ORDER BY `Time`'); 247 while($Row = $DbResult->fetch_array()) 248 { 249 if($Row['TimePayment'] == '0000-00-00 00:00:00') $Row['TimePayment'] = ' '; 250 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['BillName']. 251 '</td><td>'.$Row['SubjectName'].'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value'].'</td></tr>'; 252 $Total += $Row['Value']; 253 } 254 $Output .= '</table><br/>'; 255 $Output .= 'Celkem: '.$Total.' Kč<br/>'; 256 return $Output; 257 } 258 259 function ShowLiabilities() 260 { 261 $Table = array('Ne', 'Ano'); 262 $DbResult = $this->Database->select('FinanceYear', '*', 'Id='.$_GET['year']); 263 $Year = $DbResult->fetch_assoc(); 264 265 $Total = 0; 266 $Output = '<strong>Závazky za rok '.$Year['Year'].'</strong>'; 267 $Output .= '<table style="font-size: smaller;" class="WideTable">'; 268 $Output .= '<tr><th>Čas vystavení</th><th>Kód</th><th>Subjekt</th><th>Text</th><th>Hodnota [Kč]</th></tr>'; 269 $DbResult = $this->Database->query('SELECT *, `DocumentLineCode`.`Name` AS `BillName`, `Subject`.`Name` AS `SubjectName`, '. 270 '(SELECT GROUP_CONCAT(Description SEPARATOR ",") '. 271 'FROM `FinanceInvoiceItem` WHERE `FinanceInvoiceItem`.`FinanceInvoice` = `FinanceInvoice`.`Id`) AS `Text` '. 272 'FROM `FinanceInvoice` '. 273 'LEFT JOIN `Subject` ON `Subject`.`Id` = `FinanceInvoice`.`Subject` '. 274 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `FinanceInvoice`.`Group` '. 275 'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id` = `FinanceInvoice`.`BillCode` '. 276 'WHERE (`FinanceInvoiceGroup`.`ValueSign` = -1) AND (`FinanceInvoice`.`Time` >= "'.$Year['DateStart']. 277 '") AND (FinanceInvoice.Time <= "'.$Year['DateEnd'].'") ORDER BY Time'); 278 while($Row = $DbResult->fetch_array()) 279 { 280 if($Row['TimePayment'] == '0000-00-00 00:00:00') $Row['TimePayment'] = ' '; 281 $Row['Value'] = $Row['Value'] * $Row['ValueSign']; 282 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['BillName']. 283 '</td><td>'.$Row['SubjectName'].'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value'].'</td></tr>'; 284 $Total += $Row['Value']; 285 } 286 $Output .= '</table><br/>'; 287 $Output .= 'Celkem: '.$Total.' Kč<br/>'; 288 return $Output; 289 } 290 291 function ShowSubjectList() 292 { 293 $Output = '<strong>Seznam subjektů</strong>'; 294 $Output .= '<table style="font-size: smaller;" class="WideTable">'; 295 $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>'; 296 $DbResult = $this->Database->query('SELECT Id, Name, 0 AS Cash, '. 297 '(SELECT SUM(T1.Value) FROM FinanceInvoice AS T1 '. 298 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `T1`.`Group` '. 299 'WHERE (T1.Subject = Subject.Id) AND (`FinanceInvoiceGroup`.ValueSign = 1)) AS `Claims`, '. 300 '(SELECT SUM(T2.Value) FROM FinanceInvoice AS T2 '. 301 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `T2`.`Group` '. 302 'WHERE (T2.Subject = Subject.Id) AND (`FinanceInvoiceGroup`.`ValueSign` = 1) AND (TimePayment IS NULL)) AS `OpenedClaims`, '. 303 '(SELECT -SUM(T3.Value) FROM FinanceInvoice AS T3 '. 304 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `T3`.`Group` '. 305 'WHERE (T3.Subject = Subject.Id) AND (`FinanceInvoiceGroup`.`ValueSign` = -1)) AS `Liabilities`, '. 306 '(SELECT -SUM(T4.Value) FROM FinanceInvoice AS T4 '. 307 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `T4`.`Group` '. 308 'WHERE (T4.Subject = Subject.Id) AND (`FinanceInvoiceGroup`.`ValueSign` = -1) AND (`TimePayment` IS NULL)) AS `OpenedLiabilities`, '. 309 '(SELECT SUM(T5.Value) FROM FinanceOperation AS T5 '. 310 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `T5`.`Group` '. 311 'WHERE (T5.Subject = Subject.Id) AND (`FinanceOperationGroup`.`ValueSign` = 1)) AS `Gains`, '. 312 '(SELECT SUM(T6.Value) FROM FinanceOperation AS T6 '. 313 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `T6`.`Group` '. 314 'WHERE (T6.Subject = Subject.Id) AND (`FinanceOperationGroup`.`ValueSign` = -1)) AS `Spends` '. 315 'FROM Subject ORDER BY Name'); 316 while($Row = $DbResult->fetch_assoc()) 317 { 318 $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>'; 319 } 320 $Output .= '</table>'; 321 return $Output; 322 } 323 324 function ShowSmallAssets() 325 { 326 $Output = '<strong>Drobný majetek</strong>'; 327 $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'; 328 $Output .= '<tr><th>Název</th><th>Hodnota [Kč]</th><th>Datum zakoupení</th><th>Datum vyřezení</th></tr>'; 329 $DbResult = $this->Database->query('SELECT Product.Name AS Name, StockSerialNumber.SellPrice AS Price, StockSerialNumber.TimeEnlistment AS TimeEnlistment, StockSerialNumber.TimeElimination AS TimeElimination '. 330 'FROM StockSerialNumber JOIN Product ON Product.Id = StockSerialNumber.Product '. 331 'WHERE (TimeElimination IS NOT NULL)'); 332 while($Row = $DbResult->fetch_array()) 333 { 334 $Output .= '<tr><td>'.$Row['Name'].'</td><td>'.$Row['Price'].'</td><td>'.$Row['TimeEnlistment'].'</td><td>'.$Row['TimeElimination'].'</td></tr>'; 335 } 336 $Output .= '</table>'; 337 return $Output; 338 } 339 340 function ShowSubjectAccount() 341 { 342 $Output = '<table style="width: 100%"><tr><td style="vertical-align: top;">'; 343 $Output .= '<strong>Výpis příjmů/výdajů</strong>'; 344 $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'; 345 $Output .= '<tr><th>Datum</th><th>Název</th><th>Hodnota [Kč]</th><th>Doklad</th></tr>'; 346 $DbResult = $this->Database->query('SELECT `FinanceOperation`.*, `DocumentLineCode`.`Name` AS `BillName` '. 347 'FROM `FinanceOperation` '. 348 'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id` = `FinanceOperation`.`BillCode` '. 349 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `FinanceOperation`.`Group` '. 350 'WHERE `Subject`='.$_GET['Id'].' ORDER BY `Time`'); 351 while($Row = $DbResult->fetch_array()) 352 { 353 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['Text']. 354 '</td><td>'.$Row['Value'].'</td><td>'.$Row['BillName'].'</td></tr>'; 355 } 356 $Output .= '</table></td><td style="vertical-align: top;">'; 357 358 $Output .= '<strong>Výpis závazků/pohledávek</strong>'; 359 $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'; 360 $Output .= '<tr><th>Datum vytvoření</th><th>Datum zaplacení</th><th>Název</th><th>Hodnota [Kč]</th><th>Doklad</th></tr>'; 361 $DbResult = $this->Database->query('SELECT `FinanceInvoice`.*, (SELECT GROUP_CONCAT(Description SEPARATOR ",") '. 362 'FROM FinanceInvoiceItem WHERE `FinanceInvoiceItem`.`FinanceInvoice` = `FinanceInvoice`.`Id`) AS `Text`, `DocumentLineCode`.`Name` AS `BillName` '. 363 'FROM `FinanceInvoice` '. 364 'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id` = `FinanceInvoice`.`BillCode` '. 365 'WHERE `Subject`='.$_GET['Id'].' ORDER BY `Time`'); 366 while($Row = $DbResult->fetch_array()) 367 { 368 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.HumanDate($Row['TimePayment']). 369 '</td><td>'.$Row['Text'].'</td><td>'.round($Row['Value'], $Finance->Rounding).'</td><td>'.$Row['BillName'].'</td></tr>'; 370 } 371 $Output .= '</table></td></tr></table>'; 372 373 /*$Output .= '<strong>Výpis záloh</strong>'; 374 $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'; 375 $Output .= '<tr><th>Datum vytvoření</th><th>Datum zaplacení</th><th>Název</th><th>Hodnota [Kč]</th></tr>'; 376 $DbResult = $this->Database->select('FinanceAdvances', '*', 'Subject='.$_GET['Id']); 377 while($Row = $DbResult->fetch_array()) 378 { 379 $Output .= '<tr><td>'.$Row['Time'].'</td><td>'.$Row['TimePass'].'</td><td>'.$Row['ValueSign'].'</td><td>'.($Row['Value']).'</td><td>'.$Row['CashFlowId'].'</td></tr>'; 380 } 381 $Output .= '</table>';*/ 382 383 $DbResult = $this->Database->query('SELECT Id, 0 AS Cash, (SELECT SUM(FinanceInvoice.Value * FinanceInvoice.ValueSign) '. 384 'FROM FinanceInvoice WHERE (FinanceInvoice.Subject = Subject.Id) AND '. 385 '(FinanceInvoice.ValueSign = 1)) as Claims, (SELECT SUM(FinanceInvoice.Value * FinanceInvoice.ValueSign) '. 386 'FROM FinanceInvoice WHERE (FinanceInvoice.Subject = Subject.Id) AND ('. 387 'FinanceInvoice.ValueSign = 1) AND (TimePayment IS NULL)) as OpenedClaims, '. 388 '(SELECT SUM(FinanceInvoice.Value * FinanceInvoice.ValueSign) FROM FinanceInvoice '. 389 'WHERE (FinanceInvoice.Subject = Subject.Id) AND (FinanceInvoice.ValueSign = -1)) AS '. 390 'Liabilities, (SELECT SUM(FinanceInvoice.Value) FROM FinanceInvoice '. 391 'WHERE (FinanceInvoice.Subject = Subject.Id) AND (FinanceInvoice.ValueSign = -1) '. 392 'AND (TimePayment IS NULL)) AS OpenedLiabilities, '. 393 '(SELECT SUM(FinanceOperation.Value*FinanceOperation.ValueSign) '. 394 'FROM FinanceOperation WHERE FinanceOperation.Subject = Subject.Id AND FinanceOperation.ValueSign = 1) '. 395 'AS Gains, (SELECT SUM(FinanceOperation.Value*FinanceOperation.ValueSign) FROM FinanceOperation WHERE '. 396 'FinanceOperation.Subject = Subject.Id AND FinanceOperation.ValueSign = -1) as Spends '. 397 'FROM Subject WHERE Id='.$_GET['Id']); 398 $Row = $DbResult->fetch_array(); 399 $Output .= 'Stav placení: '.(-$Row['OpenedClaims'] + Abs($Row['OpenedLiabilities'])); 400 return $Output; 401 } 402 403 function ShowDefault() 404 { 405 $Output = '<strong>Celkové přehledy</strong><br/>'; 406 $Output .= '<a href="?table=AnnualBalance">Účetní závěrka</a><br />'; 407 $Output .= '<a href="?table=MonthlyBalance">Měsíční přehledy</a><br />'; 408 $Output .= '<a href="?table=SubjectList">Seznam subjektů</a><br />'; 409 $Output .= '<a href="?table=SmallAssets">Drobný majetek</a><br />'; 410 $Output .= '<br/>'; 411 $Output .= '<strong>Roční přehledy</strong><br/>'; 412 $Output .= $this->ShowFinanceYears(); 413 if(array_key_exists('year', $_GET)) 414 { 415 $Year = $_GET['year'] * 1; 416 $Output .= '<a href="?table=Incomes&year='.$Year.'">Příjmy</a><br />'; 417 $Output .= '<a href="?table=Expenses&year='.$Year.'">Výdaje</a><br />'; 418 $Output .= '<a href="?table=Claims&year='.$Year.'">Pohledávky</a><br />'; 419 $Output .= '<a href="?table=Liabilities&year='.$Year.'">Závazky</a><br />'; 420 $Output .= '<a href="?table=Advantages&year='.$Year.'">Zálohy</a><br />'; 421 $Output .= '<a href="?table=YearReport&year='.$Year.'">Souhrný přehled</a><br />'; 422 } 423 return $Output; 424 } 425 426 function Show() 427 { 428 if(!$this->System->User->CheckPermission('Finance', 'TradingStatus')) 429 return('Nemáte oprávnění'); 430 431 $Finance = &$this->System->Modules['Finance']; 432 433 $Output = ''; 434 if(!array_key_exists('table', $_GET)) $_GET['table'] = ''; 435 switch($_GET['table']) 436 { 437 case 'AnnualBalance': 438 $Output = $this->ShowAnnualBalance(); 113 439 break; 114 440 case 'MonthlyBalance': 115 $Output = '<table class="WideTable" style="font-size: smaller;">'; 116 $Output .= '<tr><th colspan="4">Účetní období</th><th colspan="5">Na konci</th><th colspan="6">Během</th></tr>'. 117 '<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>'; 118 119 $this->StartEvidence = mktime(0, 0, 0, 12, 1, 2007); 120 $StartYear = date('Y', $this->StartEvidence); 121 $EndYear = date('Y', time()); 122 for($Year = $StartYear; $Year <= $EndYear; $Year++) 123 { 124 for($Month = 1; $Month <= 12; $Month++) 125 { 126 $EndTime = mktime(0, 0, 0, $Month, 31, $Year); 127 //$Year = date('Y', $EndTime); 128 $StartTime = mktime(0, 0, 0, $Month, 1, $Year); 129 if(($StartTime < time()) and ($EndTime > $this->StartEvidence)) 130 { 131 if($StartTime < $this->StartEvidence) $StartTime = $this->StartEvidence; 132 133 $Balance = $this->GetTimePeriodBalance($StartTime, $EndTime); 134 135 $Output .= '<tr><td>'.$Year.'</td><td>'.$Month.'</td><td>'.date(HumanDate(TimeToMysqlDateTime($StartTime))).'</td><td>'.date(HumanDate(TimeToMysqlDateTime($EndTime))).'</td>'; 136 $Output .= '<td>'.round($Balance['Income']['End']).'</td>'; 137 $Output .= '<td>'.round($Balance['Spend']['End']).'</td>'; 138 $Output .= '<td>'.round($Balance['Claims']['End']).'</td>'; 139 $Output .= '<td>'.round($Balance['Liabilities']['End']).'</td>'; 140 $Output .= '<td>'.round($Balance['SmallAssets']['End']).'</td>'; 141 142 $Output .= '<td>'.round($Balance['Income']['End'] - $Balance['Income']['Start']).'</td>'; 143 $Output .= '<td>'.round($Balance['Spend']['End'] - $Balance['Spend']['Start']).'</td>'; 144 $Output .= '<td>'.round($Balance['Claims']['End'] - $Balance['Claims']['Start']).'</td>'; 145 $Output .= '<td>'.round($Balance['Liabilities']['End'] - $Balance['Liabilities']['Start']).'</td>'; 146 $Output .= '<td>'.round($Balance['SmallAssets']['End'] - $Balance['SmallAssets']['Start']).'</td>'; 147 $Output .= '<td>'.round(($Balance['Income']['End'] - $Balance['Income']['Start']) - ($Balance['Spend']['End'] - $Balance['Spend']['Start'])).'</td></tr>'; 148 } 149 } 150 } 151 $Output .= '</table>'; 441 $Output = $this->ShowMonthlyBalance(); 442 break; 443 case 'YearReport': 444 $Output .= $this->ShowIncomes().'<hr>'; 445 $Output .= $this->ShowExpenses().'<hr>'; 446 $Output .= $this->ShowClaims().'<hr>'; 447 $Output .= $this->ShowLiabilities().'<hr>'; 152 448 break; 153 449 case 'Incomes': 154 $Table = array('Ne', 'Ano'); 155 $DbResult = $this->Database->select('FinanceYear', '*', 'Id='.$_GET['year']); 156 $Year = $DbResult->fetch_assoc(); 157 158 $Total = 0; 159 $TotalTax = array(0, 0); 160 $TotalCash = array(0, 0); 161 $Output .= '<strong>Příjmy za rok '.$Year['Year'].'</strong>'; 162 $Output .= '<table style="font-size: smaller;" class="WideTable">'; 163 $Output .= '<tr><th>Čas</th><th>Kód</th><th>Subjekt</th><th>Text</th><th>Hodnota [Kč]</th><th>Daňový</th><th>Hotovost</th></tr>'; 164 $DbResult = $this->Database->query('SELECT `FinanceOperation`.*, `DocumentLineCode`.`Name` AS `BillName`, `Subject`.`Name` AS `Name` FROM `FinanceOperation` '. 165 'LEFT JOIN `Subject` ON `Subject`.`Id` = `FinanceOperation`.`Subject` '. 166 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `FinanceOperation`.`Group` '. 167 'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id` = `FinanceOperation`.`BillCode` '. 168 'WHERE (`ValueSign` = 1) AND (`FinanceOperation`.`Time` >= "'.$Year['DateStart'].'") '. 169 'AND (`FinanceOperation`.`Time` <= "'.$Year['DateEnd'].'") ORDER BY `Time`'); 170 while($Row = $DbResult->fetch_array()) 171 { 172 $Row['Time'] = explode(' ', $Row['Time']); 173 $Row['Time'] = $Row['Time'][0]; 174 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['BillName']. 175 '</td><td>'.$Row['Name'].'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value']. 176 '</td><td>'.$Table[$Row['Taxable']].'</td><td>'.$Table[$Row['Cash']].'</td></tr>'; 177 $Total += $Row['Value']; 178 $TotalTax[$Row['Taxable']] += $Row['Value']; 179 $TotalCash[$Row['Cash']] += $Row['Value']; 180 } 181 $Output .= '</table><br/>'; 182 $Output .= '<strong>Souhrn</strong><br/>'; 183 $Output .= 'Celkem: '.$Total.' Kč<br/>'; 184 $Output .= ' Daňové: '.$TotalTax[1].' Kč<br/>'; 185 $Output .= ' Nedaňové: '.$TotalTax[0].' Kč<br/>'; 186 $Output .= ' Hotovostní: '.$TotalCash[1].' Kč<br/>'; 187 $Output .= ' Bezhotovostní: '.$TotalCash[0].' Kč<br/>'; 450 $Output = $this->ShowIncomes(); 188 451 break; 189 452 case 'Expenses': 190 $Table = array('Ne', 'Ano'); 191 $DbResult = $this->Database->select('FinanceYear', '*', 'Id='.$_GET['year']); 192 $Year = $DbResult->fetch_assoc(); 193 194 $Total = 0; 195 $TotalTax = array(0, 0); 196 $TotalCash = array(0, 0); 197 $Output .= '<strong>Výdaje za rok '.$Year['Year'].'</strong>'; 198 $Output .= '<table style="font-size: smaller;" class="WideTable">'; 199 $Output .= '<tr><th>Čas</th><th>Kód</th><th>Subjekt</th><th>Text</th><th>Hodnota [Kč]</th><th>Daňový</th><th>Hotovost</th></tr>'; 200 $DbResult = $this->Database->query('SELECT `FinanceOperation`.*, `DocumentLineCode`.`Name` AS `BillName`, '. 201 '`Subject`.`Name` AS `SubjectName`, `FinanceOperationGroup`.`ValueSign` AS `ValueSign` FROM `FinanceOperation` '. 202 'LEFT JOIN `Subject` ON `Subject`.`Id` = `FinanceOperation`.`Subject` '. 203 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `FinanceOperation`.`Group` '. 204 'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id` = `FinanceOperation`.`BillCode` '. 205 'WHERE (`FinanceOperationGroup`.`ValueSign` = -1) AND (`FinanceOperation`.`Time` >= "'.$Year['DateStart'].'") '. 206 'AND (`FinanceOperation`.`Time` <= "'.$Year['DateEnd'].'") ORDER BY `Time`'); 207 while($Row = $DbResult->fetch_array()) 208 { 209 $Row['Time'] = explode(' ', $Row['Time']); 210 $Row['Time'] = $Row['Time'][0]; 211 $Row['Value'] = $Row['Value'] * $Row['ValueSign']; 212 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['BillName']. 213 '</td><td>'.$Row['SubjectName'].'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value']. 214 '</td><td>'.$Table[$Row['Taxable']].'</td><td>'.$Table[$Row['Cash']].'</td></tr>'; 215 $Total += $Row['Value']; 216 $TotalTax[$Row['Taxable']] += $Row['Value']; 217 $TotalCash[$Row['Cash']] += $Row['Value']; 218 } 219 $Output .= '</table><br/>'; 220 $Output .= '<strong>Souhrn</strong><br/>'; 221 $Output .= 'Celkem: '.$Total.' Kč<br/>'; 222 $Output .= ' Daňové: '.$TotalTax[1].' Kč<br/>'; 223 $Output .= ' Nedaňové: '.$TotalTax[0].' Kč<br/>'; 224 $Output .= ' Hotovostní: '.$TotalCash[1].' Kč<br/>'; 225 $Output .= ' Bezhotovostní: '.$TotalCash[0].' Kč<br/>'; 453 $Output = $this->ShowExpenses(); 226 454 break; 227 455 case 'Claims': 228 $Table = array('Ne', 'Ano'); 229 $DbResult = $this->Database->select('FinanceYear', '*', 'Id='.$_GET['year']); 230 $Year = $DbResult->fetch_assoc(); 231 232 $Total = 0; 233 $Output .= '<strong>Pohledávky za rok '.$Year['Year'].'</strong>'; 234 $Output .= '<table style="font-size: smaller;" class="WideTable">'; 235 $Output .= '<tr><th>Čas vystavení</th><th>Kód</th><th>Subjekt</th><th>Text</th><th>Hodnota [Kč]</th></tr>'; 236 $DbResult = $this->Database->query('SELECT `FinanceInvoice`.*, '. 237 '`DocumentLineCode`.`Name` AS `BillName`, `Subject`.`Name` AS `SubjectName`, '. 238 '(SELECT GROUP_CONCAT(`Description` SEPARATOR ",") '. 239 'FROM `FinanceInvoiceItem` WHERE `FinanceInvoiceItem`.`FinanceInvoice` = `FinanceInvoice`.`Id`) AS `Text` FROM `FinanceInvoice`'. 240 'LEFT JOIN `Subject` ON `Subject`.`Id` = `FinanceInvoice`.`Subject` '. 241 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `FinanceInvoice`.`Group` '. 242 'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id` = `FinanceInvoice`.`BillCode` '. 243 'WHERE (`FinanceInvoiceGroup`.`ValueSign` = 1) AND (`FinanceInvoice`.`Time` >= "'.$Year['DateStart']. 244 '") AND (`FinanceInvoice`.`Time` <= "'.$Year['DateEnd'].'") ORDER BY `Time`'); 245 while($Row = $DbResult->fetch_array()) 246 { 247 if($Row['TimePayment'] == '0000-00-00 00:00:00') $Row['TimePayment'] = ' '; 248 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['BillName']. 249 '</td><td>'.$Row['SubjectName'].'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value'].'</td></tr>'; 250 $Total += $Row['Value']; 251 } 252 $Output .= '</table><br/>'; 253 $Output .= 'Celkem: '.$Total.' Kč<br/>'; 254 break; 255 case 'Liabilities': 256 $Table = array('Ne', 'Ano'); 257 $DbResult = $this->Database->select('FinanceYear', '*', 'Id='.$_GET['year']); 258 $Year = $DbResult->fetch_assoc(); 259 260 $Total = 0; 261 $Output .= '<strong>Závazky za rok '.$Year['Year'].'</strong>'; 262 $Output .= '<table style="font-size: smaller;" class="WideTable">'; 263 $Output .= '<tr><th>Čas vystavení</th><th>Kód</th><th>Subjekt</th><th>Text</th><th>Hodnota [Kč]</th></tr>'; 264 $DbResult = $this->Database->query('SELECT *, `DocumentLineCode`.`Name` AS `BillName`, `Subject`.`Name` AS `SubjectName`, '. 265 '(SELECT GROUP_CONCAT(Description SEPARATOR ",") '. 266 'FROM `FinanceInvoiceItem` WHERE `FinanceInvoiceItem`.`FinanceInvoice` = `FinanceInvoice`.`Id`) AS `Text` '. 267 'FROM `FinanceInvoice` '. 268 'LEFT JOIN `Subject` ON `Subject`.`Id` = `FinanceInvoice`.`Subject` '. 269 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `FinanceInvoice`.`Group` '. 270 'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id` = `FinanceInvoice`.`BillCode` '. 271 'WHERE (`FinanceInvoiceGroup`.`ValueSign` = -1) AND (`FinanceInvoice`.`Time` >= "'.$Year['DateStart']. 272 '") AND (FinanceInvoice.Time <= "'.$Year['DateEnd'].'") ORDER BY Time'); 273 while($Row = $DbResult->fetch_array()) 274 { 275 if($Row['TimePayment'] == '0000-00-00 00:00:00') $Row['TimePayment'] = ' '; 276 $Row['Value'] = $Row['Value'] * $Row['ValueSign']; 277 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['BillName']. 278 '</td><td>'.$Row['SubjectName'].'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value'].'</td></tr>'; 279 $Total += $Row['Value']; 280 } 281 $Output .= '</table><br/>'; 282 $Output .= 'Celkem: '.$Total.' Kč<br/>'; 456 $Output = $this->ShowClaims(); 457 break; 458 case 'Liabilities': 459 $Output = $this->ShowLiabilities(); 283 460 break; 284 461 case 'SubjectList': 285 $Output .= '<strong>Seznam subjektů</strong>'; 286 $Output .= '<table style="font-size: smaller;" class="WideTable">'; 287 $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>'; 288 $DbResult = $this->Database->query('SELECT Id, Name, 0 AS Cash, '. 289 '(SELECT SUM(T1.Value) FROM FinanceInvoice AS T1 '. 290 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `T1`.`Group` '. 291 'WHERE (T1.Subject = Subject.Id) AND (`FinanceInvoiceGroup`.ValueSign = 1)) AS `Claims`, '. 292 '(SELECT SUM(T2.Value) FROM FinanceInvoice AS T2 '. 293 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `T2`.`Group` '. 294 'WHERE (T2.Subject = Subject.Id) AND (`FinanceInvoiceGroup`.`ValueSign` = 1) AND (TimePayment IS NULL)) AS `OpenedClaims`, '. 295 '(SELECT -SUM(T3.Value) FROM FinanceInvoice AS T3 '. 296 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `T3`.`Group` '. 297 'WHERE (T3.Subject = Subject.Id) AND (`FinanceInvoiceGroup`.`ValueSign` = -1)) AS `Liabilities`, '. 298 '(SELECT -SUM(T4.Value) FROM FinanceInvoice AS T4 '. 299 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `T4`.`Group` '. 300 'WHERE (T4.Subject = Subject.Id) AND (`FinanceInvoiceGroup`.`ValueSign` = -1) AND (`TimePayment` IS NULL)) AS `OpenedLiabilities`, '. 301 '(SELECT SUM(T5.Value) FROM FinanceOperation AS T5 '. 302 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `T5`.`Group` '. 303 'WHERE (T5.Subject = Subject.Id) AND (`FinanceOperationGroup`.`ValueSign` = 1)) AS `Gains`, '. 304 '(SELECT SUM(T6.Value) FROM FinanceOperation AS T6 '. 305 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `T6`.`Group` '. 306 'WHERE (T6.Subject = Subject.Id) AND (`FinanceOperationGroup`.`ValueSign` = -1)) AS `Spends` '. 307 'FROM Subject ORDER BY Name'); 308 while($Row = $DbResult->fetch_assoc()) 309 { 310 $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>'; 311 } 312 $Output .= '</table>'; 462 $Output = $this->ShowSubjectList(); 313 463 break; 314 464 case 'SmallAssets': 315 $Output .= '<strong>Drobný majetek</strong>'; 316 $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'; 317 $Output .= '<tr><th>Název</th><th>Hodnota [Kč]</th><th>Datum zakoupení</th><th>Datum vyřezení</th></tr>'; 318 $DbResult = $this->Database->query('SELECT Product.Name AS Name, StockSerialNumber.SellPrice AS Price, StockSerialNumber.TimeEnlistment AS TimeEnlistment, StockSerialNumber.TimeElimination AS TimeElimination '. 319 'FROM StockSerialNumber JOIN Product ON Product.Id = StockSerialNumber.Product '. 320 'WHERE (TimeElimination IS NOT NULL)'); 321 while($Row = $DbResult->fetch_array()) 322 { 323 $Output .= '<tr><td>'.$Row['Name'].'</td><td>'.$Row['Price'].'</td><td>'.$Row['TimeEnlistment'].'</td><td>'.$Row['TimeElimination'].'</td></tr>'; 324 } 325 $Output .= '</table>'; 465 $Output = $this->ShowSmallAssets(); 326 466 break; 327 467 case 'SubjectAccount': 328 $Output .= '<table style="width: 100%"><tr><td style="vertical-align: top;">'; 329 $Output .= '<strong>Výpis příjmů/výdajů</strong>'; 330 $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'; 331 $Output .= '<tr><th>Datum</th><th>Název</th><th>Hodnota [Kč]</th><th>Doklad</th></tr>'; 332 $DbResult = $this->Database->query('SELECT `FinanceOperation`.*, `DocumentLineCode`.`Name` AS `BillName` '. 333 'FROM `FinanceOperation` '. 334 'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id` = `FinanceOperation`.`BillCode` '. 335 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `FinanceOperation`.`Group` '. 336 'WHERE `Subject`='.$_GET['Id'].' ORDER BY `Time`'); 337 while($Row = $DbResult->fetch_array()) 338 { 339 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['Text']. 340 '</td><td>'.$Row['Value'].'</td><td>'.$Row['BillName'].'</td></tr>'; 341 } 342 $Output .= '</table></td><td style="vertical-align: top;">'; 343 344 $Output .= '<strong>Výpis závazků/pohledávek</strong>'; 345 $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'; 346 $Output .= '<tr><th>Datum vytvoření</th><th>Datum zaplacení</th><th>Název</th><th>Hodnota [Kč]</th><th>Doklad</th></tr>'; 347 $DbResult = $this->Database->query('SELECT `FinanceInvoice`.*, (SELECT GROUP_CONCAT(Description SEPARATOR ",") '. 348 'FROM FinanceInvoiceItem WHERE `FinanceInvoiceItem`.`FinanceInvoice` = `FinanceInvoice`.`Id`) AS `Text`, `DocumentLineCode`.`Name` AS `BillName` '. 349 'FROM `FinanceInvoice` '. 350 'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id` = `FinanceInvoice`.`BillCode` '. 351 'WHERE `Subject`='.$_GET['Id'].' ORDER BY `Time`'); 352 while($Row = $DbResult->fetch_array()) 353 { 354 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.HumanDate($Row['TimePayment']). 355 '</td><td>'.$Row['Text'].'</td><td>'.round($Row['Value'], $Finance->Rounding).'</td><td>'.$Row['BillName'].'</td></tr>'; 356 } 357 $Output .= '</table></td></tr></table>'; 358 359 /*$Output .= '<strong>Výpis záloh</strong>'; 360 $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'; 361 $Output .= '<tr><th>Datum vytvoření</th><th>Datum zaplacení</th><th>Název</th><th>Hodnota [Kč]</th></tr>'; 362 $DbResult = $this->Database->select('FinanceAdvances', '*', 'Subject='.$_GET['Id']); 363 while($Row = $DbResult->fetch_array()) 364 { 365 $Output .= '<tr><td>'.$Row['Time'].'</td><td>'.$Row['TimePass'].'</td><td>'.$Row['ValueSign'].'</td><td>'.($Row['Value']).'</td><td>'.$Row['CashFlowId'].'</td></tr>'; 366 } 367 $Output .= '</table>';*/ 368 369 $DbResult = $this->Database->query('SELECT Id, 0 AS Cash, (SELECT SUM(FinanceInvoice.Value * FinanceInvoice.ValueSign) '. 370 'FROM FinanceInvoice WHERE (FinanceInvoice.Subject = Subject.Id) AND '. 371 '(FinanceInvoice.ValueSign = 1)) as Claims, (SELECT SUM(FinanceInvoice.Value * FinanceInvoice.ValueSign) '. 372 'FROM FinanceInvoice WHERE (FinanceInvoice.Subject = Subject.Id) AND ('. 373 'FinanceInvoice.ValueSign = 1) AND (TimePayment IS NULL)) as OpenedClaims, '. 374 '(SELECT SUM(FinanceInvoice.Value * FinanceInvoice.ValueSign) FROM FinanceInvoice '. 375 'WHERE (FinanceInvoice.Subject = Subject.Id) AND (FinanceInvoice.ValueSign = -1)) AS '. 376 'Liabilities, (SELECT SUM(FinanceInvoice.Value) FROM FinanceInvoice '. 377 'WHERE (FinanceInvoice.Subject = Subject.Id) AND (FinanceInvoice.ValueSign = -1) '. 378 'AND (TimePayment IS NULL)) AS OpenedLiabilities, '. 379 '(SELECT SUM(FinanceOperation.Value*FinanceOperation.ValueSign) '. 380 'FROM FinanceOperation WHERE FinanceOperation.Subject = Subject.Id AND FinanceOperation.ValueSign = 1) '. 381 'AS Gains, (SELECT SUM(FinanceOperation.Value*FinanceOperation.ValueSign) FROM FinanceOperation WHERE '. 382 'FinanceOperation.Subject = Subject.Id AND FinanceOperation.ValueSign = -1) as Spends '. 383 'FROM Subject WHERE Id='.$_GET['Id']); 384 $Row = $DbResult->fetch_array(); 385 $Output .= 'Stav placení: '.(-$Row['OpenedClaims'] + Abs($Row['OpenedLiabilities'])); 468 $Output = $this->ShowSubjectAccount(); 386 469 break; 387 470 case 'PrintMonthOperations': … … 393 476 break; 394 477 default: 395 $Output .= '<strong>Celkové přehledy</strong><br/>'; 396 $Output .= '<a href="?table=AnnualBalance">Účetní závěrka</a><br />'; 397 $Output .= '<a href="?table=MonthlyBalance">Měsíční přehledy</a><br />'; 398 $Output .= '<a href="?table=SubjectList">Seznam subjektů</a><br />'; 399 $Output .= '<a href="?table=SmallAssets">Drobný majetek</a><br />'; 400 $Output .= '<br/>'; 401 $Output .= '<strong>Roční přehledy</strong><br/>'; 402 $Output .= $this->ShowFinanceYears(); 403 if(array_key_exists('year', $_GET)) 404 { 405 $Year = $_GET['year'] * 1; 406 $Output .= '<a href="?table=Incomes&year='.$Year.'">Příjmy</a><br />'; 407 $Output .= '<a href="?table=Expenses&year='.$Year.'">Výdaje</a><br />'; 408 $Output .= '<a href="?table=Claims&year='.$Year.'">Pohledávky</a><br />'; 409 $Output .= '<a href="?table=Liabilities&year='.$Year.'">Závazky</a><br />'; 410 $Output .= '<a href="?table=Advantages&year='.$Year.'">Zálohy</a><br />'; 411 } 478 $Output = $this->ShowDefault(); 412 479 } 413 480 return($Output);
Note:
See TracChangeset
for help on using the changeset viewer.