Jump to content

Insert A/C id into bids table


Parkho

Recommended Posts

  • Moderators

Hello there

Okay! I've been trying to change the codes in a way to add the A/C id to the bids table in DB. Here is what i've done so far:

1- Added one column to bids table as "aircraftid".

2- changed the code in ScheduleData.class.php/ Add Bid section as follows:

public function setBidOnSchedule($scheduleid, $bidid, $aircraftid)
{
	$scheduleid = intval($scheduleid);
	$bidid = intval($bidid);
	[color="#FF0000"]$aircraftid = intval($aircraftid);[/color]

	$sql = 'UPDATE '.TABLE_PREFIX.'schedules
			SET `bidid`='.$bidid.'
			[color="#FF0000"]SET `aircraftid`='.$aircraftid.'[/color] 
			WHERE `id`='.$scheduleid;

	DB::query($sql);

	if(DB::errno() != 0)
		return false;

	return true;
}
/**
 * Add a bid
 */		
public static function addBid($pilotid, $routeid, [color="#FF0000"]$aircraftid[/color])
{
	$pilotid = DB::escape($pilotid);
	$routeid = DB::escape($routeid);
	$aircraftid = DB::escape($aircraftid);
	if(DB::get_row('SELECT bidid FROM '.TABLE_PREFIX.'bids
			WHERE pilotid='.$pilotid.' AND routeid='.$routeid.' AND aircraftid='.$aircraftid ))
	{
		return false;
	}

	$pilotid = DB::escape($pilotid);
	$routeid = DB::escape($routeid);
	$aircraftid = DB::escape($aircraftid);

	$sql = 'INSERT INTO '.TABLE_PREFIX.'bids (pilotid, routeid, dateadded)
			VALUES ('.$pilotid.', '.$routeid.', '.$aircraftid.', NOW())';

	DB::query($sql);

	self::setBidOnSchedule($routeid, $aircraftid, DB::$insert_id);

	if(DB::errno() != 0)
		return false;

	return true;
}

3- Changed the code in schedules.php as follows:

public function addbid()
{
	if(!Auth::LoggedIn()) return;

	$routeid = $this->get->id;
	$aircraftid = $this->get->id;

	if($routeid == '' && $aircraftid == '')
	{
		echo 'No route passed';
		return;
	}

	// See if this is a valid route
	$route = SchedulesData::findSchedules(array('s.id' => $routeid));

	if(!is_array($route) && !isset($route[0]))
	{
		echo 'Invalid Route';
		return;
	}

	CodonEvent::Dispatch('bid_preadd', 'Schedules', $routeid);

	/* Block any other bids if they've already made a bid
	 */
	if(Config::Get('DISABLE_BIDS_ON_BID') == true)
	{
		$bids = SchedulesData::getBids(Auth::$userinfo->pilotid);

		# They've got somethin goin on
		if(count($bids) > 0)
		{
			echo '<img src="http://alvandair.com/lib/skins/aqua/images/BookingButt/Exist_.png" border="0">';
			return;
		}
	}

	$ret = SchedulesData::AddBid(Auth::$userinfo->pilotid, $routeid, $aircraftid);
	CodonEvent::Dispatch('bid_added', 'Schedules', $routeid, $aircraftid);

	if($ret == true)
	{
		echo '<img src="http://alvandair.com/lib/skins/aqua/images/BookingButt/Booked.png" border="0">';
	}
	else
	{
		echo '<img src="http://alvandair.com/lib/skins/aqua/images/BookingButt/Next.png" border="0">';
	}
}

Now I need help since these changes doesn't insert the A/C id into the DB. Please tell me where I'm wrong.

Thanks

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...