Changeset 551
- Timestamp:
- Jul 7, 2013, 9:26:44 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/Form/Form.php
r548 r551 172 172 if(!array_key_exists('ReadOnly', $Item)) $Item['ReadOnly'] = false; 173 173 if($Item['ReadOnly'] == false) 174 if(!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or175 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and176 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne')))177 {178 if(!array_key_exists($Index, $this->Values) and isset($Item['Default'])) $this->Values[$Index] = $Item['Default'];179 $Parameters = array('Value' => $this->Values[$Index], 'Name' => $Index,174 if(!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 175 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 176 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) 177 { 178 if(!array_key_exists($Index, $this->Values) and isset($Item['Default'])) $this->Values[$Index] = $Item['Default']; 179 $Parameters = array('Value' => $this->Values[$Index], 'Name' => $Index, 180 180 'Type' => $Item['Type'], 'Values' => $this->Values); 181 181 … … 194 194 $Values[$Index] = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnSaveDb', $Parameters); 195 195 if(($Item['Type'] == 'Password') and ($Values[$Index] == '')) unset($Values[$Index]); 196 }196 } 197 197 } 198 198 if($Id == 0) -
trunk/Common/Version.php
r550 r551 1 1 <?php 2 2 3 $Revision = 55 0; // Subversion revision4 $DatabaseRevision = 55 0; // SQL structure revision3 $Revision = 551; // Subversion revision 4 $DatabaseRevision = 551; // SQL structure revision 5 5 $ReleaseTime = '2013-07-07'; 6 6 -
trunk/Modules/Finance/Finance.php
r550 r551 356 356 'DefaultSortColumn' => 'Time', 357 357 'Items' => array( 358 'DocumentLine' => array('Type' => 'TDocumentLine', 'Caption' => 'Dokladová řada', 'Default' => ''), 359 'BillCode' => array('Type' => 'String', 'Caption' => 'Označení', 'Default' => ''), 360 'Subject' => array('Type' => 'TSubject', 'Caption' => 'Subjekt', 'Default' => ''), 358 361 'Time' => array('Type' => 'Date', 'Caption' => 'Čas realizace', 'Default' => ''), 359 'Subject' => array('Type' => 'TSubject', 'Caption' => 'Subjekt', 'Default' => ''),360 362 'Cash' => array('Type' => 'Boolean', 'Caption' => 'Hotově', 'Default' => ''), 361 363 'Taxable' => array('Type' => 'Boolean', 'Caption' => 'Zdanitelné', 'Default' => ''), 362 364 'Value' => array('Type' => 'Integer', 'Caption' => 'Částka', 'Default' => '0', 'Suffix' => 'Kč'), 363 'BillCode' => array('Type' => 'String', 'Caption' => 'Označení', 'Default' => ''),364 365 'Text' => array('Type' => 'String', 'Caption' => 'Popis', 'Default' => ''), 365 366 'Network' => array('Type' => 'Boolean', 'Caption' => 'Týkající sítě', 'Default' => ''), … … 368 369 'Generate' => array('Type' => 'Boolean', 'Caption' => 'Generovat', 'Default' => ''), 369 370 ), 371 'BeforeInsert' => array($this, 'BeforeInsertFinanceOperation'), 370 372 )); 371 373 $this->System->FormManager->RegisterClass('FinanceInvoice', array( … … 374 376 'DefaultSortColumn' => 'TimeCreation', 375 377 'Items' => array( 378 'DocumentLine' => array('Type' => 'TDocumentLine', 'Caption' => 'Dokladová řada', 'Default' => ''), 376 379 'BillCode' => array('Type' => 'String', 'Caption' => 'Označení', 'Default' => ''), 377 380 'Subject' => array('Type' => 'TSubject', 'Caption' => 'Subjekt', 'Default' => ''), … … 384 387 'Items' => array('Type' => 'TFinanceInvoiceItemListInvoice', 'Caption' => 'Položky', 'Default' => ''), 385 388 ), 389 'BeforeInsert' => array($this, 'BeforeInsertFinanceOperation'), 386 390 )); 387 391 $this->System->FormManager->RegisterClass('FinanceInvoiceItem', array( … … 473 477 { 474 478 } 479 480 function BeforeInsertFinanceOperation($Form) 481 { 482 $DocumentLine = $Form->Values['DocumentLine']; 483 $Form->Values['BillCode'] = $this->System->Modules['Finance']->GetNextDocumentLineNumber($DocumentLine); 484 return($Form->Values); 485 } 475 486 } -
trunk/Modules/Finance/Manage.php
r549 r551 9 9 function Show() 10 10 { 11 $Output = ''; 11 12 if(!$this->System->User->CheckPermission('Finance', 'Manage')) 12 13 return('Nemáte oprávnění'); … … 14 15 if(array_key_exists('Operation', $_GET)) $Operation = $_GET['Operation']; 15 16 else $Operation = ''; 16 //$Operation = 'ImportOldData';17 17 switch($Operation) 18 18 { 19 case 'Bills':20 $Output = $this->BillManage();21 break;22 case 'ConvertPDFToFile':23 $Output = $this->ConvertPDFDataToFiles();24 break;25 //case 'ImportOldData':26 // $Output = $this->ImportOldData();27 // break;28 case 'NewPaymentInsert':29 $Output = $this->ShowNewPaymentInsert();30 break;31 case 'NewPaymentForm':32 $Output = $this->ShowNewPaymentForm();33 break;34 case 'NewInvoiceInsert':35 $Output = $this->ShowNewInvoiceInsert();36 break;37 case 'NewInvoiceForm':38 $Output = $this->ShowNewInvoiceForm();39 break;40 19 case 'Recalculate': 41 20 $Output = $this->System->Modules['Finance']->RecalculateSegmentParameters(); … … 52 31 break; 53 32 default: 54 $Output = '<a href="?Operation=NewPaymentForm">Přidat novou platbu</a><br />';55 $Output .= '<a href="?Operation=NewInvoiceForm">Přidat novou fakturu</a><br />';56 $Output .= '<a href="?Operation=ConvertPDFToFile">Převést data z databáze do souborů</a><br />';57 $Output .= '<a href="?Operation=Bills">Správa dokladů</a><br />';58 33 //$Output .= '<a href="?Operation=Recalculate">Přepočet financí</a><br />'; 59 34 $Output .= '<a href="?Operation=ShowMonthlyPayment">Měsíční vyúčtování</a><br />'; 60 //$Output .= '<a href="clenove.php">Seznam členů</a><br />';61 35 $Output .= '<a href="'.$this->System->Link('/finance/zivnost/').'">Živnost</a><br />'; 62 36 $Output .= '<a href="?Operation=GenerateBills">Generovat chybějící doklady</a><br />'; … … 64 38 } 65 39 return($Output); 66 }67 68 function BillManage()69 {70 $Output = '';71 if(array_key_exists('subject', $_GET))72 {73 $DbResult = $this->Database->select('FinanceBills', '*', 'Subject='.$_GET['subject']);74 while($Item = $DbResult->fetch_array())75 {76 $Output .= '<a href="?Operation=Bills&bill='.$Item['Id'].'">faktura '.$Item['Id'].'</a> <a href="?Operation=Bills&billpdf='.$Item['Id'].'">Uložené PDF</a> <a href="?Operation=Bills&billpdf2='.$Item['Id'].'">Generované PDF</a> <a href="?Operation=Bills&regenerate='.$Item['Id'].'">Přegenerovat</a><br />';77 }78 } else79 if(array_key_exists('billpdf', $_GET))80 {81 $Output .= $this->System->Modules['Bill']->ShowStoredBill($_GET['billpdf']);82 } else83 if(array_key_exists('billpdf2', $_GET))84 {85 $Output .= $this->System->Modules['Bill']->ShowGeneratedBill($_GET['billpdf2']);86 } else87 if(array_key_exists('regenerate', $_GET))88 {89 $Output .= $this->System->Modules['Bill']->RegeneratePDF($_GET['regenerate']);90 } else91 if(array_key_exists('bill', $_GET))92 {93 $Output .= $this->System->Modules['Bill']->GenerateBill($_GET['bill']);94 } else95 if(array_key_exists('generate', $_GET))96 {97 $Output .= $this->System->Modules['Bill']->CreateBill(1, array(array('Description' => 'Poplatek za připojení k Internetu', 'Price' => 1000, 'Quantity' => 1)), time(), time());98 } else99 {100 //ShowHeader('Faktury', 'Faktury');101 $Output .= 'Faktury:<br />';102 $DbResult = $this->Database->select('Subject', '*', '1 ORDER BY Name');103 while($Subject = $DbResult->fetch_array())104 {105 $Output .= '<a href="?Operation=Bills&subject='.$Subject['Id'].'">'.$Subject['Name'].'</a><br />';106 }107 //ShowFooter();108 }109 return($Output);110 }111 112 function CheckAdvancesAndLiabilities($Subject)113 {114 global $LastInsertTime;115 116 do {117 $DbResult = $this->Database->select('FinanceAdvances', 'SUM(Value)', 'Subject='.$Subject.' AND Direction = "In"');118 $DbRow = $DbResult->fetch_array();119 $Advances = $DbRow[0];120 $DbResult = $this->Database->select('FinanceInvoice', '*', 'Subject='.$Subject.121 ' AND TimePayment IS NULL AND Value > 0 ORDER BY TimeCreation LIMIT 1');122 if($DbResult->num_rows > 0)123 {124 $OpenedClaim = $DbResult->fetch_array();125 if($Advances > $OpenedClaim['Value'])126 {127 $this->Database->update('FinanceInvoice', 'Id='.$OpenedClaim['Id'],128 array('TimePayment' => TimeToMysqlDateTime($LastInsertTime)));129 $this->Database->insert('FinanceAdvances', array('Subject' =>130 $OpenedClaim['Subject'], 'Value' => -$OpenedClaim['Value'],131 'TimeCreation' => TimeToMysqlDateTime($LastInsertTime),132 'CashFlowId' => $OpenedClaim['Id'], 'Direction' => 'In'));133 } else break;134 } else break;135 } while(($Advances > $OpenedClaim['Value']));136 }137 138 function InsertInvoice($Subject, $TimeCreation, $TimeDue, $Items,139 $DocumentLine, $PeriodFrom, $PeriodTo)140 {141 global $LastInsertTime;142 143 $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumber($DocumentLine);144 $SumValue = 0;145 foreach($Items as $Item)146 $SumValue = $SumValue + $Item['Price'];147 $this->Database->insert('FinanceInvoice', array(148 'Subject' => $Subject, 'TimeCreation' => TimeToMysqlDateTime($TimeCreation),149 'TimeDue' => TimeToMysqlDateTime($TimeDue), 'Value' => $SumValue, 'BillCode' => $BillCode,150 'PeriodFrom' => TimeToMysqlDate($PeriodFrom), 'PeriodTo' => TimeToMysqlDate($PeriodTo),151 'Generate' => 1));152 $InvoiceId = $this->Database->insert_id;153 foreach($Items as $Item)154 $this->Database->insert('FinanceInvoiceItem', array('FinanceInvoice' => $InvoiceId,155 'Description' => $Item['Description'], 'Price' => $Item['Price'], 'Quantity' => $Item['Quantity'], 'VAT' => $Item['VAT']));156 //$LastInsertTime = $Time;157 //$this->CheckAdvancesAndLiabilities($Subject);158 return($InvoiceId);159 }160 161 function InsertMoney($Subject, $Value, $Cash, $Taxable, $Time, $Text, $DocumentLine)162 {163 global $LastInsertTime;164 165 $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumber($DocumentLine);166 $this->Database->insert('FinanceOperation', array('Text' => $Text, 'Subject' => $Subject, 'Cash' => $Cash, 'Value' => $Value, 'Time' => TimeToMysqlDateTime($Time), 'Taxable' => $Taxable, 'BillCode' => $BillCode));167 /*if($Value >= 0)168 {169 $this->Database->insert('FinanceAdvances', array('Subject' => $Subject, 'Value' => $Value, 'TimeCreation' => TimeToMysqlDateTime($Time), 'CashFlowId' => $this->Database->insert_id, 'Direction' => 'In'));170 }171 $LastInsertTime = $Time;172 */173 //$this->CheckAdvancesAndLiabilities($Subject);174 }175 176 function ShowNewPaymentForm()177 {178 $Form = new Form($this->System->FormManager);179 $Form->SetClass('NewPayment');180 $Form->OnSubmit = '?Operation=NewPaymentInsert';181 $Output = $Form->ShowEditForm();182 return($Output);183 }184 185 function ShowNewPaymentInsert()186 {187 $Form = new Form($this->System->FormManager);188 $Form->SetClass('NewPayment');189 $Form->LoadValuesFromForm();190 $this->InsertMoney($Form->Values['Subject'], $Form->Values['Value'], $Form->Values['Cash'], $Form->Values['Taxable'], $Form->Values['Time'], $Form->Values['Text'], $Form->Values['DocumentLine']);191 $LastId = $this->Database->insert_id;192 $DbResult = $this->Database->select('FinanceOperation', 'BillCode', 'Id='.$LastId);193 $DbRow = $DbResult->fetch_assoc();194 $Output = $this->SystemMessage('Finance', 'Platba vložena '.$DbRow['BillCode'].'.');195 $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'NewPaymentInserted');196 return($Output);197 }198 199 function ShowNewInvoiceForm()200 {201 $Form = new Form($this->System->FormManager);202 $Form->SetClass('NewInvoice');203 $Form->OnSubmit = '?Operation=NewInvoiceInsert';204 $Output = $Form->ShowEditForm();205 return($Output);206 }207 208 function ShowNewInvoiceInsert()209 {210 $Form = new Form($this->System->FormManager);211 $Form->SetClass('NewInvoice');212 $Form->LoadvaluesFromForm();213 $Items = array(array('Price' => $Form->Values['Value'],214 'Description' => $Form->Values['Text'], 'Quantity' => 1, 'VAT' => 21));215 $LastId = $this->InsertInvoice($Form->Values['Subject'],216 $Form->Values['TimeCreation'], $Form->Values['TimeDue'], $Items,217 $Form->Values['DocumentLine'], NULL, NULL);218 $DbResult = $this->Database->select('FinanceInvoice', 'BillCode', 'Id='.$LastId);219 $DbRow = $DbResult->fetch_assoc();220 $Output = $this->SystemMessage('Finance', 'Faktura vložena '.$DbRow['BillCode'].'.');221 $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'NewInvoiceInserted');222 return($Output);223 }224 225 function ConvertPDFDataToFiles()226 {227 $DbResult = $this->Database->query('SELECT * FROM FinanceBills');228 while($Bill = $DbResult->fetch_assoc())229 {230 file_put_contents('doklady/doklad_'.$Bill['id'].'.pdf', $Bill['pdf']);231 echo($Bill['id'].',');232 }233 }234 235 function CheckPDFFiles()236 {237 global $InvoiceGenerator;238 239 $DbResult = $this->Database->query('SELECT * FROM FinanceBills');240 while($Bill = $DbResult->fetch_assoc())241 {242 file_put_contents('doklady2/doklad-'.$Bill['id'].'.pdf', file_get_contents('doklady/doklad-'.$Bill['id'].'.pdf'));243 //echo($InvoiceGenerator->HasPDFFile($Bill['id']).',');244 }245 40 } 246 41 -
trunk/Modules/FinanceBankAPI/FileImport.php
r550 r551 5 5 class BankImport 6 6 { 7 var $System; 7 8 var $Database; 8 9 var $BankAccount; 9 10 10 function __construct($ Database)11 function __construct($System) 11 12 { 12 $this->Database = &$Database; 13 $this->Database = &$System->Database; 14 $this->System = &$System; 13 15 } 14 16 … … 26 28 while($DbRow = $DbResult->fetch_assoc()) 27 29 { 30 echo($DbRow['Id'].','); 28 31 if(is_numeric($DbRow['VariableSymbol'])) 29 32 { … … 32 35 { 33 36 $DbRow2 = $DbResult2->fetch_assoc(); 37 if($DbRow['Value'] >= 0) $DocumentLine = 3; // Receive money 38 else $DocumentLine = 4; // Send money 39 $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumber($DocumentLine); 34 40 $DbResult3 = $this->Database->insert('FinanceOperation', array('Subject' => $DbRow2['Id'], 'Cash' => 0, 35 41 'Value' => $DbRow['Value'], 'Taxable' => 1, 'BankAccount' => $DbRow['BankAccount'], 'Network' => 1, 36 'Time' => $DbRow['Time'], 'Text' => $DbRow['Description'] ));42 'Time' => $DbRow['Time'], 'Text' => $DbRow['Description'], 'BillCode' => $BillCode)); 37 43 $this->Database->update('FinanceBankImport', 'Id='.$DbRow['Id'], array('FinanceOperation' => $this->Database->insert_id)); 38 44 } … … 60 66 $Output .= 'Účet: '.$BankAccount['Number'].'/'.$Bank['Code'].' ('.$Bank['Name'].')'; 61 67 62 if($Bank['Code'] == '2010') $Import = new ImportFio($this-> Database);63 else if($Bank['Code'] == '0300') $Import = new ImportPS($this-> Database);68 if($Bank['Code'] == '2010') $Import = new ImportFio($this->System); 69 else if($Bank['Code'] == '0300') $Import = new ImportPS($this->System); 64 70 else $Output = $this->SystemMessage('Nepodporované API', 'Pro zvolenou banku není import podporován'); 65 71 if(isset($Import)) … … 118 124 $Output .= 'Účet: '.$BankAccount['Number'].'/'.$Bank['Code'].' ('.$Bank['Name'].')'; 119 125 120 if($Bank['Code'] == '2010') $Import = new ImportFio($this-> Database);121 else if($Bank['Code'] == '0300') $Import = new ImportPS($this-> Database);126 if($Bank['Code'] == '2010') $Import = new ImportFio($this->System); 127 else if($Bank['Code'] == '0300') $Import = new ImportPS($this->System); 122 128 else $Output = $this->SystemMessage('Nepodporované API', 'Pro zvolenou banku není import podporován'); 123 129 $Import->BankAccount = $BankAccount; -
trunk/Modules/FinanceBankAPI/ImportFio.php
r550 r551 43 43 } 44 44 $Output .= '</table>'; 45 $this->Database-> Update('FinanceBankAccount', 'Id='.$this->BankAccount['Id'], array('LastImportDate' => TimeToMysqlDate($PeriodEnd)));45 $this->Database->update('FinanceBankAccount', 'Id='.$this->BankAccount['Id'], array('LastImportDate' => TimeToMysqlDate($PeriodEnd))); 46 46 return($Output); 47 47 } -
trunk/Modules/IS/IS.php
r548 r551 65 65 $DbRow = $DbResult->fetch_row(); 66 66 $Output .= 'Stav placení: '.$DbRow['0'].'<br/>'; 67 $DbResult = $this->Database->select('FinanceBankImport', 'COUNT(*)', 'FinanceOperation IS NULL'); 68 $DbRow = $DbResult->fetch_row(); 69 $Output .= 'Nezpárovaných plateb: '.$DbRow['0'].'<br/>'; 67 70 return($Output); 68 71 } … … 136 139 $Form->LoadValuesFromForm(); 137 140 try { 141 if(array_key_exists('BeforeInsert', $Form->Definition)) 142 { 143 $Class = $Form->Definition['BeforeInsert'][0]; 144 $Method = $Form->Definition['BeforeInsert'][1]; 145 $this->Values = $Class->$Method($Form); 146 } 138 147 $Form->SaveValuesToDatabase(0); 139 148 $Output .= $this->SystemMessage('Přidání položky', 'Nová položka vytvořena'); -
trunk/admin/Updates.php
r550 r551 329 329 } 330 330 331 function UpdateTo551($Manager) 332 { 333 $Manager->Execute('ALTER TABLE `FinanceOperation` ADD `DocumentLine` INT NULL AFTER `Value` , 334 ADD INDEX ( `DocumentLine` ) ;'); 335 $Manager->Execute('ALTER TABLE `FinanceOperation` ADD FOREIGN KEY ( `DocumentLine` ) REFERENCES `DocumentLine` ( 336 `Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;'); 337 $Manager->Execute('ALTER TABLE `FinanceInvoice` ADD `DocumentLine` INT NULL AFTER `Id` , 338 ADD INDEX ( `DocumentLine` ) ;'); 339 $Manager->Execute('ALTER TABLE `FinanceInvoice` ADD FOREIGN KEY ( `DocumentLine` ) REFERENCES `DocumentLine` ( 340 `Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;'); 341 $Manager->Execute('DROP TABLE `FinanceBillsOld`'); 342 $Manager->Execute('DROP TABLE `FinanceBillsItemsOld`'); 343 } 344 345 331 346 $Updates = array( 332 347 491 => array('Revision' => 493, 'Function' => 'UpdateTo493'), … … 347 362 535 => array('Revision' => 549, 'Function' => 'UpdateTo549'), 348 363 549 => array('Revision' => 550, 'Function' => 'UpdateTo550'), 364 550 => array('Revision' => 551, 'Function' => 'UpdateTo551'), 349 365 );
Note:
See TracChangeset
for help on using the changeset viewer.