Changeset 156 for www/finance/manage.php
- Timestamp:
- Feb 17, 2009, 10:00:28 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 {
Note:
See TracChangeset
for help on using the changeset viewer.