<?php
if (! $record) {
	echo _('Sorry, product not found, or your account is not authorized to view it.');
	return;
}

// Load the language
$translate = $record->product_translate->where('product_id','=',$record->id)->and_where('language_id','=','fr')->find();

// If there isnt a translated page, show the default language
// @todo - default language should come from configuration
if (! $translate->loaded())
	$translate = $record->product_translate->where('product_id','=',$record->id)->and_where('language_id','=',1)->find();

// @todo Need to add in product attributes
// @todo Need to add in product plugins

echo Form::open('cart/add');
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="table_background">
	<tr>
		<td>
			<?php echo Form::hidden('product_id',$record->id); ?>
			<?php echo Form::hidden('quantity',1); ?>
			<table width="100%" border="0" cellspacing="1" cellpadding="0">
				<tr>
					<td style="background-color: #FFFFFF;">
						<table width="100%" border="0" cellpadding="4">
							<tr>
								<td class="body" rowspan="4"><?php echo $translate->description_full; ?></td>
								<td style="text-align: right;"><?php if ($a=$record->show_thumb()) echo $a; ?></td>
							</tr>
							<tr>
								<?php if ($record->prod_plugin_file && method_exists($record->prod_plugin_file,'product_view')) {
									$pio = new $record->prod_plugin_file;
									echo '<td style="vertical-align: bottom;">'.$pio->product_view($record->prod_plugin_data).'</td>';
								} ?>
							</tr>
							<tr>
								<?php if ($record->prod_plugin_file && method_exists($record->prod_plugin_file,'contract_view')) {
									$pio = new $record->prod_plugin_file;
									echo '<td style="vertical-align: top;">'.$pio->contract_view($record->prod_plugin_data,$record->price_base,$record->price_setup).'</td>';
								} ?>
							</tr>
							<tr>
								<?php if ($record->prod_plugin_file && method_exists($record->plugin(),'feature_summary')) {
									echo '<td style="vertical-align: top;">'.$record->plugin()->feature_summary().'</td>';
								} ?>
							</tr>
							<tr>
								<td class="spacer" colspan="2">&nbsp;</td>
							</tr>
							<tr>
								<td class="body" style="width: 50%;"><b>Recurring Billing Schedule</b></td>
								<td class="body" style="width: 50%;"><b>Currency</b></td>
							</tr>
							<tr>
								<td class="body"><?php echo StaticList_RecurSchedule::form('recurr_schedule',$record,$record->price_recurr_default);?> </td>
								<!-- @todo The default currency should be system configurable and displayed by default -->
								<!-- @todo If CURRENCY's value is not active in the DB, then the wrong flag is shown, as StaticList_Module::form() only returns active values -->
								<!-- @todo Currency is not used in the cart? -->
								<?php $CURRENCY_ISO='AUD'; $CURRENCY=6; $COUNTRY=61?>
								<td class="body"><?php echo StaticList_Module::form('currency','currency',$CURRENCY,'id','name',array('status'=>'=:1'),FALSE,array('class'=>'form_button'));?> <?php echo Country::icon($COUNTRY);?></td>
							</tr>
							<tr>
								<td class="body"><b>Price Type</b></td>
								<td class="body"><b>Taxable</b></td>
							</tr>
							<tr>
								<td class="body"><?php echo StaticList_PriceType::display($record->price_type);?></td>
								<td class="body"><?php echo StaticList_YesNo::display($record->taxable);?></td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td class="spacer" colspan="2">&nbsp;</td>
				</tr>
				<tr>
					<?php if ($record->prod_plugin_file && method_exists($record->prod_plugin_file,'product_cart')) {
						$pio = new $record->prod_plugin_file;
						echo '<td style="vertical-align: top;">'.$pio->product_cart($record->prod_plugin_data).'</td>';
					} ?>
				</tr>
				<tr>
					<td style="text-align: center;"><?php echo Form::submit('submit','Add to Cart',array('class'=>'form_button','disabled'=>'disabled')); ?> | <?php echo Form::submit('submit','Add to Cart & Checkout',array('disabled'=>'disabled'),array('class'=>'form_button')); ?></td>
				</tr>
			</table>
		</td>
	</tr>
</table>
<?php echo Form::close(); ?>
<br/>
