Changeset 38


Ignore:
Timestamp:
Sep 10, 2020, 10:45:41 PM (4 years ago)
Author:
chronos
Message:
  • Fixed: Changed runner teams was updated with incorrect team id.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/index.php

    r37 r38  
    203203                'IsFamily' => 0,
    204204              ));
    205               $Teams[$Item['TeamId']] = array('Id' => $TeamId, 'Distance' => -1, 'Team' => $Item['TeamId']);
     205              $Teams[$Item['TeamId']] = array('Id' => $TeamId, 'Distance' => -1);
    206206              $NextTeamId++;
    207207            } else
     
    222222            'Year' => $Year,
    223223          ));
    224           $Runners[$Item['ChipNumber']] = array('Id' => $RunnerId, 'Distance' => -1);
     224          $Runners[$Item['ChipNumber']] = array('Id' => $RunnerId, 'Distance' => -1, 'Team' => $TeamId);
    225225          $NextRunnerId++;
    226226        } else {
     
    228228
    229229          // Update runner team if it was changed
    230           if ($Item['TeamId'] != $Runners[$Item['ChipNumber']]['Team'] and array_key_exists($Item['TeamId'], $Teams))
     230          $OldRunnerTeamId = $Runners[$Item['ChipNumber']]['Team'];
     231          if ($Item['TeamId'] == null)
    231232          {
    232             $Runners[$Item['ChipNumber']]['Team'] = $Item['TeamId'];
    233             $Queries[] = $this->Database->GetUpdate('Runner', 'Id='.$RunnerId, array('Team' => $Item['TeamId']));
     233            $NewRunnerTeamId = null;
     234          } else
     235          {
     236            $NewRunnerTeamId = $Teams[$Item['TeamId']]['Id'];
     237          }
     238          if ($OldRunnerTeamId != $NewRunnerTeamId)
     239          {
     240            $Runners[$Item['ChipNumber']]['Team'] = $NewRunnerTeamId;
     241            $Queries[] = $this->Database->GetUpdate('Runner', 'Id='.$RunnerId, array('Team' => $NewRunnerTeamId));
    234242          }
    235243        }
Note: See TracChangeset for help on using the changeset viewer.