Jump to content

Jeff

Members
  • Posts

    1307
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Jeff

  1. Slight problem! Here is the coding: <?php /** * phpVMS - Virtual Airline Administration Software * Copyright (c) 2008 Nabeel Shahzad * For more information, visit www.phpvms.net * Forums: http://www.phpvms.net/forum * Documentation: http://www.phpvms.net/docs * * phpVMS is licenced under the following license: * Creative Commons Attribution Non-commercial Share Alike (by-nc-sa) * View license.txt in the root, or visit http://creativecommons.org/licenses/by-nc-sa/3.0/ * * @author Nabeel Shahzad * @copyright Copyright (c) 2008, Nabeel Shahzad * @link http://www.phpvms.net * @license http://creativecommons.org/licenses/by-nc-sa/3.0/ */ class Import extends CodonModule { function HTMLHead() { switch($this->controller->function) { case '': default: case 'processimport': $this->set('sidebar', 'sidebar_import.tpl'); break; } } public function index() { $this->render('import_form.tpl'); } public function export() { $this->render('export_form.tpl'); } public function processexport() { $export=''; $all_schedules = SchedulesData::GetSchedules('', false); if(!$all_schedules) { echo 'No schedules found!'; return; } header('Content-Type: text/plain'); header('Content-Disposition: attachment; filename="schedules.csv"'); $fp = fopen('php://output', 'w'); $line=file_get_contents(SITE_ROOT.'/admin/lib/template.csv'); fputcsv($fp, explode(',', $line)); foreach($all_schedules as $s) { $line ="{$s->code},{$s->flightnum},{$s->depicao},{$s->arricao}," ."{$s->route},{$s->registration},{$s->flightlevel},{$s->distance}," ."{$s->deptime}, {$s->arrtime}, {$s->flighttime}, {$s->notes}, " ."{$s->price}, {$s->flighttype}, {$s->daysofweek}, {$s->enabled}"; fputcsv($fp, explode(',', $line)); } fclose($fp); } public function processimport() { echo '<h3>Processing Import</h3>'; if(!file_exists($_FILES['uploadedfile']['tmp_name'])) { $this->set('message', 'File upload failed!'); $this->render('core_error.tpl'); return; } echo '<p><strong>DO NOT REFRESH OR STOP THIS PAGE</strong></p>'; set_time_limit(270); $errs = array(); $skip = false; $fp = fopen($_FILES['uploadedfile']['tmp_name'], 'r'); if(isset($_POST['header'])) $skip = true; /* Delete all schedules before doing an import */ if(isset($_POST['erase_routes'])) { SchedulesData::deleteAllSchedules(); } $added = 0; $updated = 0; $total = 0; echo '<div style="overflow: auto; height: 400px; border: 1px solid #666; margin-bottom: 20px; padding: 5px; padding-top: 0px; padding-bottom: 20px;">'; while($fields = fgetcsv($fp, 1000, ',')) { // Skip the first line if($skip == true) { $skip = false; continue; } // list fields: $code = $fields[0]; $flightnum = $fields[1]; $depicao = $fields[2]; $arricao = $fields[3]; $route = $fields[4]; $aircraft = $fields[5]; $flightlevel = $fields[6]; $distance = $fields[7]; $deptime = $fields[8]; $arrtime = $fields[9]; $flighttime = $fields[10]; $notes = $fields[11]; $price = $fields[12]; $flighttype = $fields[13]; $daysofweek = $fields[14]; $enabled = $fields[15]; $services = $fields[16]; $duration = $fields[17]; $airline = $fields[18]; if($code == '') { continue; } // Check the code: if(!OperationsData::GetAirlineByCode($code)) { echo "Airline with code $code does not exist! Skipping...<br />"; continue; } // Make sure airports exist: if(!($depapt = OperationsData::GetAirportInfo($depicao))) { $this->get_airport_info($depicao); } if(!($arrapt = OperationsData::GetAirportInfo($arricao))) { $this->get_airport_info($arricao); } # Check the aircraft $aircraft = trim($aircraft); $ac_info = OperationsData::GetAircraftByReg($aircraft); # If the aircraft doesn't exist, skip it if(!$ac_info) { echo 'Aircraft "'.$aircraft.'" does not exist! Skipping<br />'; continue; } $ac = $ac_info->id; if($flighttype == '') { $flighttype = 'P'; } if($daysofweek == '') $daysofweek = '0123456'; // Replace a 7 (Sunday) with 0 (since PHP thinks 0 is Sunday) $daysofweek = str_replace('7', '0', $daysofweek); # Check the distance if($distance == 0 || $distance == '') { $distance = OperationsData::getAirportDistance($depicao, $arricao); } $flighttype = strtoupper($flighttype); if($enabled == '0') $enabled = false; else $enabled = true; # This is our 'struct' we're passing into the schedule function # to add or edit it $data = array( 'code'=>$code, 'flightnum'=>$flightnum, 'depicao'=>$depicao, 'arricao'=>$arricao, 'route'=>$route, 'aircraft'=>$ac, 'flightlevel'=>$flightlevel, 'distance'=>$distance, 'deptime'=>$deptime, 'arrtime'=>$arrtime, 'flighttime'=>$flighttime, 'daysofweek'=>$daysofweek, 'notes'=>$notes, 'enabled'=>$enabled, 'price'=>$price, 'flighttype'=>$flighttype, 'services'=>$services, 'duration'=>$duration, 'airline'=>$airline); # Check if the schedule exists: if(($schedinfo = SchedulesData::getScheduleByFlight($code, $flightnum))) { # Update the schedule instead $val = SchedulesData::updateScheduleFields($schedinfo->id, $data); $updated++; } else { # Add it $val = SchedulesData::addSchedule($data); $added++; } if($val === false) { if(DB::errno() == 1216) { echo "Error adding $code$flightnum: The airline code, airports, or aircraft does not exist"; } else { $error = (DB::error() != '') ? DB::error() : 'Route already exists'; echo "$code$flightnum was not added, reason: $error<br />"; } echo '<br />'; } else { $total++; echo "Imported {$code}{$flightnum} ({$depicao} to {$arricao})<br />"; } } CentralData::send_schedules(); echo "The import process is complete, added {$added} schedules, updated {$updated}, for a total of {$total}<br />"; foreach($errs as $error) { echo ' '.$error.'<br />'; } echo '</div>'; } protected function get_airport_info($icao) { echo "ICAO $icao not added... retriving information: <br />"; $aptinfo = OperationsData::RetrieveAirportInfo($icao); if($aptinfo === false) { echo 'Could not retrieve information for '.$icao.', add it manually <br />'; } else { echo "Found: $icao - ".$aptinfo->name .' ('.$aptinfo->lat.','.$aptinfo->lng.'), airport added<br /><br />'; return $aptinfo; } } } Here is what I am using to call it: <TD CLASS="MYTABLE">Depart: <strong><?php echo $route->depicao;?></strong><br />Airport: <strong><?php $departname = OperationsData::getAirportInfo($route->depicao);?><?php echo $departname->name;?></strong><br />Depart Time: <strong><?php echo $route->deptime;?><br /></strong></TD> <TD CLASS="MYTABLE">Arrive: <strong><?php echo $route->arricao;?></strong><br />Airport: <strong><?php $arrivename = OperationsData::getAirportInfo($route->arricao);?><?php echo $arrivename->name;?></strong><br />Arrive Time: <strong><?php echo $route->arrtime;?><br /></strong></TD> <TD CLASS="MYTABLE">Flight: <strong><?php echo $route->code . - $route->flightnum?></strong><br/> Aircraft: <strong><?php echo $route->aircraft ?></strong><br/> Duration: <strong><?php echo $route->notes ?></strong><br/> Meals: <strong><?php echo $route->services ?></strong><br/> Duration: <strong><?php echo $route->duration ?></strong><br/> Operated By: <strong><?php echo $route->airline ?></strong><br/> </TD>
  2. I got the boxes to show last night, but when I typed in them and clicked Update Profile, the field was blank. It just said... About Me:
  3. If you can get the chance to do it, You can get your hosting right here from Nabeel using fivedev. Most of us dedicated phpVMS users that have been around for years use this since it (and these forums) are tied together. And support is not too far away. CLICK!
  4. Isn't there a way to actually place it in the Edit Profile page so they will be able to update it at any time? I was fiddling with it last night, but couldn't get it to show. I added a custom profile field in the admin center but couldn't figure out how to have it work correctly since I've never tried the custom profile before.
  5. You can change the default Avatar by editing this file: This image will be the pilots' default avatar until they change it in their Edit Profile page.
  6. Jeff

    Pilotpay Bug

    It's not a file. It is actually located in the Admin Center. If you click on to expand the Pilots & Groups and click on Ranks, add a rank and place a price to pay each pilot for every hour they fly for that rank. Then you can choose how many hours until they reach the next rank. You can then up the pilot pay a little at a time for every rank they reach.
  7. Ray, I think what he means is have a short text form added in the profile_main.tpl so that each member (not admin) can add a short summary about themselves and that will show up in the pilot_public_profile.tpl so everyone can view info on each member. I think it would be a great add-on if someone would like to tackle this task.
  8. It is showing correctly in my IE browser. Firefox Internet Explorer
  9. Anyone interested: If you'd like to just show the airport names instead of the ICAO and Name, here is the edited code: <form action="<?php echo url('/Schedules');?>" method="post" enctype="multipart/form-data"> <table align="left" border="0" width="100%"> <tr> <td width="20px"><b>Dep:</b></font></td> <td> <select class="search" name="depicao"> <option value="">All</option> <?php if (Auth::LoggedIn()) { $report = PIREPData::getLastReports(Auth::$userinfo->pilotid, 1, PIREP_ACCEPTED); if($report) { echo '<option value="'.$report->arricao.'">All ('.$report->arricao.')</option>'; } else { echo '<option value="'.Auth::$userinfo->hub.'">All ('.Auth::$userinfo->hub.')</option>'; } } $airports = OperationsData::getAllAirports(); foreach ($airports as $airport) { echo '<option value="'.$airport->icao.'">'.$airport->name.'</option>'; }?> </select> </td> </tr> <td width="20px"><b>Arr:</b></font></td> <td> <select class="search" name="arricao"> <option value="">All</option> <?php foreach ($airports as $airport) { echo '<option value="'.$airport->icao.'">'.$airport->name.'</option>'; } ?> </select> </td> </tr> <tr> <td> <input type="hidden" name="action" value="findflight" /> <input title="Click here to search for flights" type="submit" name="submit" value="Search" /> </td> </tr> </table> </form>
  10. Not a problem. Glad I could help. (Thanks Mr. Kobus)
  11. There you go. That should do it. Does it still say YOUR CURRENT LOCATION, or did it change back to ALL? Also, when you choose the Departure Airport, you don't have to choose the Arrival. You can leave it alone and when you click Search it will show all flights out of that airport, and vice-versa.
  12. Hang on a second, let me see what I can do for you.
  13. I fixed the color issue for you
  14. Since this post is 28 months old, I don't doubt it.
  15. I was able to get it on the side menu correctly, but somehow the Dep and Arr don't have the airport's name come up. If anyone has a solution that may solve this issue, please share.
  16. If you would like for me to try to enter and get it sorted for you, PM me.
  17. try to add a </div> at the end of the code.
  18. Place it where you have your other coding in that spot.
  19. Yes indeed! View link here
  20. That's pretty much all the information I can give you, bud. You will soon find out that this will not just be your only problem you will encounter when using phpVMS with a Free Hosting Service.
  21. First off, you'll need to go in your Admin Center an rename all your airports to something smaller in order to fit it in such a tight space. What I did was went in and renamed them to the Airport's city name (if Hartsfield-Jackson Atlanta International, then I just named it Atlanta) If you come across a city that has multiple airports (London Heathrow or London Gatwick) then name them London-LHR and London-LGW). This will save a huge headache trying to fit something that large in a small space. Next you can see if this code will work. (I'm not sure because I don't have it coded like this on my site. <form action="<?php echo url('/FrontSchedules');?>" method="post" enctype="multipart/form-data"> <table align="left" border="0" width="100%"> <tr> <td bgcolor="#05305D" border="1"><font color="#FFFFFF"><b>Departure</b></font></td> <td> <select class="search" name="depicao"> <option value="">All</option> <?php if (Auth::LoggedIn()) {?> <?php $reports = PIREPData::getLastReports(Auth::$userinfo->pilotid, 1, PIREP_ACCEPTED); if(is_object($reports)) {echo '<option value="'.$reports->arricao.'">Your current location ('.$reports->arricao.')</option>';} elseif(!$reports) {echo '<option value="'.Auth::$userinfo->hub.'">Your current location ('.Auth::$userinfo->hub.')</option>';}}?> <?php foreach ($airports as $airport) { echo '<option value="'.$airport->icao.'">'.$airport->icao.' - '.$airport->name.'</option>'; }?> </select> </td> </tr> <td bgcolor="#05305D" border="1"><font color="#FFFFFF"><b>Arrival</b></font></td> <td> <select class="search" name="arricao"> <option value="">All</option> <?php foreach ($airports as $airport) {echo '<option value="'.$airport->icao.'">'.$airport->icao.' - ('.$airport->name.')</option>';} ?> </select> </td> </tr> <tr> <td> <input title="Click here to search for flights" type="hidden" name="action" value="findflight" /> <input title="Click here to search for flights" type="submit" name="submit" value="Search" /> </td> </tr> </table> </form> You are going to have to do some editing to remove some of the colors' codes I have in there.
  22. There's your problem. You need to get a paid hosting service as free hosting leaves crucial information out that phpVMS needs in order to function properly.
  23. This might help you. Give this a shot: <td bgcolor="#05305D" border="1"><font color="#FFFFFF"><b>Your Current Location:</b></font></td> <td><select id="depicao" name="depicao"> <option value="<?php echo $last_location->arricao?>"><?php echo $last_location->arricao?> (<?php echo $last_name->name?>)</option> </td>
  24. That's where it is, I wasn't even close. I thought it was somewhere in phpMyAdmin. Thanks Jeffrey
×
×
  • Create New...