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ě.
File:
1 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  } 
Note: See TracChangeset for help on using the changeset viewer.