All pastes #342179 Raw Edit

bkudria

public php v1 · immutable
·published 2007-02-06 03:58 UTC
rendered paste body
function calcPrice($conf, $data, $paymentData, $promo = null){				// Conf Type	$full = false;		// Prices	$discount = $promo;	$newPrice = 0;	$originalPrice = 0;	$lunchPrice = 0;		// Number of days	$days = 0;		// Number of Meals	$nMeals = 0;		// Dates	$today = time();	$cutOff = strtotime($conf['early_cutoff_date']);		// Get individual days		if (!$full)	{		for ($x = 1; $x <= 3; $x++)		{			if ($data['day_' . $x] == 1)				$days++;		}	}	// Get Luncheons prices	$query = execsql("SELECT * FROM meals WHERE conf_id = {$data['conf_id']}");	while($fetch = mysql_fetch_array($query))		$meals[] = $fetch;			// Add Luncheons		for ($k = 1; $k <= 3; $k++)	{		if ($data['meal_' . $k] == 1)		{			$lunchPrice = $lunchPrice + $meals[$k - 1]['fee'];			$nMeals++;		}	}			// Complete Conference?		switch ($data['full_tuition'])	{		case 1:			$full = true;			$originalPrice = $conf['full_conf_cost'] + $lunchPrice;			$earlybirdrate = $conf['early_discount'];			$days = 3;			break;		case 0:			$full = false;			// Get single day prices			$query = execsql("SELECT * FROM days WHERE conf_id = {$data['conf_id']}");			while($temp = mysql_fetch_array($query))				$single[] = $temp;						for ($z = 0; $z < $days; $z++)			{				$originalPrice = $originalPrice + $single[$z]['single_fee'];				$earlybirdrate = $earlybirdrate + $single[$z]['early_discount'];			}							$originalPrice = $originalPrice + $lunchPrice;						break;	}			$prices['meal_price'] = $lunchPrice;	$prices['new'] = $originalPrice;		// Early Bird Rate	if($today < $cutOff and (empty($promo['code']) or strtolower($promo['code']) == 'none') and ($data['payment_method'] != 'Paper Registration'))	{						// With fixes for Crucial #1 		$prices['new'] = $originalPrice - $earlybirdrate - 25 ;		$prices['discount'] = $earlybirdrate + 25;		$prices['early_discount'] = $conf['early_discount'];	}			// Promo		elseif (strtolower($promo['code']) != 'none')	{				if ($full)		{ 			$prices['new'] = $originalPrice - $promo['discount_full_conf'] - 25;			$prices['discount'] = $promo['discount_full_conf'];		}					elseif(!$full)		{			$prices['new'] = $originalPrice - (($promo['discount_single_day'] * $days))- ($days * 25);			$prices['discount'] = ($promo['discount_single_day'] * $days);		}							$prices['promo_discount'] = $prices['discount'];	}		// CC payment			/*if ($data['payment_method'] == 'Credit Card')	{		if ($full)			$cc = $paymentData['discount_full_conf'];					elseif (!$full)			$cc = $paymentData['discount_single_day'] * $days;					$prices['payment_discount'] = $cc;	}				else */	$cc = 0;	print_r($prices);		// Prices			$prices['original'] = $originalPrice;	$prices['discount'] = $prices['discount'] + $cc;	$prices['new'] = $prices['new'] - $cc;	$prices['days'] = $days;	$prices['meals'] = $nMeals;	$prices['promo'] = strtolower($promo['code']) != 'none';	if ($data['payment_method'] == 'Paper Registration')	{		if ($full)			$prices['original'] = $prices['original'] + $paymentData['discount_full_conf'];					elseif (!$full)			$cc = $prices['original'] + $paymentData['discount_single_day'] * $days;	}		return $prices;}