Changeset 494 for trunk/finance


Ignore:
Timestamp:
Mar 1, 2013, 10:44:18 PM (12 years ago)
Author:
chronos
Message:
  • Opraveno: Přepočítávání stavu placení zákazníků.
Location:
trunk/finance
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/finance/finance.php

    r486 r494  
    5959      $Tariffs['CustomerCount'] = $Row[0];
    6060     
    61       //echo($Tariff['Name'].' '.$Tariff['MemberCount'].' '.$Tariff['SpeedMax'] * $Tariff['MemberCount'].' '.$ResidualSpeed.'<br />');
    6261      switch($Tariff['Category'])
    6362      {
     
    7372      }
    7473    }
    75     $Aggregation = $ResidualSpeed / $TotalMaxSpeed;
    76     //echo($TotalMaxSpeed.' '.$Aggregation.'<br />');
     74    if($TotalMaxSpeed > 0) $Aggregation = $ResidualSpeed / $TotalMaxSpeed;
     75      else $Aggregation = 1;
    7776 
    7877    // Recalculate price
     
    8281      {
    8382        case 1:
    84           // Přepočítávání rychlostí koliduje s rozdílovým zapisováním stromu front do mikrotiku. Vždy při změně počtu počítačů či domácností docházelo ke změně minima a přepočtu všeho.
     83          // Přepočítávání rychlostí koliduje s rozdílovým zapisováním stromu front do mikrotiku.
     84          // Vždy při změně počtu počítačů či domácností docházelo ke změně minima a přepočtu všeho.
    8585          //$Tariff['InternetSpeedMin'] = round($Tariff['InternetSpeedMax'] * $Aggregation);
    8686          break;
     
    9090          break;
    9191      }
    92       //echo('MinSpeed: '.$Tariff['InternetSpeedMin'].'<br />');
    9392      $this->Database->update('Service', 'Id='.$Tariff['Id'],
    9493        array('InternetSpeedMin' => ($Tariff['InternetSpeedMin'] / 1024),
     
    196195        $DbResult2 = $this->Database->query('SELECT * FROM `NetworkSegment` WHERE `Id`='.$Id);
    197196        $Device = $DbResult2->fetch_assoc();
    198         //print_r($Device);
    199         //echo($Id.': '.$NetworkDevice.', '.$Device['Price'].', '.$Device['Users']."<br/>\n");
    200         $NetworkDevice += $Device['Price'] / $Device['Users'];
    201         $Consumption += $Device['Consumption'] / $Device['UsersOverheads'];
    202         //echo($ID.' '.$InternetSegment.' '.$InternetSegmentId.' '.$Row['inet_hw'].' '.$Price.'<br>');
     197        if($Device['Users'] > 0) $NetworkDevice += $Device['Price'] / $Device['Users'];
     198        if($Device['UsersOverheads'] > 0) $Consumption += $Device['Consumption'] / $Device['UsersOverheads'];
    203199        $Id = $Device['Parent'];
    204200      }
     
    210206      $DbRow = $DbResult2->fetch_assoc();     
    211207      $Monthly = 0;
    212       $MonthlyInet = $DbRow['Price'];
     208      if($DbRow['Price'] != '') $MonthlyInet = $DbRow['Price'];
     209        else $MonthlyInet = 0;
     210     
    213211      //if($Row['inet'] == 1)
    214212      $Monthly += $MonthlyInet;
     
    216214      $Monthly -= $Member['Hire'];
    217215      //if($Row['overheads'] == 1) $Monthly += $Sprava; // + W2Kc($Consumption);
    218       //echo($Row['fullname'].' '.$Row['inet'].' '.$Monthly.'<br>');
    219216      $Monthly = round($Monthly);
    220       //echo($Row['fullname'].' '.$Row['inet'].' '.$Monthly.'<br>')
    221217     
    222218      if($Member['BillingPeriodNext'] == 1)
     
    246242    while($NetworkSegment = $DbResult->fetch_array())
    247243    {
    248       //echo('Segment '.$Row['name'].'<br>');
    249244      $DbResult2 = $this->Database->query('SELECT `Users` FROM `NetworkSegment` WHERE `Id`='.$NetworkSegment['Id']);
    250245      $RowP = $DbResult2->fetch_array();
     
    262257      while($ID != 0)
    263258      {
    264         //echo($ID.', ');
    265259        $DbResult2 = $this->Database->query('SELECT * FROM NetworkSegment WHERE Id='.$ID);
    266260        $Row4 = $DbResult2->fetch_array();
  • trunk/finance/user_state.php

    r486 r494  
    6363   
    6464    // Account state   
    65     $UserOperationTableQuery = '((SELECT Text, Time, Value AS Value, Bill, BillCode, NULL AS PeriodFrom, NULL AS PeriodTo '.
     65    $UserOperationTableQuery = '((SELECT Text, Time, Value AS Value, File, BillCode, NULL AS PeriodFrom, NULL AS PeriodTo '.
    6666      'FROM FinanceOperation WHERE (Subject='.$Subject['Id'].')) UNION ALL '.
    6767      '(SELECT (SELECT GROUP_CONCAT(Description SEPARATOR ",") FROM FinanceInvoiceItem WHERE FinanceInvoice=FinanceInvoice.Id) AS Text, '.
    68       'TimeCreation as Time, -Value as Value, Bill, BillCode, PeriodFrom, PeriodTo FROM FinanceInvoice WHERE (Subject='.$Subject['Id'].')) ORDER BY Time DESC) AS T1';
     68      'TimeCreation as Time, -Value as Value, File, BillCode, PeriodFrom, PeriodTo FROM FinanceInvoice WHERE (Subject='.$Subject['Id'].')) ORDER BY Time DESC) AS T1';
    6969    $DbResult = $this->Database->query('SELECT SUM(T1.Value) AS Total FROM '.$UserOperationTableQuery);
    7070    $DbRow = $DbResult->fetch_array();
     
    8787      if($Row['Value'] > 0) $Row['Value'] = '+'.$Row['Value'];
    8888      if($Row['BillCode'] == '') $Row['BillCode'] = 'PDF';
    89       if($Row['Bill'] > 0) $Invoice = '<a href="bill.php?Id='.$Row['Bill'].'">'.$Row['BillCode'].'</a>';
     89      if($Row['File'] > 0) $Invoice = '<a href="'.$this->System->Link('/FileDownload.php?Id='.$Row['File']).'">'.$Row['BillCode'].'</a>';
    9090        else $Invoice = '&nbsp;';
    9191      if($Row['PeriodFrom'] != '') $Period = HumanDate($Row['PeriodFrom']).' - '.HumanDate($Row['PeriodTo']);
Note: See TracChangeset for help on using the changeset viewer.