Ignore:
Timestamp:
Mar 3, 2013, 1:03:25 PM (12 years ago)
Author:
chronos
Message:
  • Upraveno: Zobecněn proces aktualizace dat tabulek při přechodu na nové období. Nyní se používá pole Action jakožto akce přidat, změnit, odebrat a ReplaceId jakožto id položky, které se operace týká.
  • Přidáno: Podpora pro uživatelské akce v seznamech v sekci Správa dat.
  • Upraveno: Řešení procesu generování nových faktur a plateb zákazníků při přechodu na nové období.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/finance/finance.php

    r494 r497  
    5454      $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Member` '.
    5555        'LEFT JOIN `ServiceCustomerRel` ON `ServiceCustomerRel`.`Customer`=`Member`.`Id` '.
    56         'WHERE (`ServiceCustomerRel`.`Service`='.$Index.') AND (`Member`.`BillingPeriod` > 1) AND (`Member`.`Blocked`=0)');
     56        'WHERE (`ServiceCustomerRel`.`Service`='.$Index.') AND (`Member`.`BillingPeriod` > 1) '.
     57        'AND (`Member`.`Blocked`=0)');
    5758      $Row = $DbResult->fetch_row();
    5859      $this->Tariffs[$Index]['CustomerCount'] = $Row[0];
     
    103104      $this->BillingPeriods[$BillingPeriod['Id']] = $BillingPeriod;
    104105   
    105     $DbResult = $this->Database->query('SELECT * FROM `FinanceCharge` WHERE `Period`='.$Period);
     106    // Period parameter is not used as it have to be determined from item replacement
     107    $DbResult = $this->Database->query('SELECT * FROM `FinanceCharge` WHERE `ReplaceId` IS NULL LIMIT 1');
    106108    $Row = $DbResult->fetch_array();
    107109    $this->kWh = $Row['kWh'];
     
    203205         'FROM `ServiceCustomerRel` LEFT JOIN '.
    204206         '`Service` ON `Service`.`Id` = `ServiceCustomerRel`.`Service` WHERE `ServiceCustomerRel`.`Customer`='.
    205          $Member['Id'].' AND `ServiceCustomerRel`.`Period`=1');
     207         $Member['Id'].' AND `ServiceCustomerRel`.`Action` IS NULL');
    206208      $DbRow = $DbResult2->fetch_assoc();     
    207209      $Monthly = 0;
     
    259261        $DbResult2 = $this->Database->query('SELECT * FROM NetworkSegment WHERE Id='.$ID);
    260262        $Row4 = $DbResult2->fetch_array();
    261         $this->Database->update('NetworkSegment', 'Id='.$Row4['Id'], array('Users' => ($Row4['Users'] + $Row3[0]), 'UsersOverheads' => ($Row4['UsersOverheads'] + $Row3[0])));
     263        $this->Database->update('NetworkSegment', 'Id='.$Row4['Id'],
     264          array('Users' => ($Row4['Users'] + $Row3[0]), 'UsersOverheads' => ($Row4['UsersOverheads'] + $Row3[0])));
    262265        $ID = $Row4['Parent'];
    263266      }
    264       $this->Database->update('NetworkSegment', 'Id='.$NetworkSegment['Id'], array('Price' => $Row2['Price'], 'Users' => ($Row3[0] + $RowP['Users']), 'Consumption' => $Row2['Consumption'], 'UsersOverheads' => ($Row3[0] + $RowP2['UsersOverheads'])));
     267      $this->Database->update('NetworkSegment', 'Id='.$NetworkSegment['Id'],
     268        array('Price' => $Row2['Price'], 'Users' => ($Row3[0] + $RowP['Users']), 'Consumption' => $Row2['Consumption'], 'UsersOverheads' => ($Row3[0] + $RowP2['UsersOverheads'])));
    265269    }
    266270
     
    268272    $DbResult = $this->Database->select('Member', 'COUNT(*)');
    269273    $Row = $DbResult->fetch_array();
    270     $DbResult = $this->Database->update('NetworkSegment', 'Id='.$this->InternetSegmentId, array('Users' => $Row[0], 'UsersOverheads' => $Row[0]));
     274    $DbResult = $this->Database->update('NetworkSegment', 'Id='.$this->InternetSegmentId,
     275      array('Users' => $Row[0], 'UsersOverheads' => $Row[0]));
    271276    $this->System->Modules['Log']->NewRecord('Finance', 'RecalculateSegmentParameters');
    272277    return($Output);
Note: See TracChangeset for help on using the changeset viewer.