Jump to content

Nighthawk

Members
  • Posts

    168
  • Joined

  • Last visited

Everything posted by Nighthawk

  1. Try it again, i moved my Server to new Hardware....
  2. Question: When i send a Form, i want to open a little new window with a new form, how i can do that? That helps me to finish the financial modul!
  3. In the "latest Flights" table, how can i add a coloumn "Pilot" of the recent flight. i know the commands <td> and so on. i tried i can get the pilot id, but how can i convert it to the name of the Pilot?
  4. It is still NOT ready yet. This function must be rewritten. The condition of an aircraft is only an random generated Placeholder, nothing else.
  5. it´s a part of the aircraft buying mod, but it´s still in beta phase and not ready ( not stable) yet.
  6. It isn´t finished yet. Don´t use it on your page! We discuss only a way to program a part of an code.... Read all posts before you do something
  7. Hi, i use PHPVMS v2.1.934-157-g7ca06a When i export my schedules add schedules (or correct some) and then import them, there is an Error Message: Warning: unlink(C:\wamp\www\phpvms\core\cacheschedules.csv) [function.unlink]: Permission denied in C:\wamp\www\phpvms\admin\modules\Import\Import.php on line 357 My import.php is: <?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; case 'importaircraft': $this->set('sidebar', 'sidebar_aircraft.tpl'); break; } } public function index() { $this->render('import_form.tpl'); } public function export() { $this->render('export_form.tpl'); } public function exportaircraft() { $allaircraft = OperationsData::getAllAircraft(false); # Get the column headers $headers = array(); $dbcolumns = DB::get_cols(); foreach ($dbcolumns as $col) { if ($col->name == 'id' || $col->name == 'minrank' || $col->name == 'ranklevel') continue; $headers[] = $col->name; } header('Content-Type: text/plain'); header('Content-Disposition: attachment; filename="aircraft.csv"'); $fp = fopen('php://output', 'w'); # Write out the header which is the columns fputcsv($fp, $headers, ','); # Then write out all of the aircraft foreach ($allaircraft as $aircraft) { unset($aircraft->id); unset($aircraft->minrank); unset($aircraft->ranklevel); $aircraft = (array )$aircraft; fputcsv($fp, $aircraft, ','); } fclose($fp); } public function importaircraft() { if (!file_exists($_FILES['uploadedfile']['tmp_name'])) { $this->render('import_aircraftform.tpl'); return; } echo '<h3>Processing Import</h3>'; # Get the column headers $allaircraft = OperationsData::getAllAircraft(false); $headers = array(); $dbcolumns = DB::get_cols(); foreach ($dbcolumns as $col) { if ($col->name == 'id' || $col->name == 'minrank' || $col->name == 'ranklevel') continue; $headers[] = $col->name; } # Open the import file # Fix for bug VMS-325 $temp_name = $_FILES['uploadedfile']['tmp_name']; $new_name = CACHE_PATH . $_FILES['uploadedfile']['name']; move_uploaded_file($temp_name, $new_name); $fp = fopen($new_name, 'r'); if (isset($_POST['header'])) $skip = true; $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; } # Map the read in values to the columns $aircraft = array(); $aircraft = @array_combine($headers, $fields); if (empty($aircraft)) continue; # Enabled or not if ($aircraft['enabled'] == '1') { $aircraft['enabled'] = true; } else { $aircraft['enabled'] = false; } # Get the rank ID $rank = RanksData::getRankByName($aircraft['rank']); $aircraft['minrank'] = $rank->rankid; unset($aircraft['rank']); # Does this aircraft exist? $ac_info = OperationsData::getAircraftByReg($aircraft['registration']); if ($ac_info) { echo "Editing {$aircraft['name']} - {$aircraft['registration']}<br>"; $aircraft['id'] = $ac_info->id; OperationsData::editAircraft($aircraft); $updated++; } else { echo "Adding {$aircraft['name']} - {$aircraft['registration']}<br>"; OperationsData::addAircraft($aircraft); $added++; } $total++; } unlink($new_name); echo "The import process is complete, added {$added} aircraft, updated {$updated}, for a total of {$total}<br />"; } 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}, {$s->week1}, {$s->week2}, {$s->week3}, {$s->week4}"; 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; # Fix for bug VMS-325 $temp_name = $_FILES['uploadedfile']['tmp_name']; $new_name = CACHE_PATH . $_FILES['uploadedfile']['name']; move_uploaded_file($temp_name, $new_name); $fp = fopen($new_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]; $week1 = $fields[16]; $week2 = $fields[17]; $week3 = $fields[18]; $week4 = $fields[19]; 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, 'week1' => $week1, 'week2' => $week2, 'week3' => $week3, 'week4' => $week4 ); # 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>'; unlink($new_name); } 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; } } } In the database the "p" for pax is nothing ,for the days only "01234" insted of "0123456" is inserted. Need some help...
  8. Did u have the beta installed? It works only with the beta !!! It´s important to read the Readme, if not, there will problems!
  9. -For Manual Price input change in /phpvms/admin/templates/ops_buysellaircraft.tpl on line 58 "hidden" into "text" <input name="price" type="hidden" value="<?php echo number_format ((("$acprice1"*"$newrd")/100),2,",","."); ?>" /> <input name="price" type="text" value="<?php echo number_format ((("$acprice1"*"$newrd")/100),2,",","."); ?>" />
  10. i made some workarounds but didnt find a way in the moment to get it to work
  11. i know, it´s very hardcore... i think we need to connect all the main programmers here to get it work
  12. First to know is that u must!!! have installed the beta of phpvms. The next is have you filled out ALL fields ? have u inserted the sql file correct? take an look in your database /phpvms_aircrafts there must be an colomn with the name cond and some more...
  13. Hi, sorry, but have installed the beta phpvms? Schedules and pireps are the same like before my mod, there is nothing changed in it.
  14. Hi, or he use fspilot or something for autolanding?
  15. Let me know if i can help you
  16. i tried it now, but it doesn´t work. mhhh. Back to clipboard....
  17. I had it too, i use win7 64. Give it admin rights then should it ok...
  18. Some People are working to get the condition function to work... Look here: http://forum.phpvms.net/topic/7037-landing-rates-and-condition/
  19. Hi made a little Snippet in /core/templates/schedule_results.tpl It shows like this : Here is the code (Line 14-78 in my code) <tbody> <?php foreach($schedule_list as $schedule) { ?> <tr> <td> <a href="<?php echo url('/schedules/details/'.$schedule->id);?>"><?php echo $schedule->code . $schedule->flightnum?> <?php echo '('.$schedule->depicao.' - '.$schedule->arricao.')'?> </a> <br /> <strong>Departure: </strong><?php echo $schedule->deptime;?> <strong>Arrival: </strong><?php echo $schedule->arrtime;?><br /> <strong>Equipment: </strong><?php echo $schedule->aircraft; ?> (<?php echo $schedule->registration;?>) <strong>Distance: </strong><?php echo $schedule->distance . Config::Get('UNITS');?> <br /> <strong>Days Flown: </strong><?php echo Util::GetDaysCompact($schedule->daysofweek); ?><br /> <?php echo ($schedule->route=='') ? '' : '<strong>Route: </strong>'.$schedule->route.'<br />' ?> <?php echo ($schedule->notes=='') ? '' : '<strong>Notes: </strong>'.html_entity_decode($schedule->notes).'<br />' ?> <?php # Note: this will only show if the above code to # skip the schedule is commented out if($schedule->bidid != 0) { echo 'This route has been bid on'; } ?> </br> <?php //Routes Flown $Tesla2=("$schedule->flightnum"); $result2 = mysql_query("SELECT COUNT(*) FROM phpvms_pireps WHERE flightnum='$Tesla2'"); $num_rows2 = mysql_result($result2,0); ?> Route flown:<?php print "$num_rows2" ?></br> <?php //Average Fuel used $Tesla2=("$schedule->flightnum"); $result3 = mysql_query("SELECT sum(fuelused) FROM phpvms_pireps WHERE flightnum='$Tesla2'"); $num_rows3 = mysql_result($result3,0); ?> Real Average Fuel used:<?php echo"$num_rows3"/"$num_rows2"?> <?php echo Config::Get('CARGO_UNITS');?></br> <?php //Average Time $result4 = mysql_query("SELECT SUM(flighttime) FROM phpvms_pireps WHERE flightnum='$Tesla2'"); $num_rows4 = mysql_result($result4,0); $array=explode(".", $num_rows4); $hours2=$array[0]; $min2=$array[1]; $min2calc=(("$hours2"*60)+"$min2"); $min3calc=$min2calc/"$num_rows2"; $hourcalc=$min3calc/60; $hours3=("$hours2"/"$num_rows2"); $hours4=floor($hours3); $Difmin=$min3calc-(("$hours2"/"$num_rows2")*60); $totaltime2=$hours4+("$Difmin"/100); ?> Real Average Flight duration: <?php print $totaltime2;?> hrs </td>
  20. U have changed(or only opened) with an software that changes the code automatically! Notepad++ is free and my favourite Editor. You can found it here: http://notepad-plus-plus.org/ My Hint : I have an USB Stick with many portable tools on it called Liberkey Its a useful Toolsuite
×
×
  • Create New...