Changeset 156 for www/finance/user_state_ip.php
- Timestamp:
- Feb 17, 2009, 10:00:28 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
www/finance/user_state_ip.php
r154 r156 14 14 global $Tarify, $Sprava; 15 15 16 if(!$this->System->Modules['User']->CheckPermission('Finance', 'DisplaySubjectState')) return('Nemáte oprávnění');16 $UserId = GetMemberByIP(GetRemoteAddress()); 17 17 18 //$UserId = $this->System->Modules['User']->User['Id']; 19 $UserId = GetMemberByIP(GetRemoteAddress()); 20 if(!array_key_exists('show',$_GET)) $_GET['show'] = ''; 21 $DbResult = $this->Database->query("SELECT *,CONCAT(second_name, ' ', first_name) as fullname FROM users WHERE id=".$UserId); 22 $Row2 = $DbResult->fetch_array(); 23 $TarifName = $Tarify[$Row2['inet_tarif_next']]['name']; 18 if(!array_key_exists('show', $_GET)) $_GET['show'] = ''; 19 $DbResult = $this->Database->query('SELECT Id FROM Subject WHERE Id=(SELECT Subject FROM Member WHERE Id=(SELECT Member FROM User WHERE Id='.$UserId.'))'); 20 $Subject = $DbResult->fetch_assoc(); 21 $DbResult = $this->Database->query('SELECT InternetTariffCurrentMonth FROM Member WHERE Id=(SELECT Member FROM User WHERE Id='.$UserId.')'); 22 $Member = $DbResult->fetch_assoc(); 23 $TarifName = $Tarify[$Member['InternetTariffCurrentMonth']]['name']; 24 $TarifPrice = $Tarify[$Member['InternetTariffCurrentMonth']]['price']; 24 25 $Output = '<table width="100%" border="0" cellspacing="0" cellpadding="3"><tr><td valign="top">'; 25 26 26 27 // Tabulka operaci 27 $Output .= 'Výpis operací pro účastníka '.$Row2['fullname'].':<br>'; 28 $DbResult = $this->Database->query('SELECT CONCAT(SecondName, " ", FirstName) as Name FROM User WHERE Id='.$UserId); 29 $User = $DbResult->fetch_assoc(); 30 $Output .= 'Výpis operací pro účastníka '.$User['Name'].':<br>'; 28 31 $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3"><tr><th>Datum</th><th>Popis</th><th>Částka</th><th>Doklad</th></tr>'; 29 32 $Operations = array(); 30 $DbResult = $this->Database->query('(SELECT Time, Value, Text, Bill FROM FinanceCashFlow WHERE Subject='.$ UserId.') UNION ALL '.31 '(SELECT TimeCreation as Time, -Value as Value, Text, Bill FROM FinanceClaimsLiabilities WHERE Subject='.$ UserId.') ORDER BY Time DESC');33 $DbResult = $this->Database->query('(SELECT Time, Value, Text, Bill FROM FinanceCashFlow WHERE Subject='.$Subject['Id'].') UNION ALL '. 34 '(SELECT TimeCreation as Time, -Value as Value, Text, Bill FROM FinanceClaimsLiabilities WHERE Subject='.$Subject['Id'].') ORDER BY Time DESC'); 32 35 while($DbRow = $DbResult->fetch_array()) 33 36 $Operations[] = $DbRow; … … 41 44 //echo('<tr><td> </td><td>-'.$Row2['network_device'].'</td><td>Proměnná cena za zařízení</td></tr> 42 45 $Output .= '</table>'; 43 $DbResult = $this->Database->query('SELECT ((SELECT COALESCE(SUM(Value), 0) FROM FinanceCashFlow WHERE Subject='.$ UserId.') + '.44 '(SELECT COALESCE(SUM(-Value), 0) FROM FinanceClaimsLiabilities WHERE Subject='.$ UserId.')) as Total');46 $DbResult = $this->Database->query('SELECT ((SELECT COALESCE(SUM(Value), 0) FROM FinanceCashFlow WHERE Subject='.$Subject['Id'].') + '. 47 '(SELECT COALESCE(SUM(-Value), 0) FROM FinanceClaimsLiabilities WHERE Subject='.$Subject['Id'].')) as Total'); 45 48 $DbRow = $DbResult->fetch_array(); 46 49 $Total = $DbRow['Total']; … … 48 51 $Output .= '</td><td valign="top">'; 49 52 50 if($Row2['role'] == 2) 53 $Output .= 'Variabilní symbol pro platby: <strong>'.$Subject['Id'].'</strong><br><br>'; 54 55 $DbResult = $this->Database->query('SELECT SUM(consumption) AS Total FROM network_devices WHERE user='.$UserId.' AND used=1'); 56 $ConsumptionBonus = $DbResult->fetch_assoc(); 57 $ConsumptionBonus = W2Kc($ConsumptionBonus['Total']); 58 59 $Total = 0; 60 $Output .= 'Rozpis měsíčního poplatku:<br><table border="1" cellspacing="0" cellpadding="3">'. 61 '<tr><th>Část</th><th>Cena [Kč]</th></tr>'. 62 '<tr><td>Internet - tarif '.$TarifName.'</td><td>'.$TarifPrice.'</td></tr>'; 63 $Total += $TarifPrice; 64 if($ConsumptionBonus != 0) 65 $Output .= '<tr><td>Příjem za spotřebu</td><td>'.(-$ConsumptionBonus) .'</td></tr>'; 66 $Total += -$ConsumptionBonus; 67 $Output .= '<tr><td><strong>Celkem</strong></td><td><strong>'.$Total.'</strong></td></tr></table>'; 68 //echo('Tarif pro příští měsíc: '.$Tarify[$Row2['inet_tarif_next']]['name'].'<br><br>'); 69 $Output .= '<br />'; 70 71 if($ConsumptionBonus != 0) 51 72 { 52 $Output .= 'Variabilní symbol pro platby: <strong>'.$Row2['id'].'</strong><br><br>'; 53 54 // Měsíční bilance 55 if($Row2['inet'] == 1) $InternetPrice = round($Row2['monthly_inet']); else $InternetPrice = 0; 56 if($Row2['overheads'] == 0) 57 { 58 $PoplatekSprava = 0; 59 $PoplatekSpotreba = 0; 60 $PrijemSpotreba = $Row2['plus']; 61 } else { 62 $PoplatekSprava = $Sprava; 63 $PoplatekSpotreba = $Row2['consumption']; 64 $PrijemSpotreba = $Row2['plus']; 65 } 66 $Output .= 'Rozpis měsíčního poplatku:<br><table border="1" cellspacing="0" cellpadding="3">'. 67 '<tr><th>Část</th><th>Cena [Kč]</th></tr>'. 68 '<tr><td>Internet - tarif '.$TarifName.'</td><td>'.$InternetPrice.'</td></tr>'. 69 //'<tr><td>Správa</td><td>'.$PoplatekSprava.'</td></tr>'. 70 //'<tr><td>Poplatek za spotřebu</td><td>'.$PoplatekSpotreba.'</td></tr>'. 71 '<tr><td>Příjem za spotřebu</td><td>'.(-1*$PrijemSpotreba) .'</td></tr>'. 72 '<tr><td><strong>Celkem</strong></td><td><strong>'.($InternetPrice // + $PoplatekSprava + $PoplatekSpotreba 73 - $PrijemSpotreba).'</strong></td></tr></table>'; 74 //echo('Tarif pro příští měsíc: '.$Tarify[$Row2['inet_tarif_next']]['name'].'<br><br>'); 75 $Output .= '<br>'; 76 77 /* 78 79 // Rozpis ceny za zařízení 80 echo('Výpis podílu na zařízení segmentů:'); 81 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>'); 82 $ID = $Row2['network_segment']; 83 $Money = 0; 84 while($ID > 0) 85 { 86 $DbResult = $Database->query("SELECT * FROM network_segments WHERE id=".$ID); 87 $Row = $DbResult->fetch_array(); 88 if(!(($Row2['inet_hw'] == 0) and ($ID == $InternetSegmentId))) 89 { 90 $Money += $Row['price']/$Row['users']; 91 echo('<tr><td>'.$Row['name'].'</td><td>'.$Row['price'].'</td><td>'.$Row['users'].' </td><td>'.round($Row['price']/$Row['users']).'</td></tr>'); 92 } 93 $ID = $Row['parent']; 94 } 95 echo('<tr><td><strong>Celkem</strong></td><td> </td><td> </td><td><strong>'.round($Money).'</strong></td></tr>'); 96 echo('</table><br>'); 97 98 // Rozpis platba spotřeby segmentů 99 echo('Výpis podílu na spotřebě segmentů:'); 100 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>'); 101 $ID = $Row2['network_segment']; 102 $Money = 0; 103 while($ID>0) 104 { 105 $DbResult = $Database->query("SELECT * FROM network_segments WHERE id=".$ID); 106 $Row = $DbResult->fetch_array(); 107 $Money += round(W2Kc($Row['consumption'])/$Row['users_overheads']); 108 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>'); 109 $ID = $Row['parent']; 110 } 111 echo('<tr><td><strong>Celkem</strong></td><td> </td><td> </td><td><strong>'.round($Money).'</strong></td></tr>'); 112 echo('</table><br>'); 113 */ 114 115 $Output .= 'Měsíční příjem za spotřebu zařízení umístěných u uživatele:<br>'; 73 $Output .= 'Měsíční příjem za spotřebu zařízení umístěných u uživatele:<br>'; 116 74 $Output .= '<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>'; 117 $DbResult = $this->Database->query( "SELECT * FROM network_devices WHERE user=".$UserId." AND used=1");75 $DbResult = $this->Database->query('SELECT * FROM network_devices WHERE user='.$UserId.' AND used=1'); 118 76 $TotalW = 0; 119 77 $TotalPrice = 0; 120 while($Row = $DbResult->fetch_a rray())78 while($Row = $DbResult->fetch_assoc()) 121 79 { 122 80 $Output .= '<tr><td>'.$Row['name'].'</td><td>'.$Row['consumption'].'</td><td>'.W2Kc($Row['consumption']).'</td></tr>'; … … 126 84 $Output .= '<tr><td><strong>Celkem</strong></td><td><strong>'.$TotalW.'</strong></td><td><strong>'.$TotalPrice.'</strong></td></tr>'; 127 85 $Output .= '</table>'; 128 86 } 129 87 $Output .= '</td></tr></table>'; 130 88 return($Output); 131 89 } 132 133 90 } 134 91
Note:
See TracChangeset
for help on using the changeset viewer.