Jump to content

Step 1 Aircraft buying Mod Version 1.00 !!!!


Nighthawk

Recommended Posts

My Problem is, how can i do connection from this admin/template

	// Show these if it is not bought or leased

?>
<h1><?php echo $aircraft->registration; ?> Buy Screen</h1>

<img src="<?php echo $aircraft->imagelink; ?>" height="140" width="140">
<br><br><br><br>
<table border=0 id="tabledlist" class="tablesorter">
<thead>
<tr>
   <th align="center">Status</th>
   <th align="center">Condition</th>
   <th align="center" >Price</th>
   <th align="center">Buy</th>
   </tr>
</thead>
<tbody>
<form action="<?php echo adminurl('/Buysell/aircraft');?>" method="post"> <tr>
   <td align="center">New</td>
   <td align="center"><?php echo $newrd ?>%</td>
   <td align="center"><?php echo number_format((("$acprice1"*"$newrd")/100),2,",","."); echo Config::Get('MONEY_UNIT'); ?> </td>
   <td align="center"><input type="hidden" name="id" value="<?php echo $aircraft->id;?>" />
<input name="price" type="text" value="<?php echo ((("$acprice1"*"$newrd")/100)); ?>"  />
<input name="cond" type="hidden" value="<?php echo $newrd; ?>" />
<input type="hidden" name="action" value="<?php echo $action;?>" />
<input name="icao" type="hidden" value="<?php echo $aircraft->icao; ?>" />
<input name="name" type="hidden" value="<?php echo $aircraft->name; ?>" />
<input name="fullname" type="hidden"  value="<?php echo $aircraft->fullname; ?>" />
<input name="registration" type="hidden"  value="<?php echo $aircraft->registration; ?>" />
<input name="maxcargo" type="hidden"  value="<?php echo $aircraft->maxcargo; ?>" />
<input name="downloadlink" type="hidden"  value="<?php echo $aircraft->downloadlink; ?>" />
<input name="imagelink" type="hidden"  value="<?php echo $aircraft->imagelink; ?>" />
<input name="maxpax" type="hidden"  value="<?php echo $aircraft->maxpax; ?>" />
<input name="weight" type="hidden" value="<?php echo $aircraft->weight; ?>" />
<input name="bought" type="hidden" value="<?php echo $boughty; ?>" />
<input name="range" type="hidden"   value="<?php echo $aircraft->range; ?>" />
<input name="cruise" type="hidden"  value="<?php echo $aircraft->cruise; ?>" />
<input name="minrank" type="hidden"  value="<?php echo $aircraft->minrank; ?>" />
<input type="hidden" id="enabled" name="enabled" value="1" />
<input type="submit" name="submit" value="Buy" /></td>
   </form>
 </tr>

to this class ledger

 public static function addPayment($params) {

       $params = array_merge(array(
           'pilotid' => '',
           'pirepid' => 0,
           'paysource' => PAYSOURCE_PIREP,
           'paytype' => 1,
           'amount' => 0,
       ), $params);

       if(empty($params['pilotid'])) {
           return false;
       }

       $sql = 'INSERT INTO `'.TABLE_PREFIX.'ledger`
                 (`pilotid`, `pirepid`, `paysource`, `paytype`, `amount`, `submitdate`, `modifieddate`)
               VALUES ('
                   .$params['pilotid'].','
                   .$params['pirepid'].','
                   .$params['paysource'].','
                   .$params['paytype'].','
                   .$params['amount'].', NOW(), NOW()
               );';

       DB::query($sql);

       PilotData::resetPilotPay($params['pilotid']);
   }

I inserted in app.config the following for ledger

# Constants for 'paysource' column in ledger
define('PAYSOURCE_PIREP', 1);
define('Payment', 2);

# Constants for 'paytype' column in ledge
define('PILOT_PAY_HOURLY', 1);
define('PILOT_PAY_SCHEDULE', 2);
define('PILOT_PAY_FIXED', 3);
define('Payment', 4);

The "data" which i want to submit to ledger is like this "

