Jump to content

Nuclear

Members
  • Posts

    48
  • Joined

  • Last visited

Posts posted by Nuclear

  1. The lesson here, don't edit in cpanel :P

    I think that's probably good advice. I've had problems in the past with the editor in cPanel losing or otherwise maiming text. The best practice is to download the file to your local computer, edit it (preferable with something like Notepad++), and re-upload to the server.

  2. Something like this should work (note: untested):

    <?php 
    $bids=getBids(Auth::PilotID());
    if($bids)
    {
      foreach($bids as $bid)
      {
         echo $bid->code.$bid->flightnum.' - '.$bid->depicao.' - '.$bid->arricao.'<br />';
      }
    }
    else
    {
      echo 'You have not bid on any flights.';
    }?>
    

    • Like 1
  3. The SQL is in the getAllAirlines() function in OperationsData.class:

    if($all_airlines === false)
    {
    $sql = 'SELECT * FROM ' . TABLE_PREFIX ."airlines 
            $where}
            ORDER BY `code` ASC";
    
    $all_airlines= DB::get_results($sql);
    CodonCache::write($key, $all_airlines, 'long');
    }
    

    You could change the ORDER BY clause, but I don't know if that might break something somewhere else.

  4. In any language I've ever used, manipulating dates, times, datetimes...always is a big pain :)

    I'm no expert in PHP, but unless DATE_FORMAT is some PHP constant (which it could be, for all I know) then you need to actually enter the format that you want as a string. The PHP reference for the date function is here.

    An example:

    <li><strong>Date Joined: </strong><?php echo date('F j', strtotime($pilotinfo->joindate));?></li>
    

    will display the date as 'Month Day' like 'April 19'.

  5. Just as an additional note: I would suggest not using Notepad or Wordpad to edit PHP files. Over the years, I've found that they can do some strange things, like adding extra formatting characters which are not readily visible. I suggest using something specifically made for editing source code. I personally use Notepad++. Not only does it not jack up the formatting, it includes such things as syntax highlighting and auto-indent, which makes editing and writing code much easier .

  6. $queryP="SELECT SUM(`load`) as totalpax FROM `phpvms_pireps` WHERE `flighttype`='P'";
    $resultP=DB::get_results($queryP);
    
    $queryH="SELECT SUM(`load`) as totalpax FROM `phpvms_pireps` WHERE `flighttype`='H'";
    $resultH=DB::get_results($queryH);
    
    $total=$resultH[0]->totalpax + $resultP[0]->totalpax;
    
    echo $total

    I don't remember what you were doing with this, but if you're not using the results for anything but just to get the totals, you can eliminate one of the queries:

    $query="SELECT SUM(`load`) as totalpax FROM `phpvms_pireps` WHERE `flighttype`='P' OR `flighttype`='H'";
    $result=DB::get_results($query);
    $total=$result[0]->totalpax;
    

  7. Yes, you could use a series of if statements:

    <?php echo 'Flight Type: ';
    if($route->flighttype=='P')
      echo 'Passenger<br />';
    elseif($route-flighttype=='C')
      echo 'Cargo<br />';
    ...?>
    

    You can also use a switch statement:

    <?php echo 'Flight Type: ';
    switch($route->flighttype)
    {
      case 'C':
         echo 'Cargo<br />';
         break;
      case 'P':
         echo 'Passenger<br />';
         break;
      ...
    }?>
    

    • Like 1
  8. Well, I tried that and it echoed persons after the number which in my case stayed the same. I wonder if I should have deleted my cache and all that good stuff in the maint center to get the number to reflect accurately.

    Can you post the exact code you're using? The cache shouldn't make a difference; the code I posted is a direct SQL query, which is not cached, unlike the API calls, which do utilize caching. My way is not necessarily better, in fact it's worse in several ways, but it is one way to get the results.

  9. Dresdenair and twincessna, sorry about that. I apparently uploaded the wrong version of timetable.tpl in the original zip file. I've updated the download in the original post. The only changes are to timetable.tpl. Let me know if this works now, thanks.

  10. Nabeel, is of course right, but I do have a question:

    Don't use raw SQL, use the API for these queries:

    I understand the API exists to deal with most everything. but what's the problem with using raw SQL? Beside the fact that it's raw SQL? I do get it, but I find it much easier to use raw SQL (assuming that there isn't an API call for it...)

  11. Here's something I created for my VA and I thought it might be useful for others. It displays your flight schedule as a timetable.

    Installation:

    1. Copy the Timetable folder to /core/modules
    2. Copy timetable.tpl to your skins folder
    3. Create a link: <a href="<?php echo url('/timetable'); ?>">Timetable</a>

    Note that much of the table style is hard-coded, so if you don't like the way it looks, you're SOL (just kidding, you just need to edit the timetable.tpl to your liking).

    post-790-087175100 1301796233_thumb.jpg

    timetable 1.1.zip

    • Like 1
  12. I'm running into the same problem. What do I need to do in order to not show the duplicates. I have removed some of the original code and still get errors. This is the code I have now with yours that works but shows the duplicates.

    <?php

    foreach($pilots as $pilot)

    {

    if($pilot->confirmed != 1)

    continue;

    ?>

    <p><a href="<?php echo url('/profile/view/'.$pilot->pilotid);?>"><?php echo

    PilotData::GetPilotCode($pilot->code, $pilot->pilotid). ' ' .$pilot->firstname . ' ' .

    $pilot->lastname?></a></p>

    <?php

    }

    ?>

    <?php

    $query='SELECT * FROM phpvms_pilots ORDER BY joindate DESC LIMIT 5';

    $pilots=DB::get_results($query);

    foreach($pilots as $pilot)

    {

    echo '<a href='.SITE_URL.'/index.php/profile/view/'.$pilot->pilotid.'>';

    echo PilotData::getPilotCode($pilot->code,$pilot->pilotid).' '.$pilot-

    >firstname.' '.$pilot->lastname.'</a><br><br>';

    }?>

    You should remove this part:

    <?php
    
    foreach($pilots as $pilot)
    {
    if($pilot->confirmed != 1)
    continue;
    ?>
    
    <p><a href="<?php echo url('/profile/view/'.$pilot->pilotid);?>"><?php echo
    
    PilotData::GetPilotCode($pilot->code, $pilot->pilotid). ' ' .$pilot->firstname . ' ' .
    
    $pilot->lastname?></a></p>
    <?php
    }
    ?>
    

    If you only want to show pilots who have been confirmed, change this:

    $query='SELECT * FROM phpvms_pilots ORDER BY joindate DESC LIMIT 5';
    

    To this:

    $query='SELECT * FROM phpvms_pilots WHERE confirmed=1 ORDER BY joindate DESC LIMIT 5';
    

    I should have also noted - if you don't want to show the newest 5 pilots, you can change 'LIMIT 5' to however many pilots you want to display.

  13. I don't think you're going to have much luck with this unless you can use the javascript variables already given in the comments (which wouldn't really allow you to do what you want).

    The way the ACARS map is done is unfortunately really... odd.

    Yeah, I agree. I don't know if it's "odd", but it certainly isn't as straightforward as the other templates. The only way would be to edit the JS to expose the new variable.

  14. Well, there is a way to do it using SQL:

    $query="SELECT SUM(`load`) as totalpax FROM `phpvms_pireps` WHERE `flighttype`='P'";
    $result=DB::get_results($query);
    echo $result[0]->totalpax;
    

    This sums up the load for passenger flights only. This assumes that you have your cargo routes set as cargo flights.

  15. Hey Michael,

    Just to clear up, I don't think you need the 's in in the VA code.

    It should be done like that..

    <?php echo StatsData::TotalPaxCarried(MER); ?>

    and it will return the data in order of an VA.

    I just tested it again and it works either with or without the quotes. I also tested StatsData::TotalPaxCarried() without passing any arguments and it still returned the same value (2945), so I'm not sure what's wrong with the OP.

×
×
  • Create New...