Changeset 152 for www/finance
- Timestamp:
- Feb 16, 2009, 2:09:57 PM (16 years ago)
- Location:
- www/finance
- Files:
-
- 2 added
- 2 deleted
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
www/finance/bills.php
r151 r152 1 1 <?php 2 2 3 class InvoiceGenerator3 class Bill extends Module 4 4 { 5 5 var $SpecificSymbol = 1; // počítačová sít … … 9 9 function GenerateBill($BillId) 10 10 { 11 global $ Database, $SpecificSymbol;11 global $SpecificSymbol; 12 12 13 $DbResult = $ Database->select('finance_bills', '*', 'id='.$BillId);13 $DbResult = $this->Database->select('finance_bills', '*', 'id='.$BillId); 14 14 $Bill = $DbResult->fetch_array(); 15 15 16 $DbResult = $ Database->select('users', '*', 'id='.$Bill['user_id']);16 $DbResult = $this->Database->select('users', '*', 'id='.$Bill['user_id']); 17 17 $User = $DbResult->fetch_array(); 18 18 19 19 $Dodavka = array(); 20 $DbResult = $ Database->select('finance_bills_items', '*', 'bill_id='.$BillId);20 $DbResult = $this->Database->select('finance_bills_items', '*', 'bill_id='.$BillId); 21 21 while($Item = $DbResult->fetch_array()) 22 22 { … … 122 122 function CreateBill($UserId, $Items, $TimeFrom, $TimeTo, $BillCode, $Type) 123 123 { 124 global $Database; 125 126 $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), 'BillCode' => $BillCode, 'Type' => 'invoice')); 127 $BillId = $Database->insert_id; 124 $this->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), 'BillCode' => $BillCode, 'Type' => 'invoice')); 125 $BillId = $this->Database->insert_id; 128 126 foreach($Items as $Item) 129 127 { 130 $ Database->insert('finance_bills_items', array('bill_id' => $BillId, 'description' => $Item['description'], 'price' => $Item['price'], 'quantity' => $Item['quantity']));128 $this->Database->insert('finance_bills_items', array('bill_id' => $BillId, 'description' => $Item['description'], 'price' => $Item['price'], 'quantity' => $Item['quantity'])); 131 129 } 132 130 //Header('Content-Type: application/pdf'); … … 134 132 //echo($PdfData); 135 133 file_put_contents($this->FileFolder.'/'.$this->FileNamePrefix.$BillId.'.pdf', $PdfData); 136 //$ Database->query('UPDATE finance_bills SET pdf = 0x'.bin2hex($PdfData).' WHERE id='.$BillId);134 //$this->Database->query('UPDATE finance_bills SET pdf = 0x'.bin2hex($PdfData).' WHERE id='.$BillId); 137 135 return($BillId); 138 136 } … … 140 138 function CreateIncomeBill($UserId, $Description, $Price, $BillCode) 141 139 { 142 global $Database; 143 144 $Database->insert('finance_bills', array('time_create' => TimeToMysqlDateTime(time()), 'user_id' => $UserId, 'BillCode' => $BillCode, 'Type' => 'income')); 145 $BillId = $Database->insert_id; 146 $Database->insert('finance_bills_items', array('bill_id' => $BillId, 'description' => $Description, 'price' => $Price, 'quantity' => 1)); 140 $this->Database->insert('finance_bills', array('time_create' => TimeToMysqlDateTime(time()), 'user_id' => $UserId, 'BillCode' => $BillCode, 'Type' => 'income')); 141 $BillId = $this->Database->insert_id; 142 $this->Database->insert('finance_bills_items', array('bill_id' => $BillId, 'description' => $Description, 'price' => $Price, 'quantity' => 1)); 147 143 //Header('Content-Type: application/pdf'); 148 144 $PdfData = $this->HtmlToPdf($this->GenerateBill($BillId)); 149 145 //echo($PdfData); 150 146 file_put_contents($this->FileFolder.'/'.$this->FileNamePrefix.$BillId.'.pdf', $PdfData); 151 //$ Database->query('UPDATE finance_bills SET pdf = 0x'.bin2hex($PdfData).' WHERE id='.$BillId);147 //$this->Database->query('UPDATE finance_bills SET pdf = 0x'.bin2hex($PdfData).' WHERE id='.$BillId); 152 148 return($BillId); 153 149 } … … 160 156 //echo($this->FileFolder.'/'.$this->FileNamePrefix.$BillId.'.pdf'); 161 157 echo(file_put_contents($this->FileFolder.'/'.$this->FileNamePrefix.$BillId.'.pdf', $PdfData)); 162 //$ Database->query('UPDATE finance_bills SET pdf = 0x'.bin2hex($PdfData).' WHERE id='.$BillId);158 //$this->Database->query('UPDATE finance_bills SET pdf = 0x'.bin2hex($PdfData).' WHERE id='.$BillId); 163 159 } 164 160 … … 167 163 global $Database; 168 164 169 //$DbResult = $ Database->select('finance_bills', 'pdf', 'id='.$BillId);165 //$DbResult = $this->Database->select('finance_bills', 'pdf', 'id='.$BillId); 170 166 //if($DbResult->num_rows == 1) 171 167 //{ … … 204 200 global $Database; 205 201 206 $DbResult = $ Database->select('finance_operations', '*', '(date="2008-02-01" AND comment="Poplatek za měsíc Únor") OR '.202 $DbResult = $this->Database->select('finance_operations', '*', '(date="2008-02-01" AND comment="Poplatek za měsíc Únor") OR '. 207 203 '(date="2008-01-01" AND comment="Poplatek za měsíc Leden") OR (date="2007-12-01" AND comment="Poplatek za měsíc Prosinec") AND (bill_id = 0)'); 208 204 while($Row = $DbResult->fetch_array()) … … 211 207 $Time = MysqlDateToTime($Row['date']); 212 208 $BillId = $this->CreateBill($Row['user'], array(array('description' => 'Poplatek za připojení k síti', 'price' => (-$Row['money']), 'quantity' => 1)), $Time, $Time + (date("t", time()) - 1) * 24 * 3600); 213 $ Database->update('finance_operations', 'id='.$Row['id'], array('bill_id' => $BillId));209 $this->Database->update('finance_operations', 'id='.$Row['id'], array('bill_id' => $BillId)); 214 210 } 215 211 } … … 221 217 { 222 218 223 $DbResult = $ Database->select('finance_bills', '*', 'user_id='.$_GET['user']);219 $DbResult = $this->Database->select('finance_bills', '*', 'user_id='.$_GET['user']); 224 220 while($Item = $DbResult->fetch_array()) 225 221 { … … 250 246 ShowHeader('Doklady', 'Doklady'); 251 247 echo('Faktury:<br>'); 252 $DbResult = $ Database->select('users', '*, CONCAT(second_name," ", first_name) as fullname', '1 ORDER BY fullname');248 $DbResult = $this->Database->select('users', '*, CONCAT(second_name," ", first_name) as fullname', '1 ORDER BY fullname'); 253 249 while($User = $DbResult->fetch_array()) 254 250 { … … 260 256 } 261 257 262 $InvoiceGenerator = new InvoiceGenerator;263 264 258 ?> -
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 ?> -
www/finance/finance.php
r70 r152 1 1 <?php 2 2 3 include('../global.php'); 4 include_once('classes.php'); 3 class Finance extends Module 4 { 5 5 6 function MakeLink($Target, $Title)7 {8 return('<a href="'.$Target.'">'.$Title.'</a>');9 }10 11 function Table($Table)12 {13 $Result = '<table cellspacing="0" border="1" cellpadding="3" class="BasicTable">';14 $Result .= '<tr>';15 foreach($Table['Header'] as $Item)16 $Result .= '<th>'.$Item.'</th>';17 $Result .= '</tr>';18 foreach($Table['Rows'] as $Row)19 {20 $Result .= '<tr>';21 foreach($Row as $Item)22 $Result .= '<td>'.$Item.'</td>';23 $Result .= '</tr>';24 }25 $Result .= '</table>';26 return($Result);27 }28 29 function ShowEditTable($ClassName, $Values)30 {31 global $Classes, $Types, $Database;32 33 $Class = $Classes[$ClassName];34 $Table = array(35 'Header' => array('Položka', 'Hodnota'),36 'Rows' => array(),37 );38 39 foreach($Class['Items'] as $Index => $Item)40 {41 if(!array_key_exists($Index, $Values)) $Values[$Index] = $Item['Default'];42 switch($Item['Type'])43 {44 case 'Boolean':45 if($Values[$Index] == 0) $Checked = ''; else $Checked = ' CHECKED';46 $Edit = '<input type="checkbox" name="'.$Index.'"'.$Checked.'>';47 break;48 case 'String':49 $Edit = '<input type="text" name="'.$Index.'" value="'.$Values[$Index].'">';50 break;51 case 'Integer':52 $Edit = '<input type="text" name="'.$Index.'" value="'.$Values[$Index].'">';53 break;54 case 'Float':55 $Edit = '<input type="text" name="'.$Index.'" value="'.$Values[$Index].'">';56 break;57 case 'Time':58 if($Values[$Index] == 'Now') $Values[$Index] = date('j.n.Y');59 $Edit = '<input type="text" name="'.$Index.'" value="'.$Values[$Index].'">';60 break;61 case 'FinanceSubject':62 63 $Edit = '<select name="'.$Index.'">';64 $DbResult = $Database->select('users', 'id, CONCAT(second_name, " ", first_name) as fullname', 'role=2 ORDER BY fullname');65 while($Row = $DbResult->fetch_array())66 $Edit .= '<option value="'.$Row['id'].'">'.$Row['fullname'].'</option>';67 $Edit .= '</select>';68 break;69 case 'Array':70 $Edit = ShowEditTable($Item['ItemClass'], array());71 $Edit .= '<form action="?Operation=AddItem&dsd" method="post"><input type="submit" value="Přidat položku"></form>';72 break;73 default:74 $Edit = 'Neznámý typ';75 }76 array_push($Table['Rows'], array($Item['Caption'], $Edit));77 }78 $Output = '<h3>'.$Class['Title'].'</h3>'.Table($Table);79 return($Output);80 }81 82 function LoadSubmitedData($ClassName)83 {84 global $Classes, $Types, $Database;85 86 $Class = $Classes[$ClassName];87 $Values = array();88 89 foreach($Class['Items'] as $Index => $Item)90 {91 switch($Item['Type'])92 {93 case 'Boolean':94 if(array_key_exists($Index, $_POST)) $Values[$Index] = 1;95 else $Values[$Index] = 0;96 break;97 case 'String':98 $Values[$Index] = $_POST[$Index];99 break;100 case 'Integer':101 $Values[$Index] = $_POST[$Index];102 break;103 case 'Float':104 $Values[$Index] = $_POST[$Index];105 break;106 case 'Time':107 $Values[$Index] = explode('.', $_POST[$Index]);108 $Values[$Index] = mktime(0, 0, 0, $Values[$Index][1], $Values[$Index][0], $Values[$Index][2]);109 break;110 case 'FinanceSubject':111 $Values[$Index] = $_POST[$Index];112 break;113 default:114 }115 }116 return($Values);117 6 } 118 7 -
www/finance/include.php
r133 r152 131 131 } 132 132 133 133 134 ?> -
www/finance/index.php
r145 r152 1 1 <?php 2 include_once('../ style.php');2 include_once('../global.php'); 3 3 include_once('include.php'); 4 4 5 ShowHeader('Financování sítě', 'Finance'); 5 class FinanceOverview extends Page 6 { 7 var $FullTitle = 'Přehled financování sítě'; 8 var $ShortTitle = 'Přehled financí'; 6 9 7 echo('<table><tr><td valign="top">'); 10 function Show() 11 { 12 global $Config, $RealMaxSpeed, $Internet, $InternetUsers, $kWh, $TotalInternetPaid, $SpravaUsers, $Sprava, $UserIdNetwork; 8 13 9 echo('<table><tr><td width="30%">'); 10 if(GetMemberByIP(GetRemoteAddress()) > 0) echo('<a href="clenove.php">Vaše finanční operace</a><br /><br /><br />'); 11 echo('<a href="monthly_overall.php">Měsíční přehledy</a><br />'. 12 '<a href="tarify.php">Tarify</a><br />'. 13 '<a href="zarizeni.php">Výpis zařízení</a><br />'. 14 //'<a href="spotreba.php">Spotřeba energie</a><br />'. 15 '<a href="'.$Config['Web']['RootFolder'].'/aktuality/index.php?category=9">Investice v síti</a><br />'. 16 //'<a href="faktury/">Faktury za internet</a><br />'. 17 //'<a href="inventory.php">Výpis skladových zásob</a><br />'. 18 //'<a href="srovnani.php">Porovnání tarifů s konkurencí</a><br />'. 19 '</td><td width="50%">'); 14 $Output = '<table><tr><td valign="top">'; 20 15 16 $Output .= '<table><tr><td width="30%">'; 17 if(GetMemberByIP(GetRemoteAddress()) > 0) $Output .= '<a href="user_state.php">Vaše finanční operace</a><br /><br /><br />'; 18 19 $Output .= '<a href="monthly_overall.php">Měsíční přehledy</a><br />'; 20 $Output .= '<a href="tarify.php">Tarify</a><br />'; 21 $Output .= '<a href="zarizeni.php">Výpis zařízení</a><br />'; 22 if($this->System->Modules['User']->CheckPermission('Finance', 'SubjectList')) $Output .= '<a href="clenove.php">Seznam členů</a><br />'; 23 $Output .= '<a href="spotreba.php">Spotřeba energie</a><br />'; 24 $Output .= '<a href="'.$Config['Web']['RootFolder'].'/aktuality/index.php?category=9">Investice v síti</a><br />'; 25 //$Output .= '<a href="faktury/">Faktury za internet</a><br />'; 26 //$Output .= '<a href="inventory.php">Výpis skladových zásob</a><br />'; 27 $Output .= '</td><td width="50%">'; 21 28 22 /* 23 $CenaBezDPH = 11000; 24 $JednorazoveBezDPH = 29800; 25 DB_Query('SELECT COUNT(*) FROM users WHERE inet=1 AND role=0'); 26 $Row = DB_Row(); 27 echo('<table style="border-style: dotted; border-width: 1; border-color: red; font-size: small;"><tr><td>'. 28 'Měsíční poplatek za internet při navýšení rychlosti na 1024/1024 kb/s: '.round($CenaBezDPH*1.19).' / '.$Row[0].' = <strong>'.round($CenaBezDPH*1.19/$Row[0]).' Kč</strong></td></tr></table>'); 29 */ 30 /* 31 DB_Query('SELECT COUNT(*) FROM users WHERE fast_inet=1 AND role=0'); 32 $Row = DB_Row(); 33 echo('Při <a href="clenove.php">'.$Row[0].'</a> zájemcích včetně DPH: jednorázově: <strong>'.round(29800*1.19/$Row[0]).' Kč</strong>'. 34 ' měsíčně: <strong>'.round(8900*1.19/$Row[0]).' Kč</strong>'); 35 */ 29 $Output .= '</td></tr></table><br />'; 36 30 37 echo('</td></tr></table><br />'); 31 $Output .= '<strong>Souhrn:</strong><br />'; 38 32 39 echo('<strong>Souhrn:</strong><br />'); 33 $DbResult = $this->Database->query("SELECT * FROM finance_monthly_overall ORDER BY date DESC LIMIT 0,1"); 34 $Row = $DbResult->fetch_array(); 35 $Output .= 'Platba za internetovou linku ('.$RealMaxSpeed.'/'.$RealMaxSpeed.' kbit/s): <strong>'.$Internet.' Kč</strong><br />'; 40 36 41 $DbResult = $Database->query("SELECT * FROM finance_monthly_overall ORDER BY date DESC LIMIT 0,1");42 $Row= $DbResult->fetch_array();43 echo('Poplatek za hlavní internetovou linku ('.$RealMaxSpeed.'/'.$RealMaxSpeed.' kbit/s): <strong>'.$Internet.' Kč</strong><br />');37 $DbResult = $this->Database->query("SELECT COUNT(*) FROM users WHERE role=2"); 38 $Row2 = $DbResult->fetch_array(); 39 $Output .= 'Počet účastníků: <strong>'.$Row2[0].'</strong><br />'; 44 40 45 $DbResult = $Database->query("SELECT COUNT(*) FROM users WHERE role=2");46 $Row2= $DbResult->fetch_array();47 echo('Počet připojených účastníků: <strong>'.$Row2[0].'</strong><br />');41 $DbResult = $this->Database->query("SELECT SUM(price) FROM network_devices WHERE used=1"); 42 $Row4 = $DbResult->fetch_array(); 43 $Output .= 'Celková cena zařízení sítě: <strong>'.$Row4[0].' Kč</strong><br />'; 48 44 49 //echo('Předpokládané rozmezí měsíčního poplateku za internet pro jednoho uživatele: <strong>300 - 500 Kč</strong><br />'); 45 $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'); 46 $Row4 = $DbResult->fetch_array(); 47 $Output .= 'Celkem peněz na účtech: <strong>'.$Row4[0].' Kč</strong><br />'; 48 $Output .= 'Stanovená cena jedné kWh: <strong>'.$kWh.' Kč</strong><br />'; 49 //echo('Komunitou stanovený poplatek za správu sítě pro jednoho uživatele: <strong>'.$Sprava.' Kč</strong><br />'); 50 $DbResult = $this->Database->query("SELECT SUM(family) FROM users WHERE role=2"); 51 $Row5 = $DbResult->fetch_array(); 52 $TotalFamily = 600; 53 $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 />'; 54 $Output .= 'IČ: <strong>75904535</strong><br />'. 55 'DIČ: <strong>CZ8303255884</strong><br />'. 56 'Bankovní účet: <strong>218098370 / 0300</strong><br />'. 57 '<br />'; 50 58 51 //echo('Aktuální poplatek za internet pro jednoho uživatele: <strong>'.round($Internet/$InternetUsers).' Kč</strong><br />');59 $Output .= '</td><td valign="top">'; 52 60 53 $DbResult = $Database->query("SELECT SUM(price) FROM network_devices WHERE used=1"); 54 $Row4 = $DbResult->fetch_array(); 55 echo('Celková cena zařízení sítě: <strong>'.$Row4[0].' Kč</strong><br />'); 56 $DbResult = $Database->query("SELECT SUM(cash) FROM users"); 57 $Row4 = $DbResult->fetch_array(); 58 echo('Celkem peněz na účtech: <strong>'.$Row4[0].' Kč</strong><br />'); 59 echo('Stanovená cena jedné kWh: <strong>'.$kWh.' Kč</strong><br />'); 60 //echo('Komunitou stanovený poplatek za správu sítě pro jednoho uživatele: <strong>'.$Sprava.' Kč</strong><br />'); 61 $DbResult = $Database->query("SELECT SUM(family) FROM users WHERE role=2"); 62 $Row5 = $DbResult->fetch_array(); 63 $TotalFamily = 600; 64 echo('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 />'); 65 echo('IČ: <strong>75904535</strong><br />'. 66 'DIČ: <strong>CZ8303255884</strong><br />'. 67 'Bankovní účet: <strong>218098370 / 0300</strong><br />'. 68 '<br />'); 61 $UsersPayment = $TotalInternetPaid; 62 $NetworkManagement = $Sprava * $SpravaUsers; 63 $TotalGain = 0; 64 $TotalExpense = 0; 65 $DbResult = $this->Database->query("SELECT SUM(consumption) FROM network_devices WHERE used=1"); 66 $Row = $DbResult->fetch_array(); 67 $TotalConsumption = W2Kc($Row[0]); 69 68 70 echo('</td><td valign="top">'); 69 $Output .= 'Měsíční vyúčtování:<br /> 70 <table border="1" cellspacing="0" cellpadding="3"> 71 <tr><th>Položka</th><th>Cena [Kč]</th></tr> 72 <tr><th colspan="2">Příjmy</th></tr>'; 73 $Output .= '<tr><td>Poplatky účastníků za internet</td><td align="right">'.$UsersPayment.'</td></tr>'; 74 $TotalGain += $UsersPayment; 75 $Output .= '<tr><td><strong>Celkem</strong></td><td align="right"><strong>'.$TotalGain.'</strong></td></tr>'; 76 $Output .= '<tr><th colspan="2">Výdaje</th></tr><tr><td>Internet</td><td align="right">'.$Internet.'</td></tr>'; 77 $TotalExpense += $Internet; 78 $Output .= '<tr><td>Správa sítě</td><td align="right">'.$NetworkManagement.'</td></tr>'; 79 $TotalExpense += $NetworkManagement; 80 $Output .= '<tr><td>Spotřeba energie</td><td align="right">'.$TotalConsumption.'</td></tr>'; 81 $TotalExpense += $TotalConsumption; 82 $Output .= '<tr><td><strong>Celkem</strong></td><td align="right"><strong>'.$TotalExpense.'</strong></td></tr>'; 83 $Output .= '<tr><td colspan="2"> </td></tr>'; 84 $Output .= '<tr><td><strong>Rozdíl</strong></td><td align="right"><strong>'.($TotalGain - $TotalExpense).'</strong></td></tr>'; 85 $Output .= '<tr><td>Převod do dalšího měsíce</td><td align="right">'.($TotalGain - $TotalExpense).'</td></tr>'; 86 $Output .= '</table><br />'; 87 $DbResult = $this->Database->select('users', 'cash', 'id='.$UserIdNetwork); 88 $Row = $DbResult->fetch_array(); 89 $NetworkCash = $Row['cash']; 90 $Output .= 'Stav účtu sítě: '.$NetworkCash.' Kč<br /><a href="clenove.php?show=user&id='.$UserIdNetwork.'">Výpis účtu</a><br />'; 71 91 72 $UsersPayment = $TotalInternetPaid; 73 $NetworkManagement = $Sprava * $SpravaUsers; 74 $TotalGain = 0; 75 $TotalExpense = 0; 76 $DbResult = $Database->query("SELECT SUM(consumption) FROM network_devices WHERE used=1"); 77 $Row = $DbResult->fetch_array(); 78 $TotalConsumption = W2Kc($Row[0]); 79 //$Users 80 81 echo('Měsíční vyúčtování:<br /> 82 <table border="1" cellspacing="0" cellpadding="3"> 83 <tr><th>Položka</th><th>Cena [Kč]</th></tr> 84 <tr><th colspan="2">Příjmy</th></tr>'); 85 echo('<tr><td>Poplatky účastníků za internet</td><td align="right">'.$UsersPayment.'</td></tr>'); 86 $TotalGain += $UsersPayment; 87 echo('<tr><td><strong>Celkem</strong></td><td align="right"><strong>'.$TotalGain.'</strong></td></tr>'); 88 echo('<tr><th colspan="2">Výdaje</th></tr> 89 <tr><td>Internet</td><td align="right">'.$Internet.'</td></tr>'); 90 $TotalExpense += $Internet; 91 echo('<tr><td>Správa sítě</td><td align="right">'.$NetworkManagement.'</td></tr>'); 92 $TotalExpense += $NetworkManagement; 93 echo('<tr><td>Spotřeba energie</td><td align="right">'.$TotalConsumption.'</td></tr>'); 94 $TotalExpense += $TotalConsumption; 95 echo('<tr><td><strong>Celkem</strong></td><td align="right"><strong>'.$TotalExpense.'</strong></td></tr>'); 96 echo('<tr><td colspan="2"> </td></tr>'); 97 echo('<tr><td><strong>Rozdíl</strong></td><td align="right"><strong>'.($TotalGain - $TotalExpense).'</strong></td></tr>'); 98 echo('<tr><td>Převod do dalšího měsíce</td><td align="right">'.($TotalGain - $TotalExpense).'</td></tr>'); 99 echo('</table><br />'); 100 $DbResult = $Database->select('users', 'cash', 'id='.$UserIdNetwork); 101 $Row = $DbResult->fetch_array(); 102 $NetworkCash = $Row['cash']; 103 //echo('Stav účtu sítě: '.$NetworkCash.' Kč<br />'); 104 //<a href="clenove.php?show=user&id='.$UserIdNetwork.'">Výpis účtu</a><br />'); 105 106 echo('</td></tr></table>'); 92 $Output .= '</td></tr></table>'; 107 93 108 94 /* … … 110 96 echo('<strong>Jak se rozpočítávají finance</strong><br />Internet i zařízení sítě se platí za domácnost. Systém výpočtu vychází z topologie sítě. Síť má stromovou topologii přičemž listy stromu jsou jednotliví uživatelé a kořen stromu je linka do internetu. Dosavadní systém je uzpůsoben tak, aby linky, které jsou nejvíce zatíženy, byly nejlépe zaplaceny a mohlo na nich tak být dražší a výkonější zařízení. Nejvytíženější linky se nazývají páteřní. Proto platí každý uživatel podílově zařízení, které vede od něj až ke kořenu stromu, což je v našem případě server Centrála s trvalým internetovým připojením. Pro jednoduchost je síť rozdělena na segmenty. Segment je část sítě, kterou využívá konstantní počet uživatelů. Každý segment je tvořen skupinou zařízení a má svoji celkovou cenu. Každý uživatel je přirozeně napojen na některý ze segmentů. Podíl klienta na zařízení sítě je vypočten jako součet podílů na jednotlivých segmentech směrem ke kořenu. Podíl na segmentu znamená celková cena segmentu podělená počtem uživatelů využívajících daný segment.<br />'); 111 97 */ 112 ShowFooter(); 98 return($Output); 99 } 100 } 101 102 $System->AddModule(new FinanceOverview()); 103 $System->Modules['FinanceOverview']->GetOutput(); 104 113 105 ?> -
www/finance/inventory.php
r4 r152 1 1 <?php 2 include ('../global.php');3 include ('../style.php');2 include_once('../global.php'); 3 include_once('include.php'); 4 4 5 ShowHeader('Zařízení sítě','Zařízení'); 5 class FinanceStoragePage extends Page 6 { 7 var $FullTitle = 'Skladové zásoby'; 8 var $ShortTitle = 'Sklad'; 6 9 7 // Seznam segmentů a zařízení 8 $TotalPrice = 0; 9 echo('Výpis skladových zásob:<br><table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'); 10 echo('<tr><th>Název</th><th>Datum<br>zakoupení</th><th>Cena [Kč]</th><th>Počet</th><th>Cena<br> dohromady [Kč]</th></tr>'); 11 $DbResult = $Database->query("SELECT * FROM network_devices WHERE used=2"); 12 while($Row = $DbResult->fetch_array()) 13 { 14 echo('<tr><td>'.$Row['name'].'</td><td align="right">'.HumanDate($Row['date']).'</td><td align="right">'.$Row['price'].'</td><td align="right">'.$Row['count'].'</td><td align="right">'.$Row['count'] * $Row['price'].'</td></tr>'); 15 $TotalPrice = $TotalPrice + $Row['count'] * $Row['price']; 10 function Show() 11 { 12 $TotalPrice = 0; 13 $Output = 'Výpis skladových zásob:<br><table class="WideTable">'; 14 $Output .= '<tr><th>Název</th><th>Datum<br />zakoupení</th><th>Cena [Kč]</th><th>Počet</th><th>Cena<br /> dohromady [Kč]</th></tr>'; 15 $DbResult = $this->Database->query("SELECT * FROM network_devices WHERE used=2"); 16 while($Row = $DbResult->fetch_array()) 17 { 18 $Output .= '<tr><td>'.$Row['name'].'</td><td align="right">'.HumanDate($Row['date']).'</td><td align="right">'.$Row['price'].'</td><td align="right">'.$Row['count'].'</td><td align="right">'.$Row['count'] * $Row['price'].'</td></tr>'; 19 $TotalPrice = $TotalPrice + $Row['count'] * $Row['price']; 20 } 21 22 $Output .= '<tr><td colspan="4"><strong>Celkem:</strong></td><td align="right"><strong>'.$TotalPrice.'</strong></td></tr>'; 23 $Output .= '</table>'; 24 return($Output); 25 } 16 26 } 17 27 18 echo('<tr><td colspan="4"><strong>Celkem:</strong></td><td align="right"><strong>'.$TotalPrice.'</strong></td></tr>');19 echo('</table>');28 $System->AddModule(new FinanceStoragePage()); 29 $System->Modules['FinanceStoragePage']->GetOutput(); 20 30 21 ShowFooter();22 31 ?> -
www/finance/manage.php
r144 r152 1 1 <?php 2 3 include('finance.php'); 4 include('bills.php'); 5 6 /* 7 if(array_key_exists('Operation', $_GET)) $Operation = $_GET['Operation']; else $Operation = ''; 8 switch($Operation) 2 include_once('../global.php'); 3 include_once('include.php'); 4 5 class FinanceManagePage extends Page 9 6 { 10 case 'NewPaymentInsert': 11 $Output = ShowNewPaymentInsert(); 12 break; 13 case 'NewPaymentForm': 14 $Output = ShowNewPaymentForm(); 15 break; 16 case 'NewInvoiceForm': 17 $Output = ShowNewInvoiceForm(); 18 break; 19 default: 20 $Output = '<a href="?Operation=NewPaymentForm">Přidat novou platbu</a><br>'; 21 $Output .= '<a href="?Operation=NewInvoiceForm">Přidat novou fakturu</a><br>'; 22 } 23 echo(FormatOutput($Output)); 24 */ 25 26 function CheckAdvancesAndLiabilities($Subject) 27 { 28 global $Database, $LastInsertTime; 29 do { 30 $DbResult = $Database->select('FinanceAdvances', 'SUM(Value)', 'Subject='.$Subject.' AND Direction = "In"'); 31 $DbRow = $DbResult->fetch_array(); 32 $Advances = $DbRow[0]; 33 $DbResult = $Database->select('FinanceClaimsLiabilities', '*', 'Subject='.$Subject.' AND TimePayment IS NULL AND Value > 0 ORDER BY TimeCreation LIMIT 1'); 34 //echo($Database->error); 35 if($DbResult->num_rows > 0) 36 { 37 $OpenedClaim = $DbResult->fetch_array(); 38 if($Advances > $OpenedClaim['Value']) 39 { 40 $Database->update('FinanceClaimsLiabilities', 'Id='.$OpenedClaim['Id'], array('TimePayment' => TimeToMysqlDateTime($LastInsertTime))); 41 $Database->insert('FinanceAdvances', array('Subject' => $OpenedClaim['Subject'], 'Value' => -$OpenedClaim['Value'], 'TimeCreation' => TimeToMysqlDateTime($LastInsertTime), 'CashFlowId' => $OpenedClaim['Id'], 'Direction' => 'In')); 42 //echo($Database->LastQuery); 7 var $FullTitle = 'Správa financí'; 8 var $ShortTitle = 'Správa financí'; 9 10 function Show() 11 { 12 //if(!$this->System->Modules['User']->CheckPermission('Finance', 'Manage')) return('Nemáte oprávnění'); 13 14 if(array_key_exists('Operation', $_GET)) $Operation = $_GET['Operation']; else $Operation = ''; 15 switch($Operation) 16 { 17 case 'Bills': 18 $Output = $this->BillManage(); 19 break; 20 case 'ConvertPDFToFile': 21 $Output = $this->ConvertPDFDataToFiles(); 22 break; 23 case 'ImportOldData': 24 $Output = $this->ImportOldData(); 25 break; 26 case 'NewDeviceForm': 27 $Output = $this->ShowNewDeviceForm(); 28 break; 29 case 'NewDeviceInsert': 30 $Output = $this->ShowNewDeviceInsert(); 31 break; 32 case 'NewDeviceHistoryForm': 33 $Output = $this->ShowNewDeviceHistoryForm(); 34 break; 35 case 'NewDeviceHistoryInsert': 36 $Output = $this->ShowNewDeviceHistoryInsert(); 37 break; 38 case 'NewPaymentInsert': 39 $Output = $this->ShowNewPaymentInsert(); 40 break; 41 case 'NewPaymentForm': 42 $Output = $this->ShowNewPaymentForm(); 43 break; 44 case 'NewInvoiceInsert': 45 $Output = $this->ShowNewInvoiceInsert(); 46 break; 47 case 'NewInvoiceForm': 48 $Output = $this->ShowNewInvoiceForm(); 49 break; 50 default: 51 $Output = '<a href="?Operation=NewDeviceForm">Přidat nové zařízení</a><br>'; 52 $Output .= '<a href="?Operation=NewDeviceHistoryForm">Přidat nový záznam historie zařízení</a><br>'; 53 $Output .= '<a href="?Operation=NewPaymentForm">Přidat novou platbu</a><br>'; 54 $Output .= '<a href="?Operation=NewInvoiceForm">Přidat novou fakturu</a><br>'; 55 $Output .= '<a href="?Operation=ImportOldData">Importovat stará data</a><br>'; 56 $Output .= '<a href="?Operation=ConvertPDFToFile">Převést data z databáze do souborů</a><br>'; 57 $Output .= '<a href="?Operation=Bills">Správa dokladů</a><br>'; 58 } 59 return($Output); 60 } 61 62 function BillManage() 63 { 64 $Output = ''; 65 if(array_key_exists('user', $_GET)) 66 { 67 $DbResult = $this->Database->select('finance_bills', '*', 'user_id='.$_GET['user']); 68 while($Item = $DbResult->fetch_array()) 69 { 70 $Output .= '<a href="?Operation=Bills&bill='.$Item['id'].'">faktura '.$Item['id'].'</a> <a href="?Operation=Bills&billpdf='.$Item['id'].'">Uložené PDF</a> <a href="?Operation=Bills&billpdf2='.$Item['id'].'">Generované PDF</a> <a href="?Operation=Bills&regenerate='.$Item['id'].'">Přegenerovat</a><br />'; 71 } 72 } else 73 if(array_key_exists('billpdf', $_GET)) 74 { 75 $Output .= $this->System->Modules['Bill']->ShowStoredBill($_GET['billpdf']); 76 } else 77 if(array_key_exists('billpdf2', $_GET)) 78 { 79 $Output .= $this->System->Modules['Bill']->ShowGeneratedBill($_GET['billpdf2']); 80 } else 81 if(array_key_exists('regenerate', $_GET)) 82 { 83 $Output .= $this->System->Modules['Bill']->RegeneratePDF($_GET['regenerate']); 84 } else 85 if(array_key_exists('bill', $_GET)) 86 { 87 $Output .= $this->System->Modules['Bill']->GenerateBill($_GET['bill']); 88 } else 89 if(array_key_exists('generate', $_GET)) 90 { 91 $Output .= $this->System->Modules['Bill']->CreateBill(1, array(array('description' => 'Poplatek za připojení k síti', 'price' => 1000, 'quantity' => 1)), time(), time()); 92 } else 93 { 94 //ShowHeader('Faktury', 'Faktury'); 95 $Output .= 'Faktury:<br />'; 96 $DbResult = $this->Database->select('users', '*, CONCAT(second_name," ", first_name) as fullname', '1 ORDER BY fullname'); 97 while($User = $DbResult->fetch_array()) 98 { 99 $Output .= '<a href="?Operation=Bills&user='.$User['id'].'">'.$User['fullname'].'</a><br />'; 100 } 101 //ShowFooter(); 102 } 103 return($Output); 104 } 105 106 function CheckAdvancesAndLiabilities($Subject) 107 { 108 global $LastInsertTime; 109 110 do { 111 $DbResult = $this->Database->select('FinanceAdvances', 'SUM(Value)', 'Subject='.$Subject.' AND Direction = "In"'); 112 $DbRow = $DbResult->fetch_array(); 113 $Advances = $DbRow[0]; 114 $DbResult = $this->Database->select('FinanceClaimsLiabilities', '*', 'Subject='.$Subject.' AND TimePayment IS NULL AND Value > 0 ORDER BY TimeCreation LIMIT 1'); 115 //echo($Database->error); 116 if($DbResult->num_rows > 0) 117 { 118 $OpenedClaim = $DbResult->fetch_array(); 119 if($Advances > $OpenedClaim['Value']) 120 { 121 $this->Database->update('FinanceClaimsLiabilities', 'Id='.$OpenedClaim['Id'], array('TimePayment' => TimeToMysqlDateTime($LastInsertTime))); 122 $this->Database->insert('FinanceAdvances', array('Subject' => $OpenedClaim['Subject'], 'Value' => -$OpenedClaim['Value'], 'TimeCreation' => TimeToMysqlDateTime($LastInsertTime), 'CashFlowId' => $OpenedClaim['Id'], 'Direction' => 'In')); 123 //echo($Database->LastQuery); 124 } else break; 43 125 } else break; 44 } else break; 45 } while(($Advances > $OpenedClaim['Value'])); 46 } 47 48 function InsertLiability($Subject, $Value, $Time, $BillId, $Text, $TimePayment = '') 49 { 50 global $Database, $LastInsertTime; 51 if($TimePayment != '') $TimePayment = TimeToMysqlDateTime($TimePayment); 52 $Database->insert('FinanceClaimsLiabilities', array('Text' => $Text, 'Subject' => $Subject, 'TimeCreation' => TimeToMysqlDateTime($Time), 'TimeDue' => TimeToMysqlDateTime($Time + 3600*24*15), 'TimePayment' => $TimePayment, 'Value' => $Value, 'Bill' => $BillId)); 53 echo($Database->LastQuery.'<br>'); 54 $LastInsertTime = $Time; 55 CheckAdvancesAndLiabilities($Subject); 56 } 57 58 function InsertMoney($Subject, $Value, $Cash, $Taxable, $Time, $Text) 59 { 60 global $Database, $LastInsertTime; 61 $Database->insert('FinanceCashFlow', array('Text' => $Text, 'Subject' => $Subject, 'Cash' => $Cash, 'Value' => $Value, 'Time' => TimeToMysqlDateTime($Time), 'Taxable' => $Taxable)); 62 if($Value >= 0) 63 { 64 $Database->insert('FinanceAdvances', array('Subject' => $Subject, 'Value' => $Value, 'TimeCreation' => TimeToMysqlDateTime($Time), 'CashFlowId' => $Database->insert_id, 'Direction' => 'In')); 65 } 66 $LastInsertTime = $Time; 67 CheckAdvancesAndLiabilities($Subject); 68 } 69 70 function ShowNewPaymentForm() 71 { 72 global $Database; 73 $Values = array(); 74 $Output = '<form action="?Operation=NewPaymentInsert" method="post">'.ShowEditTable('NewPayment', $Values); 75 $Output .= '<input type="submit" value="Vložit"></form>'; 76 return($Output); 77 } 78 79 function ShowNewPaymentInsert() 80 { 81 global $Database; 82 $Values = LoadSubmitedData('NewPayment'); 83 InsertMoney($Values['Subject'], $Values['Value'], $Values['Cash'], $Value['Taxable'], $Values['Text'], time()); 84 echo('Nová platba vložena'); 85 //echo(phpinfo()); 86 } 87 88 function ShowNewInvoiceForm() 89 { 90 global $Database; 91 $Values = array(); 92 $Output = '<form action="?Operation=NewInvoiceInsert" method="post">'.ShowEditTable('NewInvoice', $Values); 93 $Output .= '<input type="submit" value="Vložit"></form>'; 94 return($Output); 95 } 96 97 function ImportOldData() 98 { 99 global $Database, $InvoiceGenerator; 100 101 $Database->query('TRUNCATE TABLE FinanceCashFlow'); 102 $Database->query('TRUNCATE TABLE FinanceClaimsLiabilities'); 103 $Database->query('TRUNCATE TABLE FinanceAdvances'); 104 $Database->query('TRUNCATE TABLE FinanceSmallAssets'); 105 106 // Move time of device price transformation 107 $Database->query('UPDATE finance_operations SET date="2007-11-30" WHERE comment = "Jednorázový poplatek za společné zařízení"'); 108 109 // Transfer finance before era 110 $DbResult = $Database->query('SELECT * FROM users WHERE role=2'); 111 while($User = $DbResult->fetch_array()) 112 { 113 $DbResult2 = $Database->query('SELECT SUM(money) FROM finance_operations WHERE user='.$User['id'].' AND date < "2007-12-01"'); 114 $Row = $DbResult2->fetch_array(); 115 $TotalAdvance = $Row[0]; 116 //echo($User['second_name'].' '.$User['first_name'].' '.$TotalAdvance.'<br>'); 117 // Záloha 118 if($TotalAdvance > 0) 119 { 120 InsertMoney($User['id'], $TotalAdvance, 0, 1, mktime(0, 0, 0, 12, 1, 2007), 'Přijatá záloha (z období před daňovou evidencí)'); 121 } 122 // Dluh 123 if($TotalAdvance < 0) 124 { 125 InsertLiability($User['id'], (-$Row[0]), mktime(0, 0, 0, 12, 1, 2007), 0, 'Připojení k síti (z období před daňovou evidencí)'); 126 //echo($Database->LastQuery.'<br>'); 127 } 128 } 129 130 // Transfer finance after era 131 // $DbResult = $Database->query('SELECT * FROM users WHERE role=2'); 132 // while($User = $DbResult->fetch_array()) 133 // { 134 $DbResult2 = $Database->query('SELECT finance_operations.*, users.role as role FROM finance_operations JOIN users ON users.id = finance_operations.user WHERE finance_operations.date >= "2007-12-01"'); 126 } while(($Advances > $OpenedClaim['Value'])); 127 } 128 129 function InsertLiability($Subject, $Value, $Time, $BillId, $Text, $TimePayment = '') 130 { 131 global $LastInsertTime; 132 133 if($TimePayment != '') $TimePayment = TimeToMysqlDateTime($TimePayment); 134 $this->Database->insert('FinanceClaimsLiabilities', array('Text' => $Text, 'Subject' => $Subject, 'TimeCreation' => TimeToMysqlDateTime($Time), 'TimeDue' => TimeToMysqlDateTime($Time + 3600*24*15), 'TimePayment' => $TimePayment, 'Value' => $Value, 'Bill' => $BillId)); 135 $Output = $this->Database->LastQuery.'<br />'; 136 $LastInsertTime = $Time; 137 $this->CheckAdvancesAndLiabilities($Subject); 138 return($Output); 139 } 140 141 function InsertMoney($Subject, $Value, $Cash, $Taxable, $Time, $Text) 142 { 143 global $LastInsertTime; 144 145 $this->Database->insert('FinanceCashFlow', array('Text' => $Text, 'Subject' => $Subject, 'Cash' => $Cash, 'Value' => $Value, 'Time' => TimeToMysqlDateTime($Time), 'Taxable' => $Taxable)); 146 if($Value >= 0) 147 { 148 $this->Database->insert('FinanceAdvances', array('Subject' => $Subject, 'Value' => $Value, 'TimeCreation' => TimeToMysqlDateTime($Time), 'CashFlowId' => $this->Database->insert_id, 'Direction' => 'In')); 149 } 150 $LastInsertTime = $Time; 151 $this->CheckAdvancesAndLiabilities($Subject); 152 } 153 154 function ShowNewDeviceForm() 155 { 156 $Form = new Form('NewNetworkDevice'); 157 $Form->OnSubmit = '?Operation=NewDeviceInsert'; 158 $Output = $Form->ShowEditForm(); 159 return($Output); 160 } 161 162 function ShowNewDeviceInsert() 163 { 164 $Form = new Form('NewNetworkDevice'); 165 $Form->LoadValuesFromForm(); 166 $Form->SaveValuesToDatabase(0); 167 $Output = $this->SystemMessage('Finance', 'Zařízení vloženo.'); 168 $this->System->Modules['Log']->NewRecord('Finance', 'NewDeviceInserted'); 169 return($Output); 170 } 171 172 function ShowNewDeviceHistoryForm() 173 { 174 $Form = new Form('NewNetworkDeviceHistory'); 175 $Form->OnSubmit = '?Operation=NewDeviceHistoryInsert'; 176 $Output = $Form->ShowEditForm(); 177 return($Output); 178 } 179 180 function ShowNewDeviceHistoryInsert() 181 { 182 $Form = new Form('NewNetworkDeviceHistory'); 183 $Form->LoadValuesFromForm(); 184 $Form->SaveValuesToDatabase(0); 185 $Output = $this->SystemMessage('Finance', 'Záznam historie zařízení vložen.'); 186 $this->System->Modules['Log']->NewRecord('Finance', 'NewDeviceHistoryInserted'); 187 return($Output); 188 } 189 190 function ShowNewPaymentForm() 191 { 192 $Form = new Form('NewPayment'); 193 $Form->OnSubmit = '?Operation=NewPaymentInsert'; 194 $Output = $Form->ShowEditForm(); 195 return($Output); 196 } 197 198 function ShowNewPaymentInsert() 199 { 200 $Form = new Form('NewPayment'); 201 $Form->LoadValuesFromForm(); 202 $this->InsertMoney($Form->Values['Subject'], $Form->Values['Value'], $Form->Values['Cash'], $Form->Values['Taxable'], $Form->Values['Time'], $Form->Values['Text']); 203 $Output = $this->SystemMessage('Finance', 'Platba vložena.'); 204 $this->System->Modules['Log']->NewRecord('Finance', 'NewPaymentInserted'); 205 return($Output); 206 } 207 208 function ShowNewInvoiceForm() 209 { 210 $Form = new Form('NewInvoice'); 211 $Form->OnSubmit = '?Operation=NewInvoiceInsert'; 212 $Output = $Form->ShowEditForm(); 213 return($Output); 214 } 215 216 function ShowNewInvoiceInsert() 217 { 218 $Form = new Form('NewInvoice'); 219 $Form->LoadvaluesFromForm(); 220 //print_r($Form->Values); 221 //$this->InsertLiability($Form->Values['Subject'], $Form->Values['Value'], $Form->Values['Time'], $BillId, $Text, $TimePayment = '') 222 $Output = $this->SystemMessage('Finance', 'Faktura vložena..'); 223 $this->System->Modules['Log']->NewRecord('Finance', 'NewInvoiceInserted'); 224 return($Output); 225 } 226 227 function ImportOldData() 228 { 229 global $InvoiceGenerator; 230 231 $Output = ''; 232 $this->Database->query('TRUNCATE TABLE FinanceCashFlow'); 233 $this->Database->query('TRUNCATE TABLE FinanceClaimsLiabilities'); 234 $this->Database->query('TRUNCATE TABLE FinanceAdvances'); 235 $this->Database->query('TRUNCATE TABLE FinanceSmallAssets'); 236 237 // Move time of device price transformation 238 $this->Database->query('UPDATE finance_operations SET date="2007-11-30" WHERE comment = "Jednorázový poplatek za společné zařízení"'); 239 240 // Transfer finance before era 241 $DbResult = $this->Database->query('SELECT * FROM users WHERE role=2'); 242 while($User = $DbResult->fetch_array()) 243 { 244 $DbResult2 = $this->Database->query('SELECT SUM(money) FROM finance_operations WHERE user='.$User['id'].' AND date < "2007-12-01"'); 245 $Row = $DbResult2->fetch_array(); 246 $TotalAdvance = $Row[0]; 247 //echo($User['second_name'].' '.$User['first_name'].' '.$TotalAdvance.'<br>'); 248 // Záloha 249 if($TotalAdvance > 0) 250 { 251 $this->InsertMoney($User['id'], $TotalAdvance, 0, 1, mktime(0, 0, 0, 12, 1, 2007), 'Přijatá záloha (z období před daňovou evidencí)'); 252 } 253 // Dluh 254 if($TotalAdvance < 0) 255 { 256 $this->InsertLiability($User['id'], (-$Row[0]), mktime(0, 0, 0, 12, 1, 2007), 0, 'Připojení k síti (z období před daňovou evidencí)'); 257 //echo($Database->LastQuery.'<br>'); 258 } 259 } 260 261 // Transfer finance after era 262 // $DbResult = $Database->query('SELECT * FROM users WHERE role=2'); 263 // while($User = $DbResult->fetch_array()) 264 // { 265 $DbResult2 = $this->Database->query('SELECT finance_operations.*, users.role as role FROM finance_operations JOIN users ON users.id = finance_operations.user WHERE finance_operations.date >= "2007-12-01"'); 135 266 while($Operation = $DbResult2->fetch_array()) 136 267 { … … 138 269 if(substr($Operation['comment'], 0, 19) == 'Poplatek za měsíc') 139 270 { 140 InsertLiability($Operation['user'], -$Operation['money'], MysqlDateToTime($Operation['date']), $Operation['bill_id'], 'Připojení k síti');141 echo($Operation['user'].' '.$Operation['money'].' Připojení k síti<br>');271 $this->InsertLiability($Operation['user'], -$Operation['money'], MysqlDateToTime($Operation['date']), $Operation['bill_id'], 'Připojení k síti'); 272 $Output .= $Operation['user'].' '.$Operation['money'].' Připojení k síti<br />'; 142 273 } else 143 274 if($Operation['comment'] == 'Vklad') 144 275 { 145 InsertMoney($Operation['user'], $Operation['money'], 0, 1, MysqlDateToTime($Operation['date']), 'Přijatá záloha');276 $this->InsertMoney($Operation['user'], $Operation['money'], 0, 1, MysqlDateToTime($Operation['date']), 'Přijatá záloha'); 146 277 //echo($Operation['user'].' '.$Operation['money'].' Přijatá záloha<br>'); 147 278 } else 148 279 if($Operation['comment'] == 'Internet') 149 280 { 150 InsertLiability($Operation['user'], $Operation['money'], MysqlDateToTime($Operation['date']), $Operation['bill_id'], 'Měsíční paušál za Internet', MysqlDateToTime($Operation['date']));151 InsertMoney($Operation['user'], $Operation['money'], 0, 1, MysqlDateToTime($Operation['date']), 'Měsíční paušál za Internet');281 $this->InsertLiability($Operation['user'], $Operation['money'], MysqlDateToTime($Operation['date']), $Operation['bill_id'], 'Měsíční paušál za Internet', MysqlDateToTime($Operation['date'])); 282 $this->InsertMoney($Operation['user'], $Operation['money'], 0, 1, MysqlDateToTime($Operation['date']), 'Měsíční paušál za Internet'); 152 283 } else 153 284 if($Operation['comment'] == 'Sociální pojištění') 154 285 { 155 InsertLiability($Operation['user'], $Operation['money'], MysqlDateToTime($Operation['date']), $Operation['bill_id'], $Operation['comment'], MysqlDateToTime($Operation['date']));156 InsertMoney($Operation['user'], $Operation['money'], 0, 1, MysqlDateToTime($Operation['date']), $Operation['comment']);286 $this->InsertLiability($Operation['user'], $Operation['money'], MysqlDateToTime($Operation['date']), $Operation['bill_id'], $Operation['comment'], MysqlDateToTime($Operation['date'])); 287 $this->InsertMoney($Operation['user'], $Operation['money'], 0, 1, MysqlDateToTime($Operation['date']), $Operation['comment']); 157 288 } else 158 289 { 159 $DbResult = $ Database->query('SELECT role FROM users WHERE id='.$Operation['user']);290 $DbResult = $this->Database->query('SELECT role FROM users WHERE id='.$Operation['user']); 160 291 while($User = $DbResult->fetch_array()) 161 162 InsertLiability($Operation['user'], -$Operation['money'], MysqlDateToTime($Operation['date']), $Operation['bill_id'], $Operation['comment'], MysqlDateToTime($Operation['date'])); 163 echo($Operation['user'].' '.$Operation['comment'].' '.MysqlDateToTime($Operation['date']).'<br>'); 292 $this->InsertLiability($Operation['user'], -$Operation['money'], MysqlDateToTime($Operation['date']), $Operation['bill_id'], $Operation['comment'], MysqlDateToTime($Operation['date'])); 293 $Output .= $Operation['user'].' '.$Operation['comment'].' '.MysqlDateToTime($Operation['date']).'<br />'; 164 294 165 295 if(($Operation['role'] == 2)) 166 { 167 echo('A');168 $ Database->insert('FinanceAdvances', array('Subject' => $Operation['user'], 'Value' => $Operation['money'], 'TimeCreation' => MysqlDateToTime($Operation['date']), 'CashFlowId' => 0, 'Direction' => 'In'));169 CheckAdvancesAndLiabilities($Operation['user']);296 { 297 $Output .= 'A'; 298 $this->Database->insert('FinanceAdvances', array('Subject' => $Operation['user'], 'Value' => $Operation['money'], 'TimeCreation' => MysqlDateToTime($Operation['date']), 'CashFlowId' => 0, 'Direction' => 'In')); 299 $this->CheckAdvancesAndLiabilities($Operation['user']); 170 300 } else InsertMoney($Operation['user'], $Operation['money'], 0, 1, MysqlDateToTime($Operation['date']), $Operation['comment']); 171 301 } 172 302 } 173 // } 174 175 // Import small asset 176 $Subject = 1; 177 178 // Převod pro minulý rok 179 $Time = mktime(0, 0, 0, 12, 10, 2007); 180 $DbResult = $Database->query('SELECT * FROM network_devices WHERE used <> 0 AND date < "'.TimeToMysqlDateTime($Time).'" AND (id <> 73)'); 181 $Items = array(); 182 $TotalPrice = 0; 183 while($Device = $DbResult->fetch_array()) 184 { 185 //$Database->insert('FinanceSmallAsset', array()); 186 $Items[] = array('description' => $Device['name'], 'quantity' => $Device['count'], 'price' => 0); //$Device['price']); 187 $LastId = $Device['id']; 188 $TotalPrice += $Device['price'] * $Device['count']; 189 if($TotalPrice > 55000) break; 190 } 191 //print_r($Items); 192 $BillId = $InvoiceGenerator->CreateBill($Subject, $Items, $Time, $Time); 193 $DbResult = $Database->query('UPDATE network_devices SET TimeEnlistment = "'.TimeToMysqlDateTime($Time).'" WHERE used <> 0 AND date < "'.TimeToMysqlDateTime($Time).'" AND (id <> 73) AND (id <= '.$LastId.')'); 194 //echo($Database->error); 195 InsertLiability($Subject, 0, $Time, $BillId, 'Nákup infrastruktury', $Time); 196 //InsertMoney($Subject, 0, 0, 1, $Time, 'Nákup infrastruktury'); 197 198 //echo($LastId); 199 200 // Převod tento rok 201 $Time = mktime(0, 0, 0, 1, 14, 2008); 202 $DbResult = $Database->query('SELECT * FROM network_devices WHERE (used <> 0) AND (id > '.$LastId.') AND date < "'.TimeToMysqlDateTime($Time).'"'); 203 $Items = array(); 204 $TotalPrice = 0; 205 while($Device = $DbResult->fetch_array()) 206 { 207 //$Database->insert('FinanceSmallAsset', array()); 208 $Items[] = array('description' => $Device['name'], 'quantity' => $Device['count'], 'price' => 0); //$Device['price']); 209 $TotalPrice += $Device['price'] * $Device['count']; 210 } 211 //print_r($Items); 212 $BillId = $InvoiceGenerator->CreateBill($Subject, $Items, $Time, $Time); 213 $DbResult = $Database->query('UPDATE network_devices SET TimeEnlistment = "'.TimeToMysqlDateTime($Time).'" WHERE used <> 0 AND date < "'.TimeToMysqlDateTime($Time).'" AND (id > '.$LastId.')'); 214 InsertLiability($Subject, 0, $Time, $BillId, 'Nákup infrastruktury', $Time); 215 //InsertMoney($Subject, 0, 0, 1, $Time, 'Nákup infrastruktury'); 216 217 218 // Make absolute value in monthly overall 219 //$Database->query('UPDATE finance_monthly_overall SET total_paid = ABS(total_paid)'); 220 //$Database->query('UPDATE finance_monthly_overall SET member_count = (SELECT COUNT(*) FROM users WHERE users.role=2 AND users.membership_date < finance_monthly_overall.date)'); 303 // } 304 305 // Import small asset 306 $Subject = 1; 307 308 // Převod pro minulý rok 309 $Time = mktime(0, 0, 0, 12, 10, 2007); 310 $DbResult = $this->Database->query('SELECT * FROM network_devices WHERE used <> 0 AND date < "'.TimeToMysqlDateTime($Time).'" AND (id <> 73)'); 311 $Items = array(); 312 $TotalPrice = 0; 313 while($Device = $DbResult->fetch_array()) 314 { 315 //$Database->insert('FinanceSmallAsset', array()); 316 $Items[] = array('description' => $Device['name'], 'quantity' => $Device['count'], 'price' => 0); //$Device['price']); 317 $LastId = $Device['id']; 318 $TotalPrice += $Device['price'] * $Device['count']; 319 if($TotalPrice > 55000) break; 320 } 321 //print_r($Items); 322 $BillId = $InvoiceGenerator->CreateBill($Subject, $Items, $Time, $Time); 323 $DbResult = $this->Database->query('UPDATE network_devices SET TimeEnlistment = "'.TimeToMysqlDateTime($Time).'" WHERE used <> 0 AND date < "'.TimeToMysqlDateTime($Time).'" AND (id <> 73) AND (id <= '.$LastId.')'); 324 //echo($Database->error); 325 $this->InsertLiability($Subject, 0, $Time, $BillId, 'Nákup infrastruktury', $Time); 326 //InsertMoney($Subject, 0, 0, 1, $Time, 'Nákup infrastruktury'); 327 328 //echo($LastId); 329 330 // Převod tento rok 331 $Time = mktime(0, 0, 0, 1, 14, 2008); 332 $DbResult = $this->Database->query('SELECT * FROM network_devices WHERE (used <> 0) AND (id > '.$LastId.') AND date < "'.TimeToMysqlDateTime($Time).'"'); 333 $Items = array(); 334 $TotalPrice = 0; 335 while($Device = $DbResult->fetch_array()) 336 { 337 // $Database->insert('FinanceSmallAsset', array()); 338 $Items[] = array('description' => $Device['name'], 'quantity' => $Device['count'], 'price' => 0); //$Device['price']); 339 $TotalPrice += $Device['price'] * $Device['count']; 340 } 341 //print_r($Items); 342 $BillId = $InvoiceGenerator->CreateBill($Subject, $Items, $Time, $Time); 343 $DbResult = $this->Database->query('UPDATE network_devices SET TimeEnlistment = "'.TimeToMysqlDateTime($Time).'" WHERE used <> 0 AND date < "'.TimeToMysqlDateTime($Time).'" AND (id > '.$LastId.')'); 344 $this->InsertLiability($Subject, 0, $Time, $BillId, 'Nákup infrastruktury', $Time); 345 //InsertMoney($Subject, 0, 0, 1, $Time, 'Nákup infrastruktury'); 346 347 348 // Make absolute value in monthly overall 349 //$Database->query('UPDATE finance_monthly_overall SET total_paid = ABS(total_paid)'); 350 //$Database->query('UPDATE finance_monthly_overall SET member_count = (SELECT COUNT(*) FROM users WHERE users.role=2 AND users.membership_date < finance_monthly_overall.date)'); 351 return($Output); 352 } 353 354 function ConvertPDFDataToFiles() 355 { 356 $DbResult = $this->Database->query('SELECT * FROM finance_bills'); 357 while($Bill = $DbResult->fetch_array()) 358 { 359 file_put_contents('doklady/doklad_'.$Bill['id'].'.pdf', $Bill['pdf']); 360 echo($Bill['id'].','); 361 } 362 } 363 364 function CheckPDFFiles() 365 { 366 global $Database, $InvoiceGenerator; 367 368 $DbResult = $this->Database->query('SELECT * FROM finance_bills'); 369 while($Bill = $DbResult->fetch_array()) 370 { 371 file_put_contents('doklady2/doklad-'.$Bill['id'].'.pdf', file_get_contents('doklady/doklad-'.$Bill['id'].'.pdf')); 372 //echo($InvoiceGenerator->HasPDFFile($Bill['id']).','); 373 } 374 } 375 221 376 } 222 377 223 function ConvertPDFDataToFiles() 224 { 225 global $Database; 226 $DbResult = $Database->query('SELECT * FROM finance_bills'); 227 while($Bill = $DbResult->fetch_array()) 228 { 229 file_put_contents('doklady/doklad-'.$Bill['id'].'.pdf', $Bill['pdf']); 230 echo($Bill['id'].','); 231 } 232 233 } 234 235 function CheckPDFFiles() 236 { 237 global $Database, $InvoiceGenerator; 238 239 $DbResult = $Database->query('SELECT * FROM finance_bills'); 240 while($Bill = $DbResult->fetch_array()) 241 { 242 file_put_contents('doklady2/doklad-'.$Bill['id'].'.pdf', file_get_contents('doklady/doklad-'.$Bill['id'].'.pdf')); 243 //echo($InvoiceGenerator->HasPDFFile($Bill['id']).','); 244 } 245 246 } 247 248 //ConvertPDFDataToFiles(); 249 250 //CheckPDFFiles(); 251 ImportOldData(); 378 $System->AddModule(new FinanceManagePage()); 379 $System->Modules['FinanceManagePage']->GetOutput(); 252 380 253 381 ?> -
www/finance/monthly_overall.php
r129 r152 1 1 <?php 2 include('../global.php'); 3 include('../style.php'); 4 include('include.php'); 5 ShowHeader('Měsíční přehledy', 'Měsíční přehledy'); 2 include_once('../global.php'); 3 include_once('include.php'); 6 4 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 while($Month = $DbResult->fetch_array()) 5 class FinanceMonthlyOverallPage extends Page 11 6 { 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><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>'); 7 var $FullTitle = 'Měsíční přehledy'; 8 var $ShortTitle = 'Měsíční přehledy'; 15 9 16 $Total['money'] += $Month['money']; 17 $Total['administration_total'] += $Month['administration_total']; 18 $Total['consumption_total'] += $Month['consumption_total']; 19 $Total['total_paid'] += $Month['total_paid']; 20 $Total['investment'] += $Month['investment']; 21 //if($DateParts[1] == '01') echo('<tr><td style="font-size: 4;" colspan="10"> </td></tr>'); 10 function Show() 11 { 12 global $MonthNames; 13 14 $Output = '<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 align="center">Investice [Kč]</th></tr>'; 15 $Total = array('money' => 0, 'administration_total' => 0, 'consumption_total' => 0, 'total_paid' => 0); 16 $DbResult = $this->Database->select('finance_monthly_overall', '*', '1 ORDER BY date DESC'); 17 while($Month = $DbResult->fetch_array()) 18 { 19 $DateParts = explode('-', $Month['date']); 20 $Output .= '<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>'; 21 22 $Total['money'] += $Month['money']; 23 $Total['administration_total'] += $Month['administration_total']; 24 $Total['consumption_total'] += $Month['consumption_total']; 25 $Total['total_paid'] += $Month['total_paid']; 26 $Total['investment'] += $Month['investment']; 27 //if($DateParts[1] == '01') echo('<tr><td style="font-size: 4;" colspan="10"> </td></tr>'); 28 } 29 $Output .= '<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'].'</th>'; 30 $Output .= '</table>'; 31 return($Output); 32 } 22 33 } 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>');24 echo('</table>');25 34 26 ShowFooter(); 35 $System->AddModule(new FinanceMonthlyOverallPage()); 36 $System->Modules['FinanceMonthlyOverallPage']->GetOutput(); 37 27 38 ?> -
www/finance/spotreba.php
r4 r152 1 1 <?php 2 2 include_once('../global.php'); 3 include('../style.php'); 4 include('include.php'); 3 include_once('include.php'); 5 4 6 ShowHeader('Spotřeba energie','Spotřeba'); 5 class FinanceConsumption extends Page 6 { 7 var $FullTitle = 'Spotřeba energie'; 8 var $ShortTitle = 'Spotřeba'; 7 9 8 // Seznam segmentů a zařízení 9 echo('Spotřeba zařízení jednotlivých segmentů:<br><table border="1" cellspacing="0" cellpadding="3"><tr><th>Jméno segmentu</th><th>Spotřeba [W]</th><th>Cena [Kč/měsíc]</th></tr>'); 10 $CelkovaSpotreba = 0; 11 $DbResult = $Database->query("SELECT * FROM network_segments"); 12 while($Row = $DbResult->fetch_array()) 13 { 14 $DbResult2 = $Database->query("SELECT SUM(consumption) FROM network_devices WHERE segment=".$Row['id']." AND used=1"); 15 $Row2 = $DbResult2->fetch_array(); 16 $CelkovaSpotreba = $CelkovaSpotreba + $Row2[0]; 17 echo('<tr><td>'.$Row['name'].'</td><td align="right">'.$Row2[0].'</td><td align="right">'.W2Kc($Row2[0]).'</td></tr>'); 10 function Show() 11 { 12 global $kWh; 13 14 // Seznam segmentů a zařízení 15 $Output = 'Spotřeba zařízení jednotlivých segmentů:<br /><table border="1" cellspacing="0" cellpadding="3"><tr><th>Jméno segmentu</th><th>Spotřeba [W]</th><th>Cena [Kč/měsíc]</th></tr>'; 16 $CelkovaSpotreba = 0; 17 $DbResult = $this->Database->query("SELECT * FROM network_segments"); 18 while($Row = $DbResult->fetch_array()) 19 { 20 $DbResult2 = $this->Database->query("SELECT SUM(consumption) FROM network_devices WHERE segment=".$Row['id']." AND used=1"); 21 $Row2 = $DbResult2->fetch_array(); 22 $CelkovaSpotreba = $CelkovaSpotreba + $Row2[0]; 23 $Output .= '<tr><td>'.$Row['name'].'</td><td align="right">'.$Row2[0].'</td><td align="right">'.W2Kc($Row2[0]).'</td></tr>'; 24 } 25 $Output .= '<tr style="font-weight: Bold;"><td><strong>Celkem</strong></td><td align="right">'.$CelkovaSpotreba.'</td><td align="right">'.W2Kc($CelkovaSpotreba).'</td></tr>'; 26 $Output .= '</table><br />'; 27 $Output .= 'Dohodnutá cena za jednu kWh: <strong>'.$kWh.' Kč</strong><br />'; 28 return($Output); 29 } 18 30 } 19 echo('<tr style="font-weight: Bold;"><td><strong>Celkem</strong></td><td align="right">'.$CelkovaSpotreba.'</td><td align="right">'.W2Kc($CelkovaSpotreba).'</td></tr>');20 echo('</table><br>');21 echo('Dohodnutá cena za jednu kWh: <strong>'.$kWh.' Kč</strong><br>');22 31 23 /* 24 echo('<strong>Jak se rozpočítávají finance</strong><br>Internet i zařízení sítě se platí za domácnost. Systém výpočtu vychází z topologie sítě. Síť má stromovou topologii přičemž listy stromu jsou jednotliví uživatelé a kořen stromu je linka do internetu. Dosavadní systém je uzpůsoben tak, aby linky, které jsou nejvíce zatíženy, byly nejlépe zaplaceny a mohlo na nich tak být dražší a výkonější zařízení. Nejvytíženější linky se nazývají páteřní. Proto platí každý uživatel podílově zařízení, které vede od něj až ke kořenu stromu, což je v našem případě server Centrála s trvalým internetovým připojením. Pro jednoduchost je síť rozdělena na segmenty. Segment je část sítě, kterou využívá konstantní počet uživatelů. Každý segment je tvořen skupinou zařízení a má svoji celkovou cenu. Každý uživatel je přirozeně napojen na některý ze segmentů. Podíl klienta na zařízení sítě je vypočten jako součet podílů na jednotlivých segmentech směrem ke kořenu. Podíl na segmentu znamená celková cena segmentu podělená počtem uživatelů využívajících daný segment.<br>'); 25 } 26 */ 27 ShowFooter(); 32 $System->AddModule(new FinanceConsumption()); 33 $System->Modules['FinanceConsumption']->GetOutput(); 34 28 35 ?> -
www/finance/tarify.php
r50 r152 1 1 <?php 2 include('../style.php'); 3 include('include.php'); 4 ShowHeader('Aktuální stav tarifů', 'Tarify'); 2 include_once('../global.php'); 3 include_once('include.php'); 5 4 6 function TariffTable() 5 class FinanceTarrifsPage extends Page 7 6 { 8 global $Tarify, $Internet, $InternetUsers, $RealMaxSpeed, $SpeedReserve, $MaxSpeed; 7 var $FullTitle = 'Přehled tarifů'; 8 var $ShortTitle = 'Tarify'; 9 9 10 echo('Poplatek za společný internet: <strong>'.$Internet.' Kč</strong><br>'); 11 echo('Rychlost společné linky: <strong>'.$RealMaxSpeed.' kbit/s</strong><br>'); 12 echo('Rezerva (nevyužitá kapacita pro zlepšení odezvy sítě): <strong>'.$SpeedReserve.' kbit/s</strong><br>'); 13 echo('Maximální dostupná kapacita pro použití: <strong>'.$MaxSpeed.' kbit/s</strong><br>'); 14 echo('<br>'); 15 16 echo('<table width="50%" border="1" cellspacing="0" cellpadding="2" style="font-size: small;">'); 17 echo('<tr><th>Název tarifu</th><th>Min. rychlost [kbit/s]</th><th>Max. rychlost [kbit/s]</th><th>Agregační poměr</th><th>Cenových jednotek</th><th>Počet podílníků</th><th>Celkem cenových jednotek</th><th>Cena [Kč]</th><th>Vybráno celkem [Kč]</th></tr>'); 18 $TotalPrice = 0; 19 $TotalUnits = 0; 20 foreach($Tarify as $Index => $Tarif) 10 function TariffTable() 21 11 { 22 echo('<tr><td style="color: blue;">'.$Tarif['name'].'</td><td align="center">'.round($Tarif['min_speed'] / 1024).'</td><td align="center" style="color: blue;">'.round($Tarif['max_speed'] / 1024).'</td><td align="center">'.$Tarif['aggregation'].'</td><td align="center">'.$Tarif['price_units'].'</td><td align="center">'.$Tarif['user_count'].'</td><td align="center">'. 23 $Tarif['total_units'].'</td><td align="center" style="color: blue;">'.$Tarif['price'].'</td><td align="center">'.$Tarif['user_count'] * $Tarif['price'].'</td></tr>'); 24 $TotalPrice = $TotalPrice + $Tarif['price'] * $Tarif['user_count']; 25 $TotalUnits = $TotalUnits + $Tarif['total_units']; 12 global $Tarify, $Internet, $InternetUsers, $RealMaxSpeed, $SpeedReserve, $MaxSpeed; 13 14 $Output = 'Poplatek za společný internet: <strong>'.$Internet.' Kč</strong><br />'; 15 $Output .= 'Rychlost společné linky: <strong>'.$RealMaxSpeed.' kbit/s</strong><br />'; 16 $Output .= 'Rezerva (nevyužitá kapacita pro zlepšení odezvy sítě): <strong>'.$SpeedReserve.' kbit/s</strong><br />'; 17 $Output .= 'Maximální dostupná kapacita pro použití: <strong>'.$MaxSpeed.' kbit/s</strong><br />'; 18 $Output .= '<br />'; 19 20 $Output .= '<table width="50%" border="1" cellspacing="0" cellpadding="2" style="font-size: small;">'; 21 $Output .= '<tr><th>Název tarifu</th><th>Min. rychlost [kbit/s]</th><th>Max. rychlost [kbit/s]</th><th>Agregační poměr</th><th>Cenových jednotek</th><th>Počet podílníků</th><th>Celkem cenových jednotek</th><th>Cena [Kč]</th><th>Vybráno celkem [Kč]</th></tr>'; 22 $TotalPrice = 0; 23 $TotalUnits = 0; 24 foreach($Tarify as $Index => $Tarif) 25 { 26 $Output .= '<tr><td style="color: blue;">'.$Tarif['name'].'</td><td align="center">'.round($Tarif['min_speed'] / 1024).'</td><td align="center" style="color: blue;">'.round($Tarif['max_speed'] / 1024).'</td><td align="center">'.$Tarif['aggregation'].'</td><td align="center">'.$Tarif['price_units'].'</td><td align="center">'.$Tarif['user_count'].'</td><td align="center">'. 27 $Tarif['total_units'].'</td><td align="center" style="color: blue;">'.$Tarif['price'].'</td><td align="center">'.$Tarif['user_count'] * $Tarif['price'].'</td></tr>'; 28 $TotalPrice = $TotalPrice + $Tarif['price'] * $Tarif['user_count']; 29 $TotalUnits = $TotalUnits + $Tarif['total_units']; 30 } 31 $Output .= '<tr><td>Součty</td><td colspan="4"> </td><td align="center">'.$InternetUsers.'</td><td align="center">'.$TotalUnits.'</td><td> </td><td align="center">'.$TotalPrice.'</td></tr>'; 32 $Output .= '</table>'; 33 return($Output); 26 34 } 27 echo('<tr><td>Součty</td><td colspan="4"> </td><td align="center">'.$InternetUsers.'</td><td align="center">'.$TotalUnits.'</td><td> </td><td align="center">'.$TotalPrice.'</td></tr>'); 28 echo('</table>'); 35 36 function Show() 37 { 38 global $Tarify, $Internet, $InternetUsers, $RealMaxSpeed, $SpeedReserve, $MaxSpeed; 39 $Output = 'Počet členů s internetovým připojením: <strong>'.$InternetUsers.'</strong><br /><br />'; 40 $Output .= '<table><tr><td valign="top">'; 41 42 NactiMesicniParametry(0); 43 $Output .= '<strong>Stav pro aktuální měsíc:</strong><br />'; 44 $Output .= $this->TariffTable(); 45 46 $Output .= '<br /></td></tr><tr><td valign="top">'; 47 48 NactiMesicniParametry(1); 49 $Output .= '<strong>Stav pro další měsíc:</strong><br />'; 50 $Output .= $this->TariffTable(); 51 52 $Output .= '</td></tr></table>'; 53 54 $Output .= '<br /><strong>Doplňující informace:</strong><br />'; 55 $Output .= 'Minimální rychlostí se rozumí garantovaná rychlost, tedy zaručený podíl z celkové kapacity linky.<br /> 56 Maximální rychlost je teoretická nejvyšší dostupná rychlost.<br /> 57 Skutečná rychlost může mírně kolísat kolem těchto hodnot, jelikož řízení toku není dokonalé.<br /> 58 Agregační pomněr je poměr mezi minimální garantovanou rychlostí a maximální dosažitelnou rychlostí. Ukazuje, jak moc je linka sdílena a jak hodně může rychlost kolísat. Při posuzování kvality linky je toto také důležitý ukazatel.<br /> 59 Cenové jednotky vystihují jakým podílem se poplatek za tarif podílí na celkové placené sumě.<br /> 60 Počet podílníků znamená počet uživatelů platících daný tarif.<br /> 61 Údaj celkem cenových jednotek je součin počtu podílníků a cenových jednotek. Vystihuje podíl všech uživatelů v daném tarifu na celkové placené sumě.<br /> 62 Cena udává rozpočtenou celkovou cenu na jednotlivé tarify podle cenových jednotek.<br /> 63 Sloupec vybráno dává informaci, kolik se v kterém tarifu vybralo peněz na placení společné linky.<br /><br />'; 64 $Output .= 'Tabulka Stav pro aktuální měsíc se aktualizuje první den v měsíci při odečtení peněz z účtů dle tabulky na příští měsíc.<br />'; 65 66 $Output .= '<br />Změnu tarifu na další měsíc oznamujte prozatím na email robie@centrum.cz<br />'; 67 $Output .= '<a href="http://centrala.zdechov.net/forum/viewtopic.php?t=50">Diskuse</a><br />'; 68 return($Output); 69 } 29 70 } 30 71 31 echo('Počet členů s internetovým připojením: <strong>'.$InternetUsers.'</strong><br><br>');32 echo('<table><tr><td valign="top">');72 $System->AddModule(new FinanceTarrifsPage()); 73 $System->Modules['FinanceTarrifsPage']->GetOutput(); 33 74 34 NactiMesicniParametry(0);35 echo('<strong>Stav pro aktuální měsíc:</strong><br>');36 TariffTable();37 38 echo('<br></td></tr><tr><td valign="top">');39 40 NactiMesicniParametry(1);41 echo('<strong>Stav pro další měsíc:</strong><br>');42 TariffTable();43 44 echo('</td></tr></table>');45 46 echo('<br><strong>Doplňující informace:</strong><br>');47 echo('Minimální rychlostí se rozumí garantovaná rychlost, tedy zaručený podíl z celkové kapacity linky.<br>48 Maximální rychlost je teoretická nejvyšší dostupná rychlost.<br>49 Skutečná rychlost může mírně kolísat kolem těchto hodnot, jelikož řízení toku není dokonalé.<br>50 Agregační pomněr je poměr mezi minimální garantovanou rychlostí a maximální dosažitelnou rychlostí. Ukazuje, jak moc je linka sdílena a jak hodně může rychlost kolísat. Při posuzování kvality linky je toto také důležitý ukazatel.<br>51 Cenové jednotky vystihují jakým podílem se poplatek za tarif podílí na celkové placené sumě.<br>52 Počet podílníků znamená počet uživatelů platících daný tarif.<br>53 Údaj celkem cenových jednotek je součin počtu podílníků a cenových jednotek. Vystihuje podíl všech uživatelů v daném tarifu na celkové placené sumě.<br>54 Cena udává rozpočtenou celkovou cenu na jednotlivé tarify podle cenových jednotek.<br>55 Sloupec vybráno dává informaci, kolik se v kterém tarifu vybralo peněz na placení společné linky.<br><br>');56 echo('Tabulka Stav pro aktuální měsíc se aktualizuje první den v měsíci při odečtení peněz z účtů dle tabulky na příští měsíc.<br>');57 58 echo('<br>Změnu tarifu na další měsíc oznamujte prozatím na email robie@centrum.cz<br>');59 echo('<a href="http://centrala.zdechov.net/forum/viewtopic.php?t=50">Diskuse</a><br>');60 61 ShowFooter();62 75 ?> -
www/finance/zarizeni.php
r4 r152 1 1 <?php 2 2 include_once('../global.php'); 3 include('../style.php'); 4 ShowHeader('Zařízení sítě','Zařízení'); 3 include_once('include.php'); 5 4 6 // Seznam segmentů a zařízení 7 echo('Seznam segmentů a zařízení:<br><table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3"><tr><th>Název</th><th>Spotřeba<br>[W]</th><th>Datum<br>zakoupení</th><th>Cena [Kč]</th></tr>'); 8 $DbResult = $Database->query("SELECT * FROM network_segments"); 9 while($Row = $DbResult->fetch_array()) 5 class FinanceDeviceListPage extends Page 10 6 { 11 echo('<tr><td colspan="3"><strong>Segment: '.$Row['name'].' ('.$Row['users'].')</strong></td><td style="font-weight: Bold;" align="right">'.$Row['price'].'</td></tr>'); 12 $DbResult2 = $Database->query("SELECT * FROM network_devices WHERE segment=".$Row['id']." AND used=1"); 13 while($Row = $DbResult2->fetch_array()) 7 var $FullTitle = 'Zařízení sítě'; 8 var $ShortTitle = 'Zařízení'; 9 10 function Show() 14 11 { 15 echo('<tr><td>'.$Row['name'].'</td><td align="right">'.$Row['consumption'].'</td><td align="right">'.HumanDate($Row['date']).'</td><td align="right">'.$Row['price'].'</td></tr>'); 12 // Seznam segmentů a zařízení 13 $Output = 'Seznam segmentů a zařízení:<br><table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3"><tr><th>Název</th><th>Spotřeba<br>[W]</th><th>Datum<br>zakoupení</th><th>Cena [Kč]</th></tr>'; 14 $DbResult = $this->Database->query("SELECT * FROM network_segments"); 15 while($Row = $DbResult->fetch_array()) 16 { 17 $Output .= '<tr><td colspan="3"><strong>Segment: '.$Row['name'].' ('.$Row['users'].')</strong></td><td style="font-weight: Bold;" align="right">'.$Row['price'].'</td></tr>'; 18 $DbResult2 = $this->Database->query("SELECT * FROM network_devices WHERE segment=".$Row['id']." AND used=1"); 19 while($Row = $DbResult2->fetch_array()) 20 { 21 $Output .= '<tr><td>'.$Row['name'].'</td><td align="right">'.$Row['consumption'].'</td><td align="right">'.HumanDate($Row['date']).'</td><td align="right">'.$Row['price'].'</td></tr>'; 22 } 23 } 24 $DbResult = $this->Database->query("SELECT SUM(price) FROM network_devices WHERE used=1"); 25 $Row = $DbResult->fetch_array(); 26 $Output .= '<tr><td colspan="3"><strong>Celkem:</strong></td><td align="right"><strong>'.$Row[0].'</strong></td></tr>'; 27 $Output .= '</table>'; 28 return($Output); 16 29 } 17 30 } 18 $DbResult = $Database->query("SELECT SUM(price) FROM network_devices WHERE used=1");19 $Row = $DbResult->fetch_array();20 echo('<tr><td colspan="3"><strong>Celkem:</strong></td><td align="right"><strong>'.$Row[0].'</strong></td></tr>');21 echo('</table>');22 31 23 ShowFooter(); 32 $System->AddModule(new FinanceDeviceListPage()); 33 $System->Modules['FinanceDeviceListPage']->GetOutput() 34 24 35 ?> -
www/finance/zivnost.php
r70 r152 1 1 <?php 2 3 include('../style.php'); 4 include('include.php'); 5 include('bills.php'); 6 RecalculateTariffs(1); 7 8 ShowHeader('Daňová evidence', 'Daňová evidence'); 9 10 function TransformFinance() 2 include_once('../global.php'); 3 include_once('include.php'); 4 5 class FinanceTaxFilingPage extends Page 11 6 { 12 global $Database; 13 //$Database->Query('SELECT user as Subject, date as TimeCreation, date as TimeDue, date as TimePayment, -money as Value, bill_id as Bill, comment as Text FROM `finance_operations` WHERE Comment LIKE "Poplatek za měsíc%" AND date >= "2007-12-01"'); 14 //'TRUNCATE TABLE FinanceCashFlow; INSERT INTO FinanceCashFlow (SELECT '' as Id, user as Subject, comment as Text, date as Time, 1 as Taxable, 0 as Cash, money as Value, bill_id as Bill FROM `finance_operations` WHERE comment NOT LIKE "Poplatek za měsíc%" AND date >= "2007-12-01")' 15 // 'UPDATE finance_operations SET date="2007-11-24" WHERE comment="Jednorázový poplatek za společné zařízení"' 16 17 /* 18 $DbResult = $Database->query('SELECT * FROM users WHERE role=2'); 19 while($User = $DbResult->fetch_array()) 20 { 21 $DbResult2 = $Database->query('SELECT SUM(money) FROM finance_operations WHERE user='.$User['id'].' AND date < "2007-12-01"'); 22 $Row = $DbResult2->fetch_array(); 23 echo($User['second_name'].' '.$User['first_name'].' '.$Row[0].'<br>'); 24 // if($Row[0] > 0) $Database->insert('FinanceCashFlow', array('Text' => 'Přijatá záloha (z období před účetnictvím)', 'Subject' => $User['id'], 'Time' => '2007-01-01', 'Taxable' => 1, 'Cash' => 0, 'Value' => $Row[0], 'Bill' => 0)); 25 26 if($Row[0] < 0) 27 { 28 $Database->insert('FinanceClaimsLiabilities', array('Text' => 'Připojení k síti (z období před účetnictvím)', 'Subject' => $User['id'], 'TimeCreation' => '2007-12-01', 'TimeDue' => '2007-12-14', 'TimePayment' => '', 'Value' => (-$Row[0]), 'Bill' => 0)); 29 //echo($Database->LastQuery.'<br>'); 7 var $FullTitle = 'Daňová evidence'; 8 var $ShortTitle = 'Daňová evidence'; 9 10 function TransformFinance() 11 { 12 //$Database->Query('SELECT user as Subject, date as TimeCreation, date as TimeDue, date as TimePayment, -money as Value, bill_id as Bill, comment as Text FROM `finance_operations` WHERE Comment LIKE "Poplatek za měsíc%" AND date >= "2007-12-01"'); 13 //'TRUNCATE TABLE FinanceCashFlow; INSERT INTO FinanceCashFlow (SELECT '' as Id, user as Subject, comment as Text, date as Time, 1 as Taxable, 0 as Cash, money as Value, bill_id as Bill FROM `finance_operations` WHERE comment NOT LIKE "Poplatek za měsíc%" AND date >= "2007-12-01")' 14 // 'UPDATE finance_operations SET date="2007-11-24" WHERE comment="Jednorázový poplatek za společné zařízení"' 15 16 $DbResult = $this->Database->query('SELECT * FROM users WHERE role=2'); 17 while($User = $DbResult->fetch_array()) 18 { 19 $DbResult2 = $this->Database->query('SELECT SUM(money) FROM finance_operations WHERE user='.$User['id'].' AND date < "2007-12-01"'); 20 $Row = $DbResult2->fetch_array(); 21 echo($User['second_name'].' '.$User['first_name'].' '.$Row[0].'<br />'); 22 // if($Row[0] > 0) $Database->insert('FinanceCashFlow', array('Text' => 'Přijatá záloha (z období před účetnictvím)', 'Subject' => $User['id'], 'Time' => '2007-01-01', 'Taxable' => 1, 'Cash' => 0, 'Value' => $Row[0], 'Bill' => 0)); 23 if($Row[0] < 0) 24 { 25 $this->Database->insert('FinanceClaimsLiabilities', array('Text' => 'Připojení k síti (z období před účetnictvím)', 'Subject' => $User['id'], 'TimeCreation' => '2007-12-01', 'TimeDue' => '2007-12-14', 'TimePayment' => '', 'Value' => (-$Row[0]), 'Bill' => 0)); 26 //echo($Database->LastQuery.'<br />'); 27 } 30 28 } 31 } 32 */ 33 } 34 35 TransformFinance(); 36 37 if(!array_key_exists('table', $_GET)) $_GET['table'] = ''; 38 switch($_GET['table']) 39 { 40 case 'AnnualBalance': 41 echo('<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'); 42 echo('<tr><th colspan="3">Účetní období</th><th colspan="5">Na konci</th><th colspan="6">Během</th></tr>'); 43 echo('<tr><th>Rok</th><th>Od</th><th>Do</th><th>Příjmy</th><th>Výdaje</th><th>Pohledávky</th><th>Závazky</th><th>Drobný majetek</th><th>Příjmy</th><th>Výdaje</th><th>Pohledávky</th><th>Závazky</th><th>Drobný majetek</th><th>Základ daně</th></tr>'); 44 45 $StartEvidence = mktime(0, 0, 0, 12, 1, 2007); 46 $StartYear = date('Y', $StartEvidence); 47 $EndYear = date('Y', time()); 48 for($Year = $StartYear; $Year <= $EndYear; $Year++) 49 { 50 $EndTime = mktime(0, 0, 0, 12, 31, $Year); 51 $Year = date('Y', $EndTime); 52 $StartTime = mktime(0, 0, 0, 1, 1, $Year); 53 if($StartTime < $StartEvidence) $StartTime = $StartEvidence; 54 55 $Balance = array(); 56 57 $DbResult = $Database->query('SELECT SUM(Value) FROM FinanceCashFlow WHERE Time < "'.TimeToMysqlDateTime($StartTime).'" AND Value > 0 AND Taxable = 1'); 58 $Row = $DbResult->fetch_array(); 59 $Balance['Income']['Start'] = $Row[0] + 0; 60 $DbResult = $Database->query('SELECT SUM(Value) FROM FinanceCashFlow WHERE Time <= "'.TimeToMysqlDateTime($EndTime).'" AND Value > 0 AND Taxable = 1'); 61 //echo('SELECT SUM(Value) FROM FinanceCashFlow WHERE Time <= "'.TimeToMysqlDateTime($EndTime).'" AND Value > 0 AND Taxable = 1'.'<br>'); 62 $Row = $DbResult->fetch_array(); 63 $Balance['Income']['End'] = $Row[0] + 0; 64 65 $DbResult = $Database->query('SELECT -SUM(Value) FROM FinanceCashFlow WHERE Time < "'.TimeToMysqlDateTime($StartTime).'" AND Value < 0 AND Taxable = 1'); 66 $Row = $DbResult->fetch_array(); 67 $Balance['Spend']['Start'] = $Row[0] + 0; 68 $DbResult = $Database->query('SELECT -SUM(Value) FROM FinanceCashFlow WHERE Time <= "'.TimeToMysqlDateTime($EndTime).'" AND Value < 0 AND Taxable = 1'); 69 //echo('SELECT -SUM(Value) FROM FinanceCashFlow WHERE Time <= "'.TimeToMysqlDateTime($EndTime).'" AND Value < 0 AND Taxable = 1'.'<br>'); 70 $Row = $DbResult->fetch_array(); 71 $Balance['Spend']['End'] = $Row[0] + 0; 72 73 $DbResult = $Database->query('SELECT SUM(Value) FROM FinanceClaimsLiabilities WHERE TimeCreation < "'.TimeToMysqlDateTime($StartTime).'" AND TimePayment = "0000-00-00 00:00:00" AND Value > 0'); 74 $Row = $DbResult->fetch_array(); 75 $Balance['Claims']['Start'] = $Row[0] + 0; 76 $DbResult = $Database->query('SELECT SUM(Value) FROM FinanceClaimsLiabilities WHERE TimeCreation <= "'.TimeToMysqlDateTime($EndTime).'" AND TimePayment = "0000-00-00 00:00:00" AND Value > 0'); 77 $Row = $DbResult->fetch_array(); 78 $Balance['Claims']['End'] = $Row[0] + 0; 79 80 $DbResult = $Database->query('SELECT -SUM(Value) FROM FinanceClaimsLiabilities WHERE TimeCreation < "'.TimeToMysqlDateTime($StartTime).'" AND TimePayment = "0000-00-00 00:00:00" AND Value < 0'); 81 $Row = $DbResult->fetch_array(); 82 $Balance['Liabilities']['Start'] = $Row[0] + 0; 83 $DbResult = $Database->query('SELECT -SUM(Value) FROM FinanceClaimsLiabilities WHERE TimeCreation <= "'.TimeToMysqlDateTime($EndTime).'" AND TimePayment = "0000-00-00 00:00:00" AND Value < 0'); 84 $Row = $DbResult->fetch_array(); 85 $Balance['Liabilities']['End'] = $Row[0] + 0; 86 87 // SmallAssets 88 $DbResult = $Database->query('SELECT SUM(price) FROM network_devices WHERE (TimeEnlistment < "'.TimeToMysqlDateTime($StartTime).'") AND (TimeEnlistment != 0) AND ((TimeElimination > "'.TimeToMysqlDateTime($StartTime).'") OR (TimeElimination = 0))'); 89 echo($Database->error); 90 $Row = $DbResult->fetch_array(); 91 $Balance['SmallAssets']['Start'] = $Row[0] + 0; 92 $DbResult = $Database->query('SELECT SUM(price) FROM network_devices WHERE (TimeEnlistment < "'.TimeToMysqlDateTime($EndTime).'") AND (TimeEnlistment != 0) AND ((TimeElimination > "'.TimeToMysqlDateTime($EndTime).'") OR (TimeElimination = 0))'); 93 $Row = $DbResult->fetch_array(); 94 $Balance['SmallAssets']['End'] = $Row[0] + 0; 95 96 97 echo('<tr><td>'.$Year.'</td><td>'.date(HumanDate(TimeToMysqlDateTime($StartTime))).'</td><td>'.date(HumanDate(TimeToMysqlDateTime($EndTime))).'</td>'); 98 echo('<td>'.$Balance['Income']['End'].'</td>'); 99 echo('<td>'.$Balance['Spend']['End'].'</td>'); 100 echo('<td>'.$Balance['Claims']['End'].'</td>'); 101 echo('<td>'.$Balance['Liabilities']['End'].'</td>'); 102 echo('<td>'.$Balance['SmallAssets']['End'].'</td>'); 103 104 echo('<td>'.($Balance['Income']['End'] - $Balance['Income']['Start']).'</td>'); 105 echo('<td>'.($Balance['Spend']['End'] - $Balance['Spend']['Start']).'</td>'); 106 echo('<td>'.($Balance['Claims']['End'] - $Balance['Claims']['Start']).'</td>'); 107 echo('<td>'.($Balance['Liabilities']['End'] - $Balance['Liabilities']['Start']).'</td>'); 108 echo('<td>'.($Balance['SmallAssets']['End'] - $Balance['SmallAssets']['Start']).'</td>'); 109 echo('<td>'.(($Balance['Income']['End'] - $Balance['Income']['Start']) - ($Balance['Spend']['End'] - $Balance['Spend']['Start'])).'</td></tr>'); 110 } 111 echo('</table>'); 112 113 // echo('<tr><td colspan="2">Výkaz o majetku a závazcích</td><td>Ing. Jiří Hajda</td></tr>'); 114 /* 29 } 30 31 function Show() 32 { 33 RecalculateTariffs(1); 34 //TransformFinance(); 35 36 $Output = ''; 37 if(!array_key_exists('table', $_GET)) $_GET['table'] = ''; 38 switch($_GET['table']) 39 { 40 case 'AnnualBalance': 41 $Output = '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'; 42 $Output .= '<tr><th colspan="3">Účetní období</th><th colspan="5">Na konci</th><th colspan="6">Během</th></tr>'; 43 $Output .= '<tr><th>Rok</th><th>Od</th><th>Do</th><th>Příjmy</th><th>Výdaje</th><th>Pohledávky</th><th>Závazky</th><th>Drobný majetek</th><th>Příjmy</th><th>Výdaje</th><th>Pohledávky</th><th>Závazky</th><th>Drobný majetek</th><th>Základ daně</th></tr>'; 44 45 $StartEvidence = mktime(0, 0, 0, 12, 1, 2007); 46 $StartYear = date('Y', $StartEvidence); 47 $EndYear = date('Y', time()); 48 for($Year = $StartYear; $Year <= $EndYear; $Year++) 49 { 50 $EndTime = mktime(0, 0, 0, 12, 31, $Year); 51 $Year = date('Y', $EndTime); 52 $StartTime = mktime(0, 0, 0, 1, 1, $Year); 53 if($StartTime < $StartEvidence) $StartTime = $StartEvidence; 54 55 $Balance = array(); 56 57 $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceCashFlow WHERE Time < "'.TimeToMysqlDateTime($StartTime).'" AND Value > 0 AND Taxable = 1'); 58 $Row = $DbResult->fetch_array(); 59 $Balance['Income']['Start'] = $Row[0] + 0; 60 $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceCashFlow WHERE Time <= "'.TimeToMysqlDateTime($EndTime).'" AND Value > 0 AND Taxable = 1'); 61 //echo('SELECT SUM(Value) FROM FinanceCashFlow WHERE Time <= "'.TimeToMysqlDateTime($EndTime).'" AND Value > 0 AND Taxable = 1'.'<br />'); 62 $Row = $DbResult->fetch_array(); 63 $Balance['Income']['End'] = $Row[0] + 0; 64 65 $DbResult = $this->Database->query('SELECT -SUM(Value) FROM FinanceCashFlow WHERE Time < "'.TimeToMysqlDateTime($StartTime).'" AND Value < 0 AND Taxable = 1'); 66 $Row = $DbResult->fetch_array(); 67 $Balance['Spend']['Start'] = $Row[0] + 0; 68 $DbResult = $this->Database->query('SELECT -SUM(Value) FROM FinanceCashFlow WHERE Time <= "'.TimeToMysqlDateTime($EndTime).'" AND Value < 0 AND Taxable = 1'); 69 //echo('SELECT -SUM(Value) FROM FinanceCashFlow WHERE Time <= "'.TimeToMysqlDateTime($EndTime).'" AND Value < 0 AND Taxable = 1'.'<br />'); 70 $Row = $DbResult->fetch_array(); 71 $Balance['Spend']['End'] = $Row[0] + 0; 72 73 $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceClaimsLiabilities WHERE TimeCreation < "'.TimeToMysqlDateTime($StartTime).'" AND TimePayment = "0000-00-00 00:00:00" AND Value > 0'); 74 $Row = $DbResult->fetch_array(); 75 $Balance['Claims']['Start'] = $Row[0] + 0; 76 $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceClaimsLiabilities WHERE TimeCreation <= "'.TimeToMysqlDateTime($EndTime).'" AND TimePayment = "0000-00-00 00:00:00" AND Value > 0'); 77 $Row = $DbResult->fetch_array(); 78 $Balance['Claims']['End'] = $Row[0] + 0; 79 80 $DbResult = $this->Database->query('SELECT -SUM(Value) FROM FinanceClaimsLiabilities WHERE TimeCreation < "'.TimeToMysqlDateTime($StartTime).'" AND TimePayment = "0000-00-00 00:00:00" AND Value < 0'); 81 $Row = $DbResult->fetch_array(); 82 $Balance['Liabilities']['Start'] = $Row[0] + 0; 83 $DbResult = $this->Database->query('SELECT -SUM(Value) FROM FinanceClaimsLiabilities WHERE TimeCreation <= "'.TimeToMysqlDateTime($EndTime).'" AND TimePayment = "0000-00-00 00:00:00" AND Value < 0'); 84 $Row = $DbResult->fetch_array(); 85 $Balance['Liabilities']['End'] = $Row[0] + 0; 86 87 // SmallAssets 88 $DbResult = $this->Database->query('SELECT SUM(price) FROM network_devices WHERE (TimeEnlistment < "'.TimeToMysqlDateTime($StartTime).'") AND (TimeEnlistment != 0) AND ((TimeElimination > "'.TimeToMysqlDateTime($StartTime).'") OR (TimeElimination = 0))'); 89 //$Output .= $Database->error; 90 $Row = $DbResult->fetch_array(); 91 $Balance['SmallAssets']['Start'] = $Row[0] + 0; 92 $DbResult = $this->Database->query('SELECT SUM(price) FROM network_devices WHERE (TimeEnlistment < "'.TimeToMysqlDateTime($EndTime).'") AND (TimeEnlistment != 0) AND ((TimeElimination > "'.TimeToMysqlDateTime($EndTime).'") OR (TimeElimination = 0))'); 93 $Row = $DbResult->fetch_array(); 94 $Balance['SmallAssets']['End'] = $Row[0] + 0; 95 96 $Output .= '<tr><td>'.$Year.'</td><td>'.date(HumanDate(TimeToMysqlDateTime($StartTime))).'</td><td>'.date(HumanDate(TimeToMysqlDateTime($EndTime))).'</td>'; 97 $Output .= '<td>'.$Balance['Income']['End'].'</td>'; 98 $Output .= '<td>'.$Balance['Spend']['End'].'</td>'; 99 $Output .= '<td>'.$Balance['Claims']['End'].'</td>'; 100 $Output .= '<td>'.$Balance['Liabilities']['End'].'</td>'; 101 $Output .= '<td>'.$Balance['SmallAssets']['End'].'</td>'; 102 103 $Output .= '<td>'.($Balance['Income']['End'] - $Balance['Income']['Start']).'</td>'; 104 $Output .= '<td>'.($Balance['Spend']['End'] - $Balance['Spend']['Start']).'</td>'; 105 $Output .= '<td>'.($Balance['Claims']['End'] - $Balance['Claims']['Start']).'</td>'; 106 $Output .= '<td>'.($Balance['Liabilities']['End'] - $Balance['Liabilities']['Start']).'</td>'; 107 $Output .= '<td>'.($Balance['SmallAssets']['End'] - $Balance['SmallAssets']['Start']).'</td>'; 108 $Output .= '<td>'.(($Balance['Income']['End'] - $Balance['Income']['Start']) - ($Balance['Spend']['End'] - $Balance['Spend']['Start'])).'</td></tr>'; 109 } 110 $Output .= '</table>'; 111 112 // echo('<tr><td colspan="2">Výkaz o majetku a závazcích</td><td>Ing. Jiří Hajda</td></tr>'); 113 /* 115 114 echo('<tr><td>Dlouhodobý hmotný majetek</td><td> </td><td> </td></tr>'); 116 115 echo('<tr><td>Dlouhodobý nehmotný majetek</td><td> </td><td> </td></tr>'); … … 153 152 echo('</table>'); 154 153 */ 155 break; 156 case 'CashFlow': 157 $Table = array('Ne', 'Ano'); 158 echo('<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'); 159 echo('<tr><th>Čas</th><th>Subjekt</th><th>Text</th><th>Hodnota [Kč]</th><th>Daňový</th><th>Hotovost</th></tr>'); 160 $DbResult = $Database->query('SELECT *, CONCAT(users.second_name, " ", users.first_name) as Name FROM FinanceCashFlow JOIN users ON users.id = FinanceCashFlow.Subject ORDER BY Time'); 161 while($Row = $DbResult->fetch_array()) 162 { 163 echo('<tr><td>'.$Row['Time'].'</td><td>'.$Row['Name'].'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value'].'</td><td>'.$Table[$Row['Taxable']].'</td><td>'.$Table[$Row['Cash']].'</td></tr>'); 154 break; 155 case 'CashFlow': 156 $Table = array('Ne', 'Ano'); 157 $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'; 158 $Output .= '<tr><th>Čas</th><th>Subjekt</th><th>Text</th><th>Hodnota [Kč]</th><th>Daňový</th><th>Hotovost</th></tr>'; 159 $DbResult = $this->Database->query('SELECT *, CONCAT(users.second_name, " ", users.first_name) as Name FROM FinanceCashFlow JOIN users ON users.id = FinanceCashFlow.Subject ORDER BY Time'); 160 while($Row = $DbResult->fetch_array()) 161 { 162 $Output .= '<tr><td>'.$Row['Time'].'</td><td>'.$Row['Name'].'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value'].'</td><td>'.$Table[$Row['Taxable']].'</td><td>'.$Table[$Row['Cash']].'</td></tr>'; 163 } 164 $Output .= '</table>'; 165 break; 166 case 'ClaimsLiabilities': 167 $Output .= '<table width="100%"><tr><td valign="top">'; 168 $Output .= '<strong>Pohledávky</strong>'; 169 $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'; 170 $Output .= '<tr><th>Subjekt</th><th>Text</th><th>Hodnota [Kč]</th><th>Čas vystavení</th><th>Čas splatnosti</th><th>Čas uhrazení</th></tr>'; 171 $DbResult = $this->Database->query('SELECT *, CONCAT(users.second_name, " ", users.first_name) as Name FROM FinanceClaimsLiabilities JOIN users ON users.id = FinanceClaimsLiabilities.Subject WHERE Value > 0 ORDER BY TimeCreation'); 172 while($Row = $DbResult->fetch_array()) 173 { 174 if($Row['TimePayment'] == '0000-00-00 00:00:00') $Row['TimePayment'] = ' '; 175 $Output .= '<tr><td>'.$Row['Name'].'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value'].'</td><td>'.$Row['TimeCreation'].'</td><td>'.$Row['TimeDue'].'</td><td>'.$Row['TimePayment'].'</td></tr>'; 176 } 177 $Output .= '</table></td><td valign="top">'; 178 179 $Output .= '<strong>Závazky</strong>'; 180 $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'; 181 $Output .= '<tr><th>Subjekt</th><th>Text</th><th>Hodnota [Kč]</th><th>Čas vystavení</th><th>Čas splatnosti</th><th>Čas uhrazení</th></tr>'; 182 $DbResult = $this->Database->query('SELECT *, CONCAT(users.second_name, " ", users.first_name) as Name FROM FinanceClaimsLiabilities JOIN users ON users.id = FinanceClaimsLiabilities.Subject WHERE Value < 0 ORDER BY TimeCreation'); 183 while($Row = $DbResult->fetch_array()) 184 { 185 if($Row['TimePayment'] == '0000-00-00 00:00:00') $Row['TimePayment'] = ' '; 186 $Output .= '<tr><td>'.$Row['Name'].'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value'].'</td><td>'.$Row['TimeCreation'].'</td><td>'.$Row['TimeDue'].'</td><td>'.$Row['TimePayment'].'</td></tr>'; 187 } 188 $Output .= '</table></td></tr></table>'; 189 break; 190 case 'Advantages': 191 $Output .= '<table width="100%"><tr><td valign="top">'; 192 $Output .= 'Přijaté zálohy'; 193 $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'; 194 $Output .= '<tr><th>Subjekt</th><th>Hodnota [Kč]</th><th>Čas vystavení</th><th>Čas uzavření</th></tr>'; 195 $DbResult = $this->Database->query('SELECT *, CONCAT(users.second_name, " ", users.first_name) as Name FROM FinanceAdvances JOIN users ON users.id = FinanceAdvances.Subject WHERE Direction = "In" ORDER BY TimeCreation'); 196 while($Row = $DbResult->fetch_array()) 197 { 198 if($Row['TimePass'] == '0000-00-00 00:00:00') $Row['TimePass'] = ' '; 199 $Output .= '<tr><td>'.$Row['Name'].'</td><td>'.$Row['Value'].'</td><td>'.$Row['TimeCreation'].'</td><td>'.$Row['TimePass'].'</td></tr>'; 200 } 201 $Output .= '</table></td><td valign="top">'; 202 203 $Output .= 'Vydané zálohy'; 204 $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'; 205 $Output .= '<tr><th>Subjekt</th><th>Hodnota [Kč]</th><th>Čas vystavení</th><th>Čas uzavření</th></tr>'; 206 $DbResult = $this->Database->query('SELECT *, CONCAT(users.second_name, " ", users.first_name) as Name FROM FinanceAdvances JOIN users ON users.id = FinanceAdvances.Subject WHERE Direction = "Out" ORDER BY TimeCreation'); 207 while($Row = $DbResult->fetch_array()) 208 { 209 if($Row['TimePass'] == '0000-00-00 00:00:00') $Row['TimePass'] = ' '; 210 $Output .= '<tr><td>'.$Row['Name'].'</td><td>'.$Row['Value'].'</td><td>'.$Row['TimeCreation'].'</td><td>'.$Row['TimePass'].'</td></tr>'; 211 } 212 $Output .= '</table></td></tr></table>'; 213 break; 214 case 'SubjectList': 215 $Output .= '<strong>Seznam subjektů</strong>'; 216 $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'; 217 $Output .= '<tr><th>Jméno</th><th>Závazky [Kč]</th><th>Pohledávky [Kč]</th><th>Příjmy [Kč]</th><th>Výdaje [Kč]</th><th>Zálohy [Kč]</th><th>Stav účtu</th><th>Starý systém</th></tr>'; 218 $DbResult = $this->Database->query('SELECT id, CONCAT(users.second_name, " ", users.first_name) as Fullname, cash, (SELECT SUM(FinanceClaimsLiabilities.Value) FROM FinanceClaimsLiabilities WHERE FinanceClaimsLiabilities.Subject = users.id AND FinanceClaimsLiabilities.Value > 0) as Claims, (SELECT SUM(FinanceClaimsLiabilities.Value) FROM FinanceClaimsLiabilities WHERE FinanceClaimsLiabilities.Subject = users.id AND FinanceClaimsLiabilities.Value > 0 AND TimePayment IS NULL) as OpenedClaims, (SELECT SUM(FinanceClaimsLiabilities.Value) FROM FinanceClaimsLiabilities WHERE FinanceClaimsLiabilities.Subject = users.id AND FinanceClaimsLiabilities.Value < 0) as Liabilities, (SELECT SUM(FinanceClaimsLiabilities.Value) FROM FinanceClaimsLiabilities WHERE FinanceClaimsLiabilities.Subject = users.id AND FinanceClaimsLiabilities.Value < 0 AND TimePayment IS NULL) as OpenedLiabilities, (SELECT SUM(FinanceCashFlow.Value) FROM FinanceCashFlow WHERE FinanceCashFlow.Subject = users.id AND FinanceCashFlow.Value > 0) as Gains, (SELECT SUM(FinanceCashFlow.Value) FROM FinanceCashFlow WHERE FinanceCashFlow.Subject = users.id AND FinanceCashFlow.Value < 0) as Spends, (SELECT SUM(FinanceAdvances.Value) FROM FinanceAdvances WHERE FinanceAdvances.Subject = users.id AND FinanceAdvances.Direction="In") as AdvancesIn, (SELECT SUM(FinanceAdvances.Value) FROM FinanceAdvances WHERE FinanceAdvances.Subject = users.id AND FinanceAdvances.Direction="Out") as AdvancesOut FROM users ORDER BY fullname'); 219 while($Row = $DbResult->fetch_array()) 220 { 221 $Advances = ($Row['AdvancesIn'] - $Row['AdvancesOut']); 222 $Output .= '<tr><td><a href="?table=SubjectAccount&Id='.$Row['id'].'">'.$Row['Fullname'].'</a></td><td>'.$Row['Liabilities'].'/'.$Row['OpenedLiabilities'].'</td><td>'.$Row['Claims'].'/'.$Row['OpenedClaims'].'</td><td>'.$Row['Gains'].'</td><td>'.$Row['Spends'].'</td><td>'.$Advances.'</td><td>'.($Advances - $Row['OpenedClaims'] + Abs($Row['OpenedLiabilities'])).'</td><td>'.$Row['cash'].'</td></tr>'; 223 } 224 $Output .= '</table>'; 225 break; 226 case 'SmallAssets': 227 $Output .= '<strong>Drobný majetek</strong>'; 228 $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'; 229 $Output .= '<tr><th>Název</th><th>Hodnota [Kč]</th><th>Datum zakoupení</th><th>Datum vyřezení</th></tr>'; 230 $DbResult = $this->Database->query('SELECT * FROM network_devices WHERE used != 0'); 231 while($Row = $DbResult->fetch_array()) 232 { 233 $Output .= '<tr><td>'.$Row['name'].'</td><td>'.$Row['price'].'</td><td>'.$Row['TimeEnlistment'].'</td><td>'.$Row['TimeElimination'].'</td></tr>'; 234 } 235 $Output .= '</table>'; 236 break; 237 case 'SubjectAccount': 238 $Output .= '<strong>Výpis příjmů/výdajů</strong>'; 239 $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'; 240 $Output .= '<tr><th>Datum</th><th>Název</th><th>Hodnota [Kč]</th></tr>'; 241 $DbResult = $this->Database->select('FinanceCashFlow', '*', 'Subject='.$_GET['Id']); 242 while($Row = $DbResult->fetch_array()) 243 { 244 $Output .= '<tr><td>'.$Row['Time'].'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value'].'</td><td>'.$Row['Bill'].'</td></tr>'; 245 } 246 $Output .= '</table><br />'; 247 248 $Output .= '<strong>Výpis závazků/pohledávek</strong>'; 249 $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'; 250 $Output .= '<tr><th>Datum vytvoření</th><th>Datum zaplacení</th><th>Název</th><th>Hodnota [Kč]</th></tr>'; 251 $DbResult = $this->Database->select('FinanceClaimsLiabilities', '*', 'Subject='.$_GET['Id']); 252 while($Row = $DbResult->fetch_array()) 253 { 254 $Output .= '<tr><td>'.$Row['TimeCreation'].'</td><td>'.$Row['TimePayment'].'</td><td>'.$Row['Text'].'</td><td>'.(-$Row['Value']).'</td><td>'.$Row['Bill'].'</td></tr>'; 255 } 256 $Output .= '</table><br />'; 257 258 $Output .= '<strong>Výpis záloh</strong>'; 259 $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'; 260 $Output .= '<tr><th>Datum vytvoření</th><th>Datum zaplacení</th><th>Název</th><th>Hodnota [Kč]</th></tr>'; 261 $DbResult = $this->Database->select('FinanceAdvances', '*', 'Subject='.$_GET['Id']); 262 while($Row = $DbResult->fetch_array()) 263 { 264 $Output .= '<tr><td>'.$Row['TimeCreation'].'</td><td>'.$Row['TimePass'].'</td><td>'.$Row['Direction'].'</td><td>'.($Row['Value']).'</td><td>'.$Row['CashFlowId'].'</td></tr>'; 265 } 266 $Output .= '</table>'; 267 268 $DbResult = $this->Database->query('SELECT id, CONCAT(users.second_name, " ", users.first_name) as Fullname, cash, (SELECT SUM(FinanceClaimsLiabilities.Value) FROM FinanceClaimsLiabilities WHERE FinanceClaimsLiabilities.Subject = users.id AND FinanceClaimsLiabilities.Value > 0) as Claims, (SELECT SUM(FinanceClaimsLiabilities.Value) FROM FinanceClaimsLiabilities WHERE FinanceClaimsLiabilities.Subject = users.id AND FinanceClaimsLiabilities.Value > 0 AND TimePayment IS NULL) as OpenedClaims, (SELECT SUM(FinanceClaimsLiabilities.Value) FROM FinanceClaimsLiabilities WHERE FinanceClaimsLiabilities.Subject = users.id AND FinanceClaimsLiabilities.Value < 0) as Liabilities, (SELECT SUM(FinanceClaimsLiabilities.Value) FROM FinanceClaimsLiabilities WHERE FinanceClaimsLiabilities.Subject = users.id AND FinanceClaimsLiabilities.Value < 0 AND TimePayment IS NULL) as OpenedLiabilities, (SELECT SUM(FinanceCashFlow.Value) FROM FinanceCashFlow WHERE FinanceCashFlow.Subject = users.id AND FinanceCashFlow.Value > 0) as Gains, (SELECT SUM(FinanceCashFlow.Value) FROM FinanceCashFlow WHERE FinanceCashFlow.Subject = users.id AND FinanceCashFlow.Value < 0) as Spends, (SELECT SUM(FinanceAdvances.Value) FROM FinanceAdvances WHERE FinanceAdvances.Subject = users.id AND FinanceAdvances.Direction="In") as AdvancesIn, (SELECT SUM(FinanceAdvances.Value) FROM FinanceAdvances WHERE FinanceAdvances.Subject = users.id AND FinanceAdvances.Direction="Out") as AdvancesOut FROM users WHERE id='.$_GET['Id']); 269 $Row = $DbResult->fetch_array(); 270 $Output .= 'Stav placení: '.($Row['AdvancesIn'] - $Row['AdvancesOut'] - $Row['OpenedClaims'] + Abs($Row['OpenedLiabilities'])); 271 break; 272 default: 273 $Output .= '<a href="?table=AnnualBalance">Účetní závěrka</a><br />'; 274 $Output .= '<a href="?table=CashFlow">Příjmy a výdaje</a><br />'; 275 $Output .= '<a href="?table=ClaimsLiabilities">Závazky a pohledávky</a><br />'; 276 $Output .= '<a href="?table=Advantages">Zálohy</a><br />'; 277 $Output .= '<a href="?table=SmallAssets">Drobný majetek</a><br />'; 278 $Output .= '<a href="?table=SubjectList">Seznam subjektů</a><br />'; 164 279 } 165 echo('</table>'); 166 break; 167 case 'ClaimsLiabilities': 168 echo('<table width="100%"><tr><td valign="top">'); 169 echo('<strong>Pohledávky</strong>'); 170 echo('<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'); 171 echo('<tr><th>Subjekt</th><th>Text</th><th>Hodnota [Kč]</th><th>Čas vystavení</th><th>Čas splatnosti</th><th>Čas uhrazení</th></tr>'); 172 $DbResult = $Database->query('SELECT *, CONCAT(users.second_name, " ", users.first_name) as Name FROM FinanceClaimsLiabilities JOIN users ON users.id = FinanceClaimsLiabilities.Subject WHERE Value > 0 ORDER BY TimeCreation'); 173 while($Row = $DbResult->fetch_array()) 174 { 175 if($Row['TimePayment'] == '0000-00-00 00:00:00') $Row['TimePayment'] = ' '; 176 echo('<tr><td>'.$Row['Name'].'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value'].'</td><td>'.$Row['TimeCreation'].'</td><td>'.$Row['TimeDue'].'</td><td>'.$Row['TimePayment'].'</td></tr>'); 177 } 178 echo('</table></td><td valign="top">'); 179 180 echo('<strong>Závazky</strong>'); 181 echo('<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'); 182 echo('<tr><th>Subjekt</th><th>Text</th><th>Hodnota [Kč]</th><th>Čas vystavení</th><th>Čas splatnosti</th><th>Čas uhrazení</th></tr>'); 183 $DbResult = $Database->query('SELECT *, CONCAT(users.second_name, " ", users.first_name) as Name FROM FinanceClaimsLiabilities JOIN users ON users.id = FinanceClaimsLiabilities.Subject WHERE Value < 0 ORDER BY TimeCreation'); 184 while($Row = $DbResult->fetch_array()) 185 { 186 if($Row['TimePayment'] == '0000-00-00 00:00:00') $Row['TimePayment'] = ' '; 187 echo('<tr><td>'.$Row['Name'].'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value'].'</td><td>'.$Row['TimeCreation'].'</td><td>'.$Row['TimeDue'].'</td><td>'.$Row['TimePayment'].'</td></tr>'); 188 } 189 echo('</table></td></tr></table>'); 190 break; 191 case 'Advantages': 192 echo('<table width="100%"><tr><td valign="top">'); 193 echo('Přijaté zálohy'); 194 echo('<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'); 195 echo('<tr><th>Subjekt</th><th>Hodnota [Kč]</th><th>Čas vystavení</th><th>Čas uzavření</th></tr>'); 196 $DbResult = $Database->query('SELECT *, CONCAT(users.second_name, " ", users.first_name) as Name FROM FinanceAdvances JOIN users ON users.id = FinanceAdvances.Subject WHERE Direction = "In" ORDER BY TimeCreation'); 197 while($Row = $DbResult->fetch_array()) 198 { 199 if($Row['TimePass'] == '0000-00-00 00:00:00') $Row['TimePass'] = ' '; 200 echo('<tr><td>'.$Row['Name'].'</td><td>'.$Row['Value'].'</td><td>'.$Row['TimeCreation'].'</td><td>'.$Row['TimePass'].'</td></tr>'); 201 } 202 echo('</table></td><td valign="top">'); 203 204 echo('Vydané zálohy'); 205 echo('<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'); 206 echo('<tr><th>Subjekt</th><th>Hodnota [Kč]</th><th>Čas vystavení</th><th>Čas uzavření</th></tr>'); 207 $DbResult = $Database->query('SELECT *, CONCAT(users.second_name, " ", users.first_name) as Name FROM FinanceAdvances JOIN users ON users.id = FinanceAdvances.Subject WHERE Direction = "Out" ORDER BY TimeCreation'); 208 while($Row = $DbResult->fetch_array()) 209 { 210 if($Row['TimePass'] == '0000-00-00 00:00:00') $Row['TimePass'] = ' '; 211 echo('<tr><td>'.$Row['Name'].'</td><td>'.$Row['Value'].'</td><td>'.$Row['TimeCreation'].'</td><td>'.$Row['TimePass'].'</td></tr>'); 212 } 213 echo('</table></td></tr></table>'); 214 break; 215 case 'SubjectList': 216 echo('<strong>Seznam subjektů</strong>'); 217 echo('<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'); 218 echo('<tr><th>Jméno</th><th>Závazky [Kč]</th><th>Pohledávky [Kč]</th><th>Příjmy [Kč]</th><th>Výdaje [Kč]</th><th>Zálohy [Kč]</th><th>Stav účtu</th><th>Starý systém</th></tr>'); 219 $DbResult = $Database->query('SELECT id, CONCAT(users.second_name, " ", users.first_name) as Fullname, cash, (SELECT SUM(FinanceClaimsLiabilities.Value) FROM FinanceClaimsLiabilities WHERE FinanceClaimsLiabilities.Subject = users.id AND FinanceClaimsLiabilities.Value > 0) as Claims, (SELECT SUM(FinanceClaimsLiabilities.Value) FROM FinanceClaimsLiabilities WHERE FinanceClaimsLiabilities.Subject = users.id AND FinanceClaimsLiabilities.Value > 0 AND TimePayment IS NULL) as OpenedClaims, (SELECT SUM(FinanceClaimsLiabilities.Value) FROM FinanceClaimsLiabilities WHERE FinanceClaimsLiabilities.Subject = users.id AND FinanceClaimsLiabilities.Value < 0) as Liabilities, (SELECT SUM(FinanceClaimsLiabilities.Value) FROM FinanceClaimsLiabilities WHERE FinanceClaimsLiabilities.Subject = users.id AND FinanceClaimsLiabilities.Value < 0 AND TimePayment IS NULL) as OpenedLiabilities, (SELECT SUM(FinanceCashFlow.Value) FROM FinanceCashFlow WHERE FinanceCashFlow.Subject = users.id AND FinanceCashFlow.Value > 0) as Gains, (SELECT SUM(FinanceCashFlow.Value) FROM FinanceCashFlow WHERE FinanceCashFlow.Subject = users.id AND FinanceCashFlow.Value < 0) as Spends, (SELECT SUM(FinanceAdvances.Value) FROM FinanceAdvances WHERE FinanceAdvances.Subject = users.id AND FinanceAdvances.Direction="In") as AdvancesIn, (SELECT SUM(FinanceAdvances.Value) FROM FinanceAdvances WHERE FinanceAdvances.Subject = users.id AND FinanceAdvances.Direction="Out") as AdvancesOut FROM users ORDER BY fullname'); 220 while($Row = $DbResult->fetch_array()) 221 { 222 $Advances = ($Row['AdvancesIn'] - $Row['AdvancesOut']); 223 echo('<tr><td><a href="?table=SubjectAccount&Id='.$Row['id'].'">'.$Row['Fullname'].'</a></td><td>'.$Row['Liabilities'].'/'.$Row['OpenedLiabilities'].'</td><td>'.$Row['Claims'].'/'.$Row['OpenedClaims'].'</td><td>'.$Row['Gains'].'</td><td>'.$Row['Spends'].'</td><td>'.$Advances.'</td><td>'.($Advances - $Row['OpenedClaims'] + Abs($Row['OpenedLiabilities'])).'</td><td>'.$Row['cash'].'</td></tr>'); 224 } 225 echo('</table>'); 226 break; 227 case 'SmallAssets': 228 echo('<strong>Drobný majetek</strong>'); 229 echo('<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'); 230 echo('<tr><th>Název</th><th>Hodnota [Kč]</th><th>Datum zakoupení</th><th>Datum vyřezení</th></tr>'); 231 $DbResult = $Database->query('SELECT * FROM network_devices WHERE used != 0'); 232 while($Row = $DbResult->fetch_array()) 233 { 234 echo('<tr><td>'.$Row['name'].'</td><td>'.$Row['price'].'</td><td>'.$Row['TimeEnlistment'].'</td><td>'.$Row['TimeElimination'].'</td></tr>'); 235 } 236 echo('</table>'); 237 break; 238 case 'SubjectAccount': 239 echo('<strong>Výpis příjmů/výdajů</strong>'); 240 echo('<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'); 241 echo('<tr><th>Datum</th><th>Název</th><th>Hodnota [Kč]</th></tr>'); 242 $DbResult = $Database->select('FinanceCashFlow', '*', 'Subject='.$_GET['Id']); 243 while($Row = $DbResult->fetch_array()) 244 { 245 echo('<tr><td>'.$Row['Time'].'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value'].'</td><td>'.$Row['Bill'].'</td></tr>'); 246 } 247 echo('</table><br>'); 248 249 echo('<strong>Výpis závazků/pohledávek</strong>'); 250 echo('<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'); 251 echo('<tr><th>Datum vytvoření</th><th>Datum zaplacení</th><th>Název</th><th>Hodnota [Kč]</th></tr>'); 252 $DbResult = $Database->select('FinanceClaimsLiabilities', '*', 'Subject='.$_GET['Id']); 253 while($Row = $DbResult->fetch_array()) 254 { 255 echo('<tr><td>'.$Row['TimeCreation'].'</td><td>'.$Row['TimePayment'].'</td><td>'.$Row['Text'].'</td><td>'.(-$Row['Value']).'</td><td>'.$Row['Bill'].'</td></tr>'); 256 } 257 echo('</table><br>'); 258 259 echo('<strong>Výpis záloh</strong>'); 260 echo('<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'); 261 echo('<tr><th>Datum vytvoření</th><th>Datum zaplacení</th><th>Název</th><th>Hodnota [Kč]</th></tr>'); 262 $DbResult = $Database->select('FinanceAdvances', '*', 'Subject='.$_GET['Id']); 263 while($Row = $DbResult->fetch_array()) 264 { 265 echo('<tr><td>'.$Row['TimeCreation'].'</td><td>'.$Row['TimePass'].'</td><td>'.$Row['Direction'].'</td><td>'.($Row['Value']).'</td><td>'.$Row['CashFlowId'].'</td></tr>'); 266 } 267 echo('</table>'); 268 269 $DbResult = $Database->query('SELECT id, CONCAT(users.second_name, " ", users.first_name) as Fullname, cash, (SELECT SUM(FinanceClaimsLiabilities.Value) FROM FinanceClaimsLiabilities WHERE FinanceClaimsLiabilities.Subject = users.id AND FinanceClaimsLiabilities.Value > 0) as Claims, (SELECT SUM(FinanceClaimsLiabilities.Value) FROM FinanceClaimsLiabilities WHERE FinanceClaimsLiabilities.Subject = users.id AND FinanceClaimsLiabilities.Value > 0 AND TimePayment IS NULL) as OpenedClaims, (SELECT SUM(FinanceClaimsLiabilities.Value) FROM FinanceClaimsLiabilities WHERE FinanceClaimsLiabilities.Subject = users.id AND FinanceClaimsLiabilities.Value < 0) as Liabilities, (SELECT SUM(FinanceClaimsLiabilities.Value) FROM FinanceClaimsLiabilities WHERE FinanceClaimsLiabilities.Subject = users.id AND FinanceClaimsLiabilities.Value < 0 AND TimePayment IS NULL) as OpenedLiabilities, (SELECT SUM(FinanceCashFlow.Value) FROM FinanceCashFlow WHERE FinanceCashFlow.Subject = users.id AND FinanceCashFlow.Value > 0) as Gains, (SELECT SUM(FinanceCashFlow.Value) FROM FinanceCashFlow WHERE FinanceCashFlow.Subject = users.id AND FinanceCashFlow.Value < 0) as Spends, (SELECT SUM(FinanceAdvances.Value) FROM FinanceAdvances WHERE FinanceAdvances.Subject = users.id AND FinanceAdvances.Direction="In") as AdvancesIn, (SELECT SUM(FinanceAdvances.Value) FROM FinanceAdvances WHERE FinanceAdvances.Subject = users.id AND FinanceAdvances.Direction="Out") as AdvancesOut FROM users WHERE id='.$_GET['Id']); 270 $Row = $DbResult->fetch_array(); 271 echo('Stav placení: '.($Row['AdvancesIn'] - $Row['AdvancesOut'] - $Row['OpenedClaims'] + Abs($Row['OpenedLiabilities']))); 272 break; 273 default: 274 echo('<a href="?table=AnnualBalance">Účetní závěrka</a><br>'); 275 echo('<a href="?table=CashFlow">Příjmy a výdaje</a><br>'); 276 echo('<a href="?table=ClaimsLiabilities">Závazky a pohledávky</a><br>'); 277 echo('<a href="?table=Advantages">Zálohy</a><br>'); 278 echo('<a href="?table=SmallAssets">Drobný majetek</a><br>'); 279 echo('<a href="?table=SubjectList">Seznam subjektů</a><br>'); 280 return($Output); 281 } 282 283 function AddMoney($Subject, $Value, $Text, $Time) 284 { 285 $TimeDue = $Time + 15 * 24 * 3600; // 15 dnů 286 287 } 288 289 function AddInvoice($Subject, $Value, $Text, $Time) 290 { 291 $TimeDue = $Time + 15 * 24 * 3600; // 15 dnů 292 293 } 280 294 } 281 295 282 function AddMoney($Subject, $Value, $Text, $Time) 283 { 284 $TimeDue = $Time + 15 * 24 * 3600; // 15 dnů 285 286 287 } 288 289 function AddInvoice($Subject, $Value, $Text, $Time) 290 { 291 $TimeDue = $Time + 15 * 24 * 3600; // 15 dnů 292 293 294 } 296 $System->AddModule(new FinanceTaxFilingPage()); 297 $System->Modules['FinanceTaxFilingPage']->GetOutput(); 295 298 296 299 ?>
Note:
See TracChangeset
for help on using the changeset viewer.