Changeset 486
- Timestamp:
- Feb 10, 2013, 9:20:06 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/Database.php
r456 r486 150 150 } 151 151 152 function TimeToMysqlDateTime($Time) 153 { 154 if($Time == NULL) return(NULL); 155 else return(date('Y-m-d H:i:s', $Time)); 156 } 157 158 function TimeToMysqlDate($Time) 159 { 160 if($Time == NULL) return(NULL); 161 else return(date('Y-m-d', $Time)); 162 } 163 164 function TimeToMysqlTime($Time) 165 { 166 if($Time == NULL) return(NULL); 167 else return(date('H:i:s', $Time)); 168 } 169 170 function MysqlDateTimeToTime($DateTime) 171 { 172 if($DateTime == '') return(0); 173 $Parts = explode(' ', $DateTime); 174 $DateParts = explode('-', $Parts[0]); 175 $TimeParts = explode(':', $Parts[1]); 176 $Result = mktime($TimeParts[0], $TimeParts[1], $TimeParts[2], $DateParts[1], $DateParts[2], $DateParts[0]); 177 return($Result); 178 } 179 180 function MysqlDateToTime($Date) 181 { 182 if($Date == '') return(0); 183 return(MysqlDateTimeToTime($Date.' 0:0:0')); 184 } 185 186 function MysqlTimeToTime($Time) 187 { 188 if($Time == '') return(0); 189 return(MysqlDateTimeToTime('0000-00-00 '.$Time)); 190 } 191 152 192 ?> -
trunk/Common/Global.php
r485 r486 338 338 } 339 339 340 function TimeToMysqlDateTime($Time)341 {342 if($Time == NULL) return(NULL);343 else return(date('Y-m-d H:i:s', $Time));344 }345 346 function TimeToMysqlDate($Time)347 {348 if($Time == NULL) return(NULL);349 else return(date('Y-m-d', $Time));350 }351 352 function MysqlDateTimeToTime($DateTime)353 {354 if($DateTime == '') return(0);355 $Parts = explode(' ', $DateTime);356 $DateParts = explode('-', $Parts[0]);357 $TimeParts = explode(':', $Parts[1]);358 $Result = mktime($TimeParts[0], $TimeParts[1], $TimeParts[2], $DateParts[1], $DateParts[2], $DateParts[0]);359 return($Result);360 }361 362 function MysqlDateToTime($Date)363 {364 if($Date == '') return(0);365 return(MysqlDateTimeToTime($Date.' 0:0:0'));366 }367 368 function MysqlTimeToTime($Time)369 {370 if($Time == '') return(0);371 return(MysqlDateTimeToTime('0000-00-00 '.$Time));372 }373 374 340 function HumanDate($Time) 375 341 { … … 416 382 return($Result); 417 383 } 384 385 function ExtractTime($Time) 386 { 387 return(array( 388 'Year' => date('Y', $Time), 389 'Month' => date('n', $Time), 390 'Day' => date('j', $Time), 391 'Hour' => date('h', $Time), 392 'Minute' => date('i', $Time), 393 'Second' => date('s', $Time) 394 )); 395 } 418 396 419 397 function GetQueryStringArray($QueryString) -
trunk/Modules/Portal/Portal.php
r484 r486 151 151 if($_GET['Action'] == 'Login') 152 152 { 153 if(array_key_exists('Username', $_POST) and array_key_exists('Password', $_POST)) 154 { 153 155 $Form = new Form('UserLogin'); 154 156 $Form->OnSubmit = '?Action=Login'; … … 163 165 '<a href="?Action=PasswordRecovery">Obnova zapomenutého hesla</a></div>'; 164 166 } 167 } else $Output .= $this->SystemMessage('Přihlášení', 'Nezadány přihlašovací údaje'); 165 168 } else 166 169 if($_GET['Action'] == 'Logout') -
trunk/finance/bills.php
r477 r486 212 212 } 213 213 214 function CustomGenerate()215 {216 global $Database;217 218 $DbResult = $this->Database->select('finance_operations', '*', '(date="2008-02-01" AND comment="Poplatek za měsíc Únor") OR '.219 '(date="2008-01-01" AND comment="Poplatek za měsíc Leden") OR (date="2007-12-01" AND comment="Poplatek za měsíc Prosinec") AND (bill_id = 0)');220 while($Row = $DbResult->fetch_array())221 {222 echo($Row['id']."<br>\n");223 $Time = MysqlDateToTime($Row['date']);224 $BillId = $this->CreateBill($Row['user'], array(array('Description' => 'Poplatek za připojení k síti', 'Price' => (-$Row['money']), 'Quantity' => 1)), $Time, $Time + (date("t", time()) - 1) * 24 * 3600);225 $this->Database->update('finance_operations', 'id='.$Row['id'], array('bill_id' => $BillId));226 }227 }228 229 214 function ShowPage() 230 215 { -
trunk/finance/finance.php
r481 r486 177 177 while($Member = $DbResult->fetch_assoc()) 178 178 { 179 $DbResult2 = $this->Database->query('SELECT ((SELECT COALESCE(SUM(Value), 0) FROM FinanceOperation WHERE Subject='.$Member['Subject'].') + (SELECT COALESCE(SUM(-Value), 0) FROM FinanceClaimsLiabilities WHERE Subject='.$Member['Subject'].')) as Cash'); 179 $DbResult2 = $this->Database->query('SELECT ((SELECT COALESCE(SUM(Value), 0) FROM FinanceOperation '. 180 'WHERE Subject='.$Member['Subject'].') + (SELECT COALESCE(SUM(-Value), 0) FROM FinanceInvoice '. 181 'WHERE Subject='.$Member['Subject'].')) as Cash'); 180 182 $Cash = $DbResult2->fetch_row(); 181 183 $Cash = $Cash[0]; -
trunk/finance/manage.php
r482 r486 133 133 $DbRow = $DbResult->fetch_array(); 134 134 $Advances = $DbRow[0]; 135 $DbResult = $this->Database->select('FinanceClaimsLiabilities', '*', 'Subject='.$Subject.' AND TimePayment IS NULL AND Value > 0 ORDER BY TimeCreation LIMIT 1'); 135 $DbResult = $this->Database->select('FinanceInvoice', '*', 'Subject='.$Subject. 136 ' AND TimePayment IS NULL AND Value > 0 ORDER BY TimeCreation LIMIT 1'); 136 137 //echo($Database->error); 137 138 if($DbResult->num_rows > 0) … … 140 141 if($Advances > $OpenedClaim['Value']) 141 142 { 142 $this->Database->update('FinanceClaimsLiabilities', 'Id='.$OpenedClaim['Id'], array('TimePayment' => TimeToMysqlDateTime($LastInsertTime))); 143 $this->Database->insert('FinanceAdvances', array('Subject' => $OpenedClaim['Subject'], 'Value' => -$OpenedClaim['Value'], 'TimeCreation' => TimeToMysqlDateTime($LastInsertTime), 'CashFlowId' => $OpenedClaim['Id'], 'Direction' => 'In')); 143 $this->Database->update('FinanceInvoice', 'Id='.$OpenedClaim['Id'], 144 array('TimePayment' => TimeToMysqlDateTime($LastInsertTime))); 145 $this->Database->insert('FinanceAdvances', array('Subject' => 146 $OpenedClaim['Subject'], 'Value' => -$OpenedClaim['Value'], 147 'TimeCreation' => TimeToMysqlDateTime($LastInsertTime), 148 'CashFlowId' => $OpenedClaim['Id'], 'Direction' => 'In')); 144 149 //echo($Database->LastQuery); 145 150 } else break; … … 154 159 155 160 $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumber($DocumentLine); 156 $this->Database->insert('Finance ClaimsLiabilities', array('Text' => $Text,161 $this->Database->insert('FinanceInvoice', array( 157 162 'Subject' => $Subject, 'TimeCreation' => TimeToMysqlDateTime($TimeCreation), 158 163 'TimeDue' => TimeToMysqlDateTime($TimeDue), 'Value' => $Value, 'BillCode' => $BillCode, 159 164 'PeriodFrom' => TimeToMysqlDate($PeriodFrom), 'PeriodTo' => TimeToMysqlDate($PeriodTo))); 165 $InvoiceId = $this->Database->insert_id; 166 $this->Database->insert('FinanceInvoice', array('FinanceInvoice' => $InvoiceId, 167 'Description' => $Text, 'Price' => $Value, 'Quantity' => 1, 'VAT' => 0)); 160 168 $Output = '.'; //$this->Database->LastQuery.'<br />'; 161 169 //$LastInsertTime = $Time; … … 253 261 $Form->Values['DocumentLine'], NULL, NULL); 254 262 $LastId = $this->Database->insert_id; 255 $DbResult = $this->Database->select('Finance ClaimsLiabilities', 'BillCode', 'Id='.$LastId);263 $DbResult = $this->Database->select('FinanceInvoice', 'BillCode', 'Id='.$LastId); 256 264 $DbRow = $DbResult->fetch_assoc(); 257 265 $Output = $this->SystemMessage('Finance', 'Faktura vložena '.$DbRow['BillCode'].'.'); … … 360 368 $Output .= $Finance->RecalculateSegmentParameters(); 361 369 $Output .= $Finance->LoadTariffs(); 362 //$InvoiceGenerator->CustomGenerate();363 370 $Output .= $Finance->RecalculateMemberPayment(); 364 371 … … 446 453 $BillId = $this->System->Modules['Bill']->CreateBill($Member['Subject'], 447 454 $BillItems, time(), time() + 3600 * 24 * INVOICE_DUE_DAYS, $BillCode, $Period['From'], $Period['To']); 448 $this->Database->insert('Finance ClaimsLiabilities', array('Value' => $PayPerPeriod,455 $this->Database->insert('FinanceInvoice', array( 449 456 'Subject' => $Member['Subject'], 'TimeCreation' => 'NOW()', 450 'TimeDue' => 'DATE_ADD(NOW(), INTERVAL '.INVOICE_DUE_DAYS.' DAY)', 451 'Text' => 'Vyúčtování služeb za období '.$TimePeriodText, 457 'TimeDue' => 'DATE_ADD(NOW(), INTERVAL '.INVOICE_DUE_DAYS.' DAY)', 452 458 'Bill' => $BillId, 'BillCode' => $BillCode)); 459 $InvoiceId = $this->Database->insert_id; 460 $this->Database->insert('FinanceInvoiceItem', array('FinanceInvoice' => $InvoiceId, 461 'Value' => $PayPerPeriod, 'Text' => 'Vyúčtování služeb za období '.$TimePeriodText, 462 'Quantity' => 1, 'VAT' => 0)); 463 453 464 $Output .= $this->SendPaymentEmail($Member['Id']); 454 465 $this->Database->update('Member', 'Id='.$Member['Id'], array('BillingPeriodLastDate' => TimeToMysqlDateTime($Period['To']))); … … 531 542 //$Member['BillingPeriodLastDate'] = '2009-04-01'; 532 543 $DbResult = $this->Database->query('SELECT T1.* FROM ((SELECT Text, Time, Value AS Value, Bill FROM FinanceOperation WHERE (Subject='.$Member['Subject'].')) UNION ALL '. 533 '(SELECT Text, TimeCreation as Time, -Value as Value, Bill FROM Finance ClaimsLiabilitiesWHERE (Subject='.$Member['Subject'].')) ORDER BY Time DESC) AS T1 WHERE (T1.Time > "'.$Member['BillingPeriodLastDate'].'")');544 '(SELECT Text, TimeCreation as Time, -Value as Value, Bill FROM FinanceInvoice WHERE (Subject='.$Member['Subject'].')) ORDER BY Time DESC) AS T1 WHERE (T1.Time > "'.$Member['BillingPeriodLastDate'].'")'); 534 545 while($DbRow = $DbResult->fetch_assoc()) 535 546 { … … 550 561 function GenerateBills() 551 562 { 552 // Finance ClaimsLiablities553 $DbResult = $this->Database->query('SELECT * FROM Finance ClaimsLiabilitiesWHERE (BillCode <> "") AND (Value != 0) AND (Bill = 0)');563 // FinanceInvoice 564 $DbResult = $this->Database->query('SELECT * FROM FinanceInvoice WHERE (BillCode <> "") AND (Value != 0) AND (Bill = 0)'); 554 565 while($Row = $DbResult->fetch_assoc()) 555 566 { … … 558 569 MysqlDateTimeToTime($Row['TimeCreation']), MysqlDateTimeToTime($Row['TimeDue']), 559 570 $Row['BillCode'], 'invoice', MysqlDateToTime($Row['PeriodFrom']), MysqlDateToTime($Row['PeriodTo'])); 560 $this->Database->update('Finance ClaimsLiabilities', 'Id='.$Row['Id'], array('Bill' => $BillId));571 $this->Database->update('FinanceInvoice', 'Id='.$Row['Id'], array('Bill' => $BillId)); 561 572 echo('.'); 562 573 } -
trunk/finance/user_state.php
r479 r486 52 52 else $SubjectParam = ''; 53 53 $Output .= 'Roky: '; 54 $DbResult = $this->Database->query('SELECT * FROM FinanceYear'); 54 $DbResult = $this->Database->query('SELECT * FROM FinanceYear WHERE Year >= '. 55 substr($Member['MembershipDate'], 0, strpos($Member['MembershipDate'], '-'))); 55 56 while($FinanceYear = $DbResult->fetch_assoc()) 56 57 { … … 62 63 63 64 // Account state 64 $UserOperationTableQuery = '((SELECT Text, Time, Value AS Value, Bill, BillCode FROM FinanceOperation WHERE (Subject='.$Subject['Id'].')) UNION ALL '. 65 '(SELECT Text, TimeCreation as Time, -Value as Value, Bill, BillCode FROM FinanceClaimsLiabilities WHERE (Subject='.$Subject['Id'].')) ORDER BY Time DESC) AS T1'; 65 $UserOperationTableQuery = '((SELECT Text, Time, Value AS Value, Bill, BillCode, NULL AS PeriodFrom, NULL AS PeriodTo '. 66 'FROM FinanceOperation WHERE (Subject='.$Subject['Id'].')) UNION ALL '. 67 '(SELECT (SELECT GROUP_CONCAT(Description SEPARATOR ",") FROM FinanceInvoiceItem WHERE FinanceInvoice=FinanceInvoice.Id) AS Text, '. 68 'TimeCreation as Time, -Value as Value, Bill, BillCode, PeriodFrom, PeriodTo FROM FinanceInvoice WHERE (Subject='.$Subject['Id'].')) ORDER BY Time DESC) AS T1'; 66 69 $DbResult = $this->Database->query('SELECT SUM(T1.Value) AS Total FROM '.$UserOperationTableQuery); 67 70 $DbRow = $DbResult->fetch_array(); … … 72 75 // Tabulka operaci 73 76 $Output .= 'Výpis operací pro subjekt '.$Subject['Name'].':<br />'; 74 $Output .= '<table style="font-size: smaller;" class="WideTable"><tr><th>Datum</th><th>Popis</th><th>Částka</th><th>Doklad</th></tr>'; 77 $Output .= '<table style="font-size: smaller;" class="WideTable"><tr>'. 78 '<th>Datum</th><th>Popis</th><th>Částka</th><th>Období</th><th>Doklad</th></tr>'; 75 79 $Operations = array(); 76 80 $DbResult = $this->Database->query('SELECT T1.* FROM '.$UserOperationTableQuery.$YearWhere); … … 83 87 if($Row['Value'] > 0) $Row['Value'] = '+'.$Row['Value']; 84 88 if($Row['BillCode'] == '') $Row['BillCode'] = 'PDF'; 85 if($Row['Bill'] > 0) $Invoice = '<a href="bill.php?Id='.$Row['Bill'].'">'.$Row['BillCode'].'</a>'; else $Invoice = ' '; 86 $Output .= '<tr><td style="text-align: right;">'.HumanDate($Row['Time']).'</td><td style="text-align: left;">'.$Row['Text'].'</td><td style="text-align: right;">'.$Row['Value'].'</td><td style="text-align: center;">'.$Invoice.'</td></tr>'; 89 if($Row['Bill'] > 0) $Invoice = '<a href="bill.php?Id='.$Row['Bill'].'">'.$Row['BillCode'].'</a>'; 90 else $Invoice = ' '; 91 if($Row['PeriodFrom'] != '') $Period = HumanDate($Row['PeriodFrom']).' - '.HumanDate($Row['PeriodTo']); 92 else $Period = ' '; 93 $Output .= '<tr><td style="text-align: right;">'.HumanDate($Row['Time']).'</td>'. 94 '<td style="text-align: left;">'.$Row['Text'].'</td>'. 95 '<td style="text-align: right;">'.$Row['Value'].'</td>'. 96 '<td style="text-align: center;">'.$Period.'</td>'. 97 '<td style="text-align: center;">'.$Invoice.'</td></tr>'; 87 98 $SumValue = $SumValue + $Row['Value']; 88 99 } 89 $Output .= '<tr><td style="text-align: right;" colspan="2"><strong>Celkem za rok</strong></td><td style="text-align: right;"><strong>'.$SumValue.'</strong></td><td style="text-align: center;"> </td></tr>'; 100 $Output .= '<tr><td style="text-align: right;" colspan="2"><strong>Celkem za rok</strong></td>'. 101 '<td style="text-align: right;"><strong>'.$SumValue.'</strong></td>'. 102 '<td style="text-align: center;"> </td>'. 103 '<td style="text-align: center;"> </td></tr>'; 90 104 91 105 -
trunk/finance/zivnost.php
r479 r486 11 11 var $StartEvidence = 0; 12 12 13 /*function TransformFinance()14 {15 //$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"');16 //'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")'17 // 'UPDATE finance_operations SET date="2007-11-24" WHERE comment="Jednorázový poplatek za společné zařízení"'18 19 $DbResult = $this->Database->query('SELECT * FROM users WHERE role=2');20 while($User = $DbResult->fetch_array())21 {22 $DbResult2 = $this->Database->query('SELECT SUM(money) FROM finance_operations WHERE user='.$User['id'].' AND date < "2007-12-01"');23 $Row = $DbResult2->fetch_array();24 echo($User['second_name'].' '.$User['first_name'].' '.$Row[0].'<br />');25 // 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));26 if($Row[0] < 0)27 {28 $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));29 //echo($Database->LastQuery.'<br />');30 }31 }32 }*/33 13 function GetTimePeriodBalance($StartTime, $EndTime) 34 14 { … … 50 30 $Balance['Spend']['End'] = $Row[0] + 0; 51 31 52 $DbResult = $this->Database->query('SELECT SUM(Value) FROM Finance ClaimsLiabilitiesWHERE (TimeCreation < "'.TimeToMysqlDateTime($StartTime).'") AND (TimeCreation >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Value > 0)');32 $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceInvoice WHERE (TimeCreation < "'.TimeToMysqlDateTime($StartTime).'") AND (TimeCreation >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Value > 0)'); 53 33 $Row = $DbResult->fetch_array(); 54 34 $Balance['Claims']['Start'] = $Row[0] + 0; 55 $DbResult = $this->Database->query('SELECT SUM(Value) FROM Finance ClaimsLiabilitiesWHERE (TimeCreation <= "'.TimeToMysqlDateTime($EndTime).'") AND (TimeCreation >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Value > 0)');35 $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceInvoice WHERE (TimeCreation <= "'.TimeToMysqlDateTime($EndTime).'") AND (TimeCreation >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Value > 0)'); 56 36 $Row = $DbResult->fetch_array(); 57 37 $Balance['Claims']['End'] = $Row[0] + 0; 58 38 59 $DbResult = $this->Database->query('SELECT SUM(-Value) FROM Finance ClaimsLiabilitiesWHERE (TimeCreation < "'.TimeToMysqlDateTime($StartTime).'") AND (TimeCreation >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Value < 0)');39 $DbResult = $this->Database->query('SELECT SUM(-Value) FROM FinanceInvoice WHERE (TimeCreation < "'.TimeToMysqlDateTime($StartTime).'") AND (TimeCreation >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Value < 0)'); 60 40 $Row = $DbResult->fetch_array(); 61 41 $Balance['Liabilities']['Start'] = $Row[0] + 0; 62 $DbResult = $this->Database->query('SELECT SUM(-Value) FROM Finance ClaimsLiabilitiesWHERE (TimeCreation <= "'.TimeToMysqlDateTime($EndTime).'") AND (TimeCreation >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Value < 0)');42 $DbResult = $this->Database->query('SELECT SUM(-Value) FROM FinanceInvoice WHERE (TimeCreation <= "'.TimeToMysqlDateTime($EndTime).'") AND (TimeCreation >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Value < 0)'); 63 43 $Row = $DbResult->fetch_array(); 64 44 $Balance['Liabilities']['End'] = $Row[0] + 0; … … 227 207 $Output .= '<table style="font-size: smaller;" class="WideTable">'; 228 208 $Output .= '<tr><th>Čas vystavení</th><th>Kód</th><th>Subjekt</th><th>Text</th><th>Hodnota [Kč]</th></tr>'; 229 $DbResult = $this->Database->query('SELECT * FROM FinanceClaimsLiabilities JOIN Subject ON Subject.Id = FinanceClaimsLiabilities.Subject '. 230 'WHERE (Value > 0) AND (FinanceClaimsLiabilities.TimeCreation >= "'.$Year['DateStart'].'") AND (FinanceClaimsLiabilities.TimeCreation <= "'.$Year['DateEnd'].'") ORDER BY TimeCreation'); 209 $DbResult = $this->Database->query('SELECT *, (SELECT GROUP_CONCAT(Description SEPARATOR ",") FROM FinanceInvoiceItem WHERE FinanceInvoiceItem.FinanceInvoice = FinanceInvoice.Id) AS Text '. 210 'FROM FinanceInvoice JOIN Subject ON Subject.Id = FinanceInvoice.Subject '. 211 'WHERE (Value > 0) AND (FinanceInvoice.TimeCreation >= "'.$Year['DateStart']. 212 '") AND (FinanceInvoice.TimeCreation <= "'.$Year['DateEnd'].'") ORDER BY TimeCreation'); 231 213 while($Row = $DbResult->fetch_array()) 232 214 { … … 247 229 $Output .= '<table style="font-size: smaller;" class="WideTable">'; 248 230 $Output .= '<tr><th>Čas vystavení</th><th>Kód</th><th>Subjekt</th><th>Text</th><th>Hodnota [Kč]</th></tr>'; 249 $DbResult = $this->Database->query('SELECT * FROM FinanceClaimsLiabilities JOIN Subject ON Subject.Id = FinanceClaimsLiabilities.Subject '. 250 'WHERE (Value < 0) AND (FinanceClaimsLiabilities.TimeCreation >= "'.$Year['DateStart'].'") AND (FinanceClaimsLiabilities.TimeCreation <= "'.$Year['DateEnd'].'") ORDER BY TimeCreation'); 231 $DbResult = $this->Database->query('SELECT *, (SELECT GROUP_CONCAT(Description SEPARATOR ",") FROM FinanceInvoiceItem WHERE FinanceInvoiceItem.FinanceInvoice = FinanceInvoice.Id) AS Text '. 232 'FROM FinanceInvoice JOIN Subject ON Subject.Id = FinanceInvoice.Subject '. 233 'WHERE (Value < 0) AND (FinanceInvoice.TimeCreation >= "'.$Year['DateStart']. 234 '") AND (FinanceInvoice.TimeCreation <= "'.$Year['DateEnd'].'") ORDER BY TimeCreation'); 251 235 while($Row = $DbResult->fetch_array()) 252 236 { … … 264 248 $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>'; 265 249 $DbResult = $this->Database->query('SELECT Id, Name, 0 AS Cash, '. 266 '(SELECT SUM(T1.Value) FROM Finance ClaimsLiabilitiesAS T1 WHERE (T1.Subject = Subject.Id) AND (T1.Value > 0)) as Claims, '.267 '(SELECT SUM(T2.Value) FROM Finance ClaimsLiabilitiesAS T2 WHERE (T2.Subject = Subject.Id) AND (T2.Value > 0) AND (TimePayment IS NULL)) as OpenedClaims, '.268 '(SELECT -SUM(T3.Value) FROM Finance ClaimsLiabilitiesAS T3 WHERE (T3.Subject = Subject.Id) AND (T3.Value < 0)) as Liabilities, '.269 '(SELECT -SUM(T4.Value) FROM Finance ClaimsLiabilitiesAS T4 WHERE (T4.Subject = Subject.Id) AND (T4.Value < 0) AND (TimePayment IS NULL)) AS OpenedLiabilities, '.250 '(SELECT SUM(T1.Value) FROM FinanceInvoice AS T1 WHERE (T1.Subject = Subject.Id) AND (T1.Value > 0)) as Claims, '. 251 '(SELECT SUM(T2.Value) FROM FinanceInvoice AS T2 WHERE (T2.Subject = Subject.Id) AND (T2.Value > 0) AND (TimePayment IS NULL)) as OpenedClaims, '. 252 '(SELECT -SUM(T3.Value) FROM FinanceInvoice AS T3 WHERE (T3.Subject = Subject.Id) AND (T3.Value < 0)) as Liabilities, '. 253 '(SELECT -SUM(T4.Value) FROM FinanceInvoice AS T4 WHERE (T4.Subject = Subject.Id) AND (T4.Value < 0) AND (TimePayment IS NULL)) AS OpenedLiabilities, '. 270 254 '(SELECT SUM(T5.Value) FROM FinanceOperation AS T5 WHERE (T5.Subject = Subject.Id) AND (T5.Value > 0)) AS Gains, '. 271 255 '(SELECT -SUM(T6.Value) FROM FinanceOperation AS T6 WHERE (T6.Subject = Subject.Id) AND (T6.Value < 0)) AS Spends '. … … 306 290 $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'; 307 291 $Output .= '<tr><th>Datum vytvoření</th><th>Datum zaplacení</th><th>Název</th><th>Hodnota [Kč]</th><th>Doklad</th></tr>'; 308 $DbResult = $this->Database->select('Finance ClaimsLiabilities', '*', 'Subject='.$_GET['Id'].' ORDER BY TimeCreation');292 $DbResult = $this->Database->select('FinanceInvoice', '*, (SELECT GROUP_CONCAT(Description SEPARATOR ",") FROM FinanceInvoiceItem WHERE FinanceInvoiceItem.FinanceInvoice = FinanceInvoice.Id) AS Text', 'Subject='.$_GET['Id'].' ORDER BY TimeCreation'); 309 293 while($Row = $DbResult->fetch_array()) 310 294 { … … 324 308 $Output .= '</table>';*/ 325 309 326 $DbResult = $this->Database->query('SELECT Id, 0 AS Cash, (SELECT SUM(Finance ClaimsLiabilities.Value) '.327 'FROM Finance ClaimsLiabilities WHERE FinanceClaimsLiabilities.Subject = Subject.Id AND '.328 'Finance ClaimsLiabilities.Value > 0) as Claims, (SELECT SUM(FinanceClaimsLiabilities.Value) '.329 'FROM Finance ClaimsLiabilities WHERE FinanceClaimsLiabilities.Subject = Subject.Id AND '.330 'Finance ClaimsLiabilities.Value > 0 AND TimePayment IS NULL) as OpenedClaims, '.331 '(SELECT SUM(Finance ClaimsLiabilities.Value) FROM FinanceClaimsLiabilities'.332 'WHERE Finance ClaimsLiabilities.Subject = Subject.Id AND FinanceClaimsLiabilities.Value < 0) AS '.333 'Liabilities, (SELECT SUM(Finance ClaimsLiabilities.Value) FROM FinanceClaimsLiabilities'.334 'WHERE Finance ClaimsLiabilities.Subject = Subject.Id AND FinanceClaimsLiabilities.Value < 0 '.310 $DbResult = $this->Database->query('SELECT Id, 0 AS Cash, (SELECT SUM(FinanceInvoice.Value) '. 311 'FROM FinanceInvoice WHERE FinanceInvoice.Subject = Subject.Id AND '. 312 'FinanceInvoice.Value > 0) as Claims, (SELECT SUM(FinanceInvoice.Value) '. 313 'FROM FinanceInvoice WHERE FinanceInvoice.Subject = Subject.Id AND '. 314 'FinanceInvoice.Value > 0 AND TimePayment IS NULL) as OpenedClaims, '. 315 '(SELECT SUM(FinanceInvoice.Value) FROM FinanceInvoice '. 316 'WHERE FinanceInvoice.Subject = Subject.Id AND FinanceInvoice.Value < 0) AS '. 317 'Liabilities, (SELECT SUM(FinanceInvoice.Value) FROM FinanceInvoice '. 318 'WHERE FinanceInvoice.Subject = Subject.Id AND FinanceInvoice.Value < 0 '. 335 319 'AND TimePayment IS NULL) as OpenedLiabilities, (SELECT SUM(FinanceOperation.Value) '. 336 320 'FROM FinanceOperation WHERE FinanceOperation.Subject = Subject.Id AND FinanceOperation.Value > 0) '. -
trunk/form_classes.php
r484 r486 16 16 17 17 $FormClasses = array( 18 'File' => array( 19 'Title' => 'Soubor', 20 'Table' => 'File', 21 'Items' => array( 22 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''), 23 'Directory' => array('Type' => 'TDirectory', 'Caption' => 'Adresář', 'Default' => '', 'Null' => true), 24 'Size' => array('Type' => 'Integer', 'Caption' => 'Velikost', 'Default' => ''), 25 ), 26 ), 27 'FileDirectory' => array( 28 'Title' => 'Adresář souborů', 29 'Table' => 'FileDirectory', 30 'Items' => array( 31 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''), 32 'Parent' => array('Type' => 'TDirectory', 'Caption' => 'Nadřazený adresář', 'Default' => '', 'Null' => true), 33 ), 34 ), 18 35 'NetworkLink' => array( 19 36 'Title' => 'Síťové propojení', … … 331 348 'DefaultSortColumn' => 'Comment', 332 349 'Items' => array( 350 'Subject' => array('Type' => 'TSubject', 'Caption' => 'Vlastník', 'Default' => ''), 333 351 'Comment' => array('Type' => 'String', 'Caption' => 'Komentář', 'Default' => ''), 334 352 'Number' => array('Type' => 'String', 'Caption' => 'Číslo', 'Default' => ''), 335 353 'TimeCreate' => array('Type' => 'Date', 'Caption' => 'Čas vytvoření', 'Default' => ''), 354 'TimeEnd' => array('Type' => 'Date', 'Caption' => 'Čas zrušení', 'Default' => ''), 355 'Operations' => array('Type' => 'TFinanceOperationListAccount', 'Caption' => 'Operace', 'Default' => ''), 336 356 ), 337 357 ), … … 500 520 ), 501 521 ), 502 'FinanceInvoiceItem' => array(503 'Title' => 'Položka faktury',504 'Items' => array(505 'Value' => array('Type' => 'Float', 'Caption' => 'Částka [Kč]', 'Default' => '0', 'Suffix' => 'Kč'),506 'Text' => array('Type' => 'String', 'Caption' => 'Popis', 'Default' => 'Položka'),507 'Quantity' => array('Type' => 'Integer', 'Caption' => 'Množství', 'Default' => '1'),508 'Tax' => array('Type' => 'Integer', 'Caption' => 'Daň [%]', 'Default' => '19', 'Suffix' => '%'),509 ),510 ),511 522 'FinanceOperation' => array( 512 523 'Title' => 'Finanční operace', … … 526 537 ), 527 538 ), 528 'Finance ClaimsLiabilities' => array(539 'FinanceInvoice' => array( 529 540 'Title' => 'Závazky a pohledávky', 530 'Table' => 'Finance ClaimsLiabilities',541 'Table' => 'FinanceInvoice', 531 542 'DefaultSortColumn' => 'TimeCreation', 532 543 'Items' => array( 544 'BillCode' => array('Type' => 'String', 'Caption' => 'Označení', 'Default' => ''), 545 'Subject' => array('Type' => 'TSubject', 'Caption' => 'Subjekt', 'Default' => ''), 533 546 'TimeCreation' => array('Type' => 'Date', 'Caption' => 'Čas vytvoření', 'Default' => ''), 534 547 'TimeDue' => array('Type' => 'Date', 'Caption' => 'Čas splatnosti', 'Default' => ''), 535 548 'TimePayment' => array('Type' => 'Date', 'Caption' => 'Čas zaplacení', 'Default' => ''), 536 'Subject' => array('Type' => 'TSubject', 'Caption' => 'Subjekt', 'Default' => ''),537 'BillCode' => array('Type' => 'String', 'Caption' => 'Označení', 'Default' => ''),538 549 'Value' => array('Type' => 'Integer', 'Caption' => 'Částka', 'Default' => '0', 'Suffix' => 'Kč'), 539 'Text' => array('Type' => 'String', 'Caption' => 'Popis', 'Default' => ''), 540 'Bill' => array('Type' => 'TFinanceBill', 'Caption' => 'Doklad', 'Default' => '', 'Null' => true), 550 'File' => array('Type' => 'TFile', 'Caption' => 'Doklad', 'Default' => '', 'Null' => true), 551 'Items' => array('Type' => 'TFinanceInvoiceItemListInvoice', 'Caption' => 'Položky', 'Default' => ''), 552 ), 553 ), 554 'FinanceInvoiceItem' => array( 555 'Title' => 'Položka faktury', 556 'Table' => 'FinanceInvoiceItem', 557 'Items' => array( 558 'FinanceInvoice' => array('Type' => 'TFinanceInvoice', 'Caption' => 'Faktura', 'Default' => '0'), 559 'Description' => array('Type' => 'String', 'Caption' => 'Popis', 'Default' => 'Položka'), 560 'Price' => array('Type' => 'Float', 'Caption' => 'Částka [Kč]', 'Default' => '0', 'Suffix' => 'Kč'), 561 'Quantity' => array('Type' => 'Integer', 'Caption' => 'Množství', 'Default' => '1'), 562 'VAT' => array('Type' => 'Integer', 'Caption' => 'Daň [%]', 'Default' => '19', 'Suffix' => '%'), 541 563 ), 542 564 ), … … 835 857 'Filter' => '1', 836 858 ), 837 'TFi nanceBill' => array(838 'Type' => 'Reference', 839 'Table' => 'Fi nanceBills',859 'TFile' => array( 860 'Type' => 'Reference', 861 'Table' => 'File', 840 862 'Id' => 'Id', 841 863 'Name' => 'Id', … … 894 916 'Type' => 'Reference', 895 917 'Table' => 'Language', 918 'Id' => 'Id', 919 'Name' => 'Name', 920 'Filter' => '1', 921 ), 922 'TDirectory' => array( 923 'Type' => 'Reference', 924 'Table' => 'FileDirectory', 896 925 'Id' => 'Id', 897 926 'Name' => 'Name', … … 940 969 'Filter' => '1', 941 970 ), 971 'TFinanceInvoice' => array( 972 'Type' => 'Reference', 973 'Table' => 'FinanceInvoice', 974 'Id' => 'Id', 975 'Name' => 'BillCode', 976 'Filter' => '1', 977 ), 942 978 'TPermissionGroup' => array( 943 979 'Type' => 'Reference', … … 1050 1086 'Id' => 'Id', 1051 1087 'Ref' => 'Interface2', 1088 'Filter' => '1', 1089 ), 1090 'TFinanceInvoiceItemListInvoice' => array( 1091 'Type' => 'ManyToOne', 1092 'Table' => 'FinanceInvoiceItem', 1093 'Id' => 'Id', 1094 'Ref' => 'FinanceInvoice', 1095 'Filter' => '1', 1096 ), 1097 'TFinanceOperationListAccount' => array( 1098 'Type' => 'ManyToOne', 1099 'Table' => 'FinanceOperation', 1100 'Id' => 'Id', 1101 'Ref' => 'BankAccount', 1052 1102 'Filter' => '1', 1053 1103 ), -
trunk/sql/updates/479.sql
r482 r486 41 41 ADD CONSTRAINT `Service_ibfk_1` FOREIGN KEY (`Category`) REFERENCES `ServiceCategory` (`Id`); 42 42 43 ALTER TABLE `ServiceCustomerRel` ADD FOREIGN KEY ( `Service` ) REFERENCES `Service` ( 44 `Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ; 45 43 46 -- Transform data from FinanceTariff 44 47 INSERT INTO Service (SELECT Id AS Id, Name, `Group` AS Category, Price, MemberCount AS CustomerCount, … … 60 63 ALTER TABLE `Service` ADD INDEX ( `ReplaceId` ) ; 61 64 ALTER TABLE `Service` ADD FOREIGN KEY ( `ReplaceId` ) REFERENCES `Service` (`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ; 65
Note:
See TracChangeset
for help on using the changeset viewer.