- Timestamp:
- Jan 24, 2010, 8:05:10 AM (15 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/finance/finance.php
r261 r275 23 23 var $ExternalSubject = 96; 24 24 var $MainSubject = 71; 25 25 var $BillingPeriods; 26 26 27 27 function LoadTariffs($Period = 1) … … 92 92 function LoadMonthParameters($Period = 1) // 0 - now, 1 - next month 93 93 { 94 95 96 97 94 $DbResult = $this->Database->query('SELECT * FROM FinanceBillingPeriod'); 95 while($BillingPeriod = $DbResult->fetch_assoc()) 96 $this->BillingPeriods[$BillingPeriod['Id']] = $BillingPeriod; 97 98 98 $DbResult = $this->Database->query('SELECT * FROM finance_charge WHERE period='.$Period); 99 99 $Row = $DbResult->fetch_array(); … … 130 130 } 131 131 132 function GetNextDocumentLineNumber($Id )132 function GetNextDocumentLineNumber($Id, $FinanceYear = 0) 133 133 { 134 $DbResult = $this->Database->query('SELECT Shortcut, NextNumber FROM DocumentLine WHERE Id='.$Id); 135 $DbRow = $DbResult->fetch_assoc(); 136 $Result = $DbRow['Shortcut'].$DbRow['NextNumber']; 137 $this->Database->query('UPDATE DocumentLine SET NextNumber = NextNumber + 1 WHERE Id='.$Id); 134 if($FinanceYear == 0) 135 { 136 // Get latest year 137 $DbResult = $this->Database->select('FinanceYear', '*', '1 ORDER BY Year DESC LIMIT 1'); 138 } else $DbResult = $this->Database->select('FinanceYear', '*', 'Id='.$FinanceYear); 139 $FinanceYear = $DbResult->fetch_assoc(); 140 141 $DbResult = $this->Database->query('SELECT Shortcut, Id FROM DocumentLine WHERE Id='.$Id); 142 $DocumentLine = $DbResult->fetch_assoc(); 143 144 $DbResult = $this->Database->query('SELECT Shortcut FROM DocumentLineSequence WHERE DocumentLine='.Id.' AND FinanceYear'.$FinanceYear['Id']); 145 $Sequence = $DbResult->fetch_assoc(); 146 147 if($Sequence['YearPrefix'] == 1) 148 { 149 $Result = $DbRow['Shortcut'].$Sequence['NextNumber'].'/'.$FinanceYear['Year']; 150 } else $Result = $DocumentLine['Shortcut'].$Sequence['NextNumber']; 151 152 $this->Database->query('UPDATE DocumentLineSequence SET NextNumber = NextNumber + 1 WHERE DocumentLine='.$Id.' AND FinanceYear='.$FinanceYear['Id']); 138 153 return($Result); 139 154 } … … 149 164 $Cash = $DbResult2->fetch_row(); 150 165 $Cash = $Cash[0]; 151 166 152 167 $DbResult2 = $this->Database->query('SELECT SUM(consumption) FROM network_devices WHERE (user='.$Member['Id'].') AND (used = 1)'); 153 168 $ConsumptionPlus = $DbResult2->fetch_row(); … … 166 181 $ID = $Device['parent']; 167 182 } 168 183 169 184 $Monthly = 0; 170 185 $MonthlyInet = $this->Tariffs[$Member['InternetTariffNextMonth']]['Price']; … … 177 192 $Monthly = round($Monthly); 178 193 //echo($Row['fullname'].' '.$Row['inet'].' '.$Monthly.'<br>'); 179 194 180 195 $this->Database->insert('MemberPayment', array('Member' => $Member['Id'], 'NetworkDevice' => $NetworkDevice, 'MonthlyInternet' => $MonthlyInet, 'MonthlyTotal' => $Monthly, 'MonthlyConsumption' => $this->W2Kc($Consumption), 'Cash' => $Cash, 'MonthlyPlus' => $this->W2Kc($ConsumptionPlus))); 181 196 } 182 $this->System->Modules['Log']->NewRecord('Finance', 'RecalculateMemberPayment'); 197 $this->System->Modules['Log']->NewRecord('Finance', 'RecalculateMemberPayment'); 183 198 $this->RecalculateTariffs(1); 184 199 $this->RecalculateTariffs(0); … … 189 204 { 190 205 $Output = 'Aktualizuji parametry segmentů...<br />'; 191 $this->Database->query('UPDATE network_segments SET users = 0, users_overheads = 0'); 206 $this->Database->query('UPDATE network_segments SET users = 0, users_overheads = 0'); // Vynulovat počty uživatelů 192 207 $DbResult = $this->Database->query('SELECT * FROM network_segments'); 193 208 while($NetworkSegment = $DbResult->fetch_array()) … … 219 234 $Row = $DbResult->fetch_array(); 220 235 $DbResult = $this->Database->update('network_segments','id='.$this->InternetSegmentId, array('users' => $Row[0], 'users_overheads' => $Row[0])); 221 236 $this->System->Modules['Log']->NewRecord('Finance', 'RecalculateSegmentParameters'); 222 237 return($Output); 223 238 } -
trunk/sql/updates/266.sql
r267 r275 1 CREATE TABLE `NetworkMangleSubgroup` (2 `Id` INT NOT NULL AUTO_INCREMENT,3 `AddressRange` VARCHAR( 255 ) NOT NULL,4 PRIMARY KEY ( `Id` ) ; 5 6 ALTER TABLE `NetworkMangleSubgroup` ADD INDEX ( `AddressRange` );1 CREATE TABLE IF NOT EXISTS `NetworkMangleSubgroup` ( 2 `Id` int(11) NOT NULL auto_increment, 3 `AddressRange` varchar(255) collate utf8_czech_ci NOT NULL, 4 PRIMARY KEY (`Id`), 5 KEY `AddressRange` (`AddressRange`) 6 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci ; 7 7 8 8 INSERT INTO `NetworkMangleSubgroup` ( -
trunk/sql/updates/272.sql
r272 r275 1 1 ALTER TABLE `NetworkDomainAlias` ADD `Comment` VARCHAR( 255 ) NOT NULL ; 2 3 ALTER TABLE `DocumentLine` ADD `Year` INT NOT NULL AFTER `Name` ;4 UPDATE DocumentLine SET Year = 2009;5 2 6 3 CREATE TABLE IF NOT EXISTS `NetworkInterfacePortable` ( … … 13 10 KEY `NetworkInterface` (`NetworkInterface`), 14 11 KEY `Update` (`Update`) 15 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=4 ; 12 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci; 13 14 15 DROP TABLE IF EXISTS `DocumentLineSequence`; 16 CREATE TABLE IF NOT EXISTS `DocumentLineSequence` ( 17 `Id` int(11) NOT NULL auto_increment, 18 `DocumentLine` int(11) NOT NULL, 19 `FinanceYear` int(11) NOT NULL, 20 `NextNumber` int(11) NOT NULL, 21 `YearPrefix` int(11) NOT NULL, 22 PRIMARY KEY (`Id`), 23 KEY `DocumentLine` (`DocumentLine`), 24 KEY `FinanceYear` (`FinanceYear`) 25 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci; 26 27 28 INSERT INTO DocumentLineSequence (SELECT "" AS Id, Id AS DocumentLine, 3 AS FinanceYear, NextNumber, 0 AS YearPrefix FROM `DocumentLine`); 29 INSERT INTO DocumentLineSequence (SELECT "" AS Id, Id AS DocumentLine, 4 AS FinanceYear, 1 AS NextNumber, 1 AS YearPrefix FROM `DocumentLine`); 30 31 ALTER TABLE `DocumentLine` DROP `NextNumber` ; -
trunk/system/generators/firewall_nat.php
r272 r275 33 33 $DbResult2 = $Database->select('NetworkSubnet', '*', 'Member='.$Member['Id']); 34 34 while($Subnet = $DbResult2->fetch_assoc()) 35 { 35 { 36 36 $Subnet['Name'] = RouterOSIdent('subnet-'.$Subnet['Name']); 37 37 echo($Subnet['Name'].'('.$Subnet['AddressRange'].'/'.$Subnet['Mask'].'), '); 38 $Range = CIDRToAddressRange($Subnet['ExtAddressRange'], $Subnet['ExtMask']); 38 $NewAddress = new NetworkAddressIPv4(); 39 $NewAddress->AddressFromString($Subnet['ExtAddressRange']); 40 $NewAddress->Prefix = $Subnet['ExtMask']; 41 $Range = $NewAddress->GetRange(); 39 42 if($Subnet['ExtMask'] != 32) $Range = $Range['From'].'-'.$Range['To']; 40 43 else $Range = $Range['From']; … … 43 46 $Items[] = array('chain' => 'srcnat', 'src-address' => $Src, 'out-interface' => $InetInterface, 'action' => 'src-nat', 'to-addresses' => $Range, 'comment' => $Subnet['Name'].'-out'); 44 47 45 $Range = CIDRToAddressRange($Subnet['AddressRange'], $Subnet['Mask']); 48 $NewAddress = new NetworkAddressIPv4(); 49 $NewAddress->AddressFromString($Subnet['AddressRange']); 50 $NewAddress->Prefix = $Subnet['Mask']; 51 $Range = $NewAddress->GetRange(); 46 52 if($Subnet['Mask'] != 32) $Range = $Range['From'].'-'.$Range['To']; 47 53 else $Range = $Range['From']; -
trunk/system/generators/netwatch_import.php
r273 r275 17 17 foreach($List as $Properties) 18 18 { 19 if(IsAddressInSubnet($Properties['host'], $Subnet['AddressRange'], $Subnet['Mask'])) 19 $NewAddress = new NetworkAddressIPv4(); 20 $NewAddress->AddressFromString($Subnet['AddressRange']); 21 $NewAddress->Prefix = $Subnet['Mask']; 22 if($NewAddress->Contain($Properties['host'])) 20 23 { 21 24 //echo($Properties['host'].', ');
Note:
See TracChangeset
for help on using the changeset viewer.