Changeset 156
- Timestamp:
- Feb 17, 2009, 10:00:28 PM (16 years ago)
- Location:
- www
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
www/finance/bills.php
r152 r156 11 11 global $SpecificSymbol; 12 12 13 $DbResult = $this->Database->select(' finance_bills', '*', 'id='.$BillId);14 $Bill = $DbResult->fetch_a rray();13 $DbResult = $this->Database->select('FinanceBills', '*', 'Id='.$BillId); 14 $Bill = $DbResult->fetch_assoc(); 15 15 16 $DbResult = $this->Database->select(' users', '*', 'id='.$Bill['user_id']);17 $ User = $DbResult->fetch_array();16 $DbResult = $this->Database->select('Subject', '*', 'Id='.$Bill['Subject']); 17 $Subject = $DbResult->fetch_assoc(); 18 18 19 19 $Dodavka = array(); 20 $DbResult = $this->Database->select(' finance_bills_items', '*', 'bill_id='.$BillId);21 while($Item = $DbResult->fetch_a rray())22 { 23 $Dodavka[$Item[' id']] = $Item;20 $DbResult = $this->Database->select('FinanceBillsItems', '*', 'Bill='.$BillId); 21 while($Item = $DbResult->fetch_assoc()) 22 { 23 $Dodavka[$Item['Id']] = $Item; 24 24 } 25 25 … … 40 40 '</td><td valign="top">'. 41 41 '<strong>Odběratel:</strong><br>'. 42 $ User['subject_name'].'<br>'.43 $ User['street'].'<br>'.44 $ User['psc'].' '.$User['town'].'<br>';45 if($ User['ico'] != 0) $Output .= 'IČ: '.$User['ico'].'<br>';46 if($ User['dic'] != '') $Output .= 'DIČ: '.$User['dic'].'<br>';42 $Subject['Name'].'<br>'. 43 $Subject['AddressStreet'].'<br>'. 44 $Subject['AddressPSC'].' '.$Subject['AddressTown'].'<br>'; 45 if($Subject['IC'] != 0) $Output .= 'IČ: '.$Subject['IC'].'<br>'; 46 if($Subject['DIC'] != '') $Output .= 'DIČ: '.$Subject['DIC'].'<br>'; 47 47 $Output .= 48 48 '</td></tr>'. … … 51 51 '<strong>Platební podmínky:</strong><br>'. 52 52 'Číslo dokladu: '.$Bill['BillCode'].'<br>'. 53 'Variabilní symbol: '.$ User['id'].'<br>'.53 'Variabilní symbol: '.$Subject['Id'].'<br>'. 54 54 'Specifický symbol: '.$this->SpecificSymbol.'<br>'. 55 55 'Konstantní symbol:<br>'. … … 57 57 '</td><td valign="top">'. 58 58 '<br>'. 59 'Datum vystavení: '.HumanDate($Bill[' time_create']).'<br>'.60 'Datum zdanitel. plnění: '.HumanDate($Bill[' time_create']).'<br>'.61 'Datum splatnosti: '.HumanDate($Bill[' time_due']).'<br>';62 if(($Bill[' time_from'] != '0000-00-00 00:00:00') and ($Bill['time_to'] != '0000-00-00 00:00:00'))63 $Output .= 'Fakturované období: '.HumanDate($Bill[' time_from']).' - '.HumanDate($Bill['time_to']).'<br>';59 'Datum vystavení: '.HumanDate($Bill['TimeCreate']).'<br>'. 60 'Datum zdanitel. plnění: '.HumanDate($Bill['TimeCreate']).'<br>'. 61 'Datum splatnosti: '.HumanDate($Bill['TimeDue']).'<br>'; 62 if(($Bill['TimeFrom'] != '0000-00-00 00:00:00') and ($Bill['TimeTo'] != '0000-00-00 00:00:00')) 63 $Output .= 'Fakturované období: '.HumanDate($Bill['TimeFrom']).' - '.HumanDate($Bill['TimeTo']).'<br>'; 64 64 $Output .= '</td></tr>'. 65 65 '<tr><td colspan="2">'. … … 73 73 foreach($Dodavka as $Polozka) 74 74 { 75 $Output .= '<tr><td>'.$Polozka[' description'].'</td><td align="right">'.$Polozka['quantity'].'</td><td align="right">'.$Polozka['price'].' Kč</td><td align="right">'.($Polozka['quantity'] * $Polozka['price']).' Kč</td></tr>';76 $Total += ($Polozka[' quantity'] * $Polozka['price']);75 $Output .= '<tr><td>'.$Polozka['Description'].'</td><td align="right">'.$Polozka['Quantity'].'</td><td align="right">'.$Polozka['Price'].' Kč</td><td align="right">'.($Polozka['Quantity'] * $Polozka['Price']).' Kč</td></tr>'; 76 $Total += ($Polozka['Quantity'] * $Polozka['Price']); 77 77 } 78 78 $Output .= '<tr><th colspan="3" align="left">Celkem</th><th align="right">'.$Total.' Kč</th></tr>'; … … 94 94 '<font size="5"><strong>PŘÍJMOVÝ POKLADNÍ DOKLAD</strong></font><br><br>'. 95 95 'Číslo dokladu: '.$Bill['BillCode'].'<br>'. 96 'Datum vystavení: '.HumanDate($Bill[' time_create']).'<br>'.96 'Datum vystavení: '.HumanDate($Bill['TimeCreate']).'<br>'. 97 97 '</td></tr>'. 98 98 '<tr><td colspan="2"><strong>Přijato od:</strong><br>'. 99 $ User['subject_name'].'<br>'.100 $ User['street'].'<br>'.101 $ User['psc'].' '.$User['town'].'<br>';102 if($ User['ico'] != 0) $Output .= 'IČ: '.$User['ico'].'<br>';103 if($ User['dic'] != '') $Output .= 'DIČ: '.$User['dic'].'<br>';99 $Subject['Name'].'<br>'. 100 $Subject['AddressStreet'].'<br>'. 101 $Subject['AddressPSC'].' '.$Subject['AddressTown'].'<br>'; 102 if($Subject['IC'] != 0) $Output .= 'IČ: '.$Subject['IC'].'<br>'; 103 if($Subject['DIC'] != '') $Output .= 'DIČ: '.$Subject['DIC'].'<br>'; 104 104 $Total = 0; 105 105 $Description = ''; 106 106 foreach($Dodavka as $Polozka) 107 107 { 108 $Description .= $Polozka[' description'].'<br>';109 $Total += ($Polozka[' quantity'] * $Polozka['price']);108 $Description .= $Polozka['Description'].'<br>'; 109 $Total += ($Polozka['Quantity'] * $Polozka['Price']); 110 110 } 111 111 $Output .= '</td></tr>'. … … 120 120 } 121 121 122 function CreateBill($ UserId, $Items, $TimeFrom, $TimeTo, $BillCode, $Type)123 { 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'));122 function CreateBill($SubjectId, $Items, $TimeFrom, $TimeTo, $BillCode, $Type) 123 { 124 $this->Database->insert('FinanceBills', array('TimeCreate' => TimeToMysqlDateTime(time()), 'Subject' => $SubjectId, 'TimeFrom' => TimeToMysqlDateTime($TimeFrom), 'TimeTo' => TimeToMysqlDateTime($TimeTo), 'TimeDue' => TimeToMysqlDateTime($TimeFrom + 15*24*3600), 'BillCode' => $BillCode, 'Type' => 'invoice')); 125 125 $BillId = $this->Database->insert_id; 126 126 foreach($Items as $Item) 127 127 { 128 $this->Database->insert(' finance_bills_items', array('bill_id' => $BillId, 'description' => $Item['description'], 'price' => $Item['price'], 'quantity' => $Item['quantity']));128 $this->Database->insert('FinanceBillsItems', array('Bill' => $BillId, 'Description' => $Item['Description'], 'Price' => $Item['Price'], 'Quantity' => $Item['Quantity'])); 129 129 } 130 130 //Header('Content-Type: application/pdf'); … … 136 136 } 137 137 138 function CreateIncomeBill($ UserId, $Description, $Price, $BillCode)139 { 140 $this->Database->insert(' finance_bills', array('time_create' => TimeToMysqlDateTime(time()), 'user_id' => $UserId, 'BillCode' => $BillCode, 'Type' => 'income'));138 function CreateIncomeBill($SubjectId, $Description, $Price, $BillCode) 139 { 140 $this->Database->insert('FinanceBills', array('TimeCreate' => TimeToMysqlDateTime(time()), 'Subject' => $SubjectId, 'BillCode' => $BillCode, 'Type' => 'income')); 141 141 $BillId = $this->Database->insert_id; 142 $this->Database->insert(' finance_bills_items', array('bill_id' => $BillId, 'description' => $Description, 'price' => $Price, 'quantity' => 1));142 $this->Database->insert('FinanceBillsItems', array('Bill' => $BillId, 'Description' => $Description, 'Price' => $Price, 'Quantity' => 1)); 143 143 //Header('Content-Type: application/pdf'); 144 144 $PdfData = $this->HtmlToPdf($this->GenerateBill($BillId)); … … 206 206 echo($Row['id']."<br>\n"); 207 207 $Time = MysqlDateToTime($Row['date']); 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);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); 209 209 $this->Database->update('finance_operations', 'id='.$Row['id'], array('bill_id' => $BillId)); 210 210 } … … 214 214 { 215 215 global $Database; 216 if(array_key_exists(' user', $_GET))216 if(array_key_exists('subject', $_GET)) 217 217 { 218 218 219 $DbResult = $this->Database->select(' finance_bills', '*', 'user_id='.$_GET['user']);219 $DbResult = $this->Database->select('FinanceBills', '*', 'Subject='.$_GET['subject']); 220 220 while($Item = $DbResult->fetch_array()) 221 221 { 222 echo('<a href="?bill='.$Item[' id'].'">faktura '.$Item['id'].'</a> <a href="?billpdf='.$Item['id'].'">Uložené PDF</a> <a href="?billpdf2='.$Item['id'].'">Generované PDF</a> <a href="?regenerate='.$Item['id'].'">Přegenerovat</a><br>');222 echo('<a href="?bill='.$Item['Id'].'">faktura '.$Item['Id'].'</a> <a href="?billpdf='.$Item['Id'].'">Uložené PDF</a> <a href="?billpdf2='.$Item['Id'].'">Generované PDF</a> <a href="?regenerate='.$Item['Id'].'">Přegenerovat</a><br>'); 223 223 } 224 224 } else … … 241 241 if(array_key_exists('generate', $_GET)) 242 242 { 243 $this->CreateBill(1, array(array(' description' => 'Poplatek za připojení k síti', 'price' => 1000, 'quantity' => 1)), time(), time());243 $this->CreateBill(1, array(array('Description' => 'Poplatek za připojení k síti', 'Price' => 1000, 'Quantity' => 1)), time(), time()); 244 244 } else 245 245 { 246 246 ShowHeader('Doklady', 'Doklady'); 247 echo('Faktury:<br >');248 $DbResult = $this->Database->select(' users', '*, CONCAT(second_name," ", first_name) as fullname', '1 ORDER BY fullname');249 while($ User = $DbResult->fetch_array())247 echo('Faktury:<br />'); 248 $DbResult = $this->Database->select('Subject', '*', '1 ORDER BY Name'); 249 while($Subject = $DbResult->fetch_assoc()) 250 250 { 251 echo('<a href="?user='.$ User['id'].'">'.$User['fullname'].'</a><br>');251 echo('<a href="?user='.$Subject['Id'].'">'.$Subject['Name'].'</a><br />'); 252 252 } 253 253 ShowFooter(); -
www/finance/index.php
r153 r156 14 14 $Output = '<table><tr><td valign="top">'; 15 15 16 $Output .= '<table><tr><td width="30%">'; 17 if(GetMemberByIP(GetRemoteAddress()) > 0) $Output .= '<a href="user_state_ip.php">Vaše finanční operace (Tato volba je také přístupná po přihlášení do systému v uživatelském menu).</a><br /><br /><br />'; 16 if(GetMemberByIP(GetRemoteAddress()) > 0) $Output .= '<a href="user_state_ip.php">Vaše finanční operace</a> (Tato volba je také přístupná po přihlášení do systému v uživatelském menu).<br /><br /><br />'; 18 17 19 18 $Output .= '<a href="monthly_overall.php">Měsíční přehledy</a><br />'; … … 25 24 //$Output .= '<a href="faktury/">Faktury za internet</a><br />'; 26 25 //$Output .= '<a href="inventory.php">Výpis skladových zásob</a><br />'; 27 $Output .= '</td><td width="50%">'; 28 29 $Output .= '</td></tr></table><br />'; 30 31 $Output .= '<strong>Souhrn:</strong><br />'; 26 27 $Output .= '<br /><strong>Souhrn:</strong><br />'; 32 28 33 29 $DbResult = $this->Database->query("SELECT * FROM finance_monthly_overall ORDER BY date DESC LIMIT 0,1"); -
www/finance/manage.php
r152 r156 63 63 { 64 64 $Output = ''; 65 if(array_key_exists(' user', $_GET))66 { 67 $DbResult = $this->Database->select(' finance_bills', '*', 'user_id='.$_GET['user']);65 if(array_key_exists('subject', $_GET)) 66 { 67 $DbResult = $this->Database->select('FinanceBills', '*', 'Subject='.$_GET['subject']); 68 68 while($Item = $DbResult->fetch_array()) 69 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 />';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 71 } 72 72 } else … … 89 89 if(array_key_exists('generate', $_GET)) 90 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());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 92 } else 93 93 { 94 94 //ShowHeader('Faktury', 'Faktury'); 95 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 />';96 $DbResult = $this->Database->select('Subject', '*', '1 ORDER BY Name'); 97 while($Subject = $DbResult->fetch_array()) 98 { 99 $Output .= '<a href="?Operation=Bills&subject='.$Subject['Id'].'">'.$Subject['Name'].'</a><br />'; 100 100 } 101 101 //ShowFooter(); … … 133 133 if($TimePayment != '') $TimePayment = TimeToMysqlDateTime($TimePayment); 134 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 />';135 $Output = '.'; //$this->Database->LastQuery.'<br />'; 136 136 $LastInsertTime = $Time; 137 137 $this->CheckAdvancesAndLiabilities($Subject); … … 227 227 function ImportOldData() 228 228 { 229 global $InvoiceGenerator;230 231 229 $Output = ''; 232 230 $this->Database->query('TRUNCATE TABLE FinanceCashFlow'); … … 239 237 240 238 // 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();239 $DbResult = $this->Database->query('SELECT * FROM Subject'); 240 while($Subject = $DbResult->fetch_assoc()) 241 { 242 $DbResult2 = $this->Database->query('SELECT SUM(money) FROM finance_operations WHERE user='.$Subject['Id'].' AND date < "2007-12-01"'); 243 $Row = $DbResult2->fetch_row(); 246 244 $TotalAdvance = $Row[0]; 247 245 //echo($User['second_name'].' '.$User['first_name'].' '.$TotalAdvance.'<br>'); … … 249 247 if($TotalAdvance > 0) 250 248 { 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í)');249 $this->InsertMoney($Subject['Id'], $TotalAdvance, 0, 1, mktime(0, 0, 0, 12, 1, 2007), 'Přijatá záloha (z období před daňovou evidencí)'); 252 250 } 253 251 // Dluh 254 252 if($TotalAdvance < 0) 255 253 { 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í)');254 $this->InsertLiability($Subject['Id'], (-$Row[0]), mktime(0, 0, 0, 12, 1, 2007), 0, 'Připojení k síti (z období před daňovou evidencí)'); 257 255 //echo($Database->LastQuery.'<br>'); 258 256 } … … 263 261 // while($User = $DbResult->fetch_array()) 264 262 // { 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"');266 while($Operation = $DbResult2->fetch_a rray())263 $DbResult2 = $this->Database->query('SELECT finance_operations.* FROM finance_operations JOIN Subject ON Subject.Id = finance_operations.user WHERE finance_operations.date >= "2007-12-01"'); 264 while($Operation = $DbResult2->fetch_assoc()) 267 265 { 268 266 //echo($Operation['comment'].'<br>'); … … 288 286 } else 289 287 { 290 $DbResult = $this->Database->query('SELECT role FROM users WHERE id='.$Operation['user']);288 $DbResult = $this->Database->query('SELECT Id FROM Subject WHERE Id='.$Operation['user']); 291 289 while($User = $DbResult->fetch_array()) 292 290 $this->InsertLiability($Operation['user'], -$Operation['money'], MysqlDateToTime($Operation['date']), $Operation['bill_id'], $Operation['comment'], MysqlDateToTime($Operation['date'])); 293 291 $Output .= $Operation['user'].' '.$Operation['comment'].' '.MysqlDateToTime($Operation['date']).'<br />'; 294 292 295 if(($Operation['role'] == 2))296 {293 // if(($Operation['role'] == 2)) 294 // { 297 295 $Output .= 'A'; 298 296 $this->Database->insert('FinanceAdvances', array('Subject' => $Operation['user'], 'Value' => $Operation['money'], 'TimeCreation' => MysqlDateToTime($Operation['date']), 'CashFlowId' => 0, 'Direction' => 'In')); 299 297 $this->CheckAdvancesAndLiabilities($Operation['user']); 300 } else InsertMoney($Operation['user'], $Operation['money'], 0, 1, MysqlDateToTime($Operation['date']), $Operation['comment']);298 //} else InsertMoney($Operation['user'], $Operation['money'], 0, 1, MysqlDateToTime($Operation['date']), $Operation['comment']); 301 299 } 302 300 } … … 314 312 { 315 313 //$Database->insert('FinanceSmallAsset', array()); 316 $Items[] = array(' description' => $Device['name'], 'quantity' => $Device['count'], 'price' => 0); //$Device['price']);314 $Items[] = array('Description' => $Device['name'], 'Quantity' => $Device['count'], 'Price' => 0); //$Device['price']); 317 315 $LastId = $Device['id']; 318 316 $TotalPrice += $Device['price'] * $Device['count']; … … 320 318 } 321 319 //print_r($Items); 322 $BillId = $ InvoiceGenerator->CreateBill($Subject, $Items, $Time, $Time);320 $BillId = $this->System->Modules['Bill']->CreateBill($Subject, $Items, $Time, $Time); 323 321 $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 322 //echo($Database->error); … … 336 334 { 337 335 // $Database->insert('FinanceSmallAsset', array()); 338 $Items[] = array(' description' => $Device['name'], 'quantity' => $Device['count'], 'price' => 0); //$Device['price']);336 $Items[] = array('Description' => $Device['name'], 'Quantity' => $Device['count'], 'Price' => 0); //$Device['price']); 339 337 $TotalPrice += $Device['price'] * $Device['count']; 340 338 } 341 339 //print_r($Items); 342 $BillId = $ InvoiceGenerator->CreateBill($Subject, $Items, $Time, $Time);340 $BillId = $this->System->Modules['Bill']->CreateBill($Subject, $Items, $Time, $Time); 343 341 $DbResult = $this->Database->query('UPDATE network_devices SET TimeEnlistment = "'.TimeToMysqlDateTime($Time).'" WHERE used <> 0 AND date < "'.TimeToMysqlDateTime($Time).'" AND (id > '.$LastId.')'); 344 342 $this->InsertLiability($Subject, 0, $Time, $BillId, 'Nákup infrastruktury', $Time); … … 354 352 function ConvertPDFDataToFiles() 355 353 { 356 $DbResult = $this->Database->query('SELECT * FROM finance_bills');354 $DbResult = $this->Database->query('SELECT * FROM FinanceBills'); 357 355 while($Bill = $DbResult->fetch_array()) 358 356 { … … 366 364 global $Database, $InvoiceGenerator; 367 365 368 $DbResult = $this->Database->query('SELECT * FROM finance_bills');366 $DbResult = $this->Database->query('SELECT * FROM FinanceBills'); 369 367 while($Bill = $DbResult->fetch_array()) 370 368 { -
www/finance/monthly_overall.php
r152 r156 13 13 14 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 );15 $Total = array('money' => 0, 'administration_total' => 0, 'consumption_total' => 0, 'total_paid' => 0, 'investment' => 0); 16 16 $DbResult = $this->Database->select('finance_monthly_overall', '*', '1 ORDER BY date DESC'); 17 17 while($Month = $DbResult->fetch_array()) 18 18 { 19 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>';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 21 22 22 $Total['money'] += $Month['money']; -
www/finance/user_state.php
r154 r156 18 18 $UserId = $this->System->Modules['User']->User['Id']; 19 19 if(!array_key_exists('show', $_GET)) $_GET['show'] = ''; 20 $DbResult = $this->Database->query('SELECT * FROM Subject WHERE Id=(SELECT Subject FROM Member WHERE Id=(SELECT Member FROM User='.$UserId.'))'); 21 $Row2 = $DbResult->fetch_array(); 22 $TarifName = $Tarify[$Row2['inet_tarif_next']]['name']; 20 $DbResult = $this->Database->query('SELECT Id FROM Subject WHERE Id=(SELECT Subject FROM Member WHERE Id=(SELECT Member FROM User WHERE Id='.$UserId.'))'); 21 $Subject = $DbResult->fetch_assoc(); 22 $DbResult = $this->Database->query('SELECT InternetTariffCurrentMonth FROM Member WHERE Id=(SELECT Member FROM User WHERE Id='.$UserId.')'); 23 $Member = $DbResult->fetch_assoc(); 24 $TarifName = $Tarify[$Member['InternetTariffCurrentMonth']]['name']; 25 $TarifPrice = $Tarify[$Member['InternetTariffCurrentMonth']]['price']; 23 26 $Output = '<table width="100%" border="0" cellspacing="0" cellpadding="3"><tr><td valign="top">'; 24 27 25 28 // Tabulka operaci 26 $Output .= 'Výpis operací pro účastníka '.$Row2['Name'].':<br>'; 29 $DbResult = $this->Database->query('SELECT CONCAT(SecondName, " ", FirstName) as Name FROM User WHERE Id='.$UserId); 30 $User = $DbResult->fetch_assoc(); 31 $Output .= 'Výpis operací pro účastníka '.$User['Name'].':<br>'; 27 32 $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3"><tr><th>Datum</th><th>Popis</th><th>Částka</th><th>Doklad</th></tr>'; 28 33 $Operations = array(); 29 $DbResult = $this->Database->query('(SELECT Time, Value, Text, Bill FROM FinanceCashFlow WHERE Subject='.$ UserId.') UNION ALL '.30 '(SELECT TimeCreation as Time, -Value as Value, Text, Bill FROM FinanceClaimsLiabilities WHERE Subject='.$ UserId.') ORDER BY Time DESC');34 $DbResult = $this->Database->query('(SELECT Time, Value, Text, Bill FROM FinanceCashFlow WHERE Subject='.$Subject['Id'].') UNION ALL '. 35 '(SELECT TimeCreation as Time, -Value as Value, Text, Bill FROM FinanceClaimsLiabilities WHERE Subject='.$Subject['Id'].') ORDER BY Time DESC'); 31 36 while($DbRow = $DbResult->fetch_array()) 32 37 $Operations[] = $DbRow; … … 40 45 //echo('<tr><td> </td><td>-'.$Row2['network_device'].'</td><td>Proměnná cena za zařízení</td></tr> 41 46 $Output .= '</table>'; 42 $DbResult = $this->Database->query('SELECT ((SELECT COALESCE(SUM(Value), 0) FROM FinanceCashFlow WHERE Subject='.$ UserId.') + '.43 '(SELECT COALESCE(SUM(-Value), 0) FROM FinanceClaimsLiabilities WHERE Subject='.$ UserId.')) as Total');47 $DbResult = $this->Database->query('SELECT ((SELECT COALESCE(SUM(Value), 0) FROM FinanceCashFlow WHERE Subject='.$Subject['Id'].') + '. 48 '(SELECT COALESCE(SUM(-Value), 0) FROM FinanceClaimsLiabilities WHERE Subject='.$Subject['Id'].')) as Total'); 44 49 $DbRow = $DbResult->fetch_array(); 45 50 $Total = $DbRow['Total']; … … 47 52 $Output .= '</td><td valign="top">'; 48 53 49 if($Row2['role'] == 2) 54 $Output .= 'Variabilní symbol pro platby: <strong>'.$Subject['Id'].'</strong><br><br>'; 55 56 $DbResult = $this->Database->query('SELECT SUM(consumption) AS Total FROM network_devices WHERE user='.$UserId.' AND used=1'); 57 $ConsumptionBonus = $DbResult->fetch_assoc(); 58 $ConsumptionBonus = W2Kc($ConsumptionBonus['Total']); 59 60 $Total = 0; 61 $Output .= 'Rozpis měsíčního poplatku:<br><table border="1" cellspacing="0" cellpadding="3">'. 62 '<tr><th>Část</th><th>Cena [Kč]</th></tr>'. 63 '<tr><td>Internet - tarif '.$TarifName.'</td><td>'.$TarifPrice.'</td></tr>'; 64 $Total += $TarifPrice; 65 if($ConsumptionBonus != 0) 66 $Output .= '<tr><td>Příjem za spotřebu</td><td>'.(-$ConsumptionBonus) .'</td></tr>'; 67 $Total += -$ConsumptionBonus; 68 $Output .= '<tr><td><strong>Celkem</strong></td><td><strong>'.$Total.'</strong></td></tr></table>'; 69 //echo('Tarif pro příští měsíc: '.$Tarify[$Row2['inet_tarif_next']]['name'].'<br><br>'); 70 $Output .= '<br />'; 71 72 if($ConsumptionBonus != 0) 50 73 { 51 $Output .= 'Variabilní symbol pro platby: <strong>'.$Row2['id'].'</strong><br><br>'; 52 53 // Měsíční bilance 54 if($Row2['inet'] == 1) $InternetPrice = round($Row2['monthly_inet']); else $InternetPrice = 0; 55 if($Row2['overheads'] == 0) 56 { 57 $PoplatekSprava = 0; 58 $PoplatekSpotreba = 0; 59 $PrijemSpotreba = $Row2['plus']; 60 } else { 61 $PoplatekSprava = $Sprava; 62 $PoplatekSpotreba = $Row2['consumption']; 63 $PrijemSpotreba = $Row2['plus']; 64 } 65 $Output .= 'Rozpis měsíčního poplatku:<br><table border="1" cellspacing="0" cellpadding="3">'. 66 '<tr><th>Část</th><th>Cena [Kč]</th></tr>'. 67 '<tr><td>Internet - tarif '.$TarifName.'</td><td>'.$InternetPrice.'</td></tr>'. 68 //'<tr><td>Správa</td><td>'.$PoplatekSprava.'</td></tr>'. 69 //'<tr><td>Poplatek za spotřebu</td><td>'.$PoplatekSpotreba.'</td></tr>'. 70 '<tr><td>Příjem za spotřebu</td><td>'.(-1*$PrijemSpotreba) .'</td></tr>'. 71 '<tr><td><strong>Celkem</strong></td><td><strong>'.($InternetPrice // + $PoplatekSprava + $PoplatekSpotreba 72 - $PrijemSpotreba).'</strong></td></tr></table>'; 73 //echo('Tarif pro příští měsíc: '.$Tarify[$Row2['inet_tarif_next']]['name'].'<br><br>'); 74 $Output .= '<br>'; 75 76 /* 77 78 // Rozpis ceny za zařízení 79 echo('Výpis podílu na zařízení segmentů:'); 80 echo('<table border="1" cellspacing="0" cellpadding="3"><tr><th>Název segmentu</th><th>Cena [Kč]</th><th>Uživatelů</th><th>Podíl [Kč]</th></tr>'); 81 $ID = $Row2['network_segment']; 82 $Money = 0; 83 while($ID > 0) 84 { 85 $DbResult = $Database->query("SELECT * FROM network_segments WHERE id=".$ID); 86 $Row = $DbResult->fetch_array(); 87 if(!(($Row2['inet_hw'] == 0) and ($ID == $InternetSegmentId))) 88 { 89 $Money += $Row['price']/$Row['users']; 90 echo('<tr><td>'.$Row['name'].'</td><td>'.$Row['price'].'</td><td>'.$Row['users'].' </td><td>'.round($Row['price']/$Row['users']).'</td></tr>'); 91 } 92 $ID = $Row['parent']; 93 } 94 echo('<tr><td><strong>Celkem</strong></td><td> </td><td> </td><td><strong>'.round($Money).'</strong></td></tr>'); 95 echo('</table><br>'); 96 97 // Rozpis platba spotřeby segmentů 98 echo('Výpis podílu na spotřebě segmentů:'); 99 echo('<table border="1" cellspacing="0" cellpadding="3"><tr><th>Název segmentu</th><th>Cena [Kč]</th><th>Uživatelů</th><th>Podíl [Kč]</th></tr>'); 100 $ID = $Row2['network_segment']; 101 $Money = 0; 102 while($ID>0) 103 { 104 $DbResult = $Database->query("SELECT * FROM network_segments WHERE id=".$ID); 105 $Row = $DbResult->fetch_array(); 106 $Money += round(W2Kc($Row['consumption'])/$Row['users_overheads']); 107 echo('<tr><td>'.$Row['name'].'</td><td>'.W2Kc($Row['consumption']).'</td><td>'.$Row['users_overheads'].' </td><td>'.round(W2Kc($Row['consumption'])/$Row['users_overheads']).'</td></tr>'); 108 $ID = $Row['parent']; 109 } 110 echo('<tr><td><strong>Celkem</strong></td><td> </td><td> </td><td><strong>'.round($Money).'</strong></td></tr>'); 111 echo('</table><br>'); 112 */ 113 114 $Output .= 'Měsíční příjem za spotřebu zařízení umístěných u uživatele:<br>'; 74 $Output .= 'Měsíční příjem za spotřebu zařízení umístěných u uživatele:<br>'; 115 75 $Output .= '<table border="1" cellspacing="0" cellpadding="3"><tr><th>Název zařízení</th><th>Spotřeba [W]</th><th>Příjem [Kč]</th></tr>'; 116 $DbResult = $this->Database->query( "SELECT * FROM network_devices WHERE user=".$UserId." AND used=1");76 $DbResult = $this->Database->query('SELECT * FROM network_devices WHERE user='.$UserId.' AND used=1'); 117 77 $TotalW = 0; 118 78 $TotalPrice = 0; 119 while($Row = $DbResult->fetch_a rray())79 while($Row = $DbResult->fetch_assoc()) 120 80 { 121 81 $Output .= '<tr><td>'.$Row['name'].'</td><td>'.$Row['consumption'].'</td><td>'.W2Kc($Row['consumption']).'</td></tr>'; … … 125 85 $Output .= '<tr><td><strong>Celkem</strong></td><td><strong>'.$TotalW.'</strong></td><td><strong>'.$TotalPrice.'</strong></td></tr>'; 126 86 $Output .= '</table>'; 127 87 } 128 88 $Output .= '</td></tr></table>'; 129 89 return($Output); 130 90 } 131 132 91 } 133 92 -
www/finance/user_state_ip.php
r154 r156 14 14 global $Tarify, $Sprava; 15 15 16 if(!$this->System->Modules['User']->CheckPermission('Finance', 'DisplaySubjectState')) return('Nemáte oprávnění');16 $UserId = GetMemberByIP(GetRemoteAddress()); 17 17 18 //$UserId = $this->System->Modules['User']->User['Id']; 19 $UserId = GetMemberByIP(GetRemoteAddress()); 20 if(!array_key_exists('show',$_GET)) $_GET['show'] = ''; 21 $DbResult = $this->Database->query("SELECT *,CONCAT(second_name, ' ', first_name) as fullname FROM users WHERE id=".$UserId); 22 $Row2 = $DbResult->fetch_array(); 23 $TarifName = $Tarify[$Row2['inet_tarif_next']]['name']; 18 if(!array_key_exists('show', $_GET)) $_GET['show'] = ''; 19 $DbResult = $this->Database->query('SELECT Id FROM Subject WHERE Id=(SELECT Subject FROM Member WHERE Id=(SELECT Member FROM User WHERE Id='.$UserId.'))'); 20 $Subject = $DbResult->fetch_assoc(); 21 $DbResult = $this->Database->query('SELECT InternetTariffCurrentMonth FROM Member WHERE Id=(SELECT Member FROM User WHERE Id='.$UserId.')'); 22 $Member = $DbResult->fetch_assoc(); 23 $TarifName = $Tarify[$Member['InternetTariffCurrentMonth']]['name']; 24 $TarifPrice = $Tarify[$Member['InternetTariffCurrentMonth']]['price']; 24 25 $Output = '<table width="100%" border="0" cellspacing="0" cellpadding="3"><tr><td valign="top">'; 25 26 26 27 // Tabulka operaci 27 $Output .= 'Výpis operací pro účastníka '.$Row2['fullname'].':<br>'; 28 $DbResult = $this->Database->query('SELECT CONCAT(SecondName, " ", FirstName) as Name FROM User WHERE Id='.$UserId); 29 $User = $DbResult->fetch_assoc(); 30 $Output .= 'Výpis operací pro účastníka '.$User['Name'].':<br>'; 28 31 $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3"><tr><th>Datum</th><th>Popis</th><th>Částka</th><th>Doklad</th></tr>'; 29 32 $Operations = array(); 30 $DbResult = $this->Database->query('(SELECT Time, Value, Text, Bill FROM FinanceCashFlow WHERE Subject='.$ UserId.') UNION ALL '.31 '(SELECT TimeCreation as Time, -Value as Value, Text, Bill FROM FinanceClaimsLiabilities WHERE Subject='.$ UserId.') ORDER BY Time DESC');33 $DbResult = $this->Database->query('(SELECT Time, Value, Text, Bill FROM FinanceCashFlow WHERE Subject='.$Subject['Id'].') UNION ALL '. 34 '(SELECT TimeCreation as Time, -Value as Value, Text, Bill FROM FinanceClaimsLiabilities WHERE Subject='.$Subject['Id'].') ORDER BY Time DESC'); 32 35 while($DbRow = $DbResult->fetch_array()) 33 36 $Operations[] = $DbRow; … … 41 44 //echo('<tr><td> </td><td>-'.$Row2['network_device'].'</td><td>Proměnná cena za zařízení</td></tr> 42 45 $Output .= '</table>'; 43 $DbResult = $this->Database->query('SELECT ((SELECT COALESCE(SUM(Value), 0) FROM FinanceCashFlow WHERE Subject='.$ UserId.') + '.44 '(SELECT COALESCE(SUM(-Value), 0) FROM FinanceClaimsLiabilities WHERE Subject='.$ UserId.')) as Total');46 $DbResult = $this->Database->query('SELECT ((SELECT COALESCE(SUM(Value), 0) FROM FinanceCashFlow WHERE Subject='.$Subject['Id'].') + '. 47 '(SELECT COALESCE(SUM(-Value), 0) FROM FinanceClaimsLiabilities WHERE Subject='.$Subject['Id'].')) as Total'); 45 48 $DbRow = $DbResult->fetch_array(); 46 49 $Total = $DbRow['Total']; … … 48 51 $Output .= '</td><td valign="top">'; 49 52 50 if($Row2['role'] == 2) 53 $Output .= 'Variabilní symbol pro platby: <strong>'.$Subject['Id'].'</strong><br><br>'; 54 55 $DbResult = $this->Database->query('SELECT SUM(consumption) AS Total FROM network_devices WHERE user='.$UserId.' AND used=1'); 56 $ConsumptionBonus = $DbResult->fetch_assoc(); 57 $ConsumptionBonus = W2Kc($ConsumptionBonus['Total']); 58 59 $Total = 0; 60 $Output .= 'Rozpis měsíčního poplatku:<br><table border="1" cellspacing="0" cellpadding="3">'. 61 '<tr><th>Část</th><th>Cena [Kč]</th></tr>'. 62 '<tr><td>Internet - tarif '.$TarifName.'</td><td>'.$TarifPrice.'</td></tr>'; 63 $Total += $TarifPrice; 64 if($ConsumptionBonus != 0) 65 $Output .= '<tr><td>Příjem za spotřebu</td><td>'.(-$ConsumptionBonus) .'</td></tr>'; 66 $Total += -$ConsumptionBonus; 67 $Output .= '<tr><td><strong>Celkem</strong></td><td><strong>'.$Total.'</strong></td></tr></table>'; 68 //echo('Tarif pro příští měsíc: '.$Tarify[$Row2['inet_tarif_next']]['name'].'<br><br>'); 69 $Output .= '<br />'; 70 71 if($ConsumptionBonus != 0) 51 72 { 52 $Output .= 'Variabilní symbol pro platby: <strong>'.$Row2['id'].'</strong><br><br>'; 53 54 // Měsíční bilance 55 if($Row2['inet'] == 1) $InternetPrice = round($Row2['monthly_inet']); else $InternetPrice = 0; 56 if($Row2['overheads'] == 0) 57 { 58 $PoplatekSprava = 0; 59 $PoplatekSpotreba = 0; 60 $PrijemSpotreba = $Row2['plus']; 61 } else { 62 $PoplatekSprava = $Sprava; 63 $PoplatekSpotreba = $Row2['consumption']; 64 $PrijemSpotreba = $Row2['plus']; 65 } 66 $Output .= 'Rozpis měsíčního poplatku:<br><table border="1" cellspacing="0" cellpadding="3">'. 67 '<tr><th>Část</th><th>Cena [Kč]</th></tr>'. 68 '<tr><td>Internet - tarif '.$TarifName.'</td><td>'.$InternetPrice.'</td></tr>'. 69 //'<tr><td>Správa</td><td>'.$PoplatekSprava.'</td></tr>'. 70 //'<tr><td>Poplatek za spotřebu</td><td>'.$PoplatekSpotreba.'</td></tr>'. 71 '<tr><td>Příjem za spotřebu</td><td>'.(-1*$PrijemSpotreba) .'</td></tr>'. 72 '<tr><td><strong>Celkem</strong></td><td><strong>'.($InternetPrice // + $PoplatekSprava + $PoplatekSpotreba 73 - $PrijemSpotreba).'</strong></td></tr></table>'; 74 //echo('Tarif pro příští měsíc: '.$Tarify[$Row2['inet_tarif_next']]['name'].'<br><br>'); 75 $Output .= '<br>'; 76 77 /* 78 79 // Rozpis ceny za zařízení 80 echo('Výpis podílu na zařízení segmentů:'); 81 echo('<table border="1" cellspacing="0" cellpadding="3"><tr><th>Název segmentu</th><th>Cena [Kč]</th><th>Uživatelů</th><th>Podíl [Kč]</th></tr>'); 82 $ID = $Row2['network_segment']; 83 $Money = 0; 84 while($ID > 0) 85 { 86 $DbResult = $Database->query("SELECT * FROM network_segments WHERE id=".$ID); 87 $Row = $DbResult->fetch_array(); 88 if(!(($Row2['inet_hw'] == 0) and ($ID == $InternetSegmentId))) 89 { 90 $Money += $Row['price']/$Row['users']; 91 echo('<tr><td>'.$Row['name'].'</td><td>'.$Row['price'].'</td><td>'.$Row['users'].' </td><td>'.round($Row['price']/$Row['users']).'</td></tr>'); 92 } 93 $ID = $Row['parent']; 94 } 95 echo('<tr><td><strong>Celkem</strong></td><td> </td><td> </td><td><strong>'.round($Money).'</strong></td></tr>'); 96 echo('</table><br>'); 97 98 // Rozpis platba spotřeby segmentů 99 echo('Výpis podílu na spotřebě segmentů:'); 100 echo('<table border="1" cellspacing="0" cellpadding="3"><tr><th>Název segmentu</th><th>Cena [Kč]</th><th>Uživatelů</th><th>Podíl [Kč]</th></tr>'); 101 $ID = $Row2['network_segment']; 102 $Money = 0; 103 while($ID>0) 104 { 105 $DbResult = $Database->query("SELECT * FROM network_segments WHERE id=".$ID); 106 $Row = $DbResult->fetch_array(); 107 $Money += round(W2Kc($Row['consumption'])/$Row['users_overheads']); 108 echo('<tr><td>'.$Row['name'].'</td><td>'.W2Kc($Row['consumption']).'</td><td>'.$Row['users_overheads'].' </td><td>'.round(W2Kc($Row['consumption'])/$Row['users_overheads']).'</td></tr>'); 109 $ID = $Row['parent']; 110 } 111 echo('<tr><td><strong>Celkem</strong></td><td> </td><td> </td><td><strong>'.round($Money).'</strong></td></tr>'); 112 echo('</table><br>'); 113 */ 114 115 $Output .= 'Měsíční příjem za spotřebu zařízení umístěných u uživatele:<br>'; 73 $Output .= 'Měsíční příjem za spotřebu zařízení umístěných u uživatele:<br>'; 116 74 $Output .= '<table border="1" cellspacing="0" cellpadding="3"><tr><th>Název zařízení</th><th>Spotřeba [W]</th><th>Příjem [Kč]</th></tr>'; 117 $DbResult = $this->Database->query( "SELECT * FROM network_devices WHERE user=".$UserId." AND used=1");75 $DbResult = $this->Database->query('SELECT * FROM network_devices WHERE user='.$UserId.' AND used=1'); 118 76 $TotalW = 0; 119 77 $TotalPrice = 0; 120 while($Row = $DbResult->fetch_a rray())78 while($Row = $DbResult->fetch_assoc()) 121 79 { 122 80 $Output .= '<tr><td>'.$Row['name'].'</td><td>'.$Row['consumption'].'</td><td>'.W2Kc($Row['consumption']).'</td></tr>'; … … 126 84 $Output .= '<tr><td><strong>Celkem</strong></td><td><strong>'.$TotalW.'</strong></td><td><strong>'.$TotalPrice.'</strong></td></tr>'; 127 85 $Output .= '</table>'; 128 86 } 129 87 $Output .= '</td></tr></table>'; 130 88 return($Output); 131 89 } 132 133 90 } 134 91 -
www/form_classes.php
r154 r156 120 120 'TFinanceSubject' => array( 121 121 'Type' => 'Reference', 122 'Table' => ' User',123 'Id' => ' id',124 'Name' => ' CONCAT(SecondName, " ", FirstName)',125 'Filter' => ' role=2',122 'Table' => 'Subject', 123 'Id' => 'Id', 124 'Name' => 'Name', 125 'Filter' => '1', 126 126 ), 127 127 'TNetworkDevice' => array(
Note:
See TracChangeset
for help on using the changeset viewer.