Changeset 951 for trunk/Modules/Contract/Contract.php
- Timestamp:
- Jul 12, 2023, 9:02:24 PM (18 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note:
See TracChangeset
for help on using the changeset viewer.