Changeset 129 for www/finance
- Timestamp:
- Jan 5, 2009, 7:31:45 AM (16 years ago)
- Location:
- www/finance
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
www/finance/bills.php
r79 r129 83 83 global $Database; 84 84 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))); 86 86 $BillId = $Database->insert_id; 87 87 foreach($Items as $Item) -
www/finance/monthly_overall.php
r66 r129 5 5 ShowHeader('Měsíční přehledy', 'Měsíční přehledy'); 6 6 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');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><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'); 10 10 while($Month = $DbResult->fetch_array()) 11 11 { 12 12 $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>'); 14 15 15 16 $Total['money'] += $Month['money']; … … 17 18 $Total['consumption_total'] += $Month['consumption_total']; 18 19 $Total['total_paid'] += $Month['total_paid']; 20 $Total['investment'] += $Month['investment']; 19 21 //if($DateParts[1] == '01') echo('<tr><td style="font-size: 4;" colspan="10"> </td></tr>'); 20 22 } 21 echo('<tr><th colspan="2">Celkem</th><th>'.$Total['money'].'</th><th> </th><th> </th><th>'.$Total['administration_total'].'</th><th> </th><th>'.$Total['consumption_total'].'</th><th>'.$Total['total_paid'].'</th><th> </th> ');23 echo('<tr><th colspan="2">Celkem</th><th>'.$Total['money'].'</th><th> </th><th> </th><th>'.$Total['administration_total'].'</th><th> </th><th>'.$Total['consumption_total'].'</th><th>'.$Total['total_paid'].'</th><th> </th><th>'.$Total['investment'].'</tr>'); 22 24 echo('</table>'); 23 25 -
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.