<?php

/*

  osCommRes, Services Online
  http://www.oscommres.com

  Copyright (c) 2005 osCommRes

  Released under the GNU General Public License
  
  Freeway eCommerce from ZacWare
http://www.zac-ware.com/freeway

Copyright 2007 ZacWare Pty. Ltd
*/
// Set flag that this is a parent file
	define( '_FEXEC', 1 );

	require('includes/application_top.php');
	require(DIR_WS_CLASSES . 'currencies.php');
	require(DIR_WS_CLASSES . 'order.php');
	require(DIR_WS_CLASSES . 'ot_coupon.php');
	require(DIR_WS_CLASSES . 'payment.php');
	require(DIR_WS_CLASSES . 'order_total.php');
	$currencies=new currencies();
	$cart=new shoppingcart();
	//echo $HTTP_GET_VARS['oID'];
	$oID=(int)$edit_order;
	if($HTTP_GET_VARS['do_action']=='get_counpon_details'){ 
		$HTTP_POST_VARS['coupon']=$HTTP_GET_VARS['coupon'];
		$HTTP_POST_VARS['gv_redeem_code']=$HTTP_GET_VARS['gv_redeem_code'];
		if ($credit_covers) $payment=''; //ICW added for CREDIT CLASS
		$payment_modules = new payment($payment);
		$payment_modules->update_status();
	    $order = new order($oID,true);
		  $coupon_class=new ot_coupon;
		  $coupon_class->collect_posts();
		if(isset($GLOBALS['coupon_size'])){
			$coupon=$GLOBALS['coupon_size'];
			$error="";
			$error=$GLOBALS['coupon_error'];
			if($coupon_class->code=='ot_coupon' && !$error && $coupon_class->output_value>0){
				echo '<table border="0" width="90%" cellspacing="3" cellpadding="3" class="formArea" align="center">' .
				'<tr><td></td>' .
				'   <td class="main">'.TEXT_REDEEM_CODE. $coupon_class->coupon_code.'</td>' .
				'   <td class="main">'.TEXT_VALUE. $currencies->format($coupon_class->output_value).'</td>' .
				'</tr>' . 
				'<tr><td></td>' .
				'   <td class="main">'.TEXT_VALID_UTIL. $coupon_class->expire_date.'</td>' .
				'   <td class="main">'.(($coupon_class->uses_per_user!=0)?TEXT_USES_REMAIN .$coupon_class->uses_per_user:'').'</td>' .
				'<td rowspan="2" valign="middle" align="right">'.tep_image_button('button_dont_redeem.gif','','style="cursor:pointer;cursor:hand" onclick="javascript:submitFunction(1);"').'</td>'.
				'</tr>' .   					
				'</table>';
			} else { 
				if(!$error) $error=ERROR_NO_INVALID_REDEEM_COUPON;
				echo '<table border="0" width="90%" align="center" cellspacing="0" cellpadding="0"><tr align="center"><td align="left" class="smalltext"><span class="errortext">'.$error.'</span></td></tr>';
			}
		}else{
			$error=$GLOBALS['coupon_error'];
				//if(!$error) $error=ERROR_NO_INVALID_REDEEM_COUPON;
				echo '<table border="0" width="90%" align="center" cellspacing="0" cellpadding="0"><tr align="center"><td align="left" class="smalltext"><span class="errortext">'.$error.'</span></td></tr>';
				
		}
		exit;
	}
	
	if (!tep_session_is_registered('edit_order') || ((int)$edit_order<=0))
		tep_redirect(tep_href_link(FILENAME_ORDERS));
  $detail_only=(isset($HTTP_POST_VARS["detail_only"])?$HTTP_POST_VARS["detail_only"]:0);
  if ($detail_only!=1){
	  if (!tep_session_is_registered('payment')) tep_session_register('payment');
	  if (isset($HTTP_POST_VARS['payment'])) $payment = $HTTP_POST_VARS['payment'];
	// load the selected payment module
	
	
	  $payment_modules = new payment($payment);
	  
	  if ( (is_array($payment_modules->modules)) && (sizeof($payment_modules->modules) > 1) && (!is_object($$payment))) {
		tep_redirect(tep_href_link(FILENAME_EDIT_ORDERS, 'error_message=' . urlencode(ERROR_NO_PAYMENT_MODULE_SELECTED) . '&oID=' . $oID . '&step=4', 'SSL'));
	  }
		if (!tep_session_is_registered('payment_page')) tep_session_register('payment_page');
		$payment_page='edit_orders';

      tep_session_register('payment_params');
	   $payment_params='&oID=' . $oID . '&step=4';

	  // get the customer_id
	  $customer_query=tep_db_query("SELECT customers_id from " . TABLE_ORDERS . " o where o.orders_id='" . (int)$oID . "'");
	  $customer_result=tep_db_fetch_array($customer_query);
	  $customer_id=(int)$customer_result["customers_id"];
	  $amount=$HTTP_POST_VARS['amount'];
	  $tax_amount=$HTTP_POST_VARS['tax_amount'];
	  $order=new order($oID,true);
	  $order->info['total']=$amount;
	  $order->info['tax']=$tax_amount;
	  if ( (is_array($payment_modules->modules)) && (sizeof($payment_modules->modules) > 1) && (!is_object($$payment))) {
		tep_redirect(tep_href_link(FILENAME_EDIT_ORDERS, 'error_message=' . urlencode(ERROR_NO_PAYMENT_MODULE_SELECTED) . '&oID=' . $oID . '&step=4', 'SSL'));
	  }
	   
	//ICW ADDED FOR CREDIT CLASS SYSTEM
	  if($HTTP_POST_VARS['coupon']==1){
		  $coupon_class=new ot_coupon;
		  $coupon_class->collect_posts();
		  if(isset($GLOBALS['coupon_size'])){
			$error=$GLOBALS['coupon_error'];
			/*if($error)
			{
				tep_redirect(tep_href_link(FILENAME_EDIT_ORDERS, 'error_message=' . urlencode($error) . '&oID=' . $oID . '&step=4', 'SSL'));
			}*/
		 }
	  }

	  $order_total=$amount;
	  $deduction=0;
	  if($HTTP_POST_VARS['coupon']==1){
	  	  $deduction=$coupon_class->pre_confirmation_check($order_total);
		  
	  }
      $total_deductions = $total_deductions + $deduction;
      $order_total = $order_total - $deduction_amount;
      if ($order->info['total'] - $total_deductions <= 0 ) { 
          $credit_covers = true; 
      }	  
	  	  
	  if (is_array($payment_modules->modules)) {
		$payment_modules->pre_confirmation_check();
	  } 
	  
	   if (!tep_session_is_registered('payment_page')) tep_session_register('payment_page');
	  $payment_page='edit_orders';

       tep_session_register('payment_params');
	   $payment_params='&oID=' . $oID . '&step=4';
	  
	  ?>
	
	<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script language="javascript" src="includes/general.js"></script>
<?php 	include('includes/date_format_js.php'); ?>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<!-- header //-->
<?php
    require(DIR_WS_INCLUDES . 'header.php');
?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
	<tr>
		<!-- body_text //-->
		<td width="100%" valign="top">
			<table border="0" width="100%" cellspacing="2" cellpadding="2">
				<tr>
					<!--<td class="pageHeading"><!--<font class=pageheading_alt><?php //echo TEXT_CREATE_ORDER;?> > </font><font class=pageheading><?php //echo TEXT_HEADING_CONFIRMATION;?></font></td>!-->
				</tr>
				<tr>
				<td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
				  <tr>
					<td ><font class=main><b><?php echo TEXT_CUSTOMER; ?></b></font><font class="contentTitle"  size="5"><?php echo $order->customer['name']; ?></font></td>
					<td  align="right"><?php echo tep_draw_separator('pixel_trans.gif', 1, HEADING_IMAGE_HEIGHT); ?></td>
				  </tr>
				</table></td>
			  <tr>
			  <tr><td class="infoBoxHeading">&nbsp;</td></tr>

				<tr>
					<td>
						<table border="0" cellpadding="0" cellspacing="5" width="90%"  >
							<tr>
								<td class="main" colspan="2"><b><?php echo 'Address'; ?></b></td>
							</tr>
							<tr>
							
								<td colspan=2>
								   <table border="0" width="100%" cellspacing="0" cellpadding="2" class="infoBox">
										<tr class="infoBoxContents">
											<td width="200" valign="top">
												<table border="0" width="100%" cellspacing="0" cellpadding="2">
													<tr>
														<td class="main"><?php echo '<b>' . HEADING_DELIVERY_ADDRESS . '</b>' ; ?></td>
													</tr>
													<tr>
														<td class="main"><?php echo tep_address_format($order->delivery['format_id'], $order->delivery, 1, ' ', '<br>');?></td>
													</tr> 
												</table></td>
											<td width="600" valign="top">
												<table border="0" width="100%" cellspacing="0" cellpadding="2">
													<tr>
														<td>
															<table border="0" width="100%" cellspacing="0" cellpadding="2">
																<tr>
																	<td class="main" colspan="3"><?php echo '<b>' . HEADING_PRODUCTS . '</b>'; ?></td>
																</tr>
																<?php 
																	$products_name="";
																	$products = "";
																	$products_names_p="";
																	$pre_qty="";
																	$pre_name="";
																	$qty_p = "";
																	$pre_sign="";
																	$first_event = true;
																	$first_event_id = 0;
																	for ($i=0, $n=count($order->products); $i<$n; $i++) {
																		
																		$products_names_p="";
																		$qty_p = "";
																		$sign_p="";
																		$model="";
																		if($order->products[$i]['products_type'] == "E"){ 
																		$model = "";
																		   if($order->products[$i]['model'] !="")
																			  $model .= format_date($order->products[$i]['model']) . ", ";
																		} 
																		if(($pre_name!=$order->products[$i]['name']) && ($order->products[$i]['products_type']=="E")){
																				$products_names_p = $order->products[$i]['name'] . "<br>" . tep_draw_separator('pixel_trans.gif','20','10');
																				$pre_name=$order->products[$i]['name'];	
																				$qty_p=$order->products[$i]['qty'];
																				$pre_qty=$order->products[$i]['qty']; 
																				$sign_p="X";
																				$pre_sign="X";
																		 }else if($order->products[$i]['products_type']=="V"){
																		  $products_names_p = $order->products[$i]['name'];
																		  $qty_p=$order->products[$i]['qty'];
																		  $sign_p="X";
																			  if($order->products[$i]['model'])
																				$model= $order->products[$i]['model'];
																		  }else if($order->products[$i]['products_type']=="S"){ 
																		  $products_names_p = $order->products[$i]['name'];
																		  $qty_p=$order->products[$i]['qty'];  
																		  $sign_p="X"; 
																			  if($order->products[$i]['model'])
																				$model= " , " . $order->products[$i]['model'];
																		  }else if($order->products[$i]['products_type']=="P"){ 
																		  $products_names_p = $order->products[$i]['name'];
																		  $qty_p=$order->products[$i]['qty'];
																		  $sign_p="X";
																			  if($order->products[$i]['model'])
																				 $model= $order->products[$i]['model'];
																		  }
																		$rax_total=tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']) * $order->products[$i]['qty'];
																		$sku = $order->products[$i]['sku'];
																		$event_id = 0;
																		if($order->products[$i]['products_type']=='E'){
																			$event_id = $order->products[$i]['event_id'];
																			if($first_event){ 
																				$first_event_id = $order->products[$i]['event_id'];
																				$first_event = false;
																			}
																		} 
																		$products[] = array( "qty" => $qty_p,
																							 "sign"  => $sign_p,
																							 "id" => $order->products[$i]['id'],
																							 "products_type" => $order->products[$i]['products_type'],
																							 "p_name"	 => $products_names_p,
																							 "event_id" => $event_id,
																							 "model" => $model,
																							 "sku" => $sku,
																							 "row_total"=>$rax_total
																						   ); 
																   		}
																		$session_dates = "";
																		$event_id = $first_event_id;
																		$date = array();
																		$events_row_total = array(); $jj=0;
																		for ($i = 0, $n = sizeof($products); $i < $n; $i++) { 
																			if(($products[$i]['products_type']=="E")){
																				if($event_id!=$products[$i]['event_id']){
																					$event_id=$products[$i]['event_id'];
																					$session_dates = "";
																				}
																				$session_dates .= $products[$i]['model']; 
																				$date[$products[$i]['event_id']] = substr($session_dates,0,-2); 
																				$events_row_total[$products[$i]['event_id']] += $products[$i]['row_total'];	
																				}
																		} 
																		
																		$date_keys = array_keys($date);
																		$date_keys_length = count($date_keys);
																		for($i=0;$i<$date_keys_length;$i++){
																			$final_date='';
																			$var_date = $date[$date_keys[$i]];
																			$date_split = split(',',$var_date);
																			$date_split_count = count($date_split);
																			
																			for($j=0;$j<$date_split_count;$j++){
																				$final_date .= $date_split[$j].',';
																				$m=$j+1;
																				if($m%4==0)	$final_date = substr($final_date,0,-1) . '<br>&nbsp;&nbsp;&nbsp;&nbsp;';
																			}
																			$date[$date_keys[$i]] = substr($final_date,0,-1);
																		} 
																			
																		$event_id = 0;
																		for ($i = 0, $n = sizeof($products); $i < $n; $i++) {
																			 if($products[$i]['products_type']=="P"){
																				$row_total= $products[$i]['row_total'];			
																				$date="";
																			}else if($products[$i]['products_type']=="S"){
																				$row_total= $products[$i]['row_total'];
																				   if($products[$i]['model']!="")
																					$date=$products[$i]['model'];	
																			}else if($products[$i]['products_type']=="V"){
																				$row_total= $products[$i]['row_total'];
																				   if($products[$i]['model']!="")
																				   $date=$products[$i]['model'];
																			}  
																		if($event_id!=$products[$i]['event_id'] || $products[$i]['products_type']!='E'){
																			if($products[$i]['products_type']=='E'){
																				$row_total = $events_row_total[$products[$i]['event_id']];
																			} 
																			$model = "";
																			if(($products[$i]['products_type']=="S"))
																			   if($products[$i]['model']!="")
																				 $model = $products[$i]['model'];
																				 
																			$event_id = $products[$i]['event_id'];	
																		
																		echo '          <tr>' . "\n" .
																			 '            <td class="main" align="right" valign="top" width="30">' . "&nbsp;" . $products[$i]['qty'] . "&nbsp;&nbsp;" . $products[$i]['sign'] . '&nbsp; </td>' . "\n" .
																			 '            <td class="main" width="80%"  valign="top">' . $products[$i]['p_name'] . $model ;
																		if ($order->products[$i]['products_type']=="V"){
																			if($order->products[$i]['others']['end_date'] && $order->products[$i]['others']['end_time']){	
																				$str_time=strtotime($order->products[$i]['others']['end_date'] .' '.$order->products[$i]['others']['end_time'])+60;
																				$order->products[$i]['others']['end_date']=date('Y-m-d',$str_time);
																				$order->products[$i]['others']['end_time']=date('H:i:s',$str_time); 
																			}
																																																										
																			if($order->products[$i]['others']['resource_id']!='') $resource_costs=tep_add_tax(tep_get_resource('resource_costs',$order->products[$i]['others']['resource_id'],$languages_id),$order->products[$i]['tax']);
																			echo '<br><small><i>&nbsp;	- '.TEXT_START_DATE.' : '. format_date($order->products[$i]['others']['start_date']) . '&nbsp;' . (($order->products[$i]['others']['start_time'])?date("h:i A",strtotime($order->products[$i]['others']['start_time'])):'') . ' <br>&nbsp; - ' . TEXT_END_DATE .' : ' . format_date($order->products[$i]['others']['end_date']). '&nbsp;' . (($order->products[$i]['others']['end_time'])?date("h:i A",strtotime($order->products[$i]['others']['end_time'])):'') . ' '.(($order->products[$i]['others']['resource_id'])? '<br>&nbsp; - '.tep_get_resource_name($order->products[$i]['others']['resource_id'],'resource_name').'('.$currencies->format($resource_costs).')':'').'</i></small>';																			
																			
																		}
																		else if($order->products[$i]['products_type']=="E"){
																			echo "<small><i>" . $date[$event_id]  . "</i></small>";
																		}
																		if (isset($order->products[$i]['attributes']) && is_array($order->products[$i]['attributes'])) {
																			reset($order->products[$i]['attributes']);
																			$attribute_id="";
																			for($k=0,$att_max=sizeof($order->products[$i]['attributes']);$k<$att_max;$k++) {
																				$att_row=$order->products[$i]['attributes'][$k];
																				if($attribute_id!="")
																					$attribute_id.="-";
																				$attribute_id.=$att_row['option_id'] . "{" . $att_row['value_id'] . "}";
																			}
																			for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {
																				if($order->products[$i]['attributes'][$j]['option'] && $order->products[$i]['attributes'][$j]['value'])  echo '<br><nobr><small>&nbsp;<i> - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value'] . '('.$currencies->format(tep_add_tax($order->products[$i]['attributes'][$j]['price'],$order->products[$i]['tax'])).')</i></small></nobr>';
																			}
																		}
																		echo '</td>' . "\n";
																		echo '            <td class="main" align="right" valign="top">' . $currencies->format($row_total, true, $order->info['currency'], $order->info['currency_value'])  . '</td>' . "\n" .
																		'          </tr>' . "\n";
																		
																		if ($order->products[$i]['products_type']=="P" && $order->products[$i]['sku']!=''){
																			echo '<tr><td></td><td colspan="2" class="main"><b>'. TEXT_SKU . '</b>'. $order->products[$i]['sku'] . '</td></tr>';
																		}
																	}
																 }	
																?>
															</table>
														</td>
													</tr>
												</table>
											</td>
										</tr>
									</table>
								</td>
							</tr>
							<tr>
								<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
							</tr>
							<tr>
								<td class="main" colspan="2"><b><?php echo HEADING_BILLING_INFORMATION; ?></b></td>
							</tr>
							<tr>
								<td colspan="2">
									<table border="0" width="100%" cellspacing="0" cellpadding="2" class="infoBox">
										<tr class="infoBoxContents">
											<td width="300" valign="top">
												<table border="0" width="100%" cellspacing="0" cellpadding="2">
													<tr>
														<td class="main"><?php echo '<b>' . HEADING_BILLING_ADDRESS . '</b>'?></td>
													</tr>
													<tr>
														<td class="main"><?php echo tep_address_format($order->billing['format_id'], $order->billing, 1, ' ', '<br>'); ?></td>
													</tr>
													<?php  /*if(($order_total-$deduction) > 0){?>
													<tr>
														<td class="main"><br><?php echo '<b>' . HEADING_PAYMENT_METHOD . '</b>'; ?></td>
													</tr>
													<tr>
														<td class="main"><?php echo $GLOBALS[$payment]->title; ?></td>
													</tr>
													<?php }*/?>
												</table>
											</td>
											<td width="300" valign="top" align="left">
												<table border="0" cellspacing="0" cellpadding="2" width="100%">
													<tr>
														<td align="right">
															<table border="0" cellspacing="0" cellpadding="2" width="100%">
																<?php
																echo '<tr>' . "\n" .
																'                <td align="right" class="main" width="70%">' . TEXT_SUBTOTAL . '</td>' . "\n" .
																'                <td align="right" class="main">' . $currencies->format($amount) . '</td>' . "\n" .
																'              </tr>';
																echo '<tr>' . "\n" .
																'                <td align="right" class="main">' . TEXT_TAX . '</td>' . "\n" .
																'                <td align="right" class="main">' . $currencies->format($tax_amount) . '</td>' . "\n" .
																'              </tr>';
																$order->info['total']=$amount;
																$output_string=""; 
																if($HTTP_POST_VARS['coupon']==1){
																	$coupon_class->process(); 
																	$size = sizeof($coupon_class->output);
																	for ($i=0; $i<$size; $i++) {
																		$output_string .= '              <tr>' . "\n" .
																		'                <td align="right" class="main" nowrap>' . $coupon_class->output[$i]['title'] . '</td>' . "\n" .
																		'                <td align="right" class="main">' . $coupon_class->output[$i]['text'] . '</td>' . "\n" .
																		'              </tr>';
																	}
																}
																echo $output_string;
																$get_ord_total = $coupon_class->get_order_total;
																if($size>0)
																{   
																	if($get_ord_total < $deduction) { 
																		$order_total = $order_total - $get_ord_total;
																	}
																	if($get_ord_total > $deduction) $order_total = $order_total-$deduction;
																	if($order_total < 0) $order_total=0;
																}
																	echo '<tr>' . "\n" .
																	'                <td align="right" class="main">' . TEXT_TOTAL . '</td>' . "\n" .
																	'                <td align="right" class="main"><b>' . $currencies->format($order_total) . '</b></td>' . "\n" .
																	'              </tr>';
																?>
															</table>
														</td>
													</tr>
												</table>
											</td>
										</tr>
									</table>
								</td>
							</tr>
							<?php
							// BOF: Lango modified for print order mod
							if (is_array($payment_modules->modules)) {
								if ($confirmation = $payment_modules->confirmation()) {
									$payment_info = $confirmation['title'];
									if (!tep_session_is_registered('payment_info')) tep_session_register('payment_info');
							// EOF: Lango modified for print order mod
							?>
							<tr>
								<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
							</tr>
							<tr>
								<td class="main" colspan="2"><b><?php echo HEADING_PAYMENT_INFORMATION; ?></b></td>
							</tr>
							<tr>
								<td colspan="2">
									<table border="0" width="100%" cellspacing="0" cellpadding="2" class="infoBox">
										<tr class="infoBoxContents">
											<td>
												<table border="0" cellspacing="0" cellpadding="2">
													<?php  if(($order_total-$deduction) > 0){?>
													<tr>
														<td class="main"><?php echo '<b>' . HEADING_PAYMENT_METHOD . '</b>'; ?></td>
													</tr>
													<tr>
														<td class="main"><?php echo $GLOBALS[$payment]->title; ?></td>
													</tr>
													<?php } ?>
													<tr>
														<td class="main" colspan="4"><br><?php echo $confirmation['title']; ?></td>
													</tr>
													<?php
													for ($i=0, $n=sizeof($confirmation['fields']); $i<$n; $i++) {
													?>
													<tr>
														<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
														<td class="main"><?php echo $confirmation['fields'][$i]['title']; ?></td>
														<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
														<!-- <td class="main"><?php //echo $confirmation['fields'][$i]['field']; ?></td> !-->
														<td class="main"><?php echo (($confirmation['fields'][$i]['title']=='Credit Card Number:') ? 'XXXX XXXX XXXX &nbsp;'. substr($confirmation['fields'][$i]['field'],-4) : $confirmation['fields'][$i]['field']); ?></td>
													</tr>
													<?php
													}
													?>
												</table>
											</td>
										</tr>
									</table>
								</td>
							</tr>
							<tr>
								<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
							</tr>
							<?php
								}
							}
							?>
						</table>
					</td>
				</tr>
				
	
				
			<!--	<tr>	
					<td colspan="2" class="contentTitle"><?php echo tep_draw_separator("pixel_trans.gif","1","1");?>		</td>
				</tr> -->
				
				
				</tr>	
				<tr>
					<td colspan="2">
						<table border="0" width="90%" cellspacing="0" cellpadding="2">
							<tr>
								<td align="left" class="main" width="50%">
									<?php echo '&nbsp;&nbsp;<a href="' . tep_href_link(FILENAME_EDIT_ORDERS,'oID=' . $oID . '&step=4">') . tep_image_button('button_back.gif',IMAGE_BACK) . '</a>';?>
									<input type=hidden name="amount" value="$<?php echo $amount; ?>">
									<input type=hidden name="tax_amount" value="<?php echo $tax_amount; ?>">
									<?php $validID=tep_create_random_value(5,'digits');
									$payment_params='&validID=' . $validID;
									// echo '<html><head><title>Confirm Order</title></head><body>'; 
									if (isset($$payment->form_action_url)) {
										echo "<form name='edit_confirmation' action='" . $$payment->form_action_url . "' method=post>";
									} else {
										echo tep_draw_form('edit_confirmation', FILENAME_EDIT_ORDERS_PROCESS,'validID=' . $validID);
										echo '<input type=text name="Single" value="mode" style="visibility:hidden">';?>
											<input type=hidden name="coupon" value="<?php echo $HTTP_POST_VARS['coupon'] ;?>"><?php
									}
									
									if (is_array($payment_modules->modules)) {
										echo $payment_modules->process_button();
									}
									if (!tep_session_is_registered('checkID')){
										tep_session_register('checkID');
									}
									$checkID=$validID;
									
									
									if($payment=='westpac')
									echo tep_draw_hidden_field('EPS_FINGERPRINT',$fingerprint);?>
									<input type=hidden name="amount" value="$<?php echo $amount; ?>">
									<input type=hidden name="tax_amount" value="<?php echo $tax_amount; ?>">
								
								</td>
								<td align="right"><?php  //echo "<input type=submit value=Confirm>" 
									echo '&nbsp;&nbsp;' . tep_image_submit('button_confirm.gif',BUTTON_CONFIRM). '</form>' . "\n";
									?>
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>		
	<!-- footer //-->
	<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
	<!-- footer_eof //-->

</body>
</html>
<?php } else {
				$payment_params='&oID=' . $oID . '&step=4';
				$validID=tep_create_random_value(5,'digits');
				$payment_params='&validID=' . $validID;
				echo tep_draw_form('edit_confirmation', FILENAME_EDIT_ORDERS_PROCESS,'validID=' . $validID);
				echo '<input type=text name="detail_only" value="1" style="visibility:hidden">';
				if (!tep_session_is_registered('checkID')){
				tep_session_register('checkID');
			}
				$checkID=$validID; ?>
				</form>
<script language="javascript1.2">
   document.edit_confirmation.submit();
 </script> 
				
		<?php	}?>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>