Changeset 163 for www/finance
- Timestamp:
- Feb 20, 2009, 9:53:27 AM (16 years ago)
- Location:
- www/finance
- Files:
-
- 1 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
www/finance/clenove.php
r157 r163 22 22 $TotalMonth = 0; 23 23 $TotalCash = 0; 24 $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'); 25 26 //$DbResult = $Database->query("SELECT *,CONCAT(second_name, ' ', first_name) as fullname FROM users WHERE role=2 ORDER BY fullname"); 24 $DbResult = $this->Database->query('SELECT * FROM MemberPayment JOIN Member ON Member.Id=MemberPayment.Member JOIN Subject ON Subject.Id=Member.Subject ORDER BY Name'); 27 25 while($Row = $DbResult->fetch_array()) 28 26 { 29 $Monthly = $Row['monthly'] - $Row['plus']; 30 if($Row['hw'] == 0) $Monthly = '(trvale nepřipojen) '.(-$Row['plus']); 31 else 32 { 33 if($Row['overheads'] == 0) $Monthly = '(dočasně nepřipojen) '.$Monthly; 34 else 35 { 36 if($Row['inet'] == 0) $Monthly = '(bez internetu) '.$Monthly; 37 else $Monthly = $Monthly; 38 } 39 } 40 //$Row['cash'] = $Row['AdvancesIn'] - $Row['AdvancesOut'] + $Row['Liabilities'] - $Row['Claims']; 27 //$Row['cash'] = $Row['AdvancesIn'] - $Row['AdvancesOut'] + $Row['Liabilities'] - $Row['Claims']; 41 28 $TotalCash += $Row['Cash']; 42 29 if($Row['Cash'] < 0) $Row['Cash'] = '<span style="color: red;">'.$Row['Cash'].'</span>'; 43 $Tarif = $Finance->Tarify[$Row[' inet_tarif_now']]['name'];44 $PristiTarif = $Finance->Tarify[$Row[' inet_tarif_next']]['name'];45 $Output .= '<tr><td><a href="user_state.php?id='.$Row[' id'].'">'.$Row['Fullname'].'</a></td>';30 $Tarif = $Finance->Tarify[$Row['InternetTariffCurrentMonth']]['name']; 31 $PristiTarif = $Finance->Tarify[$Row['InternetTariffNextMonth']]['name']; 32 $Output .= '<tr><td><a href="user_state.php?id='.$Row['Id'].'">'.$Row['Name'].'</a></td>'; 46 33 //<td align="right">'.$Row['network_device'].'</td> 47 $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>';48 $TotalDevice += $Row[' network_device'];49 $TotalMonth += ($Row[' monthly'] - $Row['plus']);34 $Output .= '<td align="right">'.$Row['MonthlyTotal'].'</td><td align="right">'.$Row['Cash'].'</td><td align="center">'.$Tarif.'</td><td align="center">'.$PristiTarif.'</td></tr>'; 35 $TotalDevice += $Row['NetworkDevice']; 36 $TotalMonth += ($Row['MonthlyTotal']); 50 37 } 51 38 $Output .= '<tr><td><strong>Celkem</strong></td>'; -
www/finance/finance.php
r157 r163 34 34 } 35 35 36 if($Period == 0) $Column = ' now'; else $Column = 'next';36 if($Period == 0) $Column = 'Current'; else $Column = 'Next'; 37 37 $TotalUserCount = 0; 38 38 $TotalUnits = 0; … … 41 41 foreach($Tarify as $Index => $Tarif) 42 42 { 43 $DbResult = $this->Database->select(' users', 'COUNT(*)', 'inet_tarif_'.$Column.'='.$Index.' AND inet=1 AND role=2');44 $Row = $DbResult->fetch_ array();43 $DbResult = $this->Database->select('Member', 'COUNT(*)', 'InternetTariff'.$Column.'Month='.$Index); 44 $Row = $DbResult->fetch_row(); 45 45 $Tarify[$Index]['user_count'] = $Row[0]; 46 46 switch($Tarif['group_id']) … … 108 108 $this->BaseTariffPrice = $Row['BaseTariffPrice']; 109 109 110 $DbResult = $this->Database->query( "SELECT COUNT(*) FROM users WHERE inet=1 AND role=2");111 $Row = $DbResult->fetch_ array();110 $DbResult = $this->Database->query('SELECT COUNT(*) FROM Member'); 111 $Row = $DbResult->fetch_row(); 112 112 $this->InternetUsers = $Row[0]; 113 114 $DbResult = $this->Database->query("SELECT COUNT(*) FROM users WHERE overheads=1 AND role=2"); 115 $SpravaUsers = $DbResult->fetch_array(); 116 $this->SpravaUsers = $SpravaUsers[0]; 113 114 $this->SpravaUsers = $this->InternetUsers; 117 115 $DbResult = $this->Database->query("SELECT SUM(consumption) FROM network_segments"); 118 116 $TotalConsumption = $DbResult->fetch_array(); 119 117 $this->TotalConsumption = $TotalConsumption[0]; 120 118 121 $DbResult = $this->Database->query( "SELECT SUM(`monthly`) as `internet`, SUM(`monthly` - `plus`) as `real` FROM users WHERE role=2");122 $Row = $DbResult->fetch_a rray();123 $this->TotalInternetPaid = $Row[' internet'];124 $this->TotalPaid = $Row[' real'];119 $DbResult = $this->Database->query('SELECT SUM(`MonthlyInternet`) AS `MonthlyInternet`, SUM(`MonthlyTotal`) AS `MonthlyTotal` FROM MemberPayment'); 120 $Row = $DbResult->fetch_assoc(); 121 $this->TotalInternetPaid = $Row['MonthlyInternet']; 122 $this->TotalPaid = $Row['MonthlyTotal']; 125 123 126 124 $this->RecalculateTariffs($Period); -
www/finance/index.php
r157 r163 12 12 $Output = '<table><tr><td valign="top">'; 13 13 14 if(GetMemberByIP(GetRemoteAddress()) > 0) $Output .= '<a href="user_state_ip.php ">Vaše finanční operace</a> (Tato volba je také přístupná po přihlášení do systému v uživatelském menu).<br /><br /><br />';14 if(GetMemberByIP(GetRemoteAddress()) > 0) $Output .= '<a href="user_state_ip.php?old">Vaše finanční operace</a> (Tato volba je také přístupná po přihlášení do systému v uživatelském menu).<br /><br /><br />'; 15 15 16 16 $Output .= '<a href="monthly_overall.php">Měsíční přehledy</a><br />'; … … 29 29 $Output .= 'Platba za internetovou linku ('.$Finance->RealMaxSpeed.'/'.$Finance->RealMaxSpeed.' kbit/s): <strong>'.$Finance->Internet.' Kč</strong><br />'; 30 30 31 $DbResult = $this->Database->query( "SELECT COUNT(*) FROM users WHERE role=2");31 $DbResult = $this->Database->query('SELECT COUNT(*) FROM Member'); 32 32 $Row2 = $DbResult->fetch_array(); 33 33 $Output .= 'Počet účastníků: <strong>'.$Row2[0].'</strong><br />'; 34 34 35 $DbResult = $this->Database->query( "SELECT SUM(price) FROM network_devices WHERE used=1");35 $DbResult = $this->Database->query('SELECT SUM(price) FROM network_devices WHERE used=1'); 36 36 $Row4 = $DbResult->fetch_array(); 37 37 $Output .= 'Celková cena zařízení sítě: <strong>'.$Row4[0].' Kč</strong><br />'; 38 38 39 $DbResult = $this->Database->query('SELECT SUM( (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');39 $DbResult = $this->Database->query('SELECT SUM(Cash) as Cash FROM MemberPayment'); 40 40 $Row4 = $DbResult->fetch_array(); 41 41 $Output .= 'Celkem peněz na účtech: <strong>'.$Row4[0].' Kč</strong><br />'; 42 42 $Output .= 'Stanovená cena jedné kWh: <strong>'.$Finance->kWh.' Kč</strong><br />'; 43 43 //echo('Komunitou stanovený poplatek za správu sítě pro jednoho uživatele: <strong>'.$Sprava.' Kč</strong><br />'); 44 $DbResult = $this->Database->query("SELECT SUM(family) FROM users WHERE role=2"); 45 $Row5 = $DbResult->fetch_array(); 44 $DbResult = $this->Database->query('SELECT SUM(FamilyMemberCount) AS Family FROM Member'); 45 $Family = $DbResult->fetch_assoc(); 46 $Family = $Family['Family']; 46 47 $TotalFamily = 600; 47 $Output .= 'V připojených domácnostech celkem <strong>'.$ Row5[0].'</strong> občanů ze všech <strong>'.$TotalFamily.'</strong> ('.round($Row5[0]/ $TotalFamily * 100).' %)<br />';48 $Output .= 'V připojených domácnostech celkem <strong>'.$Family.'</strong> občanů ze všech <strong>'.$TotalFamily.'</strong> ('.round($Family / $TotalFamily * 100).' %)<br />'; 48 49 $Output .= 'IČ: <strong>75904535</strong><br />'. 49 50 'DIČ: <strong>CZ8303255884</strong><br />'. … … 79 80 $Output .= '<tr><td>Převod do dalšího měsíce</td><td align="right">'.($TotalGain - $TotalExpense).'</td></tr>'; 80 81 $Output .= '</table><br />'; 81 $DbResult = $this->Database->select('users', 'cash', 'id='.$Finance->UserIdNetwork);82 /* $DbResult = $this->Database->select('', 'cash', 'id='.$Finance->UserIdNetwork); 82 83 $Row = $DbResult->fetch_array(); 83 84 $NetworkCash = $Row['cash']; 84 $Output .= 'Stav účtu sítě: '.$NetworkCash.' Kč<br /><a href="clenove.php?show=user&id='.$Finance->UserIdNetwork.'">Výpis účtu</a><br />'; 85 $Output .= 'Stav účtu sítě: '.$NetworkCash.' Kč<br /><a href="clenove.php?show=user&id='.$Finance->UserIdNetwork.'">Výpis účtu</a><br />';*/ 85 86 86 87 $Output .= '</td></tr></table>'; -
www/finance/prepocet.php
r157 r163 11 11 $Finance = &$this->System->Modules['Finance']; 12 12 $Output = 'Aktualizuju finance uživatelů...<br />'; 13 $DbResult = $this->Database->query('SELECT * FROM users WHERE role=2 OR id='.$Finance->UserIdNetwork); // Select network members only 14 while($Row = $DbResult->fetch_array()) 15 { 16 $DbResult2 = $this->Database->query('SELECT SUM(money) FROM finance_operations WHERE user='.$Row['id']); // Account state 17 $Row3 = $DbResult2->fetch_array(); 18 $DbResult2 = $this->Database->query('SELECT SUM(consumption) FROM network_devices WHERE user='.$Row['id'].' AND used=1'); 19 $Row4 = $DbResult2->fetch_array(); 20 21 $Price = 0; 13 $this->Database->query('TRUNCATE TABLE MemberPayment'); 14 $DbResult = $this->Database->query('SELECT * FROM Member'); 15 while($Member = $DbResult->fetch_assoc()) 16 { 17 $DbResult2 = $this->Database->query('SELECT ((SELECT COALESCE(SUM(Value), 0) FROM FinanceCashFlow WHERE Subject='.$Member['Subject'].') + (SELECT COALESCE(SUM(-Value), 0) FROM FinanceClaimsLiabilities WHERE Subject='.$Member['Subject'].')) as Cash'); 18 $Cash = $DbResult2->fetch_row(); 19 $Cash = $Cash[0]; 20 21 $DbResult2 = $this->Database->query('SELECT SUM(consumption) FROM network_devices WHERE user='.$Member['Id'].' AND used=1'); 22 $ConsumptionPlus = $DbResult2->fetch_row(); 23 $ConsumptionPlus = $ConsumptionPlus[0]; 24 25 $NetworkDevice = 0; 22 26 $Consumption = 0; 23 $ID = $ Row['network_segment'];27 $ID = $Member['NetworkSegment']; 24 28 while($ID != 0) 25 29 { 26 30 $DbResult2 = $this->Database->query('SELECT * FROM network_segments WHERE id='.$ID); 27 $Row2 = $DbResult2->fetch_array(); 28 if(!(($Row['inet_hw'] == 0) and ($ID == $Finance->InternetSegmentId))) 29 { 30 $Price += $Row2['price'] / $Row2['users']; 31 $Consumption += $Row2['consumption'] / $Row2['users_overheads']; 32 } 31 $Device = $DbResult2->fetch_assoc(); 32 $NetworkDevice += $Device['price'] / $Device['users']; 33 $Consumption += $Device['consumption'] / $Device['users_overheads']; 33 34 //echo($ID.' '.$InternetSegment.' '.$InternetSegmentId.' '.$Row['inet_hw'].' '.$Price.'<br>'); 34 $ID = $Row2['parent']; 35 } 35 $ID = $Device['parent']; 36 } 37 36 38 $Monthly = 0; 37 $MonthlyInet = $Finance->Tarify[$Row['inet_tarif_next']]['price']; 38 if($Row['inet'] == 1) $Monthly += $MonthlyInet; 39 $MonthlyInet = $Finance->Tarify[$Member['InternetTariffNextMonth']]['price']; 40 //if($Row['inet'] == 1) 41 $Monthly += $MonthlyInet; 42 $Monthly -= $ConsumptionPlus; 39 43 //if($Row['overheads'] == 1) $Monthly += $Sprava; // + W2Kc($Consumption); 40 44 //echo($Row['fullname'].' '.$Row['inet'].' '.$Monthly.'<br>'); 41 45 $Monthly = round($Monthly); 42 46 //echo($Row['fullname'].' '.$Row['inet'].' '.$Monthly.'<br>'); 43 $this->Database->update('users', 'id='.$Row['id'], array('network_device' => $Price, 'monthly_inet' => $MonthlyInet, 'monthly' => $Monthly, 'consumption' => $this->System->Modules['Finance']->W2Kc($Consumption), 'cash' => $Row3[0], 'plus' => $Finance->W2Kc($Row4[0]))); 47 48 $this->Database->insert('MemberPayment', array('Member' => $Member['Id'], 'NetworkDevice' => $NetworkDevice, 'MonthlyInternet' => $MonthlyInet, 'MonthlyTotal' => $Monthly, 'MonthlyConsumption' => $this->System->Modules['Finance']->W2Kc($Consumption), 'Cash' => $Cash, 'MonthlyPlus' => $Finance->W2Kc($ConsumptionPlus))); 44 49 } 45 50 return($Output); … … 52 57 $this->Database->query('UPDATE network_segments SET users = 0, users_overheads = 0'); // Vynulovat počty uživatelů 53 58 $DbResult = $this->Database->query('SELECT * FROM network_segments'); 54 while($ Row= $DbResult->fetch_array())59 while($NetworkSegment = $DbResult->fetch_array()) 55 60 { 56 61 //echo('Segment '.$Row['name'].'<br>'); 57 $DbResult2 = $this->Database->query('SELECT users FROM network_segments WHERE id='.$ Row['id']);62 $DbResult2 = $this->Database->query('SELECT users FROM network_segments WHERE id='.$NetworkSegment['id']); 58 63 $RowP = $DbResult2->fetch_array(); 59 $DbResult2 = $this->Database->query( "SELECT users_overheads FROM network_segments WHERE id=".$Row['id']);64 $DbResult2 = $this->Database->query('SELECT users_overheads FROM network_segments WHERE id='.$NetworkSegment['id']); 60 65 $RowP2 = $DbResult2->fetch_array(); 61 66 62 $DbResult2 = $this->Database->query( "SELECT SUM(price) as Price, SUM(consumption) as Consumption FROM network_devices WHERE segment=".$Row['id']." AND used=1");67 $DbResult2 = $this->Database->query('SELECT SUM(price) as Price, SUM(consumption) as Consumption FROM network_devices WHERE segment='.$NetworkSegment['id'].' AND used=1'); 63 68 $Row2 = $DbResult2->fetch_array(); 64 $DbResult2 = $this->Database->query( "SELECT COUNT(*) FROM users WHERE network_segment=".$Row['id'].' AND hw=1');69 $DbResult2 = $this->Database->query('SELECT COUNT(*) FROM Member WHERE NetworkSegment='.$NetworkSegment['id']); 65 70 $Row3 = $DbResult2->fetch_array(); 66 $DbResult2 = $this->Database->query( "SELECT COUNT(*) FROM users WHERE network_segment=".$Row['id'].' AND overheads=1');71 $DbResult2 = $this->Database->query('SELECT COUNT(*) FROM Member WHERE NetworkSegment='.$NetworkSegment['id']); 67 72 $Row5 = $DbResult2->fetch_array(); 68 $ID = $ Row['parent'];73 $ID = $NetworkSegment['parent']; 69 74 while($ID != 0) 70 75 { 71 76 //echo($ID.', '); 72 $DbResult2 = $this->Database->query( "SELECT * FROM network_segments WHERE id=".$ID);77 $DbResult2 = $this->Database->query('SELECT * FROM network_segments WHERE id='.$ID); 73 78 $Row4 = $DbResult2->fetch_array(); 74 79 $this->Database->update('network_segments', 'id='.$Row4['id'], array('users' => ($Row4['users'] + $Row3[0]), 'users_overheads' => ($Row4['users_overheads'] + $Row5[0]))); … … 76 81 } 77 82 //echo('Pocet '.$Row3[0].','.$Row['hosts'].'<br>'); 78 $this->Database->update('network_segments', 'id='.$ Row['id'], array('price' => $Row2['Price'], 'users' => ($Row3[0] + $RowP['users']), 'consumption' => $Row2['Consumption'], 'users_overheads' => ($Row5[0] + $RowP2['users_overheads'])));83 $this->Database->update('network_segments', 'id='.$NetworkSegment['id'], array('price' => $Row2['Price'], 'users' => ($Row3[0] + $RowP['users']), 'consumption' => $Row2['Consumption'], 'users_overheads' => ($Row5[0] + $RowP2['users_overheads']))); 79 84 } 80 85 81 86 // Zkorigovat segment Internet 82 $DbResult = $this->Database->select(' users', 'COUNT(*)', 'inet_hw=1');87 $DbResult = $this->Database->select('Member', 'COUNT(*)'); 83 88 $Row = $DbResult->fetch_array(); 84 $DbResult = $this->Database->select('users', 'COUNT(*)', 'inet=1'); 85 $Row2 = $DbResult->fetch_array(); 86 $DbResult = $this->Database->update('network_segments','id='.$Finance->InternetSegmentId, array('users' => $Row[0], 'users_overheads' => $Row2[0])); 89 $DbResult = $this->Database->update('network_segments','id='.$Finance->InternetSegmentId, array('users' => $Row[0], 'users_overheads' => $Row[0])); 87 90 return($Output); 88 91 } 89 92 90 function CreateMonthlyOverallBill()93 /*function CreateMonthlyOverallBill() 91 94 { 92 95 global $Sprava, $SpravaUsers, $TotalConsumption, $UserIdNetwork, $Internet, $TotalInternetPaid; … … 117 120 } 118 121 return($Output); 119 } 120 122 }*/ 121 123 122 124 function Show() … … 149 151 $Row = $DbResult->fetch_array(); 150 152 $Output .= "), Segmenty(".$Row[0]; 151 $DbResult = $this->Database->query( "SELECT SUM(network_device) FROM users");153 $DbResult = $this->Database->query('SELECT SUM(NetworkDevice) FROM MemberPayment'); 152 154 $Row5 = $DbResult->fetch_array(); 153 155 $Output .= "), Uživatelé(".$Row5[0].")<br>\n"; 154 $DbResult = $this->Database->query("SELECT SUM( cash) FROM users WHERE role=2");156 $DbResult = $this->Database->query("SELECT SUM(Cash) FROM MemberPayment"); 155 157 $Row6 = $DbResult->fetch_array(); 156 158 $Output .= "Stav pokladny: Uživatelé(".$Row6[0].")"; … … 178 180 179 181 // Generuj účetní položky 180 $DbResult = $this->Database->query( "SELECT *, CONCAT(second_name, ' ', first_name) as fullname FROM users WHERE (role = 2)");182 $DbResult = $this->Database->query('SELECT * FROM MemberPayment JOIN Member ON Member.Id=MemberPayment.Member JOIN Subject ON Subject.Id=Member.Subject'); 181 183 while($User = $DbResult->fetch_array()) 182 184 { 183 $Output .= $User[' fullname'].': ';185 $Output .= $User['Name'].': '; 184 186 $MonthCount = $BillingPeriodMonthCount[$User['BillingPeriod']]; 185 if(($MonthCount > 0) and (((($Mesic - 1) % 12) % $MonthCount) == 0) and ($User[' inet_tarif_now'] != 6))187 if(($MonthCount > 0) and (((($Mesic - 1) % 12) % $MonthCount) == 0) and ($User['InternetTariffCurrentMonth'] != 6)) 186 188 { 187 189 //echo($Mesic.'%'.$MonthCount.'='.($Mesic % $MonthCount).' '); 188 $PayPerMonth = -($User['plus'] - $User['monthly']);190 $PayPerMonth = $User['MonthlyTotal']; 189 191 $PayPerPeriod = $PayPerMonth * $MonthCount; 190 192 $PeriodFrom = mktime(0, 0, 0, date('n'), 1, date('Y')); … … 193 195 $Output .= $TimePeriodText.': '.$PayPerMonth." * ".$MonthCount." = ".$PayPerPeriod."<br />\n"; 194 196 $BillCode = $Finance->GetNextDocumentLineNumber(6); // Faktury vydané 195 $BillId = $this->System->Modules['Bill']->CreateBill($User[' id'], array(array('Description' => 'Připojení k síti', 'Price' => $PayPerPeriod, 'Quantity' => 1)), $PeriodFrom, $PeriodTo, $BillCode);196 $this->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, 'BillCode' => $BillCode));197 $BillId = $this->System->Modules['Bill']->CreateBill($User['Id'], array(array('Description' => 'Připojení k síti', 'Price' => $PayPerPeriod, 'Quantity' => 1)), $PeriodFrom, $PeriodTo, $BillCode); 198 $this->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, 'BillCode' => $BillCode)); 197 199 } else $Output .= ("<br />"); 198 200 } … … 220 222 } 221 223 222 $Output .= "Měním aktuální tarify uživatelů...<br>\n";223 224 224 // Update tariff user selection 225 $DbResult = $this->Database->query("SELECT id,inet_tarif_next FROM users WHERE role=2"); 225 $Output .= "Měním aktuální tarify uživatelů...<br />\n"; 226 $DbResult = $this->Database->query('SELECT Id, InternetTariffNextMonth FROM Member'); 226 227 while($User = $DbResult->fetch_array()) 227 228 { 228 $this->Database->update(' users', 'id='.$User['id'], array('inet_tarif_now' => $User['inet_tarif_next']));229 $this->Database->update('Member', 'Id='.$User['Id'], array('InternetTariffCurrentMonth' => $User['InternetTariffNextMonth'])); 229 230 } 230 231 -
www/finance/user_state.php
r157 r163 10 10 function Show() 11 11 { 12 global $Tarify, $Sprava; 12 if(array_key_exists('old', $_GET)) 13 { 14 $UserId = GetMemberByIP(GetRemoteAddress()); 15 } else 16 if(array_key_exists('userid', $_GET)) 17 { 18 if(!$this->System->Modules['User']->CheckPermission('Finance', 'Manage')) return('Nemáte oprávnění'); 19 $UserId = $_GET['userid']; 20 } else 21 { 22 if(!$this->System->Modules['User']->CheckPermission('Finance', 'DisplaySubjectState')) return('Nemáte oprávnění'); 23 $UserId = $this->System->Modules['User']->User['Id']; 24 } 13 25 14 if(!$this->System->Modules['User']->CheckPermission('Finance', 'DisplaySubjectState')) return('Nemáte oprávnění'); 15 26 $Finance = &$this->System->Modules['Finance']; 16 27 $this->System->Modules['Finance']->RecalculateTariffs(1); 17 $UserId = $this->System->Modules['User']->User['Id'];18 28 if(!array_key_exists('show', $_GET)) $_GET['show'] = ''; 19 29 $DbResult = $this->Database->query('SELECT Id FROM Subject WHERE Id=(SELECT Subject FROM Member WHERE Id=(SELECT Member FROM User WHERE Id='.$UserId.'))'); 20 30 $Subject = $DbResult->fetch_assoc(); 21 $DbResult = $this->Database->query('SELECT InternetTariffCurrentMonth FROM Member WHERE Id=(SELECT Member FROM User WHEREId='.$UserId.')');31 $DbResult = $this->Database->query('SELECT * FROM Member JOIN MemberPayment ON MemberPayment.Member=Member.Id WHERE Member.Id=(SELECT Member FROM User WHERE User.Id='.$UserId.')'); 22 32 $Member = $DbResult->fetch_assoc(); 23 $TarifName = $ Tarify[$Member['InternetTariffCurrentMonth']]['name'];24 $TarifPrice = $ Tarify[$Member['InternetTariffCurrentMonth']]['price'];33 $TarifName = $Finance->Tarify[$Member['InternetTariffCurrentMonth']]['name']; 34 $TarifPrice = $Finance->Tarify[$Member['InternetTariffCurrentMonth']]['price']; 25 35 $Output = '<table width="100%" border="0" cellspacing="0" cellpadding="3"><tr><td valign="top">'; 26 36 … … 53 63 $Output .= 'Variabilní symbol pro platby: <strong>'.$Subject['Id'].'</strong><br><br>'; 54 64 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 = $this->System->Modules['Finance']->W2Kc($ConsumptionBonus['Total']);58 59 65 $Total = 0; 60 66 $Output .= 'Rozpis měsíčního poplatku:<br><table border="1" cellspacing="0" cellpadding="3">'. … … 62 68 '<tr><td>Internet - tarif '.$TarifName.'</td><td>'.$TarifPrice.'</td></tr>'; 63 69 $Total += $TarifPrice; 64 if($ ConsumptionBonus!= 0)65 $Output .= '<tr><td>Příjem za spotřebu</td><td>'.(-$ ConsumptionBonus) .'</td></tr>';66 $Total += -$ ConsumptionBonus;70 if($Member['MonthlyPlus'] != 0) 71 $Output .= '<tr><td>Příjem za spotřebu</td><td>'.(-$Member['MonthlyPlus']) .'</td></tr>'; 72 $Total += -$Member['MonthlyPlus']; 67 73 $Output .= '<tr><td><strong>Celkem</strong></td><td><strong>'.$Total.'</strong></td></tr></table>'; 68 74 //echo('Tarif pro příští měsíc: '.$Tarify[$Row2['inet_tarif_next']]['name'].'<br><br>'); 69 75 $Output .= '<br />'; 70 76 71 if($ ConsumptionBonus!= 0)77 if($Member['MonthlyPlus'] != 0) 72 78 { 73 79 $Output .= 'Měsíční příjem za spotřebu zařízení umístěných u uživatele:<br>';
Note:
See TracChangeset
for help on using the changeset viewer.