<?php
/*
  $Id: make_an_offer.php,v 1.00 2005/03/15

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2005 osCommerce

  Released under the GNU General Public License
*/

echo tep_draw_form('make_an_offer', tep_href_link(FILENAME_MAKE_AN_OFFER, 'action=send'));

if ( $currencies->currencies[$currency]['decimal_point'] == ',' ) {
	$newprice = str_replace(".","",$newprice);
	$newprice = str_replace(",",".",$newprice);
}
?>

<table border="0" width="100%" cellspacing="0" cellpadding="0">
 <!-- Naglowek BOF -->
 <tr>
  <td>
   <?php
   $info_box_contents = array();
   $info_box_contents[] = array('text' => sprintf(HEADING_TITLE));
   new contentBoxHeading($info_box_contents);
   ?>
  </td>
 </tr>
 <tr>
  <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '1'); ?></td>
 </tr>
 <!-- Naglowek EOF -->

	<?php
	if ($messageStack->size('lowoffer') > 0) {
	?>
		<tr>
			<td><?php echo $messageStack->output('lowoffer'); ?></td>
		</tr>
	<?php
	}
	?>

	<?php
	if ($messageStack->size('contact') > 0) {
	?>
		<tr>
			<td><?php echo $messageStack->output('contact'); ?></td>
		</tr>
	<?php
	}

	if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'success')) {
	?>
		<tr>
			<td>
				<table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
					<tr class="infoBoxContents">
						<td class="main" align="center"><?php echo TEXT_SUCCESS; ?></td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
		</tr>
		<tr>
			<td>
				<table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
					<tr class="infoBoxContents">
						<td>
							<table border="0" width="100%" cellspacing="0" cellpadding="2">
								<tr>
									<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

										<?php
										$back = sizeof($navigation->path)-2;
										if (isset($navigation->path[$back])) {
										?>
											<td class="main" align="right"><?php echo '<a href="' . tep_href_link($navigation->path[$back]['page'], tep_array_to_string($navigation->path[$back]['get'], array('action')), $navigation->path[$back]['mode']) . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>'; ?></td>
										<?php
										} else {
										?>
											<td class="main" align="right"><a href="javascript:history.go(-1)"><?php echo tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></a></td>
										<?php
										}
										?>

									<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	<?php
	} else {
	?>
		<tr>
			<td>
				<table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
					<tr class="infoBoxContents">
						<td>
							<table border="0" width="100%" cellspacing="0" cellpadding="2">
								<tr>
									<td class="ProductTile" colspan="2">
										<?php
										if ($error == false ) {
											echo $product_info['products_name'] . ' (' . $products_price . ')';
										} else {
											$products_price = $currencies->format($HTTP_POST_VARS['originalprice']);
											$product_info['products_model'] = $HTTP_POST_VARS['productsmodel'];
											$product_info['products_name'] = $HTTP_POST_VARS['productsname'];
											echo $product_info['products_name'] . ' (' . $products_price . ' )';

										}
										?>
									</td>
								</tr>
								<tr>
									<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
								</tr>
								<tr>
									<td class="main" width="40%"><?php echo ENTRY_NAME; ?></td>
									<td class="main" width="60%"><?php echo tep_draw_input_field('name', '', 'size="35"'); ?></td>
								</tr>
								<tr>
									<td class="main" width="40%"><?php echo ENTRY_EMAIL; ?></td>
									<td class="main" width="60%"><?php echo tep_draw_input_field('email', '', 'size="35"'); ?></td>
								</tr>
								<tr>
									<td class="main" width="40%"><?php echo ENTRY_NEW_PRICE; ?></td>
									<td class="main" width="60%">
										<input name='newprice' type='text' value='<?php echo tep_round($newprice,$currencies->currencies[$currency]['decimal_places']); ?>' MAXLENGTH='15' SIZE='10'><?php echo ' ' . $currencies->currencies[$currency]['symbol_right']; ?>
									</td>
								</tr>
								<tr>
									<td class="main" width="40%"><?php echo ENTRY_REMARKS; ?></td>
									<td width="60%"><?php echo tep_draw_textarea_field('remarks', 'soft', 50, 5); ?></td>
								</tr>
								<tr>
									<td class="main" width="40%"><?php echo TEXT_SEND_EMAIL_CUSTOMER; ?></td>
									<td align="left" width="60%"><?php echo tep_draw_checkbox_field('sendemail', 'true'); ?></td>
								</tr>
								<tr>
									<td>
										<?php echo tep_draw_hidden_field('subject', EMAIL_SHOP_REMARKS . '\n\n' . EMAIL_DIVIDER . '\n' . PRODUCT_INFORMATION . '\n' . EMAIL_DIVIDER . '\n'. $product_info['products_name'] . ' [' . $product_info['products_model'] . ']' . '\n\n' . PRODUCT_ORIGINAL_PRICE . $products_price . '\n' . PRODUCT_NEW_PRICE); ?><br>

										<?php echo tep_draw_hidden_field('subject2', EMAIL_DIVIDER . '\n'. PRODUCT_INFORMATION . '\n'. EMAIL_DIVIDER . '\n'. $product_info['products_name'] . ' [' . $product_info['products_model'] . ']' . '\n\n' . PRODUCT_ORIGINAL_PRICE . ' ' . $products_price . '\n' . PRODUCT_NEW_PRICE);

										echo tep_draw_hidden_field('originalprice',$products_price_clean);
										echo tep_draw_hidden_field('originalproductid',$product_info['products_id']);
										echo tep_draw_hidden_field('productsname',$product_info['products_name']);
										echo tep_draw_hidden_field('productsmodel',$product_info['products_model']);
										?>
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<!-- Przyciski BOF -->
		<tr>
			<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '3'); ?></td>
		</tr>
		<tr>
			<td>
				<table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
					<tr class="infoBoxContents">
						<td>
							<table border="0" width="100%" cellspacing="0" cellpadding="2">
								<tr>
									<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
									<td align="right"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td>
									<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<!-- Przyciski EOF -->
	<?php
	}
	?>
	</table>
</form>