Changeset 294 for trunk/finance
- Timestamp:
- Oct 2, 2010, 6:19:19 PM (14 years ago)
- Location:
- trunk/finance
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/finance/finance.php
r292 r294 142 142 $DocumentLine = $DbResult->fetch_assoc(); 143 143 144 $DbResult = $this->Database->query('SELECT Shortcut FROM DocumentLineSequence WHERE DocumentLine='.Id.' AND FinanceYear'.$FinanceYear['Id']);144 $DbResult = $this->Database->query('SELECT * FROM DocumentLineSequence WHERE DocumentLine='.$Id.' AND FinanceYear='.$FinanceYear['Id']); 145 145 $Sequence = $DbResult->fetch_assoc(); 146 146 147 147 if($Sequence['YearPrefix'] == 1) 148 148 { 149 $Result = $D bRow['Shortcut'].$Sequence['NextNumber'].'/'.$FinanceYear['Year'];149 $Result = $DocumentLine['Shortcut'].$Sequence['NextNumber'].'/'.$FinanceYear['Year']; 150 150 } else $Result = $DocumentLine['Shortcut'].$Sequence['NextNumber']; 151 151 -
trunk/finance/index.php
r282 r294 11 11 $Finance = $this->System->Modules['Finance']; 12 12 $Output = '<table><tr><td valign="top">'; 13 if(GetMemberByIP(GetRemoteAddress()) > 0) $Output .= '<a href="user_state.php?old">Vaše finanční operace</a> (Tato volba je také přístupná po přihlášení do systému v uživatelském menu).<br /><br /><br />'; 14 13 15 14 $Output .= '<a href="monthly_overall.php">Měsíční přehledy</a><br />'; 16 15 $Output .= '<a href="tarify.php">Tarify</a><br />'; -
trunk/finance/manage.php
r227 r294 12 12 13 13 if(array_key_exists('Operation', $_GET)) $Operation = $_GET['Operation']; else $Operation = ''; 14 14 //$Operation = 'ImportOldData'; 15 15 switch($Operation) 16 16 { … … 390 390 { 391 391 $Finance = $this->System->Modules['Finance']; 392 393 394 392 $Output = ''; 393 $this->Database->query('TRUNCATE TABLE FinanceOperation'); 394 $this->Database->query('TRUNCATE TABLE FinanceClaimsLiabilities'); 395 395 396 396 // Move time of device price transformation … … 398 398 399 399 // Transform old operations 400 401 402 403 404 405 406 407 408 409 410 411 400 $DbResult = $this->Database->query('SELECT * FROM finance_operations WHERE finance_operations.date >= "2007-12-01" AND (Source = '.$Finance->ExternalSubject.')'); 401 while($DbRow = $DbResult->fetch_assoc()) 402 { 403 $this->Database->insert('FinanceOperation', array('Id' => $DbRow['id'], 'Subject' => $DbRow['Destination'], 'Cash' => $DbRow['cash'], 'Value' => abs($DbRow['money']), 'Time' => $DbRow['date'], 'BillCode' => $DbRow['BillCode'], 'Taxable' => $DbRow['Taxable'], 'Text' => $DbRow['comment'], 'Bill' => $DbRow['bill_id'])); 404 $Output .= '.'; 405 } 406 $DbResult = $this->Database->query('SELECT * FROM finance_operations WHERE finance_operations.date >= "2007-12-01" AND (Destination = '.$Finance->ExternalSubject.')'); 407 while($DbRow = $DbResult->fetch_assoc()) 408 { 409 $this->Database->insert('FinanceOperation', array('Id' => $DbRow['id'], 'Subject' => $DbRow['Source'], 'Cash' => $DbRow['cash'], 'Value' => -abs($DbRow['money']), 'Time' => $DbRow['date'], 'BillCode' => $DbRow['BillCode'], 'Taxable' => $DbRow['Taxable'], 'Text' => $DbRow['comment'], 'Bill' => $DbRow['bill_id'])); 410 $Output .= '.'; 411 } 412 412 413 413 // Transform old invoices 414 415 416 417 418 419 420 421 422 423 424 425 414 $DbResult = $this->Database->query('SELECT * FROM finance_operations WHERE finance_operations.date >= "2007-12-01" AND (Source = '.$Finance->MainSubject.')'); 415 while($DbRow = $DbResult->fetch_assoc()) 416 { 417 $this->Database->insert('FinanceClaimsLiabilities', array('Id' => $DbRow['id'], 'Subject' => $DbRow['Destination'], 'Value' => -abs($DbRow['money']), 'TimeCreation' => $DbRow['date'], 'BillCode' => $DbRow['BillCode'], 'Text' => $DbRow['comment'], 'Bill' => $DbRow['bill_id'])); 418 $Output .= 'FV '.$DbRow['comment'].'<br />'; 419 } 420 $DbResult = $this->Database->query('SELECT * FROM finance_operations WHERE finance_operations.date >= "2007-12-01" AND (Destination = '.$Finance->MainSubject.')'); 421 while($DbRow = $DbResult->fetch_assoc()) 422 { 423 $this->Database->insert('FinanceClaimsLiabilities', array('Id' => $DbRow['id'], 'Subject' => $DbRow['Source'], 'Value' => abs($DbRow['money']), 'TimeCreation' => $DbRow['date'], 'BillCode' => $DbRow['BillCode'], 'Text' => $DbRow['comment'], 'Bill' => $DbRow['bill_id'])); 424 $Output .= 'FP '.$DbRow['comment'].'<br />'; 425 } 426 426 427 427 // Transfer finance before era … … 432 432 $DbRow2 = $DbResult2->fetch_assoc(); 433 433 434 435 436 437 438 434 $DbRow2['date'] = TimeToMysqlDateTime(mktime(0, 0, 0, 12, 1, 2007)); 435 if($DbRow2['money'] > 0) 436 { 437 $Comment = 'Přijatá záloha (z období před daňovou evidencí)'; 438 $this->Database->insert('FinanceOperation', array('Subject' => $Subject['Id'], 'Cash' => 0, 'Value' => abs($DbRow2['money']), 'Time' => $DbRow2['date'], 'Taxable' => 1, 'Text' => $Comment)); 439 439 } else 440 441 442 443 444 445 } 446 447 440 { 441 $Comment = 'Připojení k síti (z období před daňovou evidencí)'; 442 $this->Database->insert('FinanceClaimsLiabilities', array('Subject' => $Subject['Id'], 'Value' => abs($DbRow2['money']), 'TimeCreation' => $DbRow2['date'], 'Text' => $Comment)); 443 } 444 $Output .= '#'; 445 } 446 447 return($Output); 448 448 } 449 449 */ 450 450 451 452 453 451 452 function GetBillingPeriod($Period) 453 { 454 454 $MonthCount = $this->System->Modules['Finance']->BillingPeriods[$Period]['MonthCount']; 455 455 $PeriodFrom = mktime(0, 0, 0, date('n'), 1, date('Y')); 456 456 $PeriodTo = mktime(0, 0, 0, date('n') + $MonthCount - 1, date('t', mktime(0, 0, 0, date('n') + $MonthCount - 1, 1, date('Y'))) , date('Y')); 457 458 457 return(array('From' => $PeriodFrom, 'To' => $PeriodTo, 'MonthCount' => $MonthCount)); 458 } 459 459 460 460 function ShowMonthlyPayment() 461 461 { 462 462 if(!$this->System->Modules['User']->CheckPermission('Finance', 'Manage')) return('Nemáte oprávnění'); 463 463 $Output = ''; 464 464 465 465 $Finance = &$this->System->Modules['Finance']; 466 466 467 467 // Načti poslední měsíční přehled a nastavení 468 468 $DbResult = $this->Database->select('finance_monthly_overall', '*', '1 ORDER BY date DESC LIMIT 1'); … … 482 482 $DbResult = $this->Database->query('SELECT SUM(price) FROM network_devices WHERE used = 1'); 483 483 $Row = $DbResult->fetch_row(); 484 484 $TotalDeviceCost = $Row[0]; 485 485 $Output .= 'Celková cena zařízení: Zařízení('.$TotalDeviceCost; 486 486 487 487 $DbResult = $this->Database->query('SELECT SUM(price) FROM network_segments'); 488 488 $Row = $DbResult->fetch_row(); 489 489 $TotalSegmentDeviceCost = $Row[0]; 490 490 $Output .= '), Segmenty('.$TotalSegmentDeviceCost; 491 491 492 492 $DbResult = $this->Database->query('SELECT SUM(NetworkDevice) FROM MemberPayment'); 493 493 $Row = $DbResult->fetch_row(); 494 494 $TotalMemberDeviceCost = $Row[0]; 495 495 $Output .= '), Členové('.$TotalMemberDeviceCost.')<br />'; 496 496 497 497 $DbResult = $this->Database->query('SELECT SUM(Cash) FROM MemberPayment'); 498 498 $Row = $DbResult->fetch_row(); 499 499 $TotalMemberCash = $Row[0]; 500 500 $Output .= 'Stav pokladny: Členové('.$TotalMemberCash.')'; 501 501 502 502 $DbResult = $this->Database->query('SELECT SUM(consumption) FROM network_devices WHERE used=1'); 503 503 $Row = $DbResult->fetch_row(); 504 504 $TotalConsumption = $Row[0]; 505 505 $TotalConsumptionCost = $Finance->W2Kc($TotalConsumption); 506 506 … … 520 520 { 521 521 $Output .= $Member['SubjectName'].': '; 522 522 //$Member['UNIX_TIMESTAMP(Member.BillingPeriodLastDate)'] = MysqlDateTimeToTime('2009-04-01 1:1:1'); 523 523 $Period = $this->GetBillingPeriod($Member['BillingPeriodNext']); 524 525 526 527 524 if($Period['From'] > $Member['UNIX_TIMESTAMP(Member.BillingPeriodLastDate)']) 525 { 526 $this->Database->update('Member', 'Id='.$Member['Id'], array('BillingPeriod' => $Member['BillingPeriodNext'], 'InternetTariffCurrentMonth' => $Member['InternetTariffNextMonth'])); 527 $Member['BillingPeriod'] = $Member['BillingPeriodNext']; 528 528 $Member['InternetTariffCurrentMonth'] = $Member['InternetTariffNextMonth']; 529 } 530 $Period = $this->GetBillingPeriod($Member['BillingPeriod']); 531 $PayPerPeriod = $Member['MonthlyTotal'] * $Period['MonthCount']; 532 if(($Period['From'] > $Member['UNIX_TIMESTAMP(Member.BillingPeriodLastDate)']) and ($Member['InternetTariffCurrentMonth'] != 6) and ($PayPerPeriod > 0)) 529 } 530 $Period = $this->GetBillingPeriod($Member['BillingPeriod']); 531 $PayPerPeriod = $Member['MonthlyTotal'] * $Period['MonthCount']; 532 if(($Period['From'] > $Member['UNIX_TIMESTAMP(Member.BillingPeriodLastDate)']) and ($Member['InternetTariffCurrentMonth'] != 6) and ($PayPerPeriod > 0) and 533 ($Member['Blocked'] == 0)) 533 534 { 534 //echo($Mesic.'%'.$MonthCount.'='.($Mesic % $MonthCount).' '); 535 //echo($Mesic.'%'.$MonthCount.'='.($Mesic % $MonthCount).' '); 535 536 $TimePeriodText = date('j.n.Y', $Period['From']).' - '.date('j.n.Y', $Period['To']); 536 537 $Output .= $TimePeriodText.': '.$Member['MonthlyTotal'].' * '.$Period['MonthCount'].' = '.$PayPerPeriod.'<br />'; 537 538 $BillCode = $Finance->GetNextDocumentLineNumber(6); // Faktury vydané 538 539 $BillId = $this->System->Modules['Bill']->CreateBill($Member['Subject'], array(array('Description' => 'Připojení k síti', 'Price' => $PayPerPeriod, 'Quantity' => 1)), $Period['From'], $Period['To'], $BillCode); 539 $this->Database->insert('FinanceClaimsLiabilities', array('Value' => $PayPerPeriod, 'Subject' => $Member['Subject'], 'TimeCreation' => 'NOW()', 'Text' => 'Připojení k síti za období '.$TimePeriodText, 'Bill' => $BillId, 'BillCode' => $BillCode));540 $this->Database->insert('FinanceClaimsLiabilities', array('Value' => $PayPerPeriod, 'Subject' => $Member['Subject'], 'TimeCreation' => 'NOW()', 'Text' => 'Připojení k síti za období '.$TimePeriodText, 'Bill' => 0, 'BillCode' => $BillCode)); 540 541 $Output .= $this->SendPaymentEmail($Member['Id']); 541 542 $this->Database->update('Member', 'Id='.$Member['Id'], array('BillingPeriodLastDate' => TimeToMysqlDateTime($Period['To']))); 542 543 } else $Output .= '<br />'; 543 544 } 544 545 545 546 // Update finance charge 546 547 $Output .= 'Měním aktuální parametry sítě...<br>'; … … 563 564 } 564 565 565 566 $Finance->RecalculateMemberPayment(); 566 567 //CreateMonthlyOverallBill(); 567 568 //$Finance->RecalculateUsersFinance(); -
trunk/finance/user_state.php
r293 r294 13 13 $this->System->Modules['Finance']->LoadTariffs(1); 14 14 15 if(array_key_exists('old', $_GET))16 {17 $MemberId = GetMemberByIP(GetRemoteAddress());18 if($MemberId != '')19 {20 $DbResult = $this->Database->query('SELECT * FROM Subject WHERE Id=(SELECT Subject FROM Member WHERE Member.Id='.$MemberId.')');21 $Subject = $DbResult->fetch_assoc();22 } else die('Nemáte oprávnění');23 } else24 15 if(array_key_exists('Subject', $_GET)) 25 16 {
Note:
See TracChangeset
for help on using the changeset viewer.