Ignore:
Timestamp:
Apr 14, 2020, 11:13:32 PM (5 years ago)
Author:
chronos
Message:
  • Modified: Improved code formatting.
File:
1 edited

Legend:

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

    r6 r7  
    140140      'Vsetín', 'Nový Jičín', 'Prostějov', 'Vyškov', 'Mohelnice', 'Ústí nad Orlicí');
    141141
    142     for($I = 0; $I < 100; $I++)
     142    for ($I = 0; $I < 100; $I++)
    143143    {
    144144      $Stops = array_fill(0, random(5), '');
    145       for($J = 0; $J < count($Stops); $J++)
     145      for ($J = 0; $J < count($Stops); $J++)
    146146        $Stops[$J] = $Cities[random(count($Cities))];
    147147
     
    158158      '<a href="'.$this->System->Link('/jizdy/').'">Hledat jízdu</a> nebo '.
    159159      '<a href="'.$this->System->Link('/nova-jizda/').'">Nabídnout jízdu</a>';
    160     return($Output);
     160    return $Output;
    161161  }
    162162
     
    173173        'LEFT JOIN RideStop AS PassengerRideStopTo ON PassengerRideStopTo.Id=Passenger.RideStopTo '.
    174174        'WHERE Passenger.Ride='.$RideId);
    175     while($DbRow = $DbResult->fetch_assoc())
    176     {
    177       for($I = $DbRow['SequenceFrom'] + 1; $I <= $DbRow['SequenceTo']; $I++)
     175    while ($DbRow = $DbResult->fetch_assoc())
     176    {
     177      for ($I = $DbRow['SequenceFrom'] + 1; $I <= $DbRow['SequenceTo']; $I++)
    178178      {
    179179        $Stops[$I] = $Stops[$I] + $DbRow['SeatCount'];
    180180      }
    181181    }
    182     foreach($Stops as $Index => $Stop)
     182    foreach ($Stops as $Index => $Stop)
    183183    {
    184184      $this->System->Database->update('RideStop', 'Ride='.$RideId.' AND Sequence='.$Index, array('PassengerCount' => $Stop));
     
    206206    $Stops = array();
    207207    $DbResult2 = $this->Database->query('SELECT * FROM RideStop WHERE Ride='.$DbRow['Id'].' ORDER BY Sequence');
    208     while($DbRow2 = $DbResult2->fetch_assoc())
     208    while ($DbRow2 = $DbResult2->fetch_assoc())
    209209    {
    210210      $Track[] = $DbRow2;
     
    239239      'LEFT JOIN User ON User.Id=Passenger.User '.
    240240      'WHERE Passenger.Ride='.$RideId);
    241     while($Passenger = $DbResult->fetch_assoc())
     241    while ($Passenger = $DbResult->fetch_assoc())
    242242    {
    243243      $Passengers[] = $Passenger;
     
    245245      do {
    246246        $Check = true;
    247         for($I = $Passenger['SequenceFrom']; $I < $Passenger['SequenceTo']; $I++)
     247        for ($I = $Passenger['SequenceFrom']; $I < $Passenger['SequenceTo']; $I++)
    248248        {
    249           if($Table[$I][$Seat] != 0) $Check = false;
     249          if ($Table[$I][$Seat] != 0) $Check = false;
    250250        }
    251251        if (!$Check) $Seat++;
    252       } while(!$Check);
    253       for($I = $Passenger['SequenceFrom']; $I < $Passenger['SequenceTo']; $I++)
     252      } while (!$Check);
     253      for ($I = $Passenger['SequenceFrom']; $I < $Passenger['SequenceTo']; $I++)
    254254        $Table[$I][$Seat] = count($Passengers) - 1;
    255255    }
     
    259259      $Output .= '<th style="width: 80px">Cestující</th>';
    260260    $Output .= '</tr>';
    261     foreach($Track as $Index => $TrackItem)
     261    foreach ($Track as $Index => $TrackItem)
    262262    {
    263263      $Output .= '<tr><td style="height: 100px">'.$TrackItem['Place'].'<br/>'.$TrackItem['Time'].'</td>';
    264       if($Index == 0) $Output .= '<td rowspan="'.count($Track).'">Řidič</td>';
     264      if ($Index == 0) $Output .= '<td rowspan="'.count($Track).'">Řidič</td>';
    265265      for ($I = 0; $I < $DbRow['SeatCount']; $I++)
    266266      {
     
    271271        } else {
    272272          // Show unused space
    273           if(($Index == 0) or ((($Index - 1) >= 0) and (!is_null($Table[$Index - 1][$I]))))
     273          if (($Index == 0) or ((($Index - 1) >= 0) and (!is_null($Table[$Index - 1][$I]))))
    274274          {
    275275            $J = 1;
    276             while((($Index + $J) < count($Table)) and is_null($Table[$Index + $J][$I])) $J++;
     276            while ((($Index + $J) < count($Table)) and is_null($Table[$Index + $J][$I])) $J++;
    277277            $Output .= '<td rowspan="'.$J.'">&nbsp;</td>';
    278278          }
     
    284284
    285285
    286     return($Output);
     286    return $Output;
    287287  }
    288288
     
    303303      }
    304304    }
    305     return($Output);
     305    return $Output;
    306306  }
    307307}
     
    311311  function Show()
    312312  {
    313     if(array_key_exists('from', $_GET)) $PlaceFrom = $_GET['from'];
     313    if (array_key_exists('from', $_GET)) $PlaceFrom = $_GET['from'];
    314314      else $PlaceFrom = '';
    315     if(array_key_exists('to', $_GET)) $PlaceTo = $_GET['to'];
     315    if (array_key_exists('to', $_GET)) $PlaceTo = $_GET['to'];
    316316      else $PlaceTo = '';
    317     if(array_key_exists('time', $_GET)) $Time = $_GET['time'];
     317    if (array_key_exists('time', $_GET)) $Time = $_GET['time'];
    318318      else $Time = '';
    319319    $Output = '<table style="width: 100%; margin-top: 100px; margin-bottom: 100px;"><tr><td style="text-align: center">'.
     
    325325      '<input type="submit" value="Hledat"/>'.
    326326      '</form></div></td></tr></table>';
    327     return($Output);
     327    return $Output;
    328328  }
    329329}
     
    333333  function Show()
    334334  {
    335     if(array_key_exists('from', $_GET)) $PlaceFrom = $_GET['from'];
     335    if (array_key_exists('from', $_GET)) $PlaceFrom = $_GET['from'];
    336336      else $PlaceFrom = '';
    337     if(array_key_exists('to', $_GET)) $PlaceTo = $_GET['to'];
     337    if (array_key_exists('to', $_GET)) $PlaceTo = $_GET['to'];
    338338      else $PlaceTo = '';
    339     if(array_key_exists('time', $_GET)) $Time = $_GET['time'];
     339    if (array_key_exists('time', $_GET)) $Time = $_GET['time'];
    340340      else $Time = '';
    341341    $Output = '<table style="width: 100%"><tr><td style="text-align: center;">'.
     
    349349      $Output .= $this->ShowRides($_GET['from'], $_GET['to']);
    350350    } else $Output .= $this->ShowRides('', '');
    351     return($Output);
     351    return $Output;
    352352  }
    353353
     
    358358    $Query = 'SELECT Ride.Id, Ride.SeatCount, User.Name AS DriverName, User.BirthDate, '.
    359359      'CONCAT(CarManufacturer.Name, " ", CarModel.Name) AS CarName ';
    360     if((trim($PlaceFrom) != '') and (trim($PlaceTo != '')))
     360    if ((trim($PlaceFrom) != '') and (trim($PlaceTo != '')))
    361361      $Query .= ', (SELECT COALESCE(MAX(RideStop.PassengerCount), 0) FROM RideStop '.
    362362      'WHERE (RideStop.Ride=Ride.Id) AND (RideStop.Sequence > RideStopFrom.Sequence) AND '.
     
    371371      'LEFT JOIN CarManufacturer ON CarManufacturer.Id = CarModel.Manufacturer '.
    372372      'LEFT JOIN User ON User.Id=Ride.Driver ';
    373     if((trim($PlaceFrom) != '') and (trim($PlaceTo != '')))
     373    if ((trim($PlaceFrom) != '') and (trim($PlaceTo != '')))
    374374      $Query .= 'JOIN RideStop AS RideStopFrom ON (RideStopFrom.Ride = Ride.Id) AND (RideStopFrom.Place LIKE "%'.$PlaceFrom.'%") '.
    375375        'JOIN RideStop AS RideStopTo ON (RideStopTo.Ride = Ride.Id) AND (RideStopTo.Place LIKE "%'.$PlaceTo.'%") '.
     
    377377    $Query .= 'LIMIT 10';
    378378    $DbResult = $this->Database->query($Query);
    379     while($DbRow = $DbResult->fetch_assoc())
     379    while ($DbRow = $DbResult->fetch_assoc())
    380380    {
    381381      $Stops = array();
    382382      $Price = 0;
    383383      $DbResult2 = $this->Database->query('SELECT * FROM RideStop WHERE Ride='.$DbRow['Id'].' ORDER BY Sequence');
    384       while($DbRow2 = $DbResult2->fetch_assoc())
     384      while ($DbRow2 = $DbResult2->fetch_assoc())
    385385      {
    386386        $Stops[] = $DbRow2['Place'];
     
    400400    $Output .= '</table>';
    401401
    402     return($Output);
     402    return $Output;
    403403  }
    404404}
     
    416416
    417417  $ret = array();
    418   foreach($bit as $k => $v)
    419     if($v > 0)$ret[] = $v . $k;
     418  foreach ($bit as $k => $v)
     419    if ($v > 0)$ret[] = $v . $k;
    420420
    421421  return join(' ', $ret);
     
    483483          'LEFT JOIN CarManufacturer ON CarManufacturer.Id = CarModel.Manufacturer '.
    484484          'WHERE Car.Owner='.$this->System->User->User['Id']);
    485         while($DbRow = $DbResult->fetch_assoc())
     485        while ($DbRow = $DbResult->fetch_assoc())
    486486        {
    487487          $Output .= '<option value="'.$DbRow['Id'].'"/>'.$DbRow['ModelName'].'</option>';
     
    500500        $PricePerKm = 0.8;
    501501        $Output .= '<table class="WideTable"><tr><th>Úsek</th><th>Odjezd</th><th>Trvání</th><th>Vzdálenost [km]</th><th>Cena [Kč]</th></tr>';
    502         foreach($Track as $Index => $TrackItem)
     502        foreach ($Track as $Index => $TrackItem)
    503503        {
    504           if($Index > 0)
     504          if ($Index > 0)
    505505          {
    506506            $Track[$Index]['Time'] = $TimeFrom + $Track[$Index - 1]['Duration'];
     
    542542        ));
    543543        $RideId = $this->Database->insert_id;
    544         foreach($_SESSION['Track'] as $Index => $TrackItem)
     544        foreach ($_SESSION['Track'] as $Index => $TrackItem)
    545545        {
    546546          $this->Database->insert('RideStop', array(
     
    556556      }
    557557    }
    558     return($Output);
    559   }
    560 }
    561 
     558    return $Output;
     559  }
     560}
     561
Note: See TracChangeset for help on using the changeset viewer.