Changeset 901 for trunk/Modules
- Timestamp:
- Feb 17, 2021, 9:27:32 PM (4 years ago)
- Location:
- trunk/Modules
- Files:
-
- 2 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Customer/Customer.php
r899 r901 37 37 'SupportActivity' => array('Type' => 'TSupportActivityListCustomer', 'Caption' => 'Zákaznická podpora', 'Default' => ''), 38 38 'Consumption' => array('Type' => 'TCustomerStockSerialNumber', 'Caption' => 'Spotřeba zařízení', 'Default' => ''), 39 'Contract' => array('Type' => 'TContract', 'Caption' => 'Smlouva', 'Default' => '', 'Null' => true), 39 40 'ChangeAction' => array('Type' => 'TActionEnum', 'Caption' => 'Změna - akce', 'Default' => '', 'Null' => true), 40 41 'ChangeTime' => array('Type' => 'DateTime', 'Caption' => 'Změna - čas', 'Default' => '', 'Null' => true, 'NotInList' => true), … … 196 197 ), 197 198 )); 199 $this->System->FormManager->RegisterFormType('TCustomerListContract', array( 200 'Type' => 'ManyToOne', 201 'Table' => 'Member', 202 'Id' => 'Id', 203 'Ref' => 'Contract', 204 'Filter' => '1', 205 )); 206 207 $this->System->RegisterPage(['user', 'dokumenty'], 'PageCustomerDocuments'); 198 208 199 209 ModuleIS::Cast(Core::Cast($this->System)->GetModule('IS'))->RegisterDashboardItem('Customer', … … 211 221 $Output .= ' platících:'.$DbRow['0'].'<br/>'; 212 222 223 return $Output; 224 } 225 } 226 227 class PageCustomerDocuments extends Page 228 { 229 function __construct(System $System) 230 { 231 parent::__construct($System); 232 $this->FullTitle = 'Dokumenty klienta'; 233 $this->ShortTitle = 'Dokumenty'; 234 $this->ParentClass = 'PageUser'; 235 } 236 237 function Show(): string 238 { 239 $Output = '<br/><div><strong>Dostupné dokumenty:</strong></div><br/>'; 240 241 $User = &ModuleUser::Cast($this->System->GetModule('User'))->User; 242 243 // Determine which customer should be displayed 244 if (array_key_exists('i', $_GET)) 245 { 246 if (!$User->CheckPermission('Finance', 'Manage')) return 'Nemáte oprávnění'; 247 $CustomerId = $_GET['i']; 248 } else 249 { 250 if (!$User->CheckPermission('Customer', 'DisplayCustomerDocuments')) return 'Nemáte oprávnění'; 251 $UserId = ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id']; 252 $DbResult = $this->Database->query('SELECT `Customer` FROM `UserCustomerRel` WHERE `User`='.$UserId.' LIMIT 1'); 253 if ($DbResult->num_rows > 0) 254 { 255 $CustomerUserRel = $DbResult->fetch_assoc(); 256 $CustomerId = $CustomerUserRel['Customer']; 257 } else return $this->SystemMessage('Chyba', 'Nejste zákazníkem'); 258 } 259 260 // Load customer info 261 $DbResult = $this->Database->query('SELECT * FROM `Member` WHERE `Id`='.$CustomerId); 262 if ($DbResult->num_rows == 1) 263 { 264 $Customer = $DbResult->fetch_assoc(); 265 } else return $this->SystemMessage('Položka nenalezena', 'Zákazník nenalezen'); 266 267 if ($Customer['Contract'] != '') 268 { 269 $DbResult = $this->Database->query('SELECT Contract.*, File.Hash AS FileHash, DocumentLineCode.Name AS BillCodeText FROM Contract '. 270 'LEFT JOIN File ON File.Id=Contract.File '. 271 'LEFT JOIN DocumentLineCode ON DocumentLineCode.Id=Contract.BillCode '. 272 'WHERE (Contract.Id='.$Customer['Contract'].')'); 273 if ($DbResult->num_rows > 0) 274 { 275 $Contract = $DbResult->fetch_assoc(); 276 if ($Contract['File'] > 0) $Output .= 'Smlouva: <a href="'.$this->System->Link('/file?h='.$Contract['FileHash']).'">'.$Contract['BillCodeText'].'</a><br/>'; 277 else $Output .= 'Smlouva: '.$Contract['BillCodeText'].'<br/>'; 278 $Output .= 'Všeobecné smluvní podmínky: <a href="http://www.zdechov.net/docs/V%C5%A1eobecn%C3%A9%20smluvn%C3%AD%20podm%C3%ADnky.pdf">PDF</a><br/>'; 279 } 280 } 213 281 return $Output; 214 282 } -
trunk/Modules/Document/Document.php
r899 r901 80 80 )); 81 81 } 82 83 static function Cast(Module $Module): ModuleDocument 84 { 85 if ($Module instanceof ModuleDocument) 86 { 87 return $Module; 88 } 89 throw new Exception('Expected ModuleDocument type but '.gettype($Module)); 90 } 91 92 function GetFinanceYear(int $Year): array 93 { 94 if ($Year == 0) 95 { 96 // Get latest year 97 $DbResult = $this->Database->select('FinanceYear', '*', '1 ORDER BY `Year` DESC LIMIT 1'); 98 } else $DbResult = $this->Database->select('FinanceYear', '*', '`Year`='.$Year); 99 if ($DbResult->num_rows == 0) 100 { 101 if ($Year == date('Y')) 102 { 103 $this->CreateFinanceYear($Year); 104 $DbResult = $this->Database->select('FinanceYear', '*', '`Year`='.$Year); 105 } else throw new Exception('Rok '.$Year.' nenalezen'); 106 } 107 $FinanceYear = $DbResult->fetch_assoc(); 108 if ($FinanceYear['Closed'] == 1) 109 throw new Exception('Rok '.$FinanceYear['Year'].' je již uzavřen. Nelze do něj přidávat položky.'); 110 return $FinanceYear; 111 } 112 113 function GetNextDocumentLineNumber(string $Id, int $FinanceYear = 0): string 114 { 115 $FinanceYear = $this->GetFinanceYear($FinanceYear); 116 117 $DbResult = $this->Database->query('SELECT `Shortcut`, `Id` FROM `DocumentLine` WHERE `Id`='.$Id); 118 $DocumentLine = $DbResult->fetch_assoc(); 119 120 $DbResult = $this->Database->query('SELECT * FROM `DocumentLineSequence` WHERE '. 121 '`DocumentLine`='.$Id.' AND `FinanceYear`='.$FinanceYear['Id']); 122 $Sequence = $DbResult->fetch_assoc(); 123 124 if ($Sequence['YearPrefix'] == 1) 125 { 126 $Result = $DocumentLine['Shortcut'].$Sequence['NextNumber'].'/'.$FinanceYear['Year']; 127 } else $Result = $DocumentLine['Shortcut'].$Sequence['NextNumber']; 128 129 $this->Database->query('UPDATE `DocumentLineSequence` SET `NextNumber` = `NextNumber` + 1 '. 130 'WHERE (`DocumentLine`='.$Id.') AND (`FinanceYear`='.$FinanceYear['Id'].')'); 131 return $Result; 132 } 133 134 function GetNextDocumentLineNumberId(string $Id, int $FinanceYear = 0): int 135 { 136 $Code = $this->GetNextDocumentLineNumber($Id, $FinanceYear); 137 $this->Database->insert('DocumentLineCode', array('DocumentLine' => $Id, 'Name' => $Code)); 138 return $this->Database->insert_id; 139 } 140 141 function CreateFinanceYear(int $Year) 142 { 143 $StartTime = mktime(0, 0, 0, 1, 1, $Year); 144 $EndTime = mktime(0, 0, 0, 12, 31, $Year); 145 $this->Database->insert('FinanceYear', array('Year' => $Year, 146 'DateStart' => TimeToMysqlDate($StartTime), 'DateEnd' => TimeToMysqlDate($EndTime), 'Closed' => 0)); 147 $YearId = $this->Database->insert_id; 148 149 // Create DocumentLineSequence from previous 150 $DbResult = $this->Database->select('DocumentLine', 'Id', '`Yearly` = 1'); 151 while ($DbRow = $DbResult->fetch_assoc()) 152 { 153 $this->Database->insert('DocumentLineSequence', array('FinanceYear' => $YearId, 154 'NextNumber' => 1, 'YearPrefix' => 1, 'DocumentLine' => $DbRow['Id'])); 155 } 156 } 82 157 } 83 158 -
trunk/Modules/Employee/Employee.php
r899 r901 83 83 'Filter' => '1', 84 84 )); 85 $this->System->FormManager->RegisterFormType('TEmployeeSalaryListContract', array( 86 'Type' => 'ManyToOne', 87 'Table' => 'EmployeeSalary', 88 'Id' => 'Id', 89 'Ref' => 'Contract', 90 'Filter' => '1', 91 )); 85 92 } 86 93 } -
trunk/Modules/File/File.php
r899 r901 20 20 $Desc->AddReference('Directory', FileDirectory::GetClassName(), true); 21 21 $Desc->AddDateTime('Time'); 22 $Desc->AddString('Hash'); 23 $Desc->AddBoolean('Generate'); 22 24 return $Desc; 23 25 } … … 59 61 } 60 62 61 function Download(string $Id): void 62 { 63 $DbResult = $this->Database->select('File', '*', 'Id='.addslashes($Id)); 63 function DownloadHash(string $Hash): void 64 { 65 $this->Download('Hash="'.addslashes($Hash).'"'); 66 } 67 68 function DownloadId(string $Id): void 69 { 70 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('File', 'DownloadById')) 71 echo('Nemáte oprávnění'); 72 $this->Download('Id='.addslashes($Id)); 73 } 74 75 function Download(string $Where): void 76 { 77 $DbResult = $this->Database->select('File', '*', $Where); 64 78 if ($DbResult->num_rows > 0) 65 79 { … … 105 119 function Show(): string 106 120 { 107 if (array_key_exists('id', $_GET)) $Id = $_GET['id']; 108 else if (array_key_exists('i', $_GET)) $Id = $_GET['i']; 121 if (array_key_exists('h', $_GET)) 122 { 123 $Hash = $_GET['h']; 124 $this->ClearPage = true; 125 ModuleFile::Cast($this->System->GetModule('File'))->File->DownloadHash($Hash); 126 return ''; 127 } 128 else if (array_key_exists('i', $_GET)) 129 { 130 $Id = $_GET['i'] * 1; 131 $this->ClearPage = true; 132 ModuleFile::Cast($this->System->GetModule('File'))->File->DownloadId($Id); 133 } 109 134 else return $this->SystemMessage('Chyba', 'Nezadáno id souboru'); 110 $this->ClearPage = true; 111 $Output = ModuleFile::Cast($this->System->GetModule('File'))->File->Download($Id); 112 return $Output; 135 return ''; 113 136 } 114 137 } … … 208 231 'Size' => array('Type' => 'Integer', 'Caption' => 'Velikost', 'Default' => ''), 209 232 'Time' => array('Type' => 'DateTime', 'Caption' => 'Čas vytvoření', 'Default' => ''), 233 'Hash' => array('Type' => 'String', 'Caption' => 'Haš', 'Default' => ''), 210 234 'Invoices' => array('Type' => 'TFinanceInvoiceListFile', 'Caption' => 'Faktury', 'Default' => ''), 211 235 'Operations' => array('Type' => 'TFinanceOperationListFile', 'Caption' => 'Operace', 'Default' => ''), -
trunk/Modules/Finance/Bill.php
r888 r901 1 1 <?php 2 2 3 class Bill extends Model3 class Bill extends Pdf 4 4 { 5 5 public int $SpecificSymbol = 1; // computer network number 6 public bool $Checked = false;7 8 function GenerateHTML(): string9 {10 return '';11 }12 13 function SaveToFile(string $FileName): void14 {15 $PdfData = $this->HtmlToPdf($this->GenerateHTML());16 file_put_contents($FileName, $PdfData);17 }18 19 function HtmlToPdf(string $HtmlCode): string20 {21 $Encoding = new Encoding();22 if ($this->Checked == false) {23 if (CommandExist('htmldoc')) {24 $this->Checked = true;25 } else throw new Exception('htmldoc is not installed.');26 }27 $Output = shell_exec('echo "'.addslashes($Encoding->FromUTF8($HtmlCode)).28 '"|htmldoc --no-numbered --webpage --no-embedfonts --charset 8859-2 -t pdf -');29 return $Output;30 }31 6 } 32 7 -
trunk/Modules/Finance/Finance.php
r900 r901 21 21 $this->License = 'GNU/GPLv3'; 22 22 $this->Description = 'Base module for finance management'; 23 $this->Dependencies = array(ModuleFile::GetName(), ModuleEmailQueue::GetName(), ModuleSubject::GetName(), ModuleDocument::GetName()); 23 $this->Dependencies = array(ModuleFile::GetName(), ModuleEmailQueue::GetName(), ModuleSubject::GetName(), 24 ModuleDocument::GetName()); 24 25 $this->Models = array(FinanceBillingPeriod::GetClassName(), FinanceVatType::GetClassName(), FinanceVat::GetClassName(), 25 26 FinanceGroup::GetClassName(), FinanceOperationGroup::GetClassName(), FinanceOperation::GetClassName(), … … 27 28 Company::GetClassName(), FinanceTreasury::GetClassName(), FinanceTreasuryCheck::GetClassName(), 28 29 Currency::GetClassName(), FinanceBank::GetClassName(), FinanceBankAccount::GetClassName(), FinanceCharge::GetClassName(), 29 Contract::GetClassName(),FinanceInvoiceOperationRel::GetClassName());30 FinanceInvoiceOperationRel::GetClassName()); 30 31 31 32 $this->Bill = new Bill($this->System); … … 423 424 'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => ''), 424 425 ), 425 ));426 $this->System->FormManager->RegisterClass('Contract', array(427 'Title' => 'Smlouvy',428 'Table' => 'Contract',429 'Items' => array(430 'DocumentLine' => array('Type' => 'TDocumentLine', 'Caption' => 'Dokladová řada', 'Default' => ''),431 'BillCode' => array('Type' => 'TDocumentLineCode', 'Caption' => 'Kód', 'Default' => '', 'Null' => true),432 'Subject' => array('Type' => 'TSubject', 'Caption' => 'Subjekt', 'Default' => ''),433 'ValidFrom' => array('Type' => 'Date', 'Caption' => 'Platnost od', 'Default' => ''),434 'ValidTo' => array('Type' => 'Date', 'Caption' => 'Platnost do', 'Default' => '', 'Null' => true),435 'File' => array('Type' => 'TFile', 'Caption' => 'Soubor', 'Default' => '', 'Null' => true),436 ),437 'BeforeInsert' => array($this, 'BeforeInsertContract'),438 ));439 $this->System->FormManager->RegisterFormType('TContract', array(440 'Type' => 'Reference',441 'Table' => 'Contract',442 'Id' => 'Id',443 'Name' => 'BillCode',444 'Filter' => '1',445 426 )); 446 427 $this->System->FormManager->RegisterFormType('TFinanceVAT', array( … … 541 522 } 542 523 543 function DoStop(): void544 {545 }546 547 524 function BeforeInsertFinanceOperation(Form $Form): array 548 525 { … … 550 527 else $Year = date("Y", $Form->Values['ValidFrom']); 551 528 $FinanceGroup = $this->Finance->GetFinanceGroupById($Form->Values['Group'], 'FinanceOperationGroup'); 552 $Form->Values['BillCode'] = $this->Finance->GetNextDocumentLineNumberId($FinanceGroup['DocumentLine'], $Year);529 $Form->Values['BillCode'] = ModuleDocument::Cast($this->System->GetModule('Document'))->GetNextDocumentLineNumberId($FinanceGroup['DocumentLine'], $Year); 553 530 return $Form->Values; 554 531 } … … 576 553 else $Year = date("Y", $Form->Values['ValidFrom']); 577 554 $Group = $this->Finance->GetFinanceGroupById($Form->Values['Group'], 'FinanceInvoiceGroup'); 578 $Form->Values['BillCode'] = $this->Finance->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year);555 $Form->Values['BillCode'] = ModuleDocument::Cast($this->System->GetModule('Document'))->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year); 579 556 return $Form->Values; 580 557 } … … 621 598 } 622 599 623 function BeforeInsertContract(Form $Form): array624 {625 if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']);626 else $Year = date("Y", $Form->Values['ValidFrom']);627 $Form->Values['BillCode'] = $this->Finance->GetNextDocumentLineNumberId($Form->Values['DocumentLine'], $Year);628 return $Form->Values;629 }630 631 600 static function Cast(Module $Module): ModuleFinance 632 601 { -
trunk/Modules/Finance/FinanceModels.php
r899 r901 77 77 } 78 78 79 function CreateFinanceYear(int $Year) 80 { 81 $StartTime = mktime(0, 0, 0, 1, 1, $Year); 82 $EndTime = mktime(0, 0, 0, 12, 31, $Year); 83 $this->Database->insert('FinanceYear', array('Year' => $Year, 84 'DateStart' => TimeToMysqlDate($StartTime), 'DateEnd' => TimeToMysqlDate($EndTime), 'Closed' => 0)); 85 $YearId = $this->Database->insert_id; 86 87 // Create DocumentLineSequence from previous 88 $DbResult = $this->Database->select('DocumentLine', 'Id', '`Yearly` = 1'); 89 while ($DbRow = $DbResult->fetch_assoc()) 79 function GetFinanceGroupById(string $Id, string $Table): ?array 80 { 81 $DbResult = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE `Id`= '.$Id); 82 if ($DbResult->num_rows == 1) 90 83 { 91 $this->Database->insert('DocumentLineSequence', array('FinanceYear' => $YearId,92 'NextNumber' => 1, 'YearPrefix' => 1, 'DocumentLine' => $DbRow['Id']));93 }94 }95 96 function GetFinanceYear(int $Year): array97 {98 if ($Year == 0)99 {100 // Get latest year101 $DbResult = $this->Database->select('FinanceYear', '*', '1 ORDER BY `Year` DESC LIMIT 1');102 } else $DbResult = $this->Database->select('FinanceYear', '*', '`Year`='.$Year);103 if ($DbResult->num_rows == 0)104 {105 if ($Year == date('Y'))106 {107 $this->CreateFinanceYear($Year);108 $DbResult = $this->Database->select('FinanceYear', '*', '`Year`='.$Year);109 } else throw new Exception('Rok '.$Year.' nenalezen');110 }111 $FinanceYear = $DbResult->fetch_assoc();112 if ($FinanceYear['Closed'] == 1)113 throw new Exception('Rok '.$FinanceYear['Year'].' je již uzavřen. Nelze do něj přidávat položky.');114 return $FinanceYear;115 }116 117 function GetNextDocumentLineNumber(string $Id, int $FinanceYear = 0): string118 {119 $FinanceYear = $this->GetFinanceYear($FinanceYear);120 121 $DbResult = $this->Database->query('SELECT `Shortcut`, `Id` FROM `DocumentLine` WHERE `Id`='.$Id);122 $DocumentLine = $DbResult->fetch_assoc();123 124 $DbResult = $this->Database->query('SELECT * FROM `DocumentLineSequence` WHERE '.125 '`DocumentLine`='.$Id.' AND `FinanceYear`='.$FinanceYear['Id']);126 $Sequence = $DbResult->fetch_assoc();127 128 if ($Sequence['YearPrefix'] == 1)129 {130 $Result = $DocumentLine['Shortcut'].$Sequence['NextNumber'].'/'.$FinanceYear['Year'];131 } else $Result = $DocumentLine['Shortcut'].$Sequence['NextNumber'];132 133 $this->Database->query('UPDATE `DocumentLineSequence` SET `NextNumber` = `NextNumber` + 1 '.134 'WHERE (`DocumentLine`='.$Id.') AND (`FinanceYear`='.$FinanceYear['Id'].')');135 return $Result;136 }137 138 function GetNextDocumentLineNumberId(string $Id, int $FinanceYear = 0): int139 {140 $Code = $this->GetNextDocumentLineNumber($Id, $FinanceYear);141 $this->Database->insert('DocumentLineCode', array('DocumentLine' => $Id, 'Name' => $Code));142 return $this->Database->insert_id;143 }144 145 function GetFinanceGroupById(string $Id, string $Table): ?array146 {147 $DbResult = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE `Id`= '.$Id);148 if ($DbResult->num_rows == 1) {149 84 $Group = $DbResult->fetch_assoc(); 150 85 return $Group; … … 443 378 } 444 379 445 class Contract extends Model446 {447 static function GetModelDesc(): ModelDesc448 {449 $Desc = new ModelDesc(self::GetClassName());450 $Desc->AddReference('DocumentLine', DocumentLine::GetClassName());451 $Desc->AddReference('BillCode', DocumentLineCode::GetClassName());452 $Desc->AddReference('Subject', Subject::GetClassName());453 $Desc->AddDate('ValidFrom');454 $Desc->AddDate('ValidTo');455 $Desc->AddReference('File', File::GetClassName());456 return $Desc;457 }458 }459 460 380 class FinanceBillingPeriod extends Model 461 381 { -
trunk/Modules/Finance/Import.php
r888 r901 131 131 { 132 132 $Year = date('Y', $Time); 133 $BillCode = Module Finance::Cast($this->System->GetModule('Finance'))->Finance->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year);133 $BillCode = ModuleDocument::Cast($this->System->GetModule('Document'))->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year); 134 134 // TODO: Fixed BankAccount=1, allow to select bank account for import 135 135 $this->Database->insert('FinanceOperation', array('Text' => $Text, -
trunk/Modules/Finance/Manage.php
r887 r901 135 135 136 136 $Year = date('Y', $TimeCreation); 137 $BillCode = $Finance->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year);137 $BillCode = ModuleDocument::Cast($this->System->GetModule('Document'))->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year); 138 138 $SumValue = 0; 139 139 foreach ($Items as $Item) { … … 377 377 $Title = 'Pravidelné vyúčtování služeb'; 378 378 $Content = 'Vyúčtovaní zákazníka <strong>'.$Subject['Name'].'</strong> zastoupeného uživatelem <strong>'. 379 $User['Name'].'</strong> ke dni <strong>'. $this->System->HumanDate(time()).'</strong>.<br/><br/>'."\n".379 $User['Name'].'</strong> ke dni <strong>'.Core::Cast($this->System)->HumanDate(time()).'</strong>.<br/><br/>'."\n". 380 380 'Vaše aktuální služby: '; 381 381 $DbResult = $this->Database->query('SELECT GROUP_CONCAT(`Service`.`Name`) AS `Name` FROM `ServiceCustomerRel` LEFT JOIN `Service` '. … … 441 441 if (file_exists($FullFileName)) 442 442 { 443 $this->Database->update('File', 'Id='.$FileId, array('Name' => $FileName, 'Size' => filesize($FullFileName) ));443 $this->Database->update('File', 'Id='.$FileId, array('Name' => $FileName, 'Size' => filesize($FullFileName), 'Hash' => 'SHA1(CONCAT(Id,Name,Size,Time))')); 444 444 $this->Database->update('FinanceInvoice', 'Id='.$Row['Id'], array('File' => $FileId)); 445 445 $Output .= 'Faktura '.$Row['Id'].' vygenerována do souboru '.$FileName.'<br/>'."\n"; … … 472 472 if (file_exists($FullFileName)) 473 473 { 474 $this->Database->update('File', 'Id='.$FileId, array('Name' => $FileName, 'Size' => filesize($FullFileName) ));474 $this->Database->update('File', 'Id='.$FileId, array('Name' => $FileName, 'Size' => filesize($FullFileName), 'Hash' => 'SHA1(CONCAT(Id,Name,Size,Time))')); 475 475 $this->Database->update('FinanceOperation', 'Id='.$Row['Id'], array('File' => $FileId)); 476 476 $Output .= 'Doklad pro platbu '.$Row['Id'].' vygenerován do souboru '.$FileName.'<br/>'."\n"; -
trunk/Modules/Finance/UserState.php
r888 r901 11 11 } 12 12 13 function ShowFinanceOperation(int $Subject ): string13 function ShowFinanceOperation(int $SubjectId): string 14 14 { 15 $UserOperationTableQuery = '((SELECT `Text`, ` Time`, `Value`, `File`, `BillCode`, NULL AS `PeriodFrom`, NULL AS `PeriodTo`, `DocumentLineCode`.`Name` AS `BillName` '.15 $UserOperationTableQuery = '((SELECT `Text`, `FinanceOperation`.`Time`, `Value`, `File`.`Hash` AS `FileHash`, `BillCode`, NULL AS `PeriodFrom`, NULL AS `PeriodTo`, `DocumentLineCode`.`Name` AS `BillName` '. 16 16 'FROM `FinanceOperation` '. 17 17 'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id`=`FinanceOperation`.`BillCode` '. 18 'WHERE (`Subject`='.$Subject['Id'].') '. 18 'LEFT JOIN `File` ON `File`.`Id`=`FinanceOperation`.`File` '. 19 'WHERE (`Subject`='.$SubjectId.') '. 19 20 ') UNION ALL '. 20 21 '(SELECT (SELECT GROUP_CONCAT(`Description` SEPARATOR ",") FROM `FinanceInvoiceItem` WHERE `FinanceInvoice`=`FinanceInvoice`.`Id`) AS `Text`, '. 21 '`Time`, -`Value`, `File`, `BillCode`, `PeriodFrom`, `PeriodTo`, `DocumentLineCode`.`Name` AS `BillName` FROM `FinanceInvoice` '. 22 '`FinanceInvoice`.`Time`, -`Value`, `File`.`Hash` AS `FileHash`, `BillCode`, `PeriodFrom`, `PeriodTo`, `DocumentLineCode`.`Name` AS `BillName` '. 23 'FROM `FinanceInvoice` '. 22 24 'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id`=`FinanceInvoice`.`BillCode` '. 23 'WHERE (`Subject`='.$Subject['Id'].') AND (`VisibleToUser` = 1)))'; 25 'LEFT JOIN `File` ON `File`.`Id`=`FinanceInvoice`.`File` '. 26 'WHERE (`Subject`='.$SubjectId.') AND (`VisibleToUser` = 1)))'; 24 27 25 28 $Output = '<div style="text-align:center">Výpis finančních operací</div>'; … … 56 59 if ($Row['Value'] > 0) $Row['Value'] = '+'.$Row['Value']; 57 60 if ($Row['BillName'] == '') $Row['BillName'] = 'PDF'; 58 if ($Row['File '] > 0) $Invoice = '<a href="'.$this->System->Link('/file?id='.$Row['File']).'">'.$Row['BillName'].'</a>';61 if ($Row['FileHash'] != '') $Invoice = '<a href="'.$this->System->Link('/file?h='.$Row['FileHash']).'">'.$Row['BillName'].'</a>'; 59 62 else $Invoice = NotBlank($Row['BillName']); 60 63 if ($Row['PeriodFrom'] != '') $Period = HumanDate($Row['PeriodFrom']).' - '.HumanDate($Row['PeriodTo']); … … 102 105 } else return $this->SystemMessage('Položka nenalezena', 'Zákazník nenalezen'); 103 106 104 105 107 // Load subject info 106 108 $DbResult = $this->Database->query('SELECT * FROM `Subject` WHERE `Id`='.$Customer['Subject']); … … 109 111 $Subject = $DbResult->fetch_assoc(); 110 112 } else return $this->SystemMessage('Položka nenalezena', 'Subjekt nenalezen'); 111 112 113 113 114 $Output = '<table width="100%" border="0" cellspacing="0" cellpadding="3"><tr><td valign="top">'; … … 124 125 125 126 // Tabulka operaci 126 $Output .= $this->ShowFinanceOperation($Subject );127 $Output .= $this->ShowFinanceOperation($Subject['Id']); 127 128 128 129 $Output .= '</td><td valign="top">'; -
trunk/Modules/FinanceBankAPI/FileImport.php
r899 r901 44 44 } 45 45 $Year = date('Y', MysqlDateToTime($DbRow['Time'])); 46 $BillCode = $Finance->GetNextDocumentLineNumberId($FinanceGroup['DocumentLine'], $Year);46 $BillCode = ModuleDocument::Cast($this->System->GetModule('Document'))->GetNextDocumentLineNumberId($FinanceGroup['DocumentLine'], $Year); 47 47 $this->Database->insert('FinanceOperation', array('Subject' => $DbRow2['Id'], 'Cash' => 0, 48 48 'ValueUser' => Abs($DbRow['Value']), 'Value' => 0, 'Taxable' => 1, 'BankAccount' => $DbRow['BankAccount'], 'Network' => 1, … … 171 171 { 172 172 $Year = date('Y', $Time); 173 $BillCode = Module Finance::Cast($this->System->GetModule('Finance'))->Finance->GetNextDocumentLineNumberId(173 $BillCode = ModuleDocument::Cast($this->System->GetModule('Document'))->GetNextDocumentLineNumberId( 174 174 $Group['DocumentLine'], $Year); 175 175 $this->Database->insert('FinanceOperation', array('Text' => $Text, -
trunk/Modules/FinanceBankAPI/FinanceBankAPI.php
r899 r901 37 37 $this->License = 'GNU/GPLv3'; 38 38 $this->Description = 'Communication through API to various banks, manual file import'; 39 $this->Dependencies = array(ModuleFinance::GetName(), ModuleScheduler::GetName(), ModuleIS::GetName()); 39 $this->Dependencies = array(ModuleFinance::GetName(), ModuleScheduler::GetName(), ModuleIS::GetName(), 40 ModuleDocument::GetName()); 40 41 $this->Models = array(FinanceBankImport::GetClassName()); 41 42 } -
trunk/Modules/OpeningHours/OpeningHours.php
r899 r901 43 43 if (ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('OpeningHours', 'Edit')) 44 44 { 45 $Output = '<div class="Cent red">';45 $Output = '<div class="Centered">'; 46 46 $DbResult = $this->Database->select('Subject', 'Name', 'Id='.$Id); 47 47 $DbRow = $DbResult->fetch_assoc(); … … 119 119 function ShowAll(): string 120 120 { 121 $Output = '<div class="Centred">'; 122 $DbResult = $this->Database->query('SELECT SubjectOpenTime.*, DATE_FORMAT(SubjectOpenTime.UpdateTime, "%e.%c.%Y") as UpdateTime, Subject.Id, Subject.Name as Name FROM SubjectOpenTime JOIN Subject ON Subject.Id = SubjectOpenTime.Subject ORDER BY Name'); 121 $Output = '<div class="Centered">'; 122 $DbResult = $this->Database->query('SELECT SubjectOpenTime.*, DATE_FORMAT(SubjectOpenTime.UpdateTime, "%e.%c.%Y") as UpdateTime, '. 123 'Subject.Id, Subject.Name as Name FROM SubjectOpenTime '. 124 'JOIN Subject ON Subject.Id = SubjectOpenTime.Subject ORDER BY Name'); 123 125 while ($Subject = $DbResult->fetch_assoc()) 124 126 { … … 190 192 if ($Subject['Notice'] != '') $Output .= 'Poznámka: '.$Subject['Notice'].'<br />'; 191 193 192 if ($Subject['Photo'] != 0) $Output .= '<a href="file?i d='.$Subject['Photo'].'">Fotka</a> ';194 if ($Subject['Photo'] != 0) $Output .= '<a href="file?i='.$Subject['Photo'].'">Fotka</a> '; 193 195 194 196 if (ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('SubjectOpenTime', 'Edit')) -
trunk/Modules/Portal/Portal.php
r900 r901 165 165 if ($User->CheckPermission('Finance', 'DisplaySubjectState')) 166 166 $Output .= '<a href="'.$this->System->Link('/finance/platby/').'">Finance</a><br />'; 167 if ($User->CheckPermission('Customer', 'DisplayCustomerDocuments')) 168 $Output .= '<a href="'.$this->System->Link('/user/dokumenty/').'">Dokumenty</a><br />'; 167 169 if ($User->CheckPermission('Network', 'RegistredHostList')) 168 170 $Output .= '<a href="'.$this->System->Link('/network/user-hosts/').'">Počítače</a><br />'; -
trunk/Modules/Stock/Stock.php
r899 r901 11 11 $this->License = 'GNU/GPLv3'; 12 12 $this->Description = 'Stock and products'; 13 $this->Dependencies = array(ModuleUser::GetName(), ModuleCustomer::GetName(), ModuleNetwork::GetName()); 13 $this->Dependencies = array(ModuleUser::GetName(), ModuleCustomer::GetName(), ModuleNetwork::GetName(), 14 ModuleDocument::GetName()); 14 15 $this->Models = array(Product::GetClassName(), StockSerialNumber::GetClassName(), Stock::GetClassName(), 15 16 StockMoveGroup::GetClassName(), StockMove::GetClassName(), StockMoveItem::GetClassName(), … … 255 256 else $Year = date("Y", $Form->Values['ValidFrom']); 256 257 $Group = $Finance->GetFinanceGroupById($Form->Values['Group'], 'StockMoveGroup'); 257 $Form->Values['BillCode'] = $Finance->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year);258 $Form->Values['BillCode'] = ModuleDocument::Cast($this->System->GetModule('Document'))->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year); 258 259 return $Form->Values; 259 260 } -
trunk/Modules/Subject/Subject.php
r899 r901 43 43 'WHERE `FinanceInvoice`.`Subject`=#Id), 0))'), 44 44 'BankAccounts' => array('Type' => 'TFinanceBankAccountListSubject', 'Caption' => 'Bankovní účty', 'Default' => ''), 45 'Contracts' => array('Type' => 'TContractListSubject', 'Caption' => 'Smlouvy', 'Default' => ''), 45 46 ), 46 47 )); … … 48 49 'Type' => 'ManyToOne', 49 50 'Table' => 'FinanceBankAccount', 51 'Id' => 'Id', 52 'Ref' => 'Subject', 53 'Filter' => '1', 54 )); 55 $this->System->FormManager->RegisterFormType('TContractListSubject', array( 56 'Type' => 'ManyToOne', 57 'Table' => 'Contract', 50 58 'Id' => 'Id', 51 59 'Ref' => 'Subject', -
trunk/Modules/User/UserPage.php
r895 r901 73 73 } else $Actions .= call_user_func($Action).'<br/>'; 74 74 } 75 $Output .= '<div class="Cent red"><table id="MainTable"><tr><td style="vertical-align:top;">';75 $Output .= '<div class="Centered"><table id="MainTable"><tr><td style="vertical-align:top;">'; 76 76 $Output .= $this->Panel('Nabídka uživatele', $Actions); 77 77 $Output .= '</td><td style="vertical-align:top;">'; … … 106 106 $Form->OnSubmit = '?Action=Login'; 107 107 $Output .= $Form->ShowEditForm(); 108 $Output .= '<div class="Cent red"><a href="?Action=UserRegister">Registrovat se</a> '.108 $Output .= '<div class="Centered"><a href="?Action=UserRegister">Registrovat se</a> '. 109 109 '<a href="?Action=PasswordRecovery">Obnova zapomenutého hesla</a></div>'; 110 110 } else … … 125 125 $Form->Values['Password'] = ''; 126 126 $Output .= $Form->ShowEditForm(); 127 $Output .= '<div class="Cent red"><a href="?Action=UserRegister">Registrovat se</a> '.127 $Output .= '<div class="Centered"><a href="?Action=UserRegister">Registrovat se</a> '. 128 128 '<a href="?Action=PasswordRecovery">Obnova zapomenutého hesla</a></div>'; 129 129 } else { 130 //$Output .= '<div class="Cent red">Za 5 sekund budete přesměrováni na <a href="?Action=UserMenu">nabídku uživatele</a></div>';130 //$Output .= '<div class="Centered">Za 5 sekund budete přesměrováni na <a href="?Action=UserMenu">nabídku uživatele</a></div>'; 131 131 //Header('refresh:5;url=?Action=UserMenu'); 132 132 Header('Location: ?Action=UserMenu');
Note:
See TracChangeset
for help on using the changeset viewer.