Changeset 129 for www/finance/prepocet.php
- Timestamp:
- Jan 5, 2009, 7:31:45 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
www/finance/prepocet.php
r55 r129 164 164 echo("Odečítám měsíční poplatek...<br>\n"); 165 165 166 $BillingPeriodMonthCount = array('never' => 0, 'monthly' => 1, 'quarterly' => 3, 'half-yearly' => 6, 'yearly' => 12); 167 166 168 // 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 } 177 187 echo('Měním aktuální parametry sítě...<br>\n'); 178 188 … … 184 194 $DbResult = $Database->insert('finance_charge', array('period' => 0, 'internet' => $Charge['internet'], 185 195 '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 187 197 echo("Přidávám měsíční přehled...<br>\n"); 188 198 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 191 201 echo("Měním aktuální tarify....<br>\n"); 192 202 … … 199 209 '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'])); 200 210 } 201 211 202 212 echo("Měním aktuální tarify uživatelů...<br>\n"); 203 213 … … 211 221 RecalculateTariffs(); 212 222 RecalculateUsersFinance(); 213 CreateMonthlyOverallBill();223 //CreateMonthlyOverallBill(); 214 224 RecalculateUsersFinance(); 215 225 216 226 // Restart traffic shaping 217 227 $Database->update('services_restart', 'id=3', array('changed' => 1));
Note:
See TracChangeset
for help on using the changeset viewer.