Changeset 427


Ignore:
Timestamp:
Oct 10, 2012, 8:46:02 PM (12 years ago)
Author:
chronos
Message:
  • Opraveno: Další chybné použití tabulky UserCustomerRel vedlo k chybě při zobrazení financí uživatele, který má právo platícího klienta, ale nemá vazbu na tabulu Member.
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/finance/user_state.php

    r415 r427  
    2222      if(!$this->System->Modules['User']->CheckPermission('Finance', 'DisplaySubjectState')) return('Nemáte oprávnění');
    2323      $UserId = $this->System->Modules['User']->User['Id'];
    24       $DbResult = $this->Database->query('SELECT * FROM Subject WHERE Id=(SELECT Subject FROM Member WHERE Id=(SELECT Customer FROM UserCustomerRel WHERE User='.$UserId.' LIMIT 1))');
    25       $Subject = $DbResult->fetch_assoc();
     24      $DbResult = $this->Database->query('SELECT Customer FROM UserCustomerRel WHERE User='.$UserId.' LIMIT 1');
     25      if($DbResult->num_rows > 0)
     26      {
     27        $CustomerUserRel = $DbResult->fetch_assoc();
     28        $DbResult = $this->Database->query('SELECT * FROM Subject WHERE Id=(SELECT Subject FROM Member WHERE Id='.$CustomerUserRel['Customer'].')');
     29        $Subject = $DbResult->fetch_assoc();
     30      } else return($this->SystemMessage('Chyba', 'Nejste zákazníkem'));
    2631    }
    2732   
     
    4247    $FinanceYearSelected = $DbResult->fetch_assoc();
    4348    $YearWhere = ' WHERE (Time >= "'.$FinanceYearSelected['DateStart'].'") AND (Time <= "'.$FinanceYearSelected['DateEnd'].'")';
    44 
    45    
     49   
    4650   
    4751    // Year list
  • trunk/global.php

    r423 r427  
    413413  }
    414414  $QueryItems['all'] = '1';
    415   if($PageCount > 1) $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'">Vše</a>';
     415  if($PageCount > 1) $Result.= ' <a href="?'.SetQueryStringArray($QueryItems).'">Vše</a>';
    416416 
    417417  $Result = '<div style="text-align: center">'.$Result.'</div>';
     
    470470  ));
    471471}
     472
    472473function GetRemoteAddress()
    473474{
  • trunk/index.php

    r420 r427  
    231231      {
    232232        $UserOptions = new Form('MemberOptions');
    233         $DbResult = $this->Database->query('SELECT Member.Id, Member.InternetTariffNextMonth, Member.FamilyMemberCount, Member.BillingPeriodNext, Subject.Name, Subject.AddressStreet, Subject.AddressTown, Subject.AddressPSC, Subject.IC, Subject.DIC FROM Member JOIN Subject ON Subject.Id = Member.Subject WHERE Member.Id='.$this->System->Modules['User']->User['Member']);
    234         $DbRow = $DbResult->fetch_array();
    235         foreach($UserOptions->Definition['Items'] as $Index => $Item)
    236         {
    237           $UserOptions->Values[$Index] = $DbRow[$Index];
    238         }
    239         $UserOptions->OnSubmit = '?Action=MemberOptionsSave';
    240         $Output .= $UserOptions->ShowEditForm();
     233        $DbResult = $this->Database->query('SELECT Customer FROM UserCustomerRel WHERE User='.$this->System->Modules['User']->User['Id']);
     234        if($DbResult->num_rows > 0)
     235        {
     236          $CustomerUserRel = $DbResult->fetch_assoc();
     237          $DbResult = $this->Database->query('SELECT Member.Id, Member.InternetTariffNextMonth, '.
     238            'Member.FamilyMemberCount, Member.BillingPeriodNext, Subject.Name, Subject.AddressStreet, '.
     239            'Subject.AddressTown, Subject.AddressPSC, Subject.IC, Subject.DIC FROM Member JOIN Subject '.
     240           'ON Subject.Id = Member.Subject WHERE Member.Id='.$CustomerUserRel['Customer']);       
     241          $DbRow = $DbResult->fetch_array();
     242          foreach($UserOptions->Definition['Items'] as $Index => $Item)
     243          {
     244            $UserOptions->Values[$Index] = $DbRow[$Index];
     245          }
     246          $UserOptions->OnSubmit = '?Action=MemberOptionsSave';
     247          $Output .= $UserOptions->ShowEditForm();
     248        } else $Output .= $this->SystemMessage('Chyba', 'Nejste zákazníkem');
    241249      } else
    242250      if($_GET['Action'] == 'MemberOptionsSave')
Note: See TracChangeset for help on using the changeset viewer.