Changeset 748
- Timestamp:
- Sep 30, 2015, 11:55:11 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Application/Version.php
r747 r748 1 1 <?php 2 2 3 $Revision = 74 7; // Subversion revision4 $DatabaseRevision = 74 7; // SQL structure revision3 $Revision = 748; // Subversion revision 4 $DatabaseRevision = 748; // SQL structure revision 5 5 $ReleaseTime = strtotime('2015-09-19'); -
trunk/Common/Setup/DefaultConfig.php
r738 r748 45 45 array('Name' => 'Finance/MainSubjectId', 'Type' => 'Integer', 'Default' => '1', 'Title' => 'Id hlavního subjektu'), 46 46 array('Name' => 'Finance/DirectoryId', 'Type' => 'Integer', 'Default' => '1', 'Title' => 'Id adresáře souborů dokladů'), 47 array('Name' => 'Finance/Rounding', 'Type' => 'Integer', 'Default' => '2', 'Title' => 'Počet desetinných míst zaokrouhlování'), 47 48 array('Name' => 'MainRouter/HostName', 'Type' => 'String', 'Default' => 'localhost', 'Title' => 'Hlavní brána'), 48 49 array('Name' => 'MainRouter/UserName', 'Type' => 'String', 'Default' => 'admin', 'Title' => 'Uživatelské jméno'), -
trunk/Common/Setup/Updates.php
r747 r748 1489 1489 } 1490 1490 1491 function UpdateTo74 8($Manager)1491 function UpdateTo747($Manager) 1492 1492 { 1493 1493 $Manager->Execute('ALTER TABLE `FinanceOperation` ADD `ValueUser` FLOAT NOT NULL AFTER `Value`;'); … … 1506 1506 $Manager->Execute('ALTER TABLE `FinanceInvoice` DROP `Direction`, DROP `ValueSign`;'); 1507 1507 // Check manual vs. calculated value from items 1508 // SELECT * FROM (SELECT `FinanceInvoice`.`Id`, ((SELECT SUM(`Price` * `Quantity`) FROM `FinanceInvoiceItem` WHERE `FinanceInvoiceItem`.`FinanceInvoice`=`FinanceInvoice`.`Id`) * `FinanceInvoiceGroup`.`ValueSign`) AS `Sum`,`FinanceInvoice`.`Value` FROM `FinanceInvoice` LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id`=`FinanceInvoice`.`Group`) AS `T` WHERE `Sum` != `Value` 1508 // SELECT * FROM (SELECT `FinanceInvoice`.`Id`, ((SELECT SUM(CEIL(`Price` * `Quantity`)) FROM `FinanceInvoiceItem` WHERE `FinanceInvoiceItem`.`FinanceInvoice`=`FinanceInvoice`.`Id`) * `FinanceInvoiceGroup`.`ValueSign`) AS `Sum`,`FinanceInvoice`.`Value` FROM `FinanceInvoice` LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id`=`FinanceInvoice`.`Group`) AS `T` WHERE `Sum` != `Value` 1509 } 1510 1511 function UpdateTo748($Manager) 1512 { 1513 $DbResult = $Manager->Database->query('SELECT * FROM (SELECT `FinanceInvoice`.`Id`, ((SELECT SUM(`Price` * `Quantity`) FROM `FinanceInvoiceItem` WHERE `FinanceInvoiceItem`.`FinanceInvoice`=`FinanceInvoice`.`Id`) * `FinanceInvoiceGroup`.`ValueSign`) AS `Sum`,`FinanceInvoice`.`Value` FROM `FinanceInvoice` LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id`=`FinanceInvoice`.`Group`) AS `T` WHERE `Sum` != `Value`'); 1514 while($DbRow = $DbResult->fetch_assoc()) 1515 { 1516 $Manager->Database->query('UPDATE `FinanceInvoiceItem` SET `Price` = -`Price` WHERE `FinanceInvoice`='.$DbRow['Id']); 1517 } 1509 1518 } 1510 1519 … … 1579 1588 740 => array('Revision' => 741, 'Function' => 'UpdateTo741'), 1580 1589 741 => array('Revision' => 742, 'Function' => 'UpdateTo742'), 1581 742 => array('Revision' => 748, 'Function' => 'UpdateTo748'), 1590 742 => array('Revision' => 747, 'Function' => 'UpdateTo747'), 1591 747 => array('Revision' => 748, 'Function' => 'UpdateTo748'), 1582 1592 )); 1583 1593 } -
trunk/Modules/Finance/Bill.php
r747 r748 52 52 function GenerateHTML() 53 53 { 54 $DbResult = $this->Database->query('SELECT `FinanceInvoice`.*, `FinanceInvoiceGroup`.`Direction` FROM `FinanceInvoice` '. 54 $Finance = &$this->System->Modules['Finance']; 55 $Finance->LoadMonthParameters(0); 56 57 $DbResult = $this->Database->query('SELECT `FinanceInvoice`.*, `FinanceInvoiceGroup`.`Direction`, `DocumentLineCode`.`Name` AS `BillName` FROM `FinanceInvoice` '. 55 58 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id`=`FinanceInvoice`.`Group` '. 59 'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id`=`FinanceInvoice`.`BillCode` '. 56 60 'WHERE `FinanceInvoice`.`Id`='.$this->InvoiceId); 57 61 $Invoice = $DbResult->fetch_assoc(); … … 72 76 $SubjectFrom['Account'] = $SubjectFromAccount['NumberFull']; 73 77 74 $Dodavka = array();75 78 $InvoiceItems = array(); 76 $DbResult = $this->Database->select('FinanceInvoiceItem', '*, CEIL(`Price` * `Quantity`) AS `Total`', '`FinanceInvoice`='.$this->InvoiceId);79 $DbResult = $this->Database->select('FinanceInvoiceItem', '*, ROUND(`Price` * `Quantity`, '.$Finance->Rounding.') AS `Total`', '`FinanceInvoice`='.$this->InvoiceId); 77 80 while($Item = $DbResult->fetch_assoc()) 78 81 { … … 108 111 '<tr><td width="50%" valign="top">'. 109 112 '<strong>Platební podmínky:</strong><br>'. 110 'Číslo dokladu: '.$Invoice['Bill Code'].'<br>'.113 'Číslo dokladu: '.$Invoice['BillName'].'<br>'. 111 114 'Variabilní symbol: '.$VarSym.'<br>'. 112 115 'Specifický symbol: '.$this->SpecificSymbol.'<br>'. … … 153 156 function GenerateHTML() 154 157 { 155 $DbResult = $this->Database->query('SELECT `FinanceOperation`.*, `FinanceOperationGroup`.`Direction` FROM `FinanceOperation` '.158 $DbResult = $this->Database->query('SELECT `FinanceOperation`.*, `FinanceOperationGroup`.`Direction`, `DocumentLineCode`.`Name` AS `BillName` FROM `FinanceOperation` '. 156 159 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id`=`FinanceOperation`.`Group` '. 160 'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id`=`FinanceOperation`.`BillCode` '. 157 161 'WHERE `FinanceOperation`.`Id`='.$this->OperationId); 158 162 $Operation = $DbResult->fetch_assoc(); … … 195 199 '</td><td width="50%" valign="top">'. 196 200 '<font size="5"><strong>'.$Desc['Type'].' POKLADNÍ DOKLAD</strong></font><br><br>'. 197 'Číslo dokladu: '.$Operation['Bill Code'].'<br>'.201 'Číslo dokladu: '.$Operation['BillName'].'<br>'. 198 202 'Datum vystavení: '.HumanDate($Operation['Time']).'<br>'. 199 203 '</td></tr>'. -
trunk/Modules/Finance/Finance.php
r747 r748 17 17 define('INVOICE_GROUP_OUT', 2); 18 18 define('VAT_TYPE_BASE', 2); 19 define('FINANCE_DIRECTION_OUT', 0);20 define('FINANCE_DIRECTION_IN', 1);19 define('FINANCE_DIRECTION_OUT', 1); 20 define('FINANCE_DIRECTION_IN', 0); 21 21 22 22 class Finance extends Model … … 39 39 var $BillingPeriods; 40 40 var $DirectoryId; 41 var $Rounding; 41 42 42 43 function LoadMonthParameters($Period = 1) // 0 - now, 1 - next month … … 74 75 $this->TotalInternetPaid = $Row['MonthlyInternet']; 75 76 $this->TotalPaid = $Row['MonthlyTotal']; 77 $this->Rounding = $this->System->Config['Finance']['Rounding']; 76 78 } 77 79 … … 293 295 'DocumentLine' => array('Type' => 'TDocumentLine', 'Caption' => 'Dokladová řada', 'Default' => '0'), 294 296 'ValueSign' => array('Type' => 'TFinanceValueSign', 'Caption' => 'Znaménko hodnoty', 'Default' => '0'), 295 297 'Direction' => array('Type' => 'TFinanceDirection', 'Caption' => 'Směr', 'Default' => '0'), 296 298 ), 297 299 )); … … 325 327 'Value' => array('Type' => 'Integer', 'Caption' => 'Částka absolutní', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true), 326 328 'ValueUser' => array('Type' => 'Integer', 'Caption' => 'Částka', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true, 327 'SQL' => 'SELECT SUM(CEIL(`Price`*`Quantity`)) FROM `FinanceInvoiceItem` WHERE `FinanceInvoiceItem`.`FinanceInvoice`=#Id'), 329 'SQL' => 'SELECT ROUND(SUM(`Price`*`Quantity`), '.$Config['Finance']['Rounding'].') FROM `FinanceInvoiceItem` WHERE `FinanceInvoiceItem`.`FinanceInvoice`=#Id'), 330 'File' => array('Type' => 'TFile', 'Caption' => 'Doklad', 'Default' => '', 'Null' => true), 328 331 'Generate' => array('Type' => 'Boolean', 'Caption' => 'Generovat', 'Default' => ''), 329 332 'PeriodFrom' => array('Type' => 'Date', 'Caption' => 'Období od', 'Default' => '', 'Null' => true), … … 390 393 'VAT' => array('Type' => 'Integer', 'Caption' => 'Daň', 'Default' => '21', 'Suffix' => '%'), 391 394 'Total' => array('Type' => 'Integer', 'Caption' => 'Celkem', 'Default' => '', 'Suffix' => 'Kč', 392 'ReadOnly' => true, 'SQL' => ' CEIL(`Price` * `Quantity`)'),395 'ReadOnly' => true, 'SQL' => 'ROUND(`Price` * `Quantity`, '.$Config['Finance']['Rounding'].')'), 393 396 ), 394 397 'AfterInsert' => array($this, 'AfterInsertFinanceInvoiceItem'), -
trunk/Modules/Finance/Manage.php
r747 r748 109 109 $SumValue = 0; 110 110 foreach($Items as $Item) { 111 $SumValue = $SumValue + ceil($Item['Price'] * $Item['Quantity']); 112 } 111 $SumValue = $SumValue + $Item['Price'] * $Item['Quantity']; 112 } 113 $Finance = &$this->System->Modules['Finance']; 114 $SumValue = round($SumValue, $Finance->Rounding); 113 115 $this->Database->insert('FinanceInvoice', array( 114 116 'Subject' => $Subject, 'Time' => TimeToMysqlDateTime($TimeCreation), -
trunk/Modules/Finance/UserState.php
r747 r748 9 9 function ShowFinanceOperation($Subject) 10 10 { 11 $UserOperationTableQuery = '((SELECT `Text`, `Time`, `Value`, `File`, `BillCode`, NULL AS `PeriodFrom`, NULL AS `PeriodTo` '. 12 'FROM `FinanceOperation` WHERE (`Subject`='.$Subject['Id'].')) UNION ALL '. 11 $UserOperationTableQuery = '((SELECT `Text`, `Time`, `Value`, `File`, `BillCode`, NULL AS `PeriodFrom`, NULL AS `PeriodTo`, `DocumentLineCode`.`Name` AS `BillName` '. 12 'FROM `FinanceOperation` '. 13 'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id`=`FinanceOperation`.`BillCode` '. 14 'WHERE (`Subject`='.$Subject['Id'].') '. 15 ') UNION ALL '. 13 16 '(SELECT (SELECT GROUP_CONCAT(`Description` SEPARATOR ",") FROM `FinanceInvoiceItem` WHERE `FinanceInvoice`=`FinanceInvoice`.`Id`) AS `Text`, '. 14 '`Time`, -`Value`, `File`, `BillCode`, `PeriodFrom`, `PeriodTo` FROM `FinanceInvoice` WHERE (`Subject`='.$Subject['Id'].')))'; 17 '`Time`, -`Value`, `File`, `BillCode`, `PeriodFrom`, `PeriodTo`, `DocumentLineCode`.`Name` AS `BillName` FROM `FinanceInvoice` '. 18 'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id`=`FinanceInvoice`.`BillCode` '. 19 'WHERE (`Subject`='.$Subject['Id'].')))'; 15 20 16 21 $Output = '<div style="text-align:center">Výpis finančních operací</div>'; … … 46 51 if($Row['Value'] == -0) $Row['Value'] = 0; 47 52 if($Row['Value'] > 0) $Row['Value'] = '+'.$Row['Value']; 48 if($Row['Bill Code'] == '') $Row['BillCode'] = 'PDF';49 if($Row['File'] > 0) $Invoice = '<a href="'.$this->System->Link('/file?id='.$Row['File']).'">'.$Row['Bill Code'].'</a>';50 else $Invoice = NotBlank($Row['BillCode']);53 if($Row['BillName'] == '') $Row['BillName'] = 'PDF'; 54 if($Row['File'] > 0) $Invoice = '<a href="'.$this->System->Link('/file?id='.$Row['File']).'">'.$Row['BillName'].'</a>'; 55 else $Invoice = NotBlank($Row['BillName']); 51 56 if($Row['PeriodFrom'] != '') $Period = HumanDate($Row['PeriodFrom']).' - '.HumanDate($Row['PeriodTo']); 52 else $Period = ' ';57 else $Period = ' '; 53 58 $Output .= '<tr><td style="text-align: right;">'.HumanDate($Row['Time']).'</td>'. 54 59 '<td style="text-align: left;">'.$Row['Text'].'</td>'. -
trunk/Modules/Finance/Zivnost.php
r740 r748 11 11 { 12 12 $Balance = array(); 13 $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceOperation WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (ValueSign = 1)'); 13 $DbResult = $this->Database->query('SELECT SUM(`Value`) FROM `FinanceOperation` '. 14 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `FinanceOperation`.`Group` '. 15 'WHERE (`Time` < "'.TimeToMysqlDateTime($StartTime).'") AND (`Time` >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (`Taxable` = 1) AND (`FinanceOperationGroup`.`ValueSign` = 1)'); 14 16 $Row = $DbResult->fetch_array(); 15 17 $Balance['Income']['Start'] = $Row[0] + 0; 16 $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceOperation WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (ValueSign = 1)'); 18 $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceOperation '. 19 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `FinanceOperation`.`Group` '. 20 'WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (`FinanceOperationGroup`.`ValueSign` = 1)'); 17 21 //echo('SELECT SUM(Value) FROM FinanceCashFlow WHERE Time <= "'.TimeToMysqlDateTime($EndTime).'" AND Value > 0 AND Taxable = 1'.'<br />'); 18 22 $Row = $DbResult->fetch_array(); 19 23 $Balance['Income']['End'] = $Row[0] + 0; 20 24 21 $DbResult = $this->Database->query('SELECT -SUM(Value*ValueSign) FROM FinanceOperation WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (ValueSign = -1)'); 25 $DbResult = $this->Database->query('SELECT SUM(Value*ValueSign) FROM FinanceOperation '. 26 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `FinanceOperation`.`Group` '. 27 'WHERE (`Time` < "'.TimeToMysqlDateTime($StartTime).'") AND (`Time` >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (`Taxable` = 1) AND (`FinanceOperationGroup`.`ValueSign` = -1)'); 22 28 $Row = $DbResult->fetch_array(); 23 29 $Balance['Spend']['Start'] = $Row[0] + 0; 24 $DbResult = $this->Database->query('SELECT -SUM(Value*ValueSign) FROM FinanceOperation WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (ValueSign = -1)'); 30 $DbResult = $this->Database->query('SELECT SUM(Value*ValueSign) FROM FinanceOperation '. 31 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `FinanceOperation`.`Group` '. 32 'WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (`FinanceOperationGroup`.`ValueSign` = -1)'); 25 33 //echo('SELECT -SUM(Value) FROM FinanceCashFlow WHERE Time <= "'.TimeToMysqlDateTime($EndTime).'" AND Value < 0 AND Taxable = 1'.'<br />'); 26 34 $Row = $DbResult->fetch_array(); 27 35 $Balance['Spend']['End'] = $Row[0] + 0; 28 36 29 $DbResult = $this->Database->query('SELECT SUM(Value*ValueSign) FROM FinanceInvoice WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (ValueSign = 1)'); 37 $DbResult = $this->Database->query('SELECT SUM(Value*ValueSign) FROM FinanceInvoice '. 38 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `FinanceInvoice`.`Group` '. 39 'WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (`FinanceInvoiceGroup`.`ValueSign` = 1)'); 30 40 $Row = $DbResult->fetch_array(); 31 41 $Balance['Claims']['Start'] = $Row[0] + 0; 32 $DbResult = $this->Database->query('SELECT SUM(Value*ValueSign) FROM FinanceInvoice WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (ValueSign = 1)'); 42 $DbResult = $this->Database->query('SELECT SUM(Value*ValueSign) FROM FinanceInvoice '. 43 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `FinanceInvoice`.`Group` '. 44 'WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (`FinanceInvoiceGroup`.`ValueSign` = 1)'); 33 45 $Row = $DbResult->fetch_array(); 34 46 $Balance['Claims']['End'] = $Row[0] + 0; 35 47 36 $DbResult = $this->Database->query('SELECT -SUM(Value*ValueSign) FROM FinanceInvoice WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (ValueSign = -1)'); 48 $DbResult = $this->Database->query('SELECT SUM(Value*ValueSign) FROM FinanceInvoice '. 49 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `FinanceInvoice`.`Group` '. 50 'WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (`FinanceInvoiceGroup`.`ValueSign` = -1)'); 37 51 $Row = $DbResult->fetch_array(); 38 52 $Balance['Liabilities']['Start'] = $Row[0] + 0; 39 $DbResult = $this->Database->query('SELECT -SUM(Value*ValueSign) FROM FinanceInvoice WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (ValueSign = -1)'); 53 $DbResult = $this->Database->query('SELECT SUM(Value*ValueSign) FROM FinanceInvoice '. 54 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `FinanceInvoice`.`Group` '. 55 'WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (`FinanceInvoiceGroup`.`ValueSign` = -1)'); 40 56 $Row = $DbResult->fetch_array(); 41 57 $Balance['Liabilities']['End'] = $Row[0] + 0; … … 54 70 function Show() 55 71 { 56 if(!$this->System->User->CheckPermission('Finance', 'TradingStatus')) return('Nemáte oprávnění'); 72 if(!$this->System->User->CheckPermission('Finance', 'TradingStatus')) 73 return('Nemáte oprávnění'); 74 75 $Finance = &$this->System->Modules['Finance']; 57 76 58 77 $Output = ''; … … 143 162 $Output .= '<table style="font-size: smaller;" class="WideTable">'; 144 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>'; 145 $DbResult = $this->Database->query('SELECT * FROM FinanceOperation LEFT JOIN Subject ON Subject.Id = FinanceOperation.Subject '. 146 'WHERE (ValueSign = 1) AND (FinanceOperation.Time >= "'.$Year['DateStart'].'") AND (FinanceOperation.Time <= "'.$Year['DateEnd'].'") ORDER BY Time'); 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`'); 147 170 while($Row = $DbResult->fetch_array()) 148 171 { 149 172 $Row['Time'] = explode(' ', $Row['Time']); 150 173 $Row['Time'] = $Row['Time'][0]; 151 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['BillCode'].'</td><td>'.$Row['Name'].'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value'].'</td><td>'.$Table[$Row['Taxable']].'</td><td>'.$Table[$Row['Cash']].'</td></tr>'; 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>'; 152 177 $Total += $Row['Value']; 153 178 $TotalTax[$Row['Taxable']] += $Row['Value']; … … 173 198 $Output .= '<table style="font-size: smaller;" class="WideTable">'; 174 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>'; 175 $DbResult = $this->Database->query('SELECT * FROM FinanceOperation LEFT JOIN Subject ON Subject.Id = FinanceOperation.Subject '. 176 'WHERE (ValueSign = -1) AND (FinanceOperation.Time >= "'.$Year['DateStart'].'") AND (FinanceOperation.Time <= "'.$Year['DateEnd'].'") ORDER BY Time'); 200 $DbResult = $this->Database->query('SELECT `FinanceOperation`.*, `DocumentLineCode`.`Name` AS `BillName`, `Subject`.`Name` AS `Name` 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`'); 177 206 while($Row = $DbResult->fetch_array()) 178 207 { … … 180 209 $Row['Time'] = $Row['Time'][0]; 181 210 $Row['Value'] = $Row['Value']; 182 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['BillCode'].'</td><td>'.$Row['Name'].'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value'].'</td><td>'.$Table[$Row['Taxable']].'</td><td>'.$Table[$Row['Cash']].'</td></tr>'; 211 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['BillName']. 212 '</td><td>'.$Row['Name'].'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value']. 213 '</td><td>'.$Table[$Row['Taxable']].'</td><td>'.$Table[$Row['Cash']].'</td></tr>'; 183 214 $Total += $Row['Value']; 184 215 $TotalTax[$Row['Taxable']] += $Row['Value']; … … 202 233 $Output .= '<table style="font-size: smaller;" class="WideTable">'; 203 234 $Output .= '<tr><th>Čas vystavení</th><th>Kód</th><th>Subjekt</th><th>Text</th><th>Hodnota [Kč]</th></tr>'; 204 $DbResult = $this->Database->query('SELECT *, (SELECT GROUP_CONCAT(Description SEPARATOR ",") FROM FinanceInvoiceItem WHERE FinanceInvoiceItem.FinanceInvoice = FinanceInvoice.Id) AS Text '. 235 $DbResult = $this->Database->query('SELECT `FinanceInvoice`.*, (SELECT GROUP_CONCAT(Description SEPARATOR ",") '. 236 'FROM FinanceInvoiceItem WHERE FinanceInvoiceItem.FinanceInvoice = FinanceInvoice.Id) AS Text, `DocumentLineCode`.`Name` AS `BillName`, `Subject`.`Name` AS `Name` '. 205 237 'FROM FinanceInvoice JOIN Subject ON Subject.Id = FinanceInvoice.Subject '. 206 'WHERE (ValueSign = 1) AND (FinanceInvoice.Time >= "'.$Year['DateStart']. 238 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `FinanceInvoice`.`Group` '. 239 'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id` = `FinanceInvoice`.`BillCode` '. 240 'WHERE (`FinanceInvoiceGroup`.`ValueSign` = 1) AND (FinanceInvoice.Time >= "'.$Year['DateStart']. 207 241 '") AND (FinanceInvoice.Time <= "'.$Year['DateEnd'].'") ORDER BY Time'); 208 242 while($Row = $DbResult->fetch_array()) 209 243 { 210 244 if($Row['TimePayment'] == '0000-00-00 00:00:00') $Row['TimePayment'] = ' '; 211 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['Bill Code'].212 '</td><td>'.$Row['Name'].'</td><td>'.$Row['Text'].'</td><td>'. ($Row['Value'] * $Row['ValueSign']).'</td></tr>';245 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['BillName']. 246 '</td><td>'.$Row['Name'].'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value'].'</td></tr>'; 213 247 $Total += $Row['Value']; 214 248 } … … 225 259 $Output .= '<table style="font-size: smaller;" class="WideTable">'; 226 260 $Output .= '<tr><th>Čas vystavení</th><th>Kód</th><th>Subjekt</th><th>Text</th><th>Hodnota [Kč]</th></tr>'; 227 $DbResult = $this->Database->query('SELECT *, (SELECT GROUP_CONCAT(Description SEPARATOR ",") FROM FinanceInvoiceItem WHERE FinanceInvoiceItem.FinanceInvoice = FinanceInvoice.Id) AS Text '. 261 $DbResult = $this->Database->query('SELECT *, (SELECT GROUP_CONCAT(Description SEPARATOR ",") '. 262 'FROM FinanceInvoiceItem WHERE FinanceInvoiceItem.FinanceInvoice = FinanceInvoice.Id) AS `Text`, `DocumentLineCode`.`Name` AS `BillName` '. 228 263 'FROM FinanceInvoice JOIN Subject ON Subject.Id = FinanceInvoice.Subject '. 229 'WHERE (ValueSign = -1) AND (FinanceInvoice.Time >= "'.$Year['DateStart']. 264 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `FinanceInvoice`.`Group` '. 265 'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id` = `FinanceInvoice`.`BillCode` '. 266 'WHERE (`FinanceInvoiceGroup`.`ValueSign` = -1) AND (`FinanceInvoice`.`Time` >= "'.$Year['DateStart']. 230 267 '") AND (FinanceInvoice.Time <= "'.$Year['DateEnd'].'") ORDER BY Time'); 231 268 while($Row = $DbResult->fetch_array()) … … 233 270 if($Row['TimePayment'] == '0000-00-00 00:00:00') $Row['TimePayment'] = ' '; 234 271 $Row['Value'] = $Row['Value'] * -1; 235 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['Bill Code'].272 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['BillName']. 236 273 '</td><td>'.$Row['Name'].'</td><td>'.$Row['Text'].'</td><td>'.($Row['Value'] * $Row['ValueSign']).'</td></tr>'; 237 274 $Total += $Row['Value']; … … 245 282 $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>'; 246 283 $DbResult = $this->Database->query('SELECT Id, Name, 0 AS Cash, '. 247 '(SELECT SUM(T1.Value*T1.ValueSign) FROM FinanceInvoice AS T1 WHERE (T1.Subject = Subject.Id) AND (T1.ValueSign = 1)) as Claims, '. 248 '(SELECT SUM(T2.Value*T2.ValueSign) FROM FinanceInvoice AS T2 WHERE (T2.Subject = Subject.Id) AND (T2.ValueSign = 1) AND (TimePayment IS NULL)) as OpenedClaims, '. 249 '(SELECT -SUM(T3.Value*T3.ValueSign) FROM FinanceInvoice AS T3 WHERE (T3.Subject = Subject.Id) AND (T3.ValueSign = -1)) as Liabilities, '. 250 '(SELECT -SUM(T4.Value*T4.ValueSign) FROM FinanceInvoice AS T4 WHERE (T4.Subject = Subject.Id) AND (T4.ValueSign = -1) AND (TimePayment IS NULL)) AS OpenedLiabilities, '. 251 '(SELECT SUM(T5.Value*T5.ValueSign) FROM FinanceOperation AS T5 WHERE (T5.Subject = Subject.Id) AND (T5.ValueSign = 1)) AS Gains, '. 252 '(SELECT SUM(T6.Value*T6.ValueSign) FROM FinanceOperation AS T6 WHERE (T6.Subject = Subject.Id) AND (T6.ValueSign = -1)) AS Spends '. 284 '(SELECT SUM(T1.Value) FROM FinanceInvoice AS T1 '. 285 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `T1`.`Group` '. 286 'WHERE (T1.Subject = Subject.Id) AND (`FinanceInvoiceGroup`.ValueSign = 1)) AS `Claims`, '. 287 '(SELECT SUM(T2.Value) FROM FinanceInvoice AS T2 '. 288 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `T2`.`Group` '. 289 'WHERE (T2.Subject = Subject.Id) AND (`FinanceInvoiceGroup`.`ValueSign` = 1) AND (TimePayment IS NULL)) AS `OpenedClaims`, '. 290 '(SELECT -SUM(T3.Value) FROM FinanceInvoice AS T3 '. 291 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `T3`.`Group` '. 292 'WHERE (T3.Subject = Subject.Id) AND (`FinanceInvoiceGroup`.`ValueSign` = -1)) AS `Liabilities`, '. 293 '(SELECT -SUM(T4.Value) FROM FinanceInvoice AS T4 '. 294 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `T4`.`Group` '. 295 'WHERE (T4.Subject = Subject.Id) AND (`FinanceInvoiceGroup`.`ValueSign` = -1) AND (`TimePayment` IS NULL)) AS `OpenedLiabilities`, '. 296 '(SELECT SUM(T5.Value) FROM FinanceOperation AS T5 '. 297 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `T5`.`Group` '. 298 'WHERE (T5.Subject = Subject.Id) AND (`FinanceOperationGroup`.`ValueSign` = 1)) AS `Gains`, '. 299 '(SELECT SUM(T6.Value) FROM FinanceOperation AS T6 '. 300 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `T6`.`Group` '. 301 'WHERE (T6.Subject = Subject.Id) AND (`FinanceOperationGroup`.`ValueSign` = -1)) AS `Spends` '. 253 302 'FROM Subject ORDER BY Name'); 254 303 while($Row = $DbResult->fetch_assoc()) … … 276 325 $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'; 277 326 $Output .= '<tr><th>Datum</th><th>Název</th><th>Hodnota [Kč]</th><th>Doklad</th></tr>'; 278 $DbResult = $this->Database->select('FinanceOperation', '*', 'Subject='.$_GET['Id'].' ORDER BY Time'); 327 $DbResult = $this->Database->query('SELECT `FinanceOperation`.*, `DocumentLineCode`.`Name` AS `BillName` FROM `FinanceOperation` '. 328 'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id` = `FinanceOperation`.`BillCode` '. 329 'WHERE `Subject=`'.$_GET['Id'].' ORDER BY `Time`'); 279 330 while($Row = $DbResult->fetch_array()) 280 331 { 281 332 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['Text']. 282 '</td><td>'.($Row['Value']*$Row['ValueSign']).'</td><td>'.$Row['Bill Code'].'</td></tr>';333 '</td><td>'.($Row['Value']*$Row['ValueSign']).'</td><td>'.$Row['BillName'].'</td></tr>'; 283 334 } 284 335 $Output .= '</table></td><td style="vertical-align: top;">'; … … 287 338 $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'; 288 339 $Output .= '<tr><th>Datum vytvoření</th><th>Datum zaplacení</th><th>Název</th><th>Hodnota [Kč]</th><th>Doklad</th></tr>'; 289 $DbResult = $this->Database->select('FinanceInvoice', '*, (SELECT GROUP_CONCAT(Description SEPARATOR ",") '. 290 'FROM FinanceInvoiceItem WHERE FinanceInvoiceItem.FinanceInvoice = FinanceInvoice.Id) AS Text', 291 'Subject='.$_GET['Id'].' ORDER BY Time'); 340 $DbResult = $this->Database->query('SELECT `FinanceInvoice`.*, (SELECT GROUP_CONCAT(Description SEPARATOR ",") '. 341 'FROM FinanceInvoiceItem WHERE `FinanceInvoiceItem`.`FinanceInvoice` = `FinanceInvoice`.`Id`) AS `Text`, `DocumentLineCode`.`Name` AS `BillName` '. 342 'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id` = `FinanceOperation`.`BillCode` '. 343 'WHERE `Subject`='.$_GET['Id'].' ORDER BY `Time`'); 292 344 while($Row = $DbResult->fetch_array()) 293 345 { 294 346 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.HumanDate($Row['TimePayment']). 295 '</td><td>'.$Row['Text'].'</td><td>'. ceil($Row['Value'] * $Row['ValueSign']).'</td><td>'.$Row['BillCode'].'</td></tr>';347 '</td><td>'.$Row['Text'].'</td><td>'.round($Row['Value'] * $Row['ValueSign'], $Finance->Rounding).'</td><td>'.$Row['BillName'].'</td></tr>'; 296 348 } 297 349 $Output .= '</table></td></tr></table>';
Note:
See TracChangeset
for help on using the changeset viewer.