Ignore:
Timestamp:
Jan 15, 2016, 10:54:40 PM (9 years ago)
Author:
chronos
Message:
  • Modified: Allow to view and edit multiple customerers per user.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Portal/Portal.php

    r786 r788  
    2828    $this->System->RegisterPage('', 'PagePortal');
    2929    $this->System->FormManager->RegisterClass('MemberOptions', array(
    30       'Title' => 'Nastavení domácnosti',
     30      'Title' => 'Nastavení zákazníka',
    3131      'SQL' => '(SELECT Member.Id, Member.FamilyMemberCount, Subject.Name, Subject.AddressStreet, Subject.AddressTown, Subject.AddressPSC, Subject.IC, Subject.DIC FROM Member JOIN Subject ON Subject.Id = Member.Subject)',
    3232      'Table' => 'MemberOptions',
     
    3939        'IC' => array('Type' => 'String', 'Caption' => 'IČ', 'Default' => ''),
    4040        'DIC' => array('Type' => 'String', 'Caption' => 'DIČ', 'Default' => ''),
    41         'FamilyMemberCount' => array('Type' => 'Integer', 'Caption' => 'Počet osob v domácnosti', 'Default' => '', 'Suffix' => 'osob'),
     41        'FamilyMemberCount' => array('Type' => 'Integer', 'Caption' => 'Počet bydlících osob', 'Default' => '', 'Suffix' => 'osob'),
    4242      ),
    4343    ));
     
    116116    $Output = '<a href="'.$this->System->Link('/user/?Action=UserOptions').'">Profil</a><br />';
    117117    if($this->System->User->CheckPermission('Finance', 'MemberOptions'))
    118       $Output .= '<a href="'.$this->System->Link('/?Action=MemberOptions').'">Domácnost</a><br />';
     118      $Output .= '<a href="'.$this->System->Link('/?Action=MemberOptions').'">Fakturační adresa</a><br />';
    119119    if($this->System->User->CheckPermission('Finance', 'DisplaySubjectState'))
    120120      $Output .= '<a href="'.$this->System->Link('/finance/platby/').'">Finance</a><br />';
     
    147147  {
    148148    $Output = '<span style="font-size: smaller;">';
    149     $DbResult = $this->Database->query('SELECT NetworkDevice.Name FROM NetworkDevice LEFT JOIN NetworkDeviceType ON NetworkDeviceType.Id = NetworkDevice.Type WHERE (NetworkDeviceType.ShowOnline = 1) AND (NetworkDevice.Online = 1) ORDER BY NetworkDevice.Name');
     149    $DbResult = $this->Database->query('SELECT `NetworkDevice`.`Name` FROM `NetworkDevice` '.
     150      'LEFT JOIN `NetworkDeviceType` ON `NetworkDeviceType`.`Id` = `NetworkDevice`.`Type` '.
     151      'WHERE (`NetworkDeviceType`.`ShowOnline` = 1) AND (`NetworkDevice`.`Online` = 1) ORDER BY `NetworkDevice`.`Name`');
    150152    while($Device = $DbResult->fetch_array())
    151153    {
     
    188190      if($Action == 'MemberOptions')
    189191      {
    190         $Form = new Form($this->System->FormManager);
    191         $Form->SetClass('MemberOptions');
    192         $DbResult = $this->Database->query('SELECT Customer FROM UserCustomerRel WHERE User='.$this->System->User->User['Id']);
    193         if($DbResult->num_rows > 0)
     192        $DbResult = $this->Database->query('SELECT `Customer` FROM `UserCustomerRel` '.
     193          'WHERE `User`='.$this->System->User->User['Id']);
     194        while($CustomerUserRel = $DbResult->fetch_assoc())
    194195        {
    195           $CustomerUserRel = $DbResult->fetch_assoc();
    196           $DbResult = $this->Database->query('SELECT Member.Id, '.
    197             'Member.FamilyMemberCount, Subject.Name, Subject.AddressStreet, '.
    198             'Subject.AddressTown, Subject.AddressPSC, Subject.AddressCountry, Subject.IC, Subject.DIC FROM Member JOIN Subject '.
    199            'ON Subject.Id = Member.Subject WHERE Member.Id='.$CustomerUserRel['Customer']);
    200           $DbRow = $DbResult->fetch_array();
     196          $DbResult2 = $this->Database->query('SELECT `Member`.`Id`, '.
     197            '`Member`.`FamilyMemberCount`, `Subject`.`Name`, `Subject`.`AddressStreet`, '.
     198            '`Subject`.`AddressTown`, `Subject`.`AddressPSC`, `Subject`.`AddressCountry`, '.
     199            '`Subject`.`IC`, `Subject`.`DIC` FROM `Member` JOIN `Subject` '.
     200           'ON `Subject`.`Id` = `Member`.`Subject` WHERE `Member`.`Id`='.$CustomerUserRel['Customer']);
     201          $Form = new Form($this->System->FormManager);
     202          $Form->SetClass('MemberOptions');
     203          $DbRow = $DbResult2->fetch_array();
    201204          foreach($Form->Definition['Items'] as $Index => $Item)
    202205          {
    203206            $Form->Values[$Index] = $DbRow[$Index];
    204207          }
    205           $Form->OnSubmit = '?Action=MemberOptionsSave';
     208          $Form->OnSubmit = '?Action=MemberOptionsSave&amp;Id='.$CustomerUserRel['Customer'];
    206209          $Output .= $Form->ShowEditForm();
    207         } else $Output .= $this->SystemMessage('Chyba', 'Nejste zákazníkem');
     210        }
    208211      } else
    209212      if($Action == 'MemberOptionsSave')
     
    224227          'AddressPSC' => $Form->Values['AddressPSC'], 'IC' => $Form->Values['IC'],
    225228          'DIC' => $Form->Values['DIC']));
    226         $Output .= $this->SystemMessage('Nastavení', 'Nastavení domácnosti uloženo.');
    227         $this->System->ModuleManager->Modules['Log']->NewRecord('Member+Subject', 'Nastavení člena/subjektu změněno',
     229        $Output .= $this->SystemMessage('Nastavení', 'Nastavení zákazníka uloženo.');
     230        $this->System->ModuleManager->Modules['Log']->NewRecord('Member+Subject', 'Nastavení zákazníka/subjektu změněno',
    228231          $Form->Values['Name']);
    229232        $DbResult = $this->Database->query('SELECT Member.Id, Member.FamilyMemberCount, '.
Note: See TracChangeset for help on using the changeset viewer.