$params = array_merge(array(
           'pilotid' => '',
           'pirepid' => '',
           'paysource' => 2,
           'paytype' => 4,
           'amount' => "price",

How can i do this the best and easiest way????

THIS IS THE MISSING LINK TO GET THIS MOD FULLY WORKING!!!!!

Optional How can i do an monthly expense from here for Leasing?

Link to comment
Share on other sites

Hi after updating i become this failure

Fatal error: Call to undefined method OperationsData::AddAircaft() in /www/htdocs/w00dac26/lausitzair/admin/modules/Operations/Operations.php on line 734

And when i will enable a aircraft i become this failure

Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'Operations::buysellaircraft' was given in /www/htdocs/w00dac26/lausitzair/core/classes/MainController.class.php on line 218

I need help so i dont will reinstall the complete vms

I cannot add more aircrafts yet

I think my system is destroyed now i cant make anymore s*** f***

any solutions

Link to comment
Share on other sites

Hi

Current phpvms Version : v2.1.934-157-g7ca06a3

Operations.php

<?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/
* @package module_admin_operations
*/


class Operations extends CodonModule
{

public function HTMLHead()
{
	switch($this->controller->function)
	{
		case 'airlines':
			$this->set('sidebar', 'sidebar_airlines.tpl');
			break;
		case 'addaircraft':
		case 'aircraft':
			$this->set('sidebar', 'sidebar_aircraft.tpl');
			break;
		case 'airports':
			$this->set('sidebar', 'sidebar_airports.tpl');
			break;
		case '':
		case 'addschedule':
		case 'activeschedules':
		case 'inactiveschedules':
		case 'schedules':
			$this->set('sidebar', 'sidebar_schedules.tpl');
			break;
		case 'editschedule':
			$this->set('sidebar', 'sidebar_editschedule.tpl');
			break;
	}
}

public function index()
{
	$this->schedules();
}



public function viewmap()
{
	if($this->get->type === 'pirep')
	{
		$data = PIREPData::getReportDetails($this->get->id);
	}

	elseif($this->get->type === 'schedule')
	{
		$data = SchedulesData::getScheduleDetailed($this->get->id);
	}

	elseif($this->get->type === 'preview')
	{
		$data = new stdClass();

		$depicao = OperationsData::getAirportInfo($this->get->depicao);
		$arricao = OperationsData::getAirportInfo($this->get->arricao);

		$data->deplat = $depicao->lat;
		$data->deplng = $depicao->lng;
		$data->depname = $depicao->name;

		$data->arrlat = $arricao->lat;
		$data->arrlng = $arricao->lng;
		$data->arrname = $arricao->name;

		$data->route = $this->get->route;

		unset($depicao);
		unset($arricao);

		$data->route_details = NavData::parseRoute($data);
	}

	$this->set('mapdata', $data);
	$this->render('route_map.tpl');
}

public function addaircraft()
{
	$this->set('title', 'Add Aircraft');
	$this->set('action', 'addaircraft');
	$this->set('allranks', RanksData::getAllRanks());
	$this->render('ops_aircraftform.tpl');	
}

public function editaircraft()
{
	$id = $this->get->id;

	$this->set('aircraft', OperationsData::GetAircraftInfo($id));
	$this->set('title', 'Edit Aircraft');
	$this->set('action', 'editaircraft');
	$this->set('allranks', RanksData::getAllRanks());
	$this->render('ops_aircraftform.tpl');	
}

public function addairline()
{
	$this->set('title', 'Add Airline');
	$this->set('action', 'addairline');
	$this->render('ops_airlineform.tpl');
}

public function editairline()
{
	$this->set('title', 'Edit Airline');
	$this->set('action', 'editairline');
	$this->set('airline', OperationsData::GetAirlineByID($this->get->id));

	$this->render('ops_airlineform.tpl');
}

public function calculatedistance($depicao='', $arricao='')
{
	if($depicao == '')
		$depicao = $this->get->depicao;

	if($arricao == '')
		$arricao = $this->get->arricao;

	echo OperationsData::getAirportDistance($depicao, $arricao);
}

public function getfuelprice()
{
	if(Config::Get('FUEL_GET_LIVE_PRICE') == false)
	{
		echo '<span style="color: red">Live fuel pricing is disabled!</span>';
		return;
	}

	$icao = $_GET['icao'];
	$price = FuelData::get_from_server($icao);

	if(is_bool($price) && $price === false)
	{
		echo '<span style="color: red">Live fuel pricing is not available for this airport</span>';
		return;
	}

	echo '<span style="color: #33CC00">OK! Found - current price: <strong>'.$price.'</strong></span>';
}

public function findairport()
{
	$results = OperationsData::searchAirport($this->get->term);

	if(count($results) > 0)
	{
		$return = array();

		foreach($results as $row)
		{
			$tmp = array(
				'label' => "{$row->icao} ({$row->name})",
				'value' => $row->icao,
				'id' => $row->id,
			);

			$return[] = $tmp;
		}

		echo json_encode($return);
	}	
}

public function airlines()
{
	if(isset($this->post->action))
	{
		if($this->post->action == 'addairline')
		{
			$this->add_airline_post();
		}
		elseif($this->post->action == 'editairline')
		{
			$this->edit_airline_post();
		}
	}

	$this->set('allairlines', OperationsData::GetAllAirlines());
	$this->render('ops_airlineslist.tpl');
}

public function aircraft()
{
	/* If they're adding an aircraft, go through this pain
	*/
	switch($this->post->action)
	{
		case 'addaircraft':

			$this->add_aircraft_post();

			break;

		case 'editaircraft':

			$this->edit_aircraft_post();

			break;
	}

	$this->set('allaircraft', OperationsData::GetAllAircraft());
	$this->render('ops_aircraftlist.tpl');
}

public function addairport()
{
	$this->set('title', 'Add Airport');
	$this->set('action', 'addairport');

	$this->render('ops_airportform.tpl');
}

public function editairport()
{
	$this->set('title', 'Edit Airport');
	$this->set('action', 'editairport');
	$this->set('airport', OperationsData::GetAirportInfo($this->get->icao));

	$this->render('ops_airportform.tpl');
}

public function airports()
{
	/* If they're adding an airport, go through this pain
	*/
	if(isset($this->post->action))
	{
		switch($this->post->action)
		{
			case 'addairport':
				$this->add_airport_post();
				break;
			case 'editairport':
				$this->edit_airport_post();
				break;
		}

		return;
	}

	//$this->set('airports', OperationsData::getAllAirports());
	$this->render('ops_airportlist.tpl');
}

public function airportgrid()
{
	$page = $this->get->page; // get the requested page 
	$limit = $this->get->rows; // get how many rows we want to have into the grid 
	$sidx = $this->get->sidx; // get index row - i.e. user click to sort 
	$sord = $this->get->sord; // get the direction 
	if(!$sidx) $sidx =1;

	# http://dev.phpvms.net/admin/action.php/operations/
	# ?_search=true&nd=1270940867171&rows=20&page=1&sidx=flightnum&sord=asc&searchField=code&searchString=TAY&searchOper=eq

	/* Do the search using jqGrid */
	$where = array();
	if($this->get->_search == 'true') 
	{
		$searchstr = jqgrid::strip($this->get->filters);
		$where_string = jqgrid::constructWhere($searchstr);

		# Append to our search, add 1=1 since it comes with AND
		#	from above
		$where[] = "1=1 {$where_string}";
	}

	# Do a search without the limits so we can find how many records
	$count = count(OperationsData::findAirport($where));

	if($count > 0) 
	{
		$total_pages = ceil($count/$limit);
	} 
	else 
	{
		$total_pages = 0;
	}

	if ($page > $total_pages) 
	{
		$page = $total_pages;
	}

	$start = $limit * $page - $limit; // do not put $limit*($page - 1)
	if ($start < 0) 
	{
		$start = 0;
	}

	# And finally do a search with the limits
	$airports = OperationsData::findAirport($where, $limit, $start, "{$sidx} {$sord}");
	if(!$airports)
	{
		$airports = array();
	}

	# Form the json header
	$json = array(
		'page' => $page,
		'total' => $total_pages,
		'records' => $count,
		'rows' => array()
		);

	# Add each row to the above array
	foreach($airports as $row)
	{
		if($row->fuelprice == 0)
		{
			$row->fuelprice = 'Live';
		}

		$edit = '<a href="#" onclick="editairport(\''.$row->icao.'\'); return false;">Edit</a>';

		$tmp = array(
			'id' => $row->id,
			'cell' => array(
					# Each column, in order
					$row->icao,
					$row->name,
					$row->country,
					$row->fuelprice,
					$row->lat,
					$row->lng,
					$edit,
					),
				);

		$json['rows'][] = $tmp;
	}

	header("Content-type: text/x-json");
	echo json_encode($json);	
}

public function addschedule()
{
	$this->set('title', 'Add Schedule');
	$this->set('action', 'addschedule');

       $this->set('allairlines', OperationsData::GetAllAirlines());
	$this->set('allaircraft', OperationsData::GetAllAircraft());
	$this->set('allairports', OperationsData::GetAllAirports());
	//$this->set('airport_json_list', OperationsData::getAllAirportsJSON());
	$this->set('flighttypes', Config::Get('FLIGHT_TYPES'));

	$this->render('ops_scheduleform.tpl');
}

public function editschedule()
{
	$id = $this->get->id;

	$this->set('title', 'Edit Schedule');
	$this->set('schedule', SchedulesData::GetSchedule($id));

	$this->set('action', 'editschedule');

       $this->set('allairlines', OperationsData::GetAllAirlines());
	$this->set('allaircraft', OperationsData::GetAllAircraft());
	$this->set('allairports', OperationsData::GetAllAirports());
	$this->set('flighttypes', Config::Get('FLIGHT_TYPES'));

	$this->render('ops_scheduleform.tpl');
}

public function activeschedules()
{
	$this->schedules('activeschedules');
}

public function inactiveschedules()
{
	$this->schedules('inactiveschedules');
}

public function schedulegrid()
{
	$page = $this->get->page; // get the requested page 
	$limit = $this->get->rows; // get how many rows we want to have into the grid 
	$sidx = $this->get->sidx; // get index row - i.e. user click to sort 
	$sord = $this->get->sord; // get the direction 
	if(!$sidx) $sidx =1;

	# http://dev.phpvms.net/admin/action.php/operations/
	# ?_search=true&nd=1270940867171&rows=20&page=1&sidx=flightnum&sord=asc&searchField=code&searchString=TAY&searchOper=eq

	/* Do the search using jqGrid */
	$where = array();
	if($this->get->_search == 'true') 
	{
		$searchstr = jqgrid::strip($this->get->filters);
		$where_string = jqgrid::constructWhere($searchstr);

		# Append to our search, add 1=1 since it comes with AND
		#	from above
		$where[] = "1=1 {$where_string}";
	}

	Config::Set('SCHEDULES_ORDER_BY', "{$sidx} {$sord}");

	# Do a search without the limits so we can find how many records
	$count = SchedulesData::countSchedules($where);
	if($count > 0) 
	{
		$total_pages = ceil($count/$limit);
	} 
	else 
	{
		$total_pages = 0;
	}

       if ($page > $total_pages) 
       {
		$page = $total_pages;
	}

	$start = $limit * $page - $limit; // do not put $limit*($page - 1)
	if ($start < 0) 
	{
		$start = 0;
	}

	# And finally do a search with the limits
	$schedules = SchedulesData::findSchedules($where, $limit, $start);
	if(!$schedules)
	{
		$schedules = array();
	}

	# Form the json header
	$json = array(
		'page' => $page,
		'total' => $total_pages,
		'records' => $count,
		'rows' => array()
	);

	# Add each row to the above array
	foreach($schedules as $row)
	{
		if($row->route != '')
		{
			$route = '<a href="#" onclick="showroute(\''.$row->id.'\'); return false;">View</a>';
		}
		else
		{
			$route = '-';
		}

		$edit = '<a href="'.adminurl('/operations/editschedule?id='.$row->id).'">Edit</a>';
		$delete = '<a href="#" onclick="deleteschedule('.$row->id.'); return false;">Delete</a>';

		$tmp = array(
			'id' => $row->id,
			'cell' => array(
				# Each column, in order
				$row->code,
				$row->flightnum,
				$row->depicao,
				$row->arricao,
				$row->aircraft,
				$row->registration,
				$route,
				Util::GetDaysCompact($row->daysofweek),
				$row->distance,
				$row->timesflown,
				$edit,
				$delete,
			),
		);

		$json['rows'][] = $tmp;
	}

	header("Content-type: text/x-json");
	echo json_encode($json);	
}

public function schedules($type='activeschedules')
{
	/* These are loaded in popup box */
	if($this->get->action == 'viewroute')
	{
		$id = $this->get->id;
		return;
	}
	if($this->get->action == 'filter')
	{
		$this->set('title', 'Filtered Schedules');

		if($this->get->type == 'flightnum')
		{
			$params = array('s.flightnum' => $this->get->query);
		}
		elseif($this->get->type == 'code')
		{
			$params = array('s.code' => $this->get->query);
		}
		elseif($this->get->type == 'aircraft')
		{
			$params = array('a.name' => $this->get->query);
		}
		elseif($this->get->type == 'depapt')
		{
			$params = array('s.depicao' => $this->get->query);
		}
		elseif($this->get->type == 'arrapt')
		{
			$params = array('s.arricao' => $this->get->query);
		}

		// Filter or don't filter enabled/disabled flights
		if(isset($this->get->enabled) && $this->get->enabled != 'all')
		{
			$params['s.enabled'] = $this->get->enabled;
		}

		$this->set('schedules', SchedulesData::findSchedules($params));
		$this->render('ops_schedules.tpl');
		return;
	}

	switch($this->post->action)
	{
		case 'addschedule':
			$this->add_schedule_post();
			break;

		case 'editschedule':
			$this->edit_schedule_post();
			break;

		case 'deleteschedule':
			$this->delete_schedule_post();
			return;
			break;			
	}

	if(!isset($this->get->start) || $this->get->start == '')
	{
		$this->get->start = 0;
	}

	$num_per_page = 20;
	$start = $num_per_page * $this->get->start;

	if($type == 'schedules' || $type == 'activeschedules')
	{
		$params = array('s.enabled' => 1);
		$schedules = SchedulesData::findSchedules($params, $num_per_page, $start);

		$this->set('title', 'Viewing Active Schedules');
		$this->set('schedules', $schedules);

		if(count($schedules) >= $num_per_page)
		{
			$this->set('paginate', true);
			$this->set('start', $this->get->start+1);

			if($this->get->start - 1 > 0)
			{
				$prev = $this->get->start - 1;
				if($prev == '')
					$prev = 0;

				$this->set('prev', intval($prev));
			}
		}
	}
	else
	{
		$this->set('title', 'Viewing Inactive Schedules');
		$this->set('schedules', SchedulesData::findSchedules(array('s.enabled'=>0)));
	}

	$this->render('ops_schedules.tpl');
}

protected function add_airline_post()
{
	$this->post->code = strtoupper($this->post->code);

	if($this->post->code == '' || $this->post->name == '')
	{
		$this->set('message', 'You must fill out all of the fields');
		$this->render('core_error.tpl');
		return;
	}

	if(OperationsData::GetAirlineByCode($this->post->code))
	{
		$this->set('message', 'An airline with this code already exists!');
		$this->render('core_error.tpl');
		return;
	}

	OperationsData::AddAirline($this->post->code, $this->post->name);

	if(DB::errno() != 0)
	{
		if(DB::errno() == 1062) // Duplicate entry
			$this->set('message', 'This airline has already been added');
		else
			$this->set('message', 'There was an error adding the airline');

           $this->render('core_error.tpl');
		return;
	}

	$this->set('message',  'Added the airline "'.$this->post->code.' - '.$this->post->name.'"');
	$this->render('core_success.tpl');

	LogData::addLog(Auth::$userinfo->pilotid, 'Added the airline "'.$this->post->code.' - '.$this->post->name.'"');
}

protected function edit_airline_post()
{
	$this->post->code = strtoupper($this->post->code);

	if($this->post->code == '' || $this->post->name == '')
	{
		$this->set('message', 'Code and name cannot be blank');
		$this->render('core_error.tpl');
	}

	$prevairline = OperationsData::GetAirlineByCode($this->post->code);
	if($prevairline && $prevairline->id != $this->post->id)
	{
		$this->set('message', 'This airline with this code already exists!');
		$this->render('core_error.tpl');
		return;
	}

	if(isset($this->post->enabled))
		$enabled = true;
	else
		$enabled = false;

	OperationsData::EditAirline($this->post->id, $this->post->code, $this->post->name, $enabled);

	if(DB::errno() != 0)
	{
		$this->set('message', 'There was an error editing the airline');
		$this->render('core_error.tpl');
		return false;
	}

	$this->set('message', 'Edited the airline "'.$this->post->code.' - '.$this->post->name.'"');
	$this->render('core_success.tpl');

	LogData::addLog(Auth::$userinfo->pilotid, 'Edited the airline "'.$this->post->code.' - '.$this->post->name.'"');
}

protected function add_aircraft_post()
{		
	if($this->post->icao == '' || $this->post->name == '' 
		|| $this->post->fullname == ''
		|| $this->post->registration == '')
	{
		$this->set('message', 'You must enter the ICAO, name, full name and the registration.');
		$this->render('core_error.tpl');
		return;
	}

	if($this->post->enabled == '1')
		$this->post->enabled = true;
	else
		$this->post->enabled = false;

	# Check aircraft registration, make sure it's not a duplicate

	$ac = OperationsData::GetAircraftByReg($this->post->registration);
	if($ac)
	{
		$this->set('message', 'The aircraft registration must be unique');
		$this->render('core_error.tpl');
		return;
	}

	$data = array(	
		'icao'=>$this->post->icao,
		'name'=>$this->post->name,
		'fullname'=>$this->post->fullname,
		'registration'=>$this->post->registration,
		'downloadlink'=>$this->post->downloadlink,
		'imagelink'=>$this->post->imagelink,
		'range'=>$this->post->range,
		'weight'=>$this->post->weight,
		'cruise'=>$this->post->cruise,
		'maxpax'=>$this->post->maxpax,
		'maxcargo'=>$this->post->maxcargo,
		'minrank'=>$this->post->minrank,
		'enabled'=>$this->post->enabled
	);

	OperationsData::AddAircaft($data);

	if(DB::errno() != 0)
	{
		if(DB::$errno == 1062) // Duplicate entry
			$this->set('message', 'This aircraft already exists');
		else
			$this->set('message', 'There was an error adding the aircraft');

		$this->render('core_error.tpl');
		return false;
	}

	$this->set('message', 'The aircraft has been added');
	$this->render('core_success.tpl');

	LogData::addLog(Auth::$userinfo->pilotid, 'Added the aircraft "'.$this->post->name.' - '.$this->post->registration.'"');
}

protected function edit_aircraft_post()
{
	if($this->post->id == '')
	{
		$this->set('message', 'Invalid ID specified');
		$this->render('core_error.tpl');
		return;
	}

	if($this->post->icao == '' || $this->post->name == '' 
		|| $this->post->fullname == '' || $this->post->registration == '')
	{
		$this->set('message', 'You must enter the ICAO, name, full name, and registration');
		$this->render('core_error.tpl');
		return;
	}

	$ac = OperationsData::CheckRegDupe($this->post->id, $this->post->registration);
	if($ac)
	{
		$this->set('message', 'This registration is already assigned to another active aircraft');
		$this->render('core_error.tpl');
		return;
	}

	if($this->post->enabled == '1')
		$this->post->enabled = true;
	else
		$this->post->enabled = false;

	$data = array(	
		'id' => $this->post->id,
		'icao'=>$this->post->icao,
		'name'=>$this->post->name,
		'fullname'=>$this->post->fullname,
		'registration'=>$this->post->registration,
		'downloadlink'=>$this->post->downloadlink,
		'imagelink'=>$this->post->imagelink,
		'range'=>$this->post->range,
		'weight'=>$this->post->weight,
		'cruise'=>$this->post->cruise,
		'maxpax'=>$this->post->maxpax,
		'maxcargo'=>$this->post->maxcargo,
		'minrank'=>$this->post->minrank,
		'enabled'=>$this->post->enabled
	);

	OperationsData::EditAircraft($data);

	if(DB::errno() != 0)
	{
		$this->set('message', 'There was an error editing the aircraft');
           $this->render('core_error.tpl');
		return;
	}

	LogData::addLog(Auth::$userinfo->pilotid, 'Edited the aircraft "'.$this->post->name.' - '.$this->post->registration.'"');

	$this->set('message', 'The aircraft "'.$this->post->registration.'" has been edited');
	$this->render('core_success.tpl');
}

protected function add_airport_post()
{

	if($this->post->icao == '' || $this->post->name == '' 
		|| $this->post->country == '' 
		|| $this->post->lat == '' || $this->post->lng == '')
	{
		$this->set('message', 'Some fields were blank!');
		$this->render('core_error.tpl');
		return;
	}

	if($this->post->hub == 'true')
		$this->post->hub = true;
	else
		$this->post->hub = false;

	$data = array(
		'icao' => $this->post->icao,
		'name' => $this->post->name,
		'country' => $this->post->country,
		'lat' => $this->post->lat,
		'lng' => $this->post->lng,
		'hub' => $this->post->hub,
		'chartlink' => $this->post->chartlink,
		'fuelprice' => $this->post->fuelprice
		);

	OperationsData::AddAirport($data);

	if(DB::errno() != 0)
	{
		if(DB::$errno == 1062) // Duplicate entry
			$this->set('message', 'This airport has already been added');
		else
			$this->set('message', 'There was an error adding the airport');

		$this->render('core_error.tpl');
		return;
	}

	/*$this->set('message', 'The airport has been added');
	$this->render('core_success.tpl');*/

	LogData::addLog(Auth::$userinfo->pilotid, 'Added the airport "'.$this->post->icao.' - '.$this->post->name.'"');
}

protected function edit_airport_post()
{
	if($this->post->icao == '' || $this->post->name == '' 
			|| $this->post->country == '' || $this->post->lat == '' || $this->post->lng == '')
	{
		$this->set('message', 'Some fields were blank!');
		$this->render('core_message.tpl');
		return;
	}

	if($this->post->hub == 'true')
		$this->post->hub = true;
	else
		$this->post->hub = false;


	$data = array(
		'icao' => $this->post->icao,
		'name' => $this->post->name,
		'country' => $this->post->country,
		'lat' => $this->post->lat,
		'lng' => $this->post->lng,
		'hub' => $this->post->hub,
		'chartlink' => $this->post->chartlink,
		'fuelprice' => $this->post->fuelprice
	);

	OperationsData::EditAirport($data);

	if(DB::errno() != 0)
	{
		$this->set('message', 'There was an error adding the airport: '.DB::$error);

		$this->render('core_error.tpl');
		return;
	}

	$this->set('message', $icao . ' has been edited');
	$this->render('core_success.tpl');

	LogData::addLog(Auth::$userinfo->pilotid, 'Edited the airport "'.$this->post->icao.' - '.$this->post->name.'"');
}

protected function add_schedule_post()
{	
	if($this->post->code == '' || $this->post->flightnum == '' 
		|| $this->post->deptime == '' || $this->post->arrtime == ''
		|| $this->post->depicao == '' || $this->post->arricao == '')
	{
		$this->set('message', 'All of the fields must be filled out');
		$this->render('core_error.tpl');

		return;
	}

	# Check if the schedule exists
	$sched = SchedulesData::getScheduleByFlight($this->post->code, $this->post->flightnum);
	if(is_object($sched))
	{
		$this->set('message', 'This schedule already exists!');
		$this->render('core_error.tpl');

		return;			
	}

	$enabled = ($this->post->enabled == 'on') ? true : false;

	# Check the distance
	if($this->post->distance == '' || $this->post->distance == 0)
	{
		$this->post->distance = OperationsData::getAirportDistance($this->post->depicao, $this->post->arricao);
	}

	# Format the flight level
	$this->post->flightlevel = str_replace(',', '', $this->post->flightlevel);
	$this->post->flightlevel = str_replace(' ', '', $this->post->flightlevel);

	$this->post->route = strtoupper($this->post->route);
	$this->post->route = str_replace($this->post->depicao, '', $this->post->route);
	$this->post->route = str_replace($this->post->arricao, '', $this->post->route);
	$this->post->route = str_replace('SID', '', $this->post->route);
	$this->post->route = str_replace('STAR', '', $this->post->route);

	$data = array(	'code'=>$this->post->code,
					'flightnum'=>$this->post->flightnum,
					'depicao'=>$this->post->depicao,
					'arricao'=>$this->post->arricao,
					'route'=>$this->post->route,
					'aircraft'=>$this->post->aircraft,
					'flightlevel'=>$this->post->flightlevel,
					'distance'=>$this->post->distance,
					'deptime'=>$this->post->deptime,
					'arrtime'=>$this->post->arrtime,
					'flighttime'=>$this->post->flighttime,
					'daysofweek'=>implode('', $_POST['daysofweek']),
					'price'=>$this->post->price,
					'flighttype'=>$this->post->flighttype,
					'notes'=>$this->post->notes,
					'enabled'=>$enabled);

	# Add it in
	$ret = SchedulesData::AddSchedule($data);

	if(DB::errno() != 0 && $ret == false)
	{
           $this->set('message', 'There was an error adding the schedule, already exists DB error: '.DB::error());
		$this->render('core_error.tpl');
		return;
	}

       $this->set('message', 'The schedule "'.$this->post->code.$this->post->flightnum.'" has been added');
	$this->render('core_success.tpl');

	LogData::addLog(Auth::$userinfo->pilotid, 'Added schedule "'.$this->post->code.$this->post->flightnum.'"');
}

protected function edit_schedule_post()
{
	if($this->post->code == '' || $this->post->flightnum == '' 
		|| $this->post->deptime == '' || $this->post->arrtime == ''
		|| $this->post->depicao == '' || $this->post->arricao == '')
	{
		$this->set('message', 'All of the fields must be filled out');
		$this->render('core_error.tpl');

		return;
	}

	$enabled = ($this->post->enabled == 'on') ? true : false;
	$this->post->route = strtoupper($this->post->route);

	# Format the flight level
	$this->post->flightlevel = str_replace(',', '', $this->post->flightlevel);
	$this->post->flightlevel = str_replace(' ', '', $this->post->flightlevel);

	# Clear anything invalid out of the route
	$this->post->route = strtoupper($this->post->route);
	$this->post->route = str_replace($this->post->depicao, '', $this->post->route);
	$this->post->route = str_replace($this->post->arricao, '', $this->post->route);
	$this->post->route = str_replace('SID', '', $this->post->route);
	$this->post->route = str_replace('STAR', '', $this->post->route);

	$data = array(	'code'=>$this->post->code,
					'flightnum'=>$this->post->flightnum,
					'depicao'=>$this->post->depicao,
					'arricao'=>$this->post->arricao,
					'route'=>$this->post->route,
					'aircraft'=>$this->post->aircraft,
					'flightlevel'=>$this->post->flightlevel,
					'distance'=>$this->post->distance,
					'deptime'=>$this->post->deptime,
					'arrtime'=>$this->post->arrtime,
					'flighttime'=>$this->post->flighttime,
					'daysofweek'=>implode('', $_POST['daysofweek']),
					'price'=>$this->post->price,
					'flighttype'=>$this->post->flighttype,
					'notes'=>$this->post->notes,
					'enabled'=>$enabled);

	$val = SchedulesData::editScheduleFields($this->post->id, $data);
	if(!$val)
	{
		$this->set('message', 'There was an error editing the schedule: '.DB::error());
		$this->render('core_error.tpl');
		return;
	}

	# Parse the route:
	SchedulesData::getRouteDetails($this->post->id, $this->post->route);

	$this->set('message', 'The schedule "'.$this->post->code.$this->post->flightnum.'" has been edited');
	$this->render('core_success.tpl');

	LogData::addLog(Auth::$userinfo->pilotid, 'Edited schedule "'.$this->post->code.$this->post->flightnum.'"');
}

protected function delete_schedule_post()
{
	$schedule = SchedulesData::findSchedules(array('s.id'=>$this->post->id));
	SchedulesData::DeleteSchedule($this->post->id);

	$params = array();
       if(DB::errno() != 0)
	{
		$params['status'] = 'There was an error deleting the schedule';
		$params['error'] = DB::error();
		echo json_encode($params);
		return;
	}

	$params['status'] = 'ok';
	echo json_encode($params);

	LogData::addLog(Auth::$userinfo->pilotid, 'Deleted schedule "'.$schedule->code.$schedule->flightnum.'"');
}
}

And Maincontroller

<?php
/**
* Codon PHP Framework
*	www.nsslive.net/codon
* Software License Agreement (BSD License)
*
* Copyright (c) 2008 Nabeel Shahzad, nsslive.net
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
*    notice, this list of conditions and the following disclaimer.
* 2.  Redistributions in binary form must reproduce the above copyright
*    notice, this list of conditions and the following disclaimer in the
*    documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
*    derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @author Nabeel Shahzad
* @copyright Copyright (c) 2008, Nabeel Shahzad
* @link http://www.nsslive.net/codon
* @license BSD License
* @package codon_core
*/

class MainController
{
public static $ModuleList = array();
public static $activeModule;
private static $stop_execute = false;
private static $listSize;
private static $keys = array();	

public static $page_title;

public static function loadEngineTasks()
{		
	CodonRewrite::ProcessRewrite();
	Vars::setParameters();

	self::$activeModule = strtoupper(CodonRewrite::$current_module);
	Config::loadSettings();
	self::loadModules();
}

/**
 * Search for any modules in the core/modules directory
 * 	Then call loadModules() after building the list
 *
 * @param string $path Base folder from where to run modules
 */
protected static function getModulesFromPath($path)
{
	$dh = opendir($path);

	while (($file = readdir($dh)) !== false)
	{
	    if($file != "." && $file != "..")
	    {
	    	if(is_dir($path.'/'.$file))
	    	{
				$fullpath = $path . DS . $file . DS . $file . '.php';

				if(file_exists($fullpath))
				{
					$file = strtoupper($file);
					$modules[$file] = $fullpath;
				}
			}
	    }
	}

	closedir($dh);
	return $modules;
}

/**
 * Load and initialize any modules from a list
 *
 * @param array $ModuleList List of modules. $key is name, $value is path
 */
public static function loadModules()
{
	global $NAVBAR;
	global $HTMLHead;

	self::$ModuleList = self::getModulesFromPath(CODON_MODULES_PATH);
	if(empty(self::$ModuleList))
	{
		Debug::showCritical('No modules were found in module path! ('.CODON_MODULES_PATH.')');
		return;
	}

	self::$listSize = sizeof(self::$ModuleList);
	self::$keys = array_keys(self::$ModuleList);

	for ($i=0; $i<self::$listSize; $i++)
	{
		$ModuleName = self::$keys[$i];
		$ModuleController = self::$ModuleList[$ModuleName];

		if(file_exists($ModuleController))
		{
			include_once $ModuleController;

			if(class_exists($ModuleName))
			{
				$ModuleName = strtoupper($ModuleName);
				global $$ModuleName;

				$$ModuleName = new $ModuleName();
				$$ModuleName->init($ModuleName); // Call the parent constructor

				if(self::$activeModule == $ModuleName)
				{
					# Skip it for now, run it last since it's the active
					#	one, and may overwrite some other parameters
					continue;
				}
				else
				{
					ob_start();
					self::Run($ModuleName, 'NavBar');
					$NAVBAR .= ob_get_clean();

					self::Run($ModuleName, 'HTMLHead');
					$HTMLHead .= ob_get_clean();

					@ob_end_clean();
				}
			}
		}
	}

	# Run the init tasks
	ob_start();
	self::Run(self::$activeModule, 'NavBar');
	$NAVBAR .= ob_get_clean();

	self::Run(self::$activeModule, 'HTMLHead');
	$HTMLHead .= ob_get_clean();

	@ob_end_clean();
}

/**
 * Return an instance of the module/controller specified
 * 
 */
public static function getInstance($module)
{
	$ModuleName = strtoupper($module);
	global $$ModuleName;

	// Make sure this module is valid
	if(!is_object($$ModuleName))
	{	
		return false;
	}

	return $$ModuleName;
}

/**
 * This runs the Controller() function of all the
 * 	modules, and gives priority to the module passed
 *	in the parameter
 *
 * @param string $module_priority Module that is called first
 * 
 * Change - Oct 2009
 *	Makes this more "cake-esque" - check if the "Controller" function
 *	exists (for backwards compat), if it doesn't then run the function
 *	defined by the "action" bit in the URL
 */
public static function RunAllActions()
{
	//$call_function = 'Controller';
	$ModuleName = strtoupper(self::$activeModule);
	global $$ModuleName;

	// Make sure this module is valid
	if(!is_object($$ModuleName))
	{	
		Debug::showCritical("The module \"{$ModuleName}\" doesn't exist!");
		return;
	}

	// Check if we have a function for the page we are calling
	$name = CodonRewrite::$current_action;
	if($name == '')
	{
		$call_function = 'index';
	}
	else
	{
		$call_function = $name;
	}

	/* Don't call self::Run() - parameters could change. They have to stay the same
		due to the fact that outside modules, etc will still use Run(), so it has
		to stay the same */

	$ret = call_user_func_array(array($$ModuleName, $call_function), CodonRewrite::$params);

	/* Set the title, based on what the module has, if it's blank,
		then just set it to the module name */
	self::$page_title = $$ModuleName->title;
	if(strlen(self::$page_title) === 0)
	{
		self::$page_title = ucwords(strtolower($ModuleName));
	}

	return true;	
}

/**
 * Call a specific function in a module
 *	Function accepts additional parameters, and then passes
 *	those parameters to the function which is being called.
 *
 * @param string $ModuleName Name of the module to call
 * @param string $MethodName Method in the module to call
 * @return value
 */
public static function Run($ModuleName, $MethodName)
{
	$ModuleName = strtoupper($ModuleName);
	global $$ModuleName;

	// have a reference to the self
	if(!is_object($$ModuleName) || ! method_exists($$ModuleName, $MethodName))
	{
		return false;
	}

	// if there are parameters added, then call the function
	//	using those additional params
	$args = func_num_args();
	if($args>2)
	{
		$vals=array();
		for($i=2;$i<$args;$i++)
		{
			$param = func_get_arg($i);
			array_push($vals, $param);
		}

		return call_user_func_array(array($$ModuleName, $MethodName), $vals);
	}
	else
	{
		//no parameters, straight return
		return $$ModuleName->$MethodName();
	}
}

/**
 * This stops execution of additional modules when
 * 	RunAllActions() is being called. After the current
 *	module is called, no more of them will be called
 *	afterwards
 */
public static function stopExecution()
{
	self::$stop_execute = true;
}

/**
 * Seperate function because it will be expanded with API
 *	later on when the install routines, etc are included
 *	just makes sure the module is a valid one in the module's list
 *
 * @param string $Module See if $Module is a valid, initilized module
 */
protected static function valid_module($Module)
{
	if(self::$ModuleList[$Module] != '')
		return true;

	return false;
}

/**
 * Return the list of loaded modules
 *
 * @return array List of active modules
 */
public static function getModuleList()
{
	return self::$ModuleList;
}
}	

Link to comment
Share on other sites

You didn´t have inserted the mod correctly! phpvms folder is your lausitzair folder! before you insert, you must rename it phpvms to lausitzair. The error is normal, because its something missing... Overwrite the files then. And for the next time a - read the "readme" !

This mod isn`t finished yet and only for test and development released!

Posted 31 August 2011 - 06:18 PM

thanks :) Danke!!

another considerable idea could be an lease option monthly rates in expenses dont know if that is possible?

i run your mod in an test install of phpvms but as soon all is completed I will definately implement to my operative VA

http://www.flyeurope-va.org

best regards from Vienna, Austria

Thomas

Link to comment
Share on other sites

Hi

Nighthawk. Ich hab die Readme schon gelesen....aber es...Kannst du mir eventuell über icq helfen........Ich glaub das ist die beste Lösung

Kannst mich adden unter 222552352

danke dir schon mal im vorraus

The only thing I was able to make of that is "Nighthawk" :unsure:

Link to comment
Share on other sites

Sorry,, i have again a error,,

Okay, i buy a plane, en than:

Warning: call_user_func_array() expects parameter 1 to be a valid callback, class 'Operations' does not have a method 'buysellaircraft' in /home/airopavi/public_html/core/classes/MainController.class.php on line 218

This is my PHPVMS BETA VERSION: that is te last update that i found..

License & About | Version v2.1.934-163-g97231fb

Link to comment
Share on other sites

Nightgwawk, the files is on the just place. (admin/modules/Buysell/Buysell.php) i have install the files to my phpvms and the mysql in mysql database!

i have install correct!:) but i have only the error when i buy a aircraft, and de price is: 0,00

Warning: call_user_func_array() expects parameter 1 to be a valid callback, class 'Operations' does not have a method 'buysellaircraft' in /home/airopavi/public_html/core/classes/MainController.class.php on line 218

Do you have the solution? :rolleyes:

Link to comment
Share on other sites

hm try to replace this in /admin/modules/Buysell in Buysell.php :

class buysell extends CodonModule

with

class Buysell extends CodonModule

best regards

Thomas

It now not working,, its same error.. <_< maybe you with teamviewer, see what the problem is with me? or i send the files to you? with mediafire? wait i upload my files, than can you look, if you want?

Michael

Link to comment
Share on other sites

You where to fast , the link above wasnt actual to 0.91 !!!!

This patch fix the problems THANSK! :lol: :lol: Only one think the price is 0 dollar.. haha thats only probleem, (I enter all data from the aircraft at the site)

0,00� that stands to me as the price :o

Edited by michael Kraan
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...