Jump to content

nexissair

Members
  • Posts

    35
  • Joined

  • Last visited

Posts posted by nexissair

  1. Afternoon everyone

    I'm currently building a module for my site which I plan to share on here for everyone to use if they want, it allows you to add extra information to an aircraft that can then be shown on a nice shiney fleet page, I am a bit stuck though, whilst I can pull the aircraft, add extra information to them and display it all on the fleet page with no problems, I just cannot for the life of me get it to update existing added extra data, I've been staring at this for four days without success, the query works when run direct in SQL command line, I've tried absolutley everything but clearly I've missed something that I can't spot, Please please please can some one look over what I've done and let me know what I've missed because I can't find my error and its driving me nuts now, I so close to having this done but its vital that people have the ability to update what they've added. The code is below.

    Core Class:

    <?php
    /**
    * Karl Sawdy
    */
    
    class FleetInfoData extends CodonData
    {
    //Public Functions - Fleet Page
    
    //Get enabled ICAO's
    
    public static function getAllicao()
    {
    $sql = 'SELECT DISTINCT icao, fullname FROM '.TABLE_PREFIX.'aircraft
    WHERE enabled=1 ORDER BY `icao` ASC';
    
    return DB::get_results($sql);
    }
    
    
    // Get all of the enabledd aircraft
    
    public static function getAllAircraft()
    {
    $sql = "SELECT a.* FROM ".TABLE_PREFIX."aircraft a
    WHERE enabled=1 ORDER BY a.registration";
    
    return DB::get_results($sql);
    }
    //End Public Functions - Fleet Page
    
    
    
    
    //Admin Functions
    
    //Get All Aircraft Added
    public static function getEveryAircraft()
    {
    $sql = "SELECT a.* FROM ".TABLE_PREFIX."aircraft a
    ORDER BY a.registration";
    
    return DB::get_results($sql);
    }
    
    //Get Aircraft with Added Details for Main Page
    public function getAcDetails()
    {
     $query = "SELECT a.*, e.* FROM phpvms_aircraft_details as e
    LEFT JOIN ".TABLE_PREFIX."aircraft AS a ON a.id = e.aircraftid
    ORDER BY a.icao ASC";
     return DB::get_results($query);
    }
    
    
    //Get a Specific Aircraft to Add Details to
    public static function getAircraftInfo($id)
    {
    $id = DB::escape($id);
    
    return DB::get_row('SELECT * FROM '.TABLE_PREFIX.'aircraft
     WHERE `id`='.$id);
    }
    
    //Add New Details to Existing Aircraft
    public function save_new_details($aircraftid, $detregistration, $wingspan, $length, $height, $cruisemach, $ceiling, $engines, $base, $department, $status, $comments) {
     $query = "INSERT INTO phpvms_aircraft_details (aircraftid, detregistration, wingspan, length, height, cruisemach, ceiling, engines, base, department, status, comments )
    				 VALUES('$aircraftid', '$detregistration', '$wingspan', '$length', '$height', '$cruisemach', '$ceiling', '$engines', '$base', '$department', '$status', '$comments')";
     DB::query($query);
    }
    // End Adding Details to Existing Aircraft
    
    //Get a Specific Aircraft with Existing Details to Edit
    public static function getAircraftEdit($id)
    {
    $id = DB::escape($id);
    
    return DB::get_row('SELECT a.*,e.* FROM phpvms_aircraft_details AS e
    LEFT JOIN phpvms_aircraft AS a ON a.id = e.aircraftid
     WHERE `aircraftid`='.$id);
    
    }
    
    //Edit Existing Details on Existing Aircraft
    public function update_details($wingspan, $length, $height, $cruisemach, $ceiling, $engines, $base, $department, $status, $comments, $detid) {
     $query = "UPDATE phpvms_aircraft_details SET
    wingspan='$wingspan'
    length='$length'
    height='$height'
    cruisemach='$cruisemach'
    ceiling='$ceiling'
    engines='$engines'
    base='$base'
    department='$department'
    status='$status'
    comments='$comments'
    WHERE detid='$detid'";
     DB::query($query);
    }
    }
    

    Admin Module:

    <?php
    
    class FleetInfo extends CodonModule {
    
    public function HTMLHead()
    {
     $this->set('sidebar', 'fleetinfo/fleetinfo_sidebar.tpl');
    }
    public function NavBar()
    {
     echo '<li><a href="'.SITE_URL.'/admin/index.php/FleetInfo">Additional Aircraft Info</a></li>';
    }
    public function index() {
    
    $this->set('info', FleetInfoData::getAcDetails());
    	 $this->show('fleetinfo/fleetinfo_index.tpl');
    }
    
    //Edit Existing Aircraft - Pages
    
    //See All Existing Aircraft
    public function SeeAllAddedAircraft()
    {
    $this->set('allaircraft', FleetInfoData::getEveryAircraft());
    $this->render('fleetinfo/all_aircraftlist.tpl');
    }
    
    //Select The Existing Aircraft to Add Details to and show Add Details Page
    public function SelectAircraft()
    {
    $id = $this->get->id;
    $this->set('action', 'adddetails');
    $this->set('allranks', RanksData::getAllRanks());
    $this->set('aircraft', OperationsData::GetAircraftInfo($id));
    
    $this->render('fleetinfo/fleetinfo_adddetails.tpl');
    }
    
    //Add Details 'action'
    public function adddetails()
    {
     $details = array();
     $details['aircraftid'] = DB::escape($this->post->aircraftid);
     $details['detregistration'] = DB::escape($this->post->detregistration);
     $details['wingspan'] = DB::escape($this->post->wingspan);
     $details['length'] = DB::escape($this->post->length);
     $details['height'] = DB::escape($this->post->height);
     $details['cruisemach'] = DB::escape($this->post->cruisemach);
     $details['ceiling'] = DB::escape($this->post->ceiling);
     $details['engines'] = DB::escape($this->post->engines);
     $details['base'] = DB::escape($this->post->base);
     $details['department'] = DB::escape($this->post->department);
     $details['status'] = DB::escape($this->post->status);
     $details['comments'] = DB::escape($this->post->comments);
    $details['fullname'] = DB::escape($this->post->fullname);
    
     FleetInfoData::save_new_details($details['aircraftid'],
    							 $details['detregistration'],
    							 $details['wingspan'],
    							 $details['length'],
    							 $details['height'],
    							 $details['cruisemach'],
    							 $details['ceiling'],
    							 $details['engines'],
    							 $details['base'],
    							 $details['department'],
    	 $details['status'],
    							 $details['comments']);
    //Go to Admin Index page After Saving
    $this->set('info', FleetInfoData::getAcDetails());
     $this->show('fleetinfo/fleetinfo_index.tpl');
    
    //Add Successful Save info to user log
    LogData::addLog(Auth::$userinfo->pilotid, 'Added Details To Aircraft "'.$this->post->fullname.' Registration '.$this->post->registration.'"');
    }
    //END Adding Details to Existing Aircraft
    
    
    
    
    
    
    //Select The Existing Aircraft to Edit Details of and show Edit Details Page
    public function EditAircaftDetails($id)
    {
    $this->set('action', 'save_edit_details');
    
    $this->set('details',FleetInfoData::GetAircraftEdit($id));
    $this->set('allranks', RanksData::getAllRanks());
    
    $this->render('fleetinfo/fleetinfo_editdetail.tpl');
    }
    
    //Save Edited Details 'action'
    public function save_edit_details()
    {
     $ac = array();
     $ac['wingspan'] = DB::escape($this->post->wingspan);
     $ac['length'] = DB::escape($this->post->length);
     $ac['height'] = DB::escape($this->post->height);
     $ac['cruisemach'] = DB::escape($this->post->cruisemach);
     $ac['ceiling'] = DB::escape($this->post->ceiling);
     $ac['engines'] = DB::escape($this->post->engines);
     $ac['base'] = DB::escape($this->post->base);
     $ac['department'] = DB::escape($this->post->department);
     $ac['status'] = DB::escape($this->post->status);
     $ac['comments'] = DB::escape($this->post->comments);
    $ac['detregistration'] = DB::escape($this->post->detregistration);
    $ac['detid'] = DB::escape($this->post->detid);
    $ac['fullname'] = DB::escape($this->post->fullname);
    
     FleetInfoData::update_details($ac['wingspan'],
    								 $ac['length'],
    								 $ac['height'],
    								 $ac['cruisemach'],
    								 $ac['ceiling'],
    								 $ac['engines'],
    								 $ac['base'],
    								 $ac['department'],
    	 $ac['status'],
    								 $ac['comments'],
    	 $ac['detregistration'],
    	 $ac['detid']);
    
    //Show Successful Update Message to User and index page
    $this->set('message', 'The Aircraft "'.$this->post->fullname.' '.$this->post->detregistration.'" has been successfully Updated');
    $this->render('core_success.tpl');
    $this->set('info', FleetInfoData::getAcDetails());
     $this->show('fleetinfo/fleetinfo_index.tpl');
    
    //Add Successful Update info to user log
    LogData::addLog(Auth::$userinfo->pilotid, 'Edited Aircraft "'.$this->post->fullname.' '.$this->post->detregistration.'"');
    }
    }
    

    Edit Details TPL

    <h4>Existing Aircraft Details</h4>
    <hr>
    
    <form action="<?php echo adminurl('/FleetInfo/'.$action.'');?>" method="post">
    <table width="100%" border="0" cellspacing="5" cellpadding="5">
    <tr>
    <td width="15%">Database ID Number</td>
    <td><?php echo $details->id; ?></td>
    </tr>
    <tr>
    <td width="15%">Aircraft ICAO</td>
    <td><?php echo $details->icao; ?></td>
    </tr>
    <tr>
    <td>Aircraft Name / Type</td>
    <td><?php echo $details->name; ?></td>
    </tr>
    <tr>
    <td>Full Name</td>
    <td><?php echo $details->fullname; ?></td>
    </tr>
    <tr>
    <td>Aircraft Registration</td>
    <td><?php echo $details->registration; ?></td>
    </tr>
    <tr>
    <td>Max Pax</td>
    <td><?php echo $details->maxpax; ?> PAX</td>
    </tr>
    <tr>
    <td>Max Cargo</td>
    <td><?php echo $details->maxcargo; ?> lbs</td>
    </tr>
    <tr>
    <td>Range</td>
    <td><?php echo $details->range; ?> nM</td>
    </tr>
    <tr>
    <td>weight</td>
    <td><?php echo $details->weight; ?> lbs</td>
    </tr>
    <tr>
    <td>Cruise Speed Kts</td>
    <td><?php echo $details->cruise; ?> kts</td>
    </tr>
    <tr>
    <td>Minimum Rank to Fly This Aircraft</td>
    <td><?php
    foreach($allranks as $rank)
    
    if($details->minrank == $rank->rankid)
    
    echo $rank->rank;
    
    
    ?></td>
    </tr>
    <tr>	
     <?php
    if($details->enabled == 1)
    {
    echo '<td colspan="2" bgcolor="#00FF00" align="center"><strong>Aircraft Active - Can Be Flown Now</strong></td>';
    }
    else echo '<td colspan="2" bgcolor="#FF0000" align="center"><strong>Aircraft Not Active - Cannot Be Flown By Pilots</strong></td>'; ?>
    </tr>
    <tr>
     <td colspan="2">
     <hr>
     <h4>Update Additional Aircraft Details</h4>
     <hr>
     </td>
     </tr>
    <tr>
     <td>Wingspan</td>
     <td><input type="text" name="wingspan" value="<?php echo $details->wingspan;?>" /> ft</td>
    </tr>
    <tr>
     <td>Length</td>
     <td><input type="text" name="length" value="<?php echo $details->length;?>" /> ft</td>
    </tr>
    <tr>
     <td>Height</td>
     <td><input type="text" name="height" value="<?php echo $details->height;?>" /> ft</td>
    </tr>
    <tr>
     <td>Cruise Mach</td>
     <td><input type="text" name="cruisemach" value="<?php echo $details->cruisemach;?>" /> mach</td>
    </tr>
    <tr>
     <td>Ceiling</td>
     <td><input type="text" name="ceiling" value="<?php echo $details->ceiling;?>" /> ft</td>
    </tr>
    <tr>
     <td>Engines</td>
     <td><input type="text" name="engines" style="width: 40%;" value="<?php echo $details->engines;?>" /></td>
    </tr>
    <tr>
     <td>Base</td>
     <td><select name="base"><option value="<?php echo $details->base;?>"></option>
    	 <option value="To Be Confirmed">To Be Confirmed</option>
    				 <option value="EGSS">EGSS</option>
    				 <option value="PANC">PANC</option>
    				 <option value="KMIA">KMIA</option>
    			 </select> Currently Set To: <strong><?php echo $details->base;?></strong></td>
    </tr>
    <tr>
     <td>Department</td>
     <td><select name="department"><option value="<?php echo $details->department;?>"></option>
     <option value="To Be Confirmed">To Be Confirmed</option>
    				 <option value="Schedules">Schedules</option>
    				 <option value="Charters">Charters</option>
    				 <option value="Cargo">Cargo</option>
    				 <option value="Executive Charters">Executive Charters</option>
    				 <option value="Vintage">Vintage</option>
    				 <option value="Private">Private</option>
    			 </select> Currently Set To: <strong><?php echo $details->department;?></strong></td>
    </tr>
    <tr>
     <td>Status</td>
     <td><select name="status"><option value="<?php echo $details->status;?>"></option>
    	 <option value="Active">Active</option>
    				 <option value="On Order">On Order</option>
    				 <option value="In Storage">In Storage</option>
    				 <option value="Retired">Retired</option>
    				 <option value="External Contract">External Contract</option>
    				 <option value="Leased">Leased</option>
    				 <option value="Re-Fit">Re-Fit</option>
    				 <option value="Sold">Sold</option>
    				 <option value="Scrapped">Scrapped</option>
    			 </select> Currently Set To: <strong><?php echo $details->status;?></strong></td>
    </tr>
    <tr>
     <td>Notes</td>
     <td><textarea name="comments" style="width: 50%; height: 100px"><?php echo $details->comments;?></textarea></td>
    </tr>
    <tr>
    <td></td>
    <td>
    <input type="hidden" name="detid" value="<?php echo $details->detid;?>" />
    	 <input type="hidden" name="detregistration" value="<?php echo $details->registration;?>" />
    	 <input type="hidden" name="fullname" value="<?php echo $details->fullname;?>" />
    <input type="submit" name="submit" value="Edit Details" />
    </td>
    </tr>
    </table>
    </form>
    <?php print_r($details);?>
    

    Thankyou all for your help

    Karl

    • Like 1
  2. Afternoon All

    I currently have on my site a static fleet page gouped by aircraft type, however as part of my quest to learn MVC and php I thought I would have a go at making it dynamic so that when I add an aircraft the page auto updates saving me loads of work in the long run.

    So after an evening of browsing though phpvms files to see how it all ticks, and based on the public pilots list, grouped by hubs I made my class, module and tpl files. I had some success but not completely, the page gives me one group for each icao which is what I wanted, but it also gives me all the whole fleet repeated in each group! not just the aircraft specific to the group.

    If this was an access database I know the answer, php is not access so I'm stuffed, could some of you php wizards please look over what I've done and let me know where I've gone wrong please, All said and done this was only a learning excersise with a useful out come, so its not the end of the world, but if I don't know where or why I've gone wrong I can't learn from it, I did do a search but nothing came up specific to the way I'm trying to do this.

    My code is below:

    FleetData Class

    <?php
    /**
    * Karl Sawdy
    */
    
    class FleetData extends CodonData
    {
    
    //Get ICAO's
    public static function getAllicao()
    {
    $sql = 'SELECT DISTINCT icao, fullname FROM '.TABLE_PREFIX.'aircraft
    WHERE enabled=1 ORDER BY `icao` ASC';
    
    return DB::get_results($sql);
    }
    
    /**
    * Get all of the aircraft
    */
    public static function getAllAircraft()
    {
    $sql = "SELECT a.* FROM ".TABLE_PREFIX."aircraft a
    WHERE a.enabled=1 ORDER BY a.registration";
    
    return DB::get_results($sql);
    }
    
    }
    

    Fleet module

    <?php
    /**
    * Karl Sawdy
    */
    
    class Fleet extends CodonModule
    {
    
    
    public function index()
    {
    // Get all aircraft types, and list aircraft by type
    $alltypes = FleetData::GetAllicao();
    
    if(!$alltypes) $alltypes = array();
    
    foreach($alltypes as $type)
    {
    $this->set('title', $type->fullname);
    $this->set('icao', $type->icao);
    
    $this->set('allaircraft', FleetData::getAllAircraft(array('a.icao'=>$type->icao)));
    
    $this->render('fleet/fleet_list.tpl');
    }
    }
    }
    

    fleet list tpl

    <div id="newshead">
    <h3head><?php echo $title?></h3head>
    </div>
    <?php
    if(!$allaircraft)
    {
    echo '<div id="news">There are no aircraft!</div>';
    return;
    }
    ?>
    <div id="news">
    <table id="tabledlist" class="tablesorter">
    <thead>
    <tr>
    <th>Registration</th>
    <th>Name</th>
    </tr>
    </thead>
    <tbody>
    <?php
    foreach($allaircraft as $aircraft)
    {
    ?>
    <tr>
    <td><?php echo $aircraft->registration;?></td>
    <td><?php echo $aircraft->fullname;?></td>
    </tr>
    <?php
    }
    ?>
    </tbody>
    </table>
    </div>
    

    Many thanks All your help is much appreciated

    Karl

    • Like 1
  3. Hi all

    I'm currently having a go t building a module,

    I need a little help, is there a piece of code that I can put on the template page i'm working on during development to show me all he fields that my query is pulling from the database, obviously once I'm done the little helper code can be deleted,

    many thanks

    karl

  4. Evening all

    I am pretty sure that some time ago I soor or read that one of our developers was offering phpvms packaged up with some of their addons included.

    For the life of me I can't remember who it was or where I soor it.

    Could someone please point me in the right direction, search didn't dig anything up for me, and I now can't find it.

    Thanks

    Karl

  5. Thanks for your replies, we now have something to think about, I understand how to get data out of my schedules table, but not sure about my partner airlines table, presumably if we was going to think about a custom module, we would have to give it a path to the schedule table of the partner VA?

  6. You can have a look at logical operators here is a link that explains it http://php.net/manua...ors.logical.php

    in your case now and without me being able to try it out

    try

    <?php
    foreach($allroutes as $route)
    {
    if ($route->code != 'NEX' || '3XE') continue;
    
    

    Many thanks, the link is very interesting I will have a good read through the whole thing time permitting, I tried the code you supplied but it didn't work, still only showed the NEX schedules.

  7. Hi all, I have a couple of questions and was hoping someone may be able to answer them for me.

    My airline and another have gone into a code-share partnership, what we would like to know is that is it possible to share our schedules tables from the databases with each other and display the results on a custom schedules results page from within each other sites?

    Also is it possible to get KACARS to report back to two VA's at the same time during a flight?

    Also how would I go about setting Microsoft access up to access my database?

    Many Thanks

    Karl

  8. Hi all

    Could someone please help me out, I think the solution is so simple but I just can't see it with limited PHP skills.

    Ok I have multiple airlines but my schedules all come under the airline code "NEX" as the other airlines are for charters, code share etc.

    so I have filtered my NEX schedules on the results.tpl like so which works a treat:

     <?php
    foreach($allroutes as $route)
    {
    if ($route->code != 'NEX') continue;
    

    But I wanted to show two or more airline codes in the schedule results.tpl like "NEX" and"3XE" but not any others how would I adjust the code?

    I've tried a few things but with no success.

    Many thanks

  9. Hi I would very much like a module that allows pilots to request aircraft position changes in exchange for points that you earn from the Simpilotgroup Pilot Rewards System 1.0.0. so for example it knows where all your aircraft are positioned from the latest pireps filed, then for example you have an aircraft at egss but the pilot wants to fly from ebbr he could request a ferry flight from egss to ebbr and points would be deducted from what he has been awarded by the reward system. Don't know if this is possible, just a thought.

  10. There is no connection between the events module and the biddign system. The pilot needs to find the flight inthe database and bid on it at that time, or load the flight directly into their ACARS client if they are using kACARS.

    Ok This I understand, however I've created an event for the 1st Nov 2013, however its not showing in the schedule, So I can't see how pilots will bid on this flight when the time comes to fly it, as for entering directly in to ACARS that's a inviting a disaster for some of my pilots as they are a little challenged to say the least
×
×
  • Create New...