Changeset 152 for www/finance/clenove.php
- Timestamp:
- Feb 16, 2009, 2:09:57 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
www/finance/clenove.php
r147 r152 1 1 <?php 2 include('../ style.php');2 include('../global.php'); 3 3 include('include.php'); 4 include('bills.php');5 4 RecalculateTariffs(1); 6 5 7 if(array_key_exists('id',$_GET)) $UserID = $_GET['id']; 8 if(!array_key_exists('show',$_GET)) $_GET['show'] = ''; 9 switch($_GET['show']) 6 class FinanceUserList extends Page 10 7 { 11 default: 12 ShowHeader('Finance účastníka', 'Finance účastníka'); 13 $UserID = GetMemberByIP(GetRemoteAddress()); 8 var $FullTitle = 'Seznam účastníků sítě'; 9 var $ShortTitle = 'Seznam účastníků'; 14 10 15 $DbResult = $Database->query("SELECT *,CONCAT(second_name, ' ', first_name) as fullname FROM users WHERE id=".$UserID); 16 $Row2 = $DbResult->fetch_array(); 17 $TarifName = $Tarify[$Row2['inet_tarif_next']]['name']; 18 echo('<table width="100%" border="0" cellspacing="0" cellpadding="3"><tr><td valign="top">'); 19 20 // Tabulka operaci 21 echo('Výpis operací pro účastníka '.$Row2['fullname'].':<br>'); 22 echo('<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3"><tr><th>Datum</th><th>Popis</th><th>Částka [Kč]</th><th>Doklad</th></tr>'); 23 $Operations = array(); 24 $DbResult = $Database->query('(SELECT Time, Value, Text, Bill FROM FinanceCashFlow WHERE Subject='.$UserID.') UNION ALL '. 25 '(SELECT TimeCreation as Time, (-Value) as Value, Text, Bill FROM FinanceClaimsLiabilities WHERE Subject='.$UserID.') ORDER BY Time DESC'); 26 while($DbRow = $DbResult->fetch_array()) 27 $Operations[] = $DbRow; 28 foreach($Operations as $Row) 11 function Show() 12 { 13 global $Tarify; 14 15 if($this->System->Modules['User']->CheckPermission('Finance', 'SubjectList')) 29 16 { 30 if($Row['Value'] > 0) $Row['Value'] = '+'.$Row['Value']; 31 if($Row['Bill'] > 0) $Invoice = '<a href="?show=bill&id='.$Row['Bill'].'">PDF</a>'; else $Invoice = ' '; 32 echo('<tr><td align="right">'.HumanDate($Row['Time']).'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value'].'</td><td>'.$Invoice.'</td></tr>'); 33 } 34 //echo('<tr><td> </td><td>-'.$Row2['network_device'].'</td><td>Proměnná cena za zařízení</td></tr> 35 echo('</table>'); 36 $DbResult = $Database->query('SELECT ((SELECT COALESCE(SUM(Value), 0) FROM FinanceCashFlow WHERE Subject='.$UserID.') + '. 37 '(SELECT COALESCE(SUM(-Value), 0) FROM FinanceClaimsLiabilities WHERE Subject='.$UserID.')) as Total'); 38 $DbRow = $DbResult->fetch_array(); 39 $Total = $DbRow['Total']; 40 echo('<h3><strong>Stav účtu: </strong>'.$Total.' Kč</h3><br>'); 41 echo('</td><td valign="top">'); 17 // Seznam členů 18 $Output = 'Seznam účastníků:<br>'. 19 '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'. 20 '<tr><th>Jméno</th>'; 21 //<th>Cena za zařízení [Kč]</th> 22 $Output .= '<th>Měsíční poplatek [Kč]</th><th>Stav účtu [Kč]</th><th>Běžící tarif</th><th>Příští tarif</th><th>Poznámky</th></tr>'; 23 $TotalDevice = 0; 24 $TotalMonth = 0; 25 $TotalCash = 0; 26 $DbResult = $this->Database->query('SELECT *, CONCAT(users.second_name, " ", users.first_name) as Fullname, ((SELECT COALESCE(SUM(Value), 0) FROM FinanceCashFlow WHERE Subject=users.id) + (SELECT COALESCE(SUM(-Value), 0) FROM FinanceClaimsLiabilities WHERE Subject=users.id)) as Cash FROM users WHERE role=2 ORDER BY fullname'); 42 27 43 if($Row2['role'] == 2) 44 { 45 echo('Variabilní symbol pro platby: <strong>'.$Row2['id'].'</strong><br><br>'); 46 47 // Měsíční bilance 48 if($Row2['inet'] == 1) $InternetPrice = round($Row2['monthly_inet']); else $InternetPrice = 0; 49 if($Row2['overheads'] == 0) 50 { 51 $PoplatekSprava = 0; 52 $PoplatekSpotreba = 0; 53 $PrijemSpotreba = $Row2['plus']; 54 } else { 55 $PoplatekSprava = $Sprava; 56 $PoplatekSpotreba = $Row2['consumption']; 57 $PrijemSpotreba = $Row2['plus']; 58 } 59 echo('Rozpis měsíčního poplatku:<br><table border="1" cellspacing="0" cellpadding="3">'. 60 '<tr><th>Část</th><th>Cena [Kč]</th></tr>'. 61 '<tr><td>Internet - tarif '.$TarifName.'</td><td>'.$InternetPrice.'</td></tr>'. 62 //'<tr><td>Správa</td><td>'.$PoplatekSprava.'</td></tr>'. 63 //'<tr><td>Poplatek za spotřebu</td><td>'.$PoplatekSpotreba.'</td></tr>'. 64 '<tr><td>Příjem za spotřebu</td><td>'.(-1*$PrijemSpotreba) .'</td></tr>'. 65 '<tr><td><strong>Celkem</strong></td><td><strong>'.($InternetPrice // + $PoplatekSprava + $PoplatekSpotreba 66 - $PrijemSpotreba).'</strong></td></tr></table>'); 67 //echo('Tarif pro příští měsíc: '.$Tarify[$Row2['inet_tarif_next']]['name'].'<br><br>'); 68 echo('<br>'); 69 70 /* 71 72 // Rozpis ceny za zařízení 73 echo('Výpis podílu na zařízení segmentů:'); 74 echo('<table border="1" cellspacing="0" cellpadding="3"><tr><th>Název segmentu</th><th>Cena [Kč]</th><th>Uživatelů</th><th>Podíl [Kč]</th></tr>'); 75 $ID = $Row2['network_segment']; 76 $Money = 0; 77 while($ID > 0) 78 { 79 $DbResult = $Database->query("SELECT * FROM network_segments WHERE id=".$ID); 80 $Row = $DbResult->fetch_array(); 81 if(!(($Row2['inet_hw'] == 0) and ($ID == $InternetSegmentId))) 82 { 83 $Money += $Row['price']/$Row['users']; 84 echo('<tr><td>'.$Row['name'].'</td><td>'.$Row['price'].'</td><td>'.$Row['users'].' </td><td>'.round($Row['price']/$Row['users']).'</td></tr>'); 85 } 86 $ID = $Row['parent']; 87 } 88 echo('<tr><td><strong>Celkem</strong></td><td> </td><td> </td><td><strong>'.round($Money).'</strong></td></tr>'); 89 echo('</table><br>'); 90 91 // Rozpis platba spotřeby segmentů 92 echo('Výpis podílu na spotřebě segmentů:'); 93 echo('<table border="1" cellspacing="0" cellpadding="3"><tr><th>Název segmentu</th><th>Cena [Kč]</th><th>Uživatelů</th><th>Podíl [Kč]</th></tr>'); 94 $ID = $Row2['network_segment']; 95 $Money = 0; 96 while($ID>0) 97 { 98 $DbResult = $Database->query("SELECT * FROM network_segments WHERE id=".$ID); 99 $Row = $DbResult->fetch_array(); 100 $Money += round(W2Kc($Row['consumption'])/$Row['users_overheads']); 101 echo('<tr><td>'.$Row['name'].'</td><td>'.W2Kc($Row['consumption']).'</td><td>'.$Row['users_overheads'].' </td><td>'.round(W2Kc($Row['consumption'])/$Row['users_overheads']).'</td></tr>'); 102 $ID = $Row['parent']; 103 } 104 echo('<tr><td><strong>Celkem</strong></td><td> </td><td> </td><td><strong>'.round($Money).'</strong></td></tr>'); 105 echo('</table><br>'); 106 */ 107 108 echo('Měsíční příjem za spotřebu zařízení umístěných u uživatele:<br>'); 109 echo('<table border="1" cellspacing="0" cellpadding="3"><tr><th>Název zařízení</th><th>Spotřeba [W]</th><th>Příjem [Kč]</th></tr>'); 110 $DbResult = $Database->query("SELECT * FROM network_devices WHERE user=".$UserID." AND used=1"); 111 $TotalW = 0; 112 $TotalPrice = 0; 28 //$DbResult = $Database->query("SELECT *,CONCAT(second_name, ' ', first_name) as fullname FROM users WHERE role=2 ORDER BY fullname"); 113 29 while($Row = $DbResult->fetch_array()) 114 30 { 115 echo('<tr><td>'.$Row['name'].'</td><td>'.$Row['consumption'].'</td><td>'.W2Kc($Row['consumption']).'</td></tr>'); 116 $TotalW += $Row['consumption']; 117 $TotalPrice += W2Kc($Row['consumption']); 31 $Monthly = $Row['monthly'] - $Row['plus']; 32 if($Row['hw'] == 0) $Monthly = '(trvale nepřipojen) '.(-$Row['plus']); 33 else 34 { 35 if($Row['overheads'] == 0) $Monthly = '(dočasně nepřipojen) '.$Monthly; 36 else 37 { 38 if($Row['inet'] == 0) $Monthly = '(bez internetu) '.$Monthly; 39 else $Monthly = $Monthly; 40 } 41 } 42 //$Row['cash'] = $Row['AdvancesIn'] - $Row['AdvancesOut'] + $Row['Liabilities'] - $Row['Claims']; 43 $TotalCash += $Row['Cash']; 44 if($Row['Cash'] < 0) $Row['Cash'] = '<span style="color: red;">'.$Row['Cash'].'</span>'; 45 $Tarif = $Tarify[$Row['inet_tarif_now']]['name']; 46 $PristiTarif = $Tarify[$Row['inet_tarif_next']]['name']; 47 $Output .= '<tr><td><a href="user_state.php?id='.$Row['id'].'">'.$Row['Fullname'].'</a></td>'; 48 //<td align="right">'.$Row['network_device'].'</td> 49 $Output .= '<td align="right">'.$Monthly.'</td><td align="right">'.$Row['Cash'].'</td><td align="center">'.$Tarif.'</td><td align="center">'.$PristiTarif.'</td><td>'.$Row['notice'].' </td></tr>'; 50 $TotalDevice += $Row['network_device']; 51 $TotalMonth += ($Row['monthly'] - $Row['plus']); 118 52 } 119 echo('<tr><td><strong>Celkem</strong></td><td><strong>'.$TotalW.'</strong></td><td><strong>'.$TotalPrice.'</strong></td></tr>'); 120 echo('</table>'); 121 } 122 echo('</td></tr></table>'); 123 ShowFooter(); 124 break; 125 case 'bill': 126 $InvoiceGenerator->ShowStoredBill($_GET['id']); 127 break; 128 case 'admin_user_list': 129 ShowHeader('Seznam účastníků sítě', 'Seznam účastníků'); 130 // Seznam členů 131 echo('Seznam účastníků:<br>'. 132 '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'. 133 '<tr><th>Jméno</th>'); 134 //<th>Cena za zařízení [Kč]</th> 135 echo('<th>Měsíční poplatek [Kč]</th><th>Stav účtu [Kč]</th><th>Běžící tarif</th><th>Příští tarif</th><th>Poznámky</th></tr>'); 136 $TotalDevice = 0; 137 $TotalMonth = 0; 138 $TotalCash = 0; 139 $DbResult = $Database->query('SELECT *, CONCAT(users.second_name, " ", users.first_name) as Fullname, ((SELECT COALESCE(SUM(Value), 0) FROM FinanceCashFlow WHERE Subject=users.id) + '. 140 '(SELECT COALESCE(SUM(-Value), 0) FROM FinanceClaimsLiabilities WHERE Subject=users.id)) as Cash FROM users WHERE role=2 ORDER BY fullname'); 53 $Output .= '<tr><td><strong>Celkem</strong></td>'; 54 //<td align="right"><strong>'.$TotalDevice.'</strong></td> 55 $Output .= '<td align="right"><strong>'.$TotalMonth.'</strong></td><td align="right"><strong>'.$TotalCash.'</strong></td><td align="right"> </td><td align="right"> </td><td align="right"> </td></tr>'; 56 $Output .= '</table>'; 57 } else $Output = 'Nemáte oprávnění'; 58 return($Output); 59 } 60 } 141 61 142 //$DbResult = $Database->query("SELECT *,CONCAT(second_name, ' ', first_name) as fullname FROM users WHERE role=2 ORDER BY fullname"); 143 while($Row = $DbResult->fetch_array()) 144 { 145 $Monthly = $Row['monthly'] - $Row['plus']; 146 if($Row['hw'] == 0) $Monthly = '(trvale nepřipojen) '.(-$Row['plus']); 147 else { 148 if($Row['overheads'] == 0) $Monthly = '(dočasně nepřipojen) '.$Monthly; 149 else { 150 if($Row['inet'] == 0) $Monthly = '(bez internetu) '.$Monthly; 151 else $Monthly = $Monthly; 152 } 153 } 154 //$Row['cash'] = $Row['AdvancesIn'] - $Row['AdvancesOut'] + $Row['Liabilities'] - $Row['Claims']; 155 $TotalCash += $Row['Cash']; 156 if($Row['Cash'] < 0) $Row['Cash'] = '<span style="color: red;">'.$Row['Cash'].'</span>'; 157 $Tarif = $Tarify[$Row['inet_tarif_now']]['name']; 158 $PristiTarif = $Tarify[$Row['inet_tarif_next']]['name']; 159 echo('<tr><td><a href="?show=user&id='.$Row['id'].'">'.$Row['Fullname'].'</a></td>'); 160 //<td align="right">'.$Row['network_device'].'</td> 161 echo('<td align="right">'.$Monthly.'</td><td align="right">'.$Row['Cash'].'</td><td align="center">'.$Tarif.'</td><td align="center">'.$PristiTarif.'</td><td>'.$Row['notice'].' </td></tr>'); 162 $TotalDevice += $Row['network_device']; 163 $TotalMonth += ($Row['monthly'] - $Row['plus']); 164 } 165 echo('<tr><td><strong>Celkem</strong></td>'); 166 //<td align="right"><strong>'.$TotalDevice.'</strong></td> 167 echo('<td align="right"><strong>'.$TotalMonth.'</strong></td><td align="right"><strong>'.$TotalCash.'</strong></td><td align="right"> </td><td align="right"> </td><td align="right"> </td></tr>'); 168 echo('</table>'); 169 ShowFooter(); 170 } 62 $System->AddModule(new FinanceUserList()); 63 $System->Modules['FinanceUserList']->GetOutput(); 171 64 172 65 ?>
Note:
See TracChangeset
for help on using the changeset viewer.