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