Changeset 129 for www/finance


Ignore:
Timestamp:
Jan 5, 2009, 7:31:45 AM (16 years ago)
Author:
george
Message:
  • Odstraněno: Openwebmail. * Odstraněno: phpMyAdmin. * Upraveno: Mnoho malých úprav a oprav.
Location:
www/finance
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • www/finance/bills.php

    r79 r129  
    8383    global $Database;
    8484 
    85     $Database->insert('finance_bills', array('time_create' => TimeToMysqlDateTime($TimeFrom), 'user_id' => $UserId, 'time_from' => TimeToMysqlDateTime($TimeFrom), 'time_to' => TimeToMysqlDateTime($TimeTo), 'time_due' => TimeToMysqlDateTime($TimeFrom + 15*24*3600)));
     85    $Database->insert('finance_bills', array('time_create' => TimeToMysqlDateTime(time()), 'user_id' => $UserId, 'time_from' => TimeToMysqlDateTime($TimeFrom), 'time_to' => TimeToMysqlDateTime($TimeTo), 'time_due' => TimeToMysqlDateTime($TimeFrom + 15*24*3600)));
    8686    $BillId = $Database->insert_id;
    8787    foreach($Items as $Item)
  • www/finance/monthly_overall.php

    r66 r129  
    55ShowHeader('Měsíční přehledy', 'Měsíční přehledy');
    66
    7 echo('<table cellspacing="0" cellpadding="2" border="1"><tr><th>Rok</th><th>Měsíc</th><th>Internet [Kč]</th><th>Účastníků</th><th>Správa [Kč/účastníka]</th><th>Správa [Kč]</th><th>Spotřeba [Kč/kWh]</th><th>Spotřeba [Kč]</th><th>Obrat [Kč]</th><th>Průměrná cena [Kč/účastníka]</th></tr>');
    8 $Total = array('money' => 0, 'administration_total' => 0, 'consumption_total' => 0, 'total_paid' => 0);
    9 $DbResult = $Database->select('finance_monthly_overall', '*', '1 ORDER BY date DESC');
     7echo('<table cellspacing="0" cellpadding="2" border="1"><tr><th>Rok</th><th>Měsíc</th><th>Internet [Kč]</th><th>Účastníků</th><th>Správa [Kč/účastníka]</th><th>Správa [Kč]</th><th>Spotřeba [Kč/kWh]</th><th>Spotřeba [Kč]</th><th>Obrat [Kč]</th><th>Průměrná cena [Kč/účastníka]</th><th>Investice [Kč]</th></tr>');
     8$Total = array('money' => 0, 'administration_total' => 0, 'consumption_total' => 0, 'total_paid' => 0, 'investment' => 0);
     9$DbResult = $Database->select('finance_monthly_overall', '*', '1 ORDER BY date ASC');
    1010while($Month = $DbResult->fetch_array())
    1111{
    1212  $DateParts = explode('-', $Month['date']);
    13   echo('<tr><td>'.$DateParts[0].'</td><td align="center">'.$MonthNames[$DateParts[1]*1].'</td><td align="center">'.$Month['money'].'</td><td align="center">'.$Month['member_count'].'</td><td align="center">'.$Month['administration'].'</td><td align="center">'.$Month['administration_total'].'</td><td align="center">'.$Month['kWh'].'</td><td align="center">'.$Month['consumption_total'].'</td><td align="center">'.$Month['total_paid'].'</td><td align="center">'.round($Month['total_paid'] / $Month['member_count']).'</td></tr>');
     13  echo('<tr><td>'.$DateParts[0].'</td><td align="center">'.$MonthNames[$DateParts[1]*1].'</td><td align="center">'.$Month['money'].'</td><td align="center">'.$Month['member_count'].'</td><td align="center">'.$Month['administration'].'</td><td align="center">'.$Month['administration_total'].'</td><td align="center">'.$Month['kWh'].'</td><td align="center">'.$Month['consumption_total'].'</td><td align="center">'.$Month['total_paid'].'</td><td align="center">'.round($Month['total_paid'] / $Month['member_count']).'</td><td align="center">'.$Month['investment'].'</td></tr>');
     14//  echo('<tr><td>'.$Month['date'].'</td><td align="center">'.$MonthNames[$DateParts[1]*1].'</td><td align="center">'.$Month['money'].'</td><td align="center">'.$Month['member_count'].'</td><td align="center">'.$Month['administration'].'</td><td align="center">'.$Month['administration_total'].'</td><td align="center">'.$Month['kWh'].'</td><td align="center">'.$Month['consumption_total'].'</td><td align="center">'.$Month['total_paid'].'</td><td align="center">'.round($Month['total_paid'] / $Month['member_count']).'</td></tr>');
    1415
    1516  $Total['money'] += $Month['money'];
     
    1718  $Total['consumption_total'] += $Month['consumption_total'];
    1819  $Total['total_paid'] += $Month['total_paid'];
     20  $Total['investment'] += $Month['investment'];
    1921  //if($DateParts[1] == '01') echo('<tr><td style="font-size: 4;" colspan="10">&nbsp;</td></tr>');
    2022}
    21 echo('<tr><th colspan="2">Celkem</th><th>'.$Total['money'].'</th><th>&nbsp;</th><th>&nbsp;</th><th>'.$Total['administration_total'].'</th><th>&nbsp;</th><th>'.$Total['consumption_total'].'</th><th>'.$Total['total_paid'].'</th><th>&nbsp;</th>');
     23echo('<tr><th colspan="2">Celkem</th><th>'.$Total['money'].'</th><th>&nbsp;</th><th>&nbsp;</th><th>'.$Total['administration_total'].'</th><th>&nbsp;</th><th>'.$Total['consumption_total'].'</th><th>'.$Total['total_paid'].'</th><th>&nbsp;</th><th>'.$Total['investment'].'</tr>');
    2224echo('</table>');
    2325
  • www/finance/prepocet.php

    r55 r129  
    164164  echo("Odečítám měsíční poplatek...<br>\n");
    165165
     166  $BillingPeriodMonthCount = array('never' => 0, 'monthly' => 1, 'quarterly' => 3, 'half-yearly' => 6, 'yearly' => 12);
     167
    166168  // Generuj účetní položky
    167   $DbResult = $Database->query("SELECT *,CONCAT(second_name, ' ', first_name) as fullname FROM users WHERE role=2");
    168   while($Row = $DbResult->fetch_array())
    169   {
    170     echo($Row['fullname'].': '.($Row['plus'] - $Row['monthly'])."<br>\n");
    171 
    172     $BillId = $InvoiceGenerator->CreateBill($Row['id'], array(array('description' => 'Poplatek za připojení k síti', 'price' => ($Row['monthly'] - $Row['plus']), 'quantity' => 1)), time(), time() + (date("t", time()) - 1) * 24 * 3600);
    173 
    174     $Database->insert('finance_operations',array('money' => ($Row['plus'] - $Row['monthly']), 'user' => $Row['id'], 'type' => 2, 'date' => 'NOW()', 'comment' => 'Poplatek za měsíc '.$Mesice[$Mesic], 'group' => 1, 'bill_id' => $BillId));
    175   }
    176 
     169  $DbResult = $Database->query("SELECT *, CONCAT(second_name, ' ', first_name) as fullname FROM users WHERE (role = 2)");
     170  while($User = $DbResult->fetch_array())
     171  {
     172    echo($User['fullname'].': ');
     173    $MonthCount = $BillingPeriodMonthCount[$User['BillingPeriod']];
     174    if(($MonthCount > 0) and (((($Mesic - 1) % 12) % $MonthCount) == 0) and ($User['inet_tarif_now'] != 6))
     175    {
     176      //echo($Mesic.'%'.$MonthCount.'='.($Mesic % $MonthCount).' ');
     177      $PayPerMonth = -($User['plus'] - $User['monthly']);
     178      $PayPerPeriod = $PayPerMonth * $MonthCount;
     179      $PeriodFrom = mktime(0, 0, 0, date('n'), 1, date('Y'));
     180      $PeriodTo = mktime(0, 0, 0, date('n') + $MonthCount - 1, date('t', mktime(0, 0, 0, date('n') + $MonthCount - 1, 1, date('Y'))) , date('Y'));
     181      $TimePeriodText = date('j.n.Y', $PeriodFrom).' - '.date('j.n.Y', $PeriodTo);
     182      echo($TimePeriodText.': '.$PayPerMonth." * ".$MonthCount." = ".$PayPerPeriod."\n");
     183      $BillId = $InvoiceGenerator->CreateBill($User['id'], array(array('description' => 'Připojení k síti', 'price' => $PayPerPeriod, 'quantity' => 1)), $PeriodFrom, $PeriodTo);
     184      $Database->insert('finance_operations', array('money' => -$PayPerPeriod, 'user' => $User['id'], 'type' => 2, 'date' => 'NOW()', 'comment' => 'Připojení k síti za období '.$TimePeriodText, 'group' => 1, 'bill_id' => $BillId));
     185    } else echo("\n");
     186  }
    177187  echo('Měním aktuální parametry sítě...<br>\n');
    178188
     
    184194  $DbResult = $Database->insert('finance_charge', array('period' => 0, 'internet' => $Charge['internet'],
    185195    'internet_speed' => $Charge['internet_speed'], 'internet_speed_reserve' => $Charge['internet_speed_reserve'], 'administration_per_user' => $Charge['administration_per_user'], 'kWh' => $Charge['kWh'], 'base_speed_element' => $Charge['base_speed_element'], 'BaseTariffPrice' => $Charge['BaseTariffPrice'], 'TopTariffPrice' => $Charge['TopTariffPrice']));
    186  
     196
    187197  echo("Přidávám měsíční přehled...<br>\n");
    188198
    189   $Database->insert('finance_monthly_overall', array('date' => 'NOW()', 'money' => $Internet, 'kWh' => $kWh, 'administration' => $Sprava, 'administration_total' => $SpravaCelkem, 'consumption_total' => $CelkemSpotreba, 'total_paid' => $TotalPaid, 'BaseTariffPrice' => $Charge['BaseTariffPrice'], 'TopTariffPrice' => $Charge['TopTariffPrice']));
    190  
     199  $Database->insert('finance_monthly_overall', array('date' => 'NOW()', 'money' => $Internet, 'kWh' => $kWh, 'administration' => $Sprava, 'administration_total' => $SpravaCelkem, 'consumption_total' => $CelkemSpotreba, 'total_paid' => $TotalPaid, 'BaseTariffPrice' => $Charge['BaseTariffPrice'], 'TopTariffPrice' => $Charge['TopTariffPrice'], 'member_count' => $InternetUsers));
     200
    191201  echo("Měním aktuální tarify....<br>\n");
    192202
     
    199209      'speed_factor' => $Tariff['speed_factor'], 'price_units' => $Tariff['price_units'], 'group_id' => $Tariff['group_id'], 'min_speed' => $Tariff['min_speed'], 'max_speed' => $Tariff['max_speed'], 'price' => $Tariff['price']));
    200210  }
    201  
     211
    202212  echo("Měním aktuální tarify uživatelů...<br>\n");
    203213
     
    211221  RecalculateTariffs();
    212222  RecalculateUsersFinance();
    213   CreateMonthlyOverallBill();
     223  //CreateMonthlyOverallBill();
    214224  RecalculateUsersFinance();
    215  
     225
    216226  // Restart traffic shaping
    217227  $Database->update('services_restart', 'id=3', array('changed' => 1));
Note: See TracChangeset for help on using the changeset viewer.