Changeset 444


Ignore:
Timestamp:
Oct 14, 2012, 10:27:19 PM (12 years ago)
Author:
chronos
Message:
  • Opraveno: Chyby při přepočítávání financí.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/finance/finance.php

    r419 r444  
    170170      $Cash = $Cash[0];
    171171   
    172       $DbResult2 = $this->Database->query('SELECT SUM(Consumption) FROM Product WHERE (User='.$Member['Id'].') AND (used = 1)');
     172      $DbResult2 = $this->Database->query('SELECT SUM(Consumption) FROM Product WHERE (User='.$Member['Id'].') AND (Used = 1)');
    173173      $ConsumptionPlus = $DbResult2->fetch_row();
    174174      $ConsumptionPlus = $ConsumptionPlus[0];
     
    176176      $NetworkDevice = 0;
    177177      $Consumption = 0;
    178       $ID = $Member['NetworkSegment'];
    179       while($ID != '')
    180       {
    181         $DbResult2 = $this->Database->query('SELECT * FROM `NetworkSegment` WHERE `Id`='.$ID);
     178      $Id = $Member['NetworkSegment'];
     179      while(($Id != '') and ($Id != 0))
     180      {
     181        $DbResult2 = $this->Database->query('SELECT * FROM `NetworkSegment` WHERE `Id`='.$Id);
    182182        $Device = $DbResult2->fetch_assoc();
     183        //print_r($Device);
     184        //echo($Id.': '.$NetworkDevice.', '.$Device['Price'].', '.$Device['Users']."<br/>\n");
    183185        $NetworkDevice += $Device['Price'] / $Device['Users'];
    184186        $Consumption += $Device['Consumption'] / $Device['UsersOverheads'];
    185187        //echo($ID.' '.$InternetSegment.' '.$InternetSegmentId.' '.$Row['inet_hw'].' '.$Price.'<br>');
    186         $ID = $Device['Parent'];
     188        $Id = $Device['Parent'];
    187189      }
    188190   
     
    206208        $Consumption = 0;
    207209      }
    208       $this->Database->insert('MemberPayment', array('Member' => $Member['Id'], 'NetworkDevice' => $NetworkDevice, 'MonthlyInternet' => $MonthlyInet, 'MonthlyTotal' => $Monthly, 'MonthlyConsumption' => $this->W2Kc($Consumption), 'Cash' => $Cash, 'MonthlyPlus' => $this->W2Kc($ConsumptionPlus)));
     210      $this->Database->insert('MemberPayment', array('Member' => $Member['Id'],
     211        'NetworkDevice' => $NetworkDevice, 'MonthlyInternet' => $MonthlyInet,
     212        'MonthlyTotal' => $Monthly, 'MonthlyConsumption' => $this->W2Kc($Consumption),
     213        'Cash' => $Cash, 'MonthlyPlus' => $this->W2Kc($ConsumptionPlus)));
    209214    }
    210215    $this->System->Modules['Log']->NewRecord('Finance', 'RecalculateMemberPayment'); 
     
    238243        $Row4 = $DbResult2->fetch_array();
    239244        $this->Database->update('NetworkSegment', 'Id='.$Row4['Id'], array('Users' => ($Row4['Users'] + $Row3[0]), 'UsersOverheads' => ($Row4['UsersOverheads'] + $Row3[0])));
    240         $ID = $Row4['parent'];
     245        $ID = $Row4['Parent'];
    241246      }
    242247      $this->Database->update('NetworkSegment', 'Id='.$NetworkSegment['Id'], array('Price' => $Row2['Price'], 'Users' => ($Row3[0] + $RowP['Users']), 'Consumption' => $Row2['Consumption'], 'UsersOverheads' => ($Row3[0] + $RowP2['UsersOverheads'])));
Note: See TracChangeset for help on using the changeset viewer.