Changeset 294


Ignore:
Timestamp:
Oct 2, 2010, 6:19:19 PM (14 years ago)
Author:
george
Message:
  • Opraveno: Nové generování dokladových řad při generování nových faktůr.
  • Odstraněno: Přímý přístup na stav financí uživatele bez přihlášení.
  • Upraveno: Uživatelský panel je také ohraničen boxem.
Location:
trunk
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/block/index.php

    r291 r294  
    2020<strong>Důvod:</strong> ';
    2121
    22     $DbResult = $this->Database->query('SELECT * FROM NetworkInterface WHERE LocalIP="'.$_SERVER['REMOTE_ADDR'].'"');
     22    $DbResult = $this->Database->query('SELECT * FROM NetworkInterface WHERE LocalIP="'.GetRemoteAddress().'"');
    2323    if($DbResult->num_rows > 0)
    2424    {
  • trunk/finance/finance.php

    r292 r294  
    142142    $DocumentLine = $DbResult->fetch_assoc();
    143143   
    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']);
    145145    $Sequence = $DbResult->fetch_assoc();
    146146   
    147147    if($Sequence['YearPrefix'] == 1)
    148148    {
    149       $Result = $DbRow['Shortcut'].$Sequence['NextNumber'].'/'.$FinanceYear['Year'];
     149      $Result = $DocumentLine['Shortcut'].$Sequence['NextNumber'].'/'.$FinanceYear['Year'];
    150150    } else $Result = $DocumentLine['Shortcut'].$Sequence['NextNumber'];
    151151       
  • trunk/finance/index.php

    r282 r294  
    1111    $Finance = $this->System->Modules['Finance'];
    1212    $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   
    1514    $Output .= '<a href="monthly_overall.php">Měsíční přehledy</a><br />';
    1615    $Output .= '<a href="tarify.php">Tarify</a><br />';
  • trunk/finance/manage.php

    r227 r294  
    1212
    1313    if(array_key_exists('Operation', $_GET)) $Operation = $_GET['Operation']; else $Operation = '';
    14           //$Operation = 'ImportOldData';
     14    //$Operation = 'ImportOldData';
    1515    switch($Operation)
    1616    {
     
    390390  {
    391391    $Finance = $this->System->Modules['Finance'];
    392           $Output = '';
    393           $this->Database->query('TRUNCATE TABLE FinanceOperation');
    394           $this->Database->query('TRUNCATE TABLE FinanceClaimsLiabilities');
     392    $Output = '';
     393    $this->Database->query('TRUNCATE TABLE FinanceOperation');
     394    $this->Database->query('TRUNCATE TABLE FinanceClaimsLiabilities');
    395395
    396396    // Move time of device price transformation
     
    398398
    399399    // Transform old operations
    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           }
     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    }
    412412
    413413    // Transform old invoices
    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           }
     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    }
    426426
    427427    // Transfer finance before era
     
    432432      $DbRow2 = $DbResult2->fetch_assoc();
    433433
    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));
     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));
    439439} else
    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);
     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);
    448448  }
    449449  */
    450450
    451        
    452         function GetBillingPeriod($Period)
    453         {
     451 
     452  function GetBillingPeriod($Period)
     453  {
    454454    $MonthCount = $this->System->Modules['Finance']->BillingPeriods[$Period]['MonthCount'];
    455455    $PeriodFrom = mktime(0, 0, 0, date('n'), 1, date('Y'));
    456456    $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                 return(array('From' => $PeriodFrom, 'To' => $PeriodTo, 'MonthCount' => $MonthCount));
    458         }
     457    return(array('From' => $PeriodFrom, 'To' => $PeriodTo, 'MonthCount' => $MonthCount));
     458  }
    459459
    460460  function ShowMonthlyPayment()
    461461  {
    462462    if(!$this->System->Modules['User']->CheckPermission('Finance', 'Manage')) return('Nemáte oprávnění');
    463           $Output = '';
     463    $Output = '';
    464464
    465465    $Finance = &$this->System->Modules['Finance'];
    466          
     466   
    467467    // Načti poslední měsíční přehled a nastavení
    468468    $DbResult = $this->Database->select('finance_monthly_overall', '*', '1 ORDER BY date DESC LIMIT 1');
     
    482482    $DbResult = $this->Database->query('SELECT SUM(price) FROM network_devices WHERE used = 1');
    483483    $Row = $DbResult->fetch_row();
    484                 $TotalDeviceCost = $Row[0];
     484    $TotalDeviceCost = $Row[0];
    485485    $Output .= 'Celková cena zařízení: Zařízení('.$TotalDeviceCost;
    486                
     486   
    487487    $DbResult = $this->Database->query('SELECT SUM(price) FROM network_segments');
    488488    $Row = $DbResult->fetch_row();
    489                 $TotalSegmentDeviceCost = $Row[0];
     489    $TotalSegmentDeviceCost = $Row[0];
    490490    $Output .= '), Segmenty('.$TotalSegmentDeviceCost;
    491                
     491   
    492492    $DbResult = $this->Database->query('SELECT SUM(NetworkDevice) FROM MemberPayment');
    493493    $Row = $DbResult->fetch_row();
    494                 $TotalMemberDeviceCost = $Row[0];
     494    $TotalMemberDeviceCost = $Row[0];
    495495    $Output .= '), Členové('.$TotalMemberDeviceCost.')<br />';
    496                
     496   
    497497    $DbResult = $this->Database->query('SELECT SUM(Cash) FROM MemberPayment');
    498498    $Row = $DbResult->fetch_row();
    499                 $TotalMemberCash = $Row[0];
     499    $TotalMemberCash = $Row[0];
    500500    $Output .= 'Stav pokladny: Členové('.$TotalMemberCash.')';   
    501501
    502502    $DbResult = $this->Database->query('SELECT SUM(consumption) FROM network_devices WHERE used=1');
    503503    $Row = $DbResult->fetch_row();
    504                 $TotalConsumption = $Row[0];
     504    $TotalConsumption = $Row[0];
    505505    $TotalConsumptionCost = $Finance->W2Kc($TotalConsumption);
    506506
     
    520520      {
    521521        $Output .= $Member['SubjectName'].': ';
    522                                 //$Member['UNIX_TIMESTAMP(Member.BillingPeriodLastDate)'] = MysqlDateTimeToTime('2009-04-01 1:1:1');
     522        //$Member['UNIX_TIMESTAMP(Member.BillingPeriodLastDate)'] = MysqlDateTimeToTime('2009-04-01 1:1:1');
    523523        $Period = $this->GetBillingPeriod($Member['BillingPeriodNext']);
    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'];
     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'];
    528528          $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))
    533534        {
    534           //echo($Mesic.'%'.$MonthCount.'='.($Mesic % $MonthCount).' ');                                                
     535          //echo($Mesic.'%'.$MonthCount.'='.($Mesic % $MonthCount).' ');                  
    535536          $TimePeriodText = date('j.n.Y', $Period['From']).' - '.date('j.n.Y', $Period['To']);
    536537          $Output .= $TimePeriodText.': '.$Member['MonthlyTotal'].' * '.$Period['MonthCount'].' = '.$PayPerPeriod.'<br />';
    537538          $BillCode = $Finance->GetNextDocumentLineNumber(6); // Faktury vydané
    538539          $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));
    540541          $Output .= $this->SendPaymentEmail($Member['Id']);
    541                                         $this->Database->update('Member', 'Id='.$Member['Id'], array('BillingPeriodLastDate' => TimeToMysqlDateTime($Period['To'])));
     542          $this->Database->update('Member', 'Id='.$Member['Id'], array('BillingPeriodLastDate' => TimeToMysqlDateTime($Period['To'])));
    542543        } else $Output .= '<br />';
    543544      }
    544                        
     545     
    545546      // Update finance charge
    546547      $Output .= 'Měním aktuální parametry sítě...<br>';
     
    563564      }
    564565
    565             $Finance->RecalculateMemberPayment();
     566      $Finance->RecalculateMemberPayment();
    566567      //CreateMonthlyOverallBill();
    567568      //$Finance->RecalculateUsersFinance();
  • trunk/finance/user_state.php

    r293 r294  
    1313    $this->System->Modules['Finance']->LoadTariffs(1);
    1414
    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     } else
    2415    if(array_key_exists('Subject', $_GET))
    2516    {
  • trunk/index.php

    r291 r294  
    7777  function UserPanel()
    7878  {
    79     $Output = '<a href="'.$this->System->Config['Web']['RootFolder'].'/?Action=UserOptions">Nastavení uživatele</a><br />';
     79    $Output = '<a href="'.$this->System->Config['Web']['RootFolder'].'/?Action=UserOptions">Profil</a><br />';
    8080    if($this->System->Modules['User']->CheckPermission('Finance', 'MemberOptions'))
    81       $Output .= '<a href="'.$this->System->Config['Web']['RootFolder'].'?Action=MemberOptions">Nastavení domácnosti</a><br />';
     81      $Output .= '<a href="'.$this->System->Config['Web']['RootFolder'].'?Action=MemberOptions">Domácnost</a><br />';
    8282    if($this->System->Modules['User']->CheckPermission('Finance', 'DisplaySubjectState'))
    83       $Output .= '<a href="'.$this->System->Config['Web']['RootFolder'].'/finance/user_state.php">Stav financí</a><br />';
     83      $Output .= '<a href="'.$this->System->Config['Web']['RootFolder'].'/finance/user_state.php">Finance</a><br />';
    8484    if($this->System->Modules['User']->CheckPermission('Network', 'RegistredHostList'))
    85       $Output .= '<a href="'.$this->System->Config['Web']['RootFolder'].'/network/user_hosts.php">Registrované počítače</a><br />';
     85      $Output .= '<a href="'.$this->System->Config['Web']['RootFolder'].'/network/user_hosts.php">Počítače</a><br />';
    8686    if($this->System->Modules['User']->CheckPermission('News', 'Insert'))
    8787      $Output .= '<a href="'.$this->System->Config['Web']['RootFolder'].'/aktuality/?action=add">Vložení aktuality</a><br />';
     
    309309        else if($Panel['Module'] == 'UserOptions')
    310310        {
    311           if($this->System->Modules['User']->User['Id'] != $this->System->Modules['User']->AnonymousUserId) $Output .= $this->UserPanel();
     311          if($this->System->Modules['User']->User['Id'] != $this->System->Modules['User']->AnonymousUserId) $Output .= $this->Panel('Přihlášený uživatel', $this->UserPanel());
    312312        } else
    313313        if($Panel['Module'] == 'Webcam') $Output .= $this->Panel('Kamery', $this->WebcamPanel());
  • trunk/sql/updates/291.sql

    r291 r294  
    1 ALTER TABLE `Member` ADD `Blocked` INT NOT NULL DEFAULT '0' AFTER `Id`
     1ALTER TABLE `Member` ADD `Blocked` INT NOT NULL DEFAULT '0';
Note: See TracChangeset for help on using the changeset viewer.