[comment]
ui_component: promo
ui_component_type: content, vertical
ui_component_group: promotion
ui_component_label: Promotion

promo_type:
	label: Promotion type
	options: specials=Specials, new=New items
	widget: select

matches:
	label: Number to show
	widget: select
	options: 1,2,3*,4,5,6,7,8,9,10

cols:
	label: Columns
	options: 1,2,3*,4
	widget: select

banner:
	label: Banner for top box
	default: Specials
	widget: text
	width: 40

[/comment]

<!-- BEGIN COMPONENT [control component promo] -->

<table width="95%" align=center>
<tr class="categorybar"> 
  <td class="categorybar" align="left"><b>[control banner Specials]</b></td>
</tr>
<tr> 
  <td> 
	[query arrayref=main
		   sql="
		   	SELECT sku,timed_promotion,start_date,finish_date
			FROM [either]__UI_MERCH_TABLE__[or]merchandising[/either]
			WHERE featured = '[control promo_type specials]'
			"][/query]
	[perl tables="__UI_MERCH_TABLE__ merchandising"]
		my @out;
		my $ref;
		my $db;
		delete $Scratch->{promo_codes};
		my $date = $Tag->time( { body => '%Y%m%d' } );
		$ref = $Tmp->{main} or return;
		for(@$ref) {
			my $line = $_;
			push(@out, $line->[0]), next if ! $line->[1];
			next if $line->[2] gt $date;
			next if $line->[3] lt $date;
			push @out, $line->[0];
		}
		$Scratch->{promo_codes} = join(' ', @out);
		return;
	[/perl]
      <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
    [table-organize embed=1 pretty=1 cols="[control cols 2]"]
[loop
	random="[control matches 3]"
	list="[scratch promo_codes]"
	 ] 
     <TD> 
	  <table border="0" cellspacing="0" cellpadding="0">
	  <tr> 
		<td align="center" colspan="2" class="contentbar1">
		  <b>
		  [if-loop-data merchandising blurb_begin]
			[loop-data merchandising blurb_begin]
		  [else]
			[loop-description]
		  [/else]
		  [/if-loop-data]</b>
		</td>
	  </tr>
   
      [if-loop-field thumb]
	  <tr> 
		<td align="center" colspan="2"> 
		  <img src="thumb/[loop-field thumb]" height="80">
		</td>
	  </tr>
      [/if-loop-field]

	  <tr> 
		<td align="center" colspan="2">
		  Our Price: <b>[loop-price]</b>
		</td>
	  </tr>
	[if-loop-data merchandising blurb_end]
	  <tr> 
		<td align="center" colspan="2">
		  <a href="[area [loop-code]]">[loop-data merchandising blurb_end]</a>
		</td>
	  </tr>
	[else]
	  <tr> 
		<td align="center">
		  <a href="[area [loop-code]]">More Info</a>&nbsp;
		</td>
		<td align="center">
		  [if-loop-data options o_modular]
				[page [loop-code]]
				[else][order [loop-code]]
				[/else]
				[/if-loop-data]<img border="0" alt="buy now" src="__THEME_IMG_DIR__buynow.gif">[/order]
		</td>
	  </tr>
	[/else]
	[/if-loop-data]
	  <tr> 
		<td align="center">&nbsp;</td>
	  </tr>
	  </table>
  	</TD>
[/loop]
[/table-organize]
      </table>

      <p>&nbsp;</p>

  </td>
</tr>
</table>

<!-- END COMPONENT [control component promo] -->
