Changeset 951
- Timestamp:
- Jul 12, 2023, 9:02:24 PM (18 months ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Application/Core.php
r922 r951 131 131 if (isset($this->Config['Web']['LogSQLQuery'])) 132 132 $this->Database->LogSQLQuery = $this->Config['Web']['LogSQLQuery']; 133 if (isset($this->Config['Web']['MeasureQueryDuration'])) 134 $this->Database->MeasureDuration = $this->Config['Web']['MeasureQueryDuration']; 133 135 } catch (Exception $E) 134 136 { -
trunk/Modules/Contract/Contract.php
r940 r951 21 21 function DoStart(): void 22 22 { 23 $this->DirectoryId = $this->System->Config['Contract']['DirectoryId'];23 $this->DirectoryId = Core::Cast($this->System)->Config['Contract']['DirectoryId']; 24 24 $this->System->RegisterPage(['smlouvy', 'generovat'], 'PageContractGenerate'); 25 $this->System->FormManager->RegisterClass('Contract', array(25 Core::Cast($this->System)->FormManager->RegisterClass('Contract', array( 26 26 'Title' => 'Smlouvy', 27 27 'Table' => 'Contract', … … 42 42 ) 43 43 )); 44 $this->System->FormManager->RegisterFormType('TContract', array(44 Core::Cast($this->System)->FormManager->RegisterFormType('TContract', array( 45 45 'Type' => 'Reference', 46 46 'Table' => 'Contract', … … 129 129 $this->FontSize = 10; 130 130 131 $DbResult = $this->Database->select('Subject', '*', '`Id`='. $this->System->Config['Finance']['MainSubjectId']);131 $DbResult = $this->Database->select('Subject', '*', '`Id`='.Core::Cast($this->System)->Config['Finance']['MainSubjectId']); 132 132 if ($DbResult->num_rows > 0) 133 133 { … … 159 159 } else die('Customer not found.'); 160 160 161 $PrefixMultiplier = new PrefixMultiplier(); 162 $ServiceType = ''; 163 $Price = 0; 164 $MaxSpeed = ''; 165 $MinSpeed = ''; 161 166 $DbResult = $this->Database->query('SELECT * FROM ServiceCustomerRel '. 162 167 'LEFT JOIN Service ON Service.Id=ServiceCustomerRel.Service '. 163 168 'WHERE `ServiceCustomerRel`.`Customer`='.$Customer['Id'].' '); 164 169 if ($DbResult->num_rows > 0) 165 { 166 $Service = $DbResult->fetch_assoc(); 167 } else die('Service not found.'); 168 $ServiceType = $Service['Name']; 169 $Price = $Service['Price']; 170 { 171 while ($Service = $DbResult->fetch_assoc()) 172 { 173 if ($ServiceType != '') $ServiceType .= ', '; 174 $ServiceType .= $Service['Name']; 175 $Price += $Service['Price']; 176 if ($Service['InternetSpeedMax'] != 0) 177 $MaxSpeed = $PrefixMultiplier->Add($Service['InternetSpeedMax'], 'bit/s'); 178 if ($Service['InternetSpeedMin'] != 0) 179 $MinSpeed = $PrefixMultiplier->Add($Service['InternetSpeedMin'], 'bit/s'); 180 } 181 } 170 182 171 183 $DbResult = $this->Database->query('SELECT NetworkInterface.LocalIP, NetworkInterface.MAC FROM NetworkDevice '. … … 175 187 { 176 188 $NetworkInterface = $DbResult->fetch_assoc(); 177 } else die('NetworkDevice not found.'); 178 179 $PrefixMultiplier = new PrefixMultiplier(); 180 $MaxSpeed = $PrefixMultiplier->Add($Service['InternetSpeedMax'], 'bit/s'); 181 $MinSpeed = $PrefixMultiplier->Add($Service['InternetSpeedMin'], 'bit/s'); 182 $IpAddress = $NetworkInterface['LocalIP']; 183 $MacAddress = $NetworkInterface['MAC']; 184 185 $DbResult = $this->Database->query('SELECT * FROM NetworkSubnet '. 189 $IpAddress = $NetworkInterface['LocalIP']; 190 $MacAddress = $NetworkInterface['MAC']; 191 192 $DbResult = $this->Database->query('SELECT * FROM NetworkSubnet '. 186 193 'WHERE CompareNetworkPrefix(INET_ATON("'.$IpAddress.'"), INET_ATON(`AddressRange`), `Mask`)'); 187 if ($DbResult->num_rows > 0) 188 { 189 $Subnet = $DbResult->fetch_assoc(); 190 $DefaultGateway = $Subnet['Gateway']; 191 $NetworkAddressIPv4 = new NetworkAddressIPv4(); 192 $NetworkAddressIPv4->Prefix = $Subnet['Mask']; 193 $NetworkAddressIPv4->Address = $NetworkAddressIPv4->GetNetMask(); 194 $NetMask = $NetworkAddressIPv4->AddressToString(); 195 } else die('Subnet not found.'); 196 197 $Interface = 'Ethernet'; 198 $PrimaryDNS = '10.145.64.8'; 194 if ($DbResult->num_rows > 0) 195 { 196 $Subnet = $DbResult->fetch_assoc(); 197 $DefaultGateway = $Subnet['Gateway']; 198 $NetworkAddressIPv4 = new NetworkAddressIPv4(); 199 $NetworkAddressIPv4->Prefix = $Subnet['Mask']; 200 $NetworkAddressIPv4->Address = $NetworkAddressIPv4->GetNetMask(); 201 $NetMask = $NetworkAddressIPv4->AddressToString(); 202 } else die('Subnet not found.'); 203 $Interface = 'Ethernet'; 204 $PrimaryDNS = '10.145.64.8'; 205 } else 206 { 207 $IpAddress = ''; 208 $MacAddress = ''; 209 $DefaultGateway = ''; 210 $NetMask = ''; 211 $Interface = ''; 212 $PrimaryDNS = ''; 213 } 199 214 200 215 $VarSymbol = $Subject['Id']; 201 216 $DbResult = $this->Database->query('SELECT FinanceBankAccount.*, CONCAT(FinanceBankAccount.Number, "/", FinanceBank.Code) AS NumberFull FROM FinanceBankAccount '. 202 217 'JOIN FinanceBank ON FinanceBank.Id=FinanceBankAccount.Bank '. 203 'WHERE (FinanceBankAccount.`Subject`='. $this->System->Config['Finance']['MainSubjectId'].') AND (FinanceBankAccount.`Use`=1)');218 'WHERE (FinanceBankAccount.`Subject`='.Core::Cast($this->System)->Config['Finance']['MainSubjectId'].') AND (FinanceBankAccount.`Use`=1)'); 204 219 if ($DbResult->num_rows > 0) 205 220 { … … 216 231 $BankAccount = $SupplierBankAccount['NumberFull']; 217 232 218 $DbResult = $this->Database->select('Member', '*', '`Subject`='. $this->System->Config['Finance']['MainSubjectId']);233 $DbResult = $this->Database->select('Member', '*', '`Subject`='.Core::Cast($this->System)->Config['Finance']['MainSubjectId']); 219 234 if ($DbResult->num_rows > 0) 220 235 { … … 224 239 $DbResult = $this->Database->query('SELECT Contact.Value AS Phone FROM User '. 225 240 'LEFT JOIN Contact ON Contact.User=User.ID AND Contact.Category=1 '. 226 'WHERE User.Id='.$SupplierMember['ResponsibleUser'] );241 'WHERE User.Id='.$SupplierMember['ResponsibleUser'].' ORDER BY `Contact`.`Receive` DESC'); 227 242 if ($DbResult->num_rows > 0) 228 243 { … … 233 248 $DbResult = $this->Database->query('SELECT Contact.Value AS Phone FROM User '. 234 249 'LEFT JOIN Contact ON Contact.User=User.ID AND Contact.Category=1 '. 235 'WHERE User.Id='.$Customer['ResponsibleUser'] );250 'WHERE User.Id='.$Customer['ResponsibleUser'].' ORDER BY `Contact`.`Receive` DESC'); 236 251 if ($DbResult->num_rows > 0) 237 252 { … … 243 258 $DbResult = $this->Database->query('SELECT Email, Contact.Value AS ContactEmail FROM User '. 244 259 'LEFT JOIN Contact ON Contact.User=User.ID AND Contact.Category=4 '. 245 'WHERE User.Id='.$Customer['ResponsibleUser'] );260 'WHERE User.Id='.$Customer['ResponsibleUser'].' ORDER BY `Contact`.`Receive` DESC'); 246 261 if ($DbResult->num_rows > 0) 247 262 { … … 260 275 $SupplierPsc = $Supplier['AddressPSC']; 261 276 $SupplierIC = $Supplier['IC']; 262 $SupplierDIC = 'neplátce DPH'; 263 264 $Web = '<a href="https://www.zdechov.net/">www.zdechov.net</a>'; 277 if ($Supplier['PayVAT'] == 1) $SupplierDIC = 'plátce DPH'; 278 else $SupplierDIC = 'neplátce DPH'; 279 280 $Web = '<a href="'.$Supplier['WWW'].'">'.$this->SimplifiedLink($Supplier['WWW']).'</a>'; 265 281 266 282 $CustomerName = $Subject['Name']; … … 302 318 '<strong>II. Poskytované služby:</strong><br/>'. 303 319 '<table width="100%" border="1">'. 304 '<tr><td width="50%">Zvolen ý typ (tarif)služby:</td><td>'.NotBlank($ServiceType).'</td></tr>'.320 '<tr><td width="50%">Zvolené služby:</td><td>'.NotBlank($ServiceType).'</td></tr>'. 305 321 '</table>'. 306 322 '<br/>'. … … 316 332 'Poplatky a pravidelné platby budou na základě této smlouvy hrazeny Odběratelem na bankovní účet Poskytovatele bankovním převodem, nebo složenkou, v uvedené výši a s uvedenou frekvencí. Jako VS bude uvedeno přidělené číslo. V případě prodlení s platbou mohou být uplatněny sankce, či služba pozastavena, nebo zrušena (dle Ceníku a Všeobecných smluvních podmínek).<br/>'. 317 333 '<table width="100%">'. 318 '<tr><td width="25%">Cena služ by:</td><td width="25%">'.NotBlank($Price).' Kč</td><td width="25%">Číslo účtu:</td><td width="25%">'.NotBlank($BankAccount).'</td></tr>'.334 '<tr><td width="25%">Cena služeb:</td><td width="25%">'.NotBlank($Price).' Kč</td><td width="25%">Číslo účtu:</td><td width="25%">'.NotBlank($BankAccount).'</td></tr>'. 319 335 '<tr><td>Pronájem zařízení:</td><td>0 Kč</td><td>Variabilní symbol:</td><td>'.NotBlank($VarSymbol).'</td></tr>'. 320 336 '<tr><td>Frekvence platby:</td><td>'.NotBlank($PaymentPeriod).'</td><td></td><td></td></tr>'. … … 337 353 '</body></html>'; 338 354 return $Output; 355 } 356 357 function SimplifiedLink(string $Link): string 358 { 359 if (substr($Link, 0, 8) == 'https://') $Link = substr($Link, 8); 360 if (substr($Link, 0, 7) == 'http://') $Link = substr($Link, 7); 361 return $Link; 339 362 } 340 363 } -
trunk/Modules/Subject/Subject.php
r914 r951 44 44 'BankAccounts' => array('Type' => 'TFinanceBankAccountListSubject', 'Caption' => 'Bankovní účty', 'Default' => ''), 45 45 'Contracts' => array('Type' => 'TContractListSubject', 'Caption' => 'Smlouvy', 'Default' => ''), 46 'Contacts' => array('Type' => 'TContactListSubject', 'Caption' => 'Kontakty', 'Default' => ''), 46 47 ), 47 48 )); … … 56 57 'Type' => 'ManyToOne', 57 58 'Table' => 'Contract', 59 'Id' => 'Id', 60 'Ref' => 'Subject', 61 'Filter' => '1', 62 )); 63 $this->System->FormManager->RegisterFormType('TContactListSubject', array( 64 'Type' => 'ManyToOne', 65 'Table' => 'Contact', 58 66 'Id' => 'Id', 59 67 'Ref' => 'Subject', -
trunk/Modules/User/User.php
r916 r951 50 50 Core::Cast($this->System)->RegisterPage(['user'], 'PageUser'); 51 51 Core::Cast($this->System)->RegisterPageBarItem('Top', 'User', array($this, 'TopBarCallback')); 52 $this->System->FormManager->RegisterClass('UserLogin', array(52 Core::Cast($this->System)->FormManager->RegisterClass('UserLogin', array( 53 53 'Title' => 'Přihlášení uživatele', 54 54 'SubmitText' => 'Přihlásit', … … 60 60 ), 61 61 )); 62 $this->System->FormManager->RegisterClass('UserOptions', array(62 Core::Cast($this->System)->FormManager->RegisterClass('UserOptions', array( 63 63 'Title' => 'Základní nastavení', 64 64 'Table' => 'User', … … 72 72 ), 73 73 )); 74 $this->System->FormManager->RegisterClass('UserRegister', array(74 Core::Cast($this->System)->FormManager->RegisterClass('UserRegister', array( 75 75 'Title' => 'Registrace uživatele', 76 76 'SubmitText' => 'Registrovat', … … 84 84 ), 85 85 )); 86 $this->System->FormManager->RegisterClass('PasswordRecovery', array(86 Core::Cast($this->System)->FormManager->RegisterClass('PasswordRecovery', array( 87 87 'Title' => 'Obnova hesla', 88 88 'SubmitText' => 'Obnovit', … … 93 93 ), 94 94 )); 95 $this->System->FormManager->RegisterClass('APIToken', array(95 Core::Cast($this->System)->FormManager->RegisterClass('APIToken', array( 96 96 'Title' => 'Přístupový token', 97 97 'Table' => 'APIToken', … … 101 101 ), 102 102 )); 103 $this->System->FormManager->RegisterClass('User', array(103 Core::Cast($this->System)->FormManager->RegisterClass('User', array( 104 104 'Title' => 'Uživatelé', 105 105 'Table' => 'User', … … 120 120 ), 121 121 )); 122 $this->System->FormManager->RegisterClass('PermissionUserAssignment', array(122 Core::Cast($this->System)->FormManager->RegisterClass('PermissionUserAssignment', array( 123 123 'Title' => 'Oprávnění uživatelů', 124 124 'Table' => 'PermissionUserAssignment', … … 129 129 ), 130 130 )); 131 $this->System->FormManager->RegisterClass('PermissionGroup', array(131 Core::Cast($this->System)->FormManager->RegisterClass('PermissionGroup', array( 132 132 'Title' => 'Skupiny oprávnění', 133 133 'Table' => 'PermissionGroup', … … 138 138 ), 139 139 )); 140 $this->System->FormManager->RegisterClass('PermissionGroupAssignment', array(140 Core::Cast($this->System)->FormManager->RegisterClass('PermissionGroupAssignment', array( 141 141 'Title' => 'Přiřazení skupin oprávnění', 142 142 'Table' => 'PermissionGroupAssignment', … … 147 147 ), 148 148 )); 149 $this->System->FormManager->RegisterClass('PermissionOperation', array(149 Core::Cast($this->System)->FormManager->RegisterClass('PermissionOperation', array( 150 150 'Title' => 'Operace oprávnění', 151 151 'Table' => 'PermissionOperation', … … 158 158 ), 159 159 )); 160 $this->System->FormManager->RegisterFormType('TUser', array(160 Core::Cast($this->System)->FormManager->RegisterFormType('TUser', array( 161 161 'Type' => 'Reference', 162 162 'Table' => 'User', … … 165 165 'Filter' => '1', 166 166 )); 167 $this->System->FormManager->RegisterFormType('TPermissionGroup', array(167 Core::Cast($this->System)->FormManager->RegisterFormType('TPermissionGroup', array( 168 168 'Type' => 'Reference', 169 169 'Table' => 'PermissionGroup', … … 172 172 'Filter' => '1', 173 173 )); 174 $this->System->FormManager->RegisterFormType('TPermissionGroupAssignment', array(174 Core::Cast($this->System)->FormManager->RegisterFormType('TPermissionGroupAssignment', array( 175 175 'Type' => 'Reference', 176 176 'Table' => 'PermissionGroupAssignment', … … 179 179 'Filter' => '1', 180 180 )); 181 $this->System->FormManager->RegisterFormType('TPermissionOperation', array(181 Core::Cast($this->System)->FormManager->RegisterFormType('TPermissionOperation', array( 182 182 'Type' => 'Reference', 183 183 'Table' => 'PermissionOperation', -
trunk/Packages/Common/Database.php
r929 r951 43 43 public bool $ShowSQLQuery; 44 44 public bool $LogSQLQuery; 45 public bool $MeasureDuration; 45 46 public string $LogFile; 46 47 public string $Database; … … 56 57 $this->ShowSQLQuery = false; 57 58 $this->LogSQLQuery = false; 59 $this->MeasureDuration = false; 58 60 $this->LogFile = dirname(__FILE__).'/../../Query.log'; 59 61 $this->Database = ''; … … 93 95 { 94 96 if (!$this->Connected()) throw new Exception(T('Not connected to database')); 95 if (($this->ShowSQLQuery == true) or ($this->LogSQLQuery == true)) $QueryStartTime = microtime_float(); 97 $Duration = ''; 98 if ($this->MeasureDuration) 99 { 100 $QueryStartTime = microtime_float(); 101 } 96 102 $this->LastQuery = $Query; 97 if (($this->ShowSQLQuery == true) or ($this->LogSQLQuery == true))98 {99 $Time = round(microtime_float() - $QueryStartTime, 4);100 $Duration = ' ; '.$Time. ' s';101 }102 if (($this->LogSQLQuery == true) and ($Time != 0))103 file_put_contents($this->LogFile, $Query.$Duration."\n", FILE_APPEND);104 if ($this->ShowSQLQuery == true)105 echo('<div style="border-bottom-width: 1px; border-bottom-style: solid; '.106 'padding-bottom: 3px; padding-top: 3px; font-size: 12px; font-family: Arial;">'.$Query.$Duration.'</div>'."\n");107 103 $Result = new DatabaseResult(); 108 104 $Statement = $this->PDO->query($Query); … … 119 115 echo('<div><strong>SQL Error: </strong>'.$this->Error.'<br />'.$Query.'</div>'); 120 116 throw new Exception('SQL Error: '.$this->Error.', Query: '.$Query); 117 } 118 if ($this->MeasureDuration) 119 { 120 $Time = round(microtime_float() - $QueryStartTime, 4); 121 $Duration = ' ; '.$Time. ' s'; 122 } 123 if ($this->ShowSQLQuery == true) 124 { 125 echo('<div style="border-bottom-width: 1px; border-bottom-style: solid; '. 126 'padding-bottom: 3px; padding-top: 3px; font-size: 12px; font-family: Arial;">'.$Query.$Duration.'</div>'."\n"); 127 } 128 if ($this->LogSQLQuery == true) 129 { 130 file_put_contents($this->LogFile, $Query.$Duration."\n", FILE_APPEND); 121 131 } 122 132 return $Result;
Note:
See TracChangeset
for help on using the changeset viewer.