Changeset 275


Ignore:
Timestamp:
Jan 24, 2010, 8:05:10 AM (15 years ago)
Author:
george
Message:
  • Upraveno: Nově rozšířená tabulka dokladových řad pro podporu oddělených účetních roků.
  • Opraveno: Nové volání funkcí pro IPv4 ze skriptů generování nastavení sítě.
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/finance/finance.php

    r261 r275  
    2323  var $ExternalSubject = 96;
    2424  var $MainSubject = 71;
    25         var $BillingPeriods;
     25  var $BillingPeriods;
    2626 
    2727  function LoadTariffs($Period = 1)
     
    9292  function LoadMonthParameters($Period = 1) // 0 - now, 1 - next month
    9393  {   
    94                 $DbResult = $this->Database->query('SELECT * FROM FinanceBillingPeriod');
    95                 while($BillingPeriod = $DbResult->fetch_assoc())
    96                   $this->BillingPeriods[$BillingPeriod['Id']] = $BillingPeriod;
    97                
     94    $DbResult = $this->Database->query('SELECT * FROM FinanceBillingPeriod');
     95    while($BillingPeriod = $DbResult->fetch_assoc())
     96      $this->BillingPeriods[$BillingPeriod['Id']] = $BillingPeriod;
     97   
    9898    $DbResult = $this->Database->query('SELECT * FROM finance_charge WHERE period='.$Period);
    9999    $Row = $DbResult->fetch_array();
     
    130130  }
    131131
    132   function GetNextDocumentLineNumber($Id)
     132  function GetNextDocumentLineNumber($Id, $FinanceYear = 0)
    133133  {   
    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']);
    138153    return($Result);
    139154  }
     
    149164      $Cash = $DbResult2->fetch_row();
    150165      $Cash = $Cash[0];
    151          
     166   
    152167      $DbResult2 = $this->Database->query('SELECT SUM(consumption) FROM network_devices WHERE (user='.$Member['Id'].') AND (used = 1)');
    153168      $ConsumptionPlus = $DbResult2->fetch_row();
     
    166181        $ID = $Device['parent'];
    167182      }
    168          
     183   
    169184      $Monthly = 0;
    170185      $MonthlyInet = $this->Tariffs[$Member['InternetTariffNextMonth']]['Price'];
     
    177192      $Monthly = round($Monthly);
    178193      //echo($Row['fullname'].' '.$Row['inet'].' '.$Monthly.'<br>');
    179                
     194     
    180195      $this->Database->insert('MemberPayment', array('Member' => $Member['Id'], 'NetworkDevice' => $NetworkDevice, 'MonthlyInternet' => $MonthlyInet, 'MonthlyTotal' => $Monthly, 'MonthlyConsumption' => $this->W2Kc($Consumption), 'Cash' => $Cash, 'MonthlyPlus' => $this->W2Kc($ConsumptionPlus)));
    181196    }
    182                 $this->System->Modules['Log']->NewRecord('Finance', 'RecalculateMemberPayment');       
     197    $this->System->Modules['Log']->NewRecord('Finance', 'RecalculateMemberPayment'); 
    183198    $this->RecalculateTariffs(1);
    184199    $this->RecalculateTariffs(0);
     
    189204  {
    190205    $Output = 'Aktualizuji parametry segmentů...<br />';
    191     $this->Database->query('UPDATE network_segments SET users = 0, users_overheads = 0');               // Vynulovat počty uživatelů
     206    $this->Database->query('UPDATE network_segments SET users = 0, users_overheads = 0');     // Vynulovat počty uživatelů
    192207    $DbResult = $this->Database->query('SELECT * FROM network_segments');
    193208    while($NetworkSegment = $DbResult->fetch_array())
     
    219234    $Row = $DbResult->fetch_array();
    220235    $DbResult = $this->Database->update('network_segments','id='.$this->InternetSegmentId, array('users' => $Row[0], 'users_overheads' => $Row[0]));
    221                 $this->System->Modules['Log']->NewRecord('Finance', 'RecalculateSegmentParameters');
     236    $this->System->Modules['Log']->NewRecord('Finance', 'RecalculateSegmentParameters');
    222237    return($Output);
    223238  } 
  • 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` ) ;
     1CREATE 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 ;
    77
    88INSERT INTO `NetworkMangleSubgroup` (
  • trunk/sql/updates/272.sql

    r272 r275  
    11ALTER 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;
    52
    63CREATE TABLE IF NOT EXISTS `NetworkInterfacePortable` (
     
    1310  KEY `NetworkInterface` (`NetworkInterface`),
    1411  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
     15DROP TABLE IF EXISTS `DocumentLineSequence`;
     16CREATE 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
     28INSERT INTO DocumentLineSequence (SELECT "" AS Id, Id AS DocumentLine, 3 AS FinanceYear, NextNumber, 0 AS YearPrefix FROM `DocumentLine`);
     29INSERT INTO DocumentLineSequence (SELECT "" AS Id, Id AS DocumentLine, 4 AS FinanceYear, 1 AS NextNumber, 1 AS YearPrefix FROM `DocumentLine`);
     30
     31ALTER TABLE `DocumentLine` DROP `NextNumber` ;
  • trunk/system/generators/firewall_nat.php

    r272 r275  
    3333  $DbResult2 = $Database->select('NetworkSubnet', '*', 'Member='.$Member['Id']);
    3434  while($Subnet = $DbResult2->fetch_assoc())
    35   {
     35  {   
    3636    $Subnet['Name'] = RouterOSIdent('subnet-'.$Subnet['Name']);
    3737    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();
    3942    if($Subnet['ExtMask'] != 32) $Range = $Range['From'].'-'.$Range['To'];
    4043      else $Range = $Range['From'];
     
    4346    $Items[] = array('chain' => 'srcnat', 'src-address' => $Src, 'out-interface' => $InetInterface, 'action' => 'src-nat', 'to-addresses' => $Range, 'comment' => $Subnet['Name'].'-out');
    4447   
    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();
    4652    if($Subnet['Mask'] != 32) $Range = $Range['From'].'-'.$Range['To'];
    4753      else $Range = $Range['From'];
  • trunk/system/generators/netwatch_import.php

    r273 r275  
    1717  foreach($List as $Properties)
    1818  {
    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']))
    2023    {
    2124      //echo($Properties['host'].', ');
Note: See TracChangeset for help on using the changeset viewer.