[comment]
ui_name: saved_carts_list_small
ui_type: component
ui_class: vertical
ui_group: info
ui_label: Small saved cart list for left/right display


[/comment]
<!-- BEGIN COMPONENT [control component saved_carts_list_small] -->

[tmp myimagedir][image dir_only=1 ui=1][/tmp]

[if session logged_in]
<table width="100%" cellpadding=0 cellspacing=0 align=center>

  [if cgi delete_cart][delete_cart nickname="[cgi delete_cart]"][/if]
  [if cgi retrieve_cart][load_cart nickname="[cgi retrieve_cart]"][/if]

  [userdb function=get_cart_names hide=1]

[if value carts]

  [perl global=1]
  push(@Vend::TmpScratch,qw/saved_carts_carts saved_carts_recurring/);
  $Scratch->{saved_carts_carts} = '';
  $Scratch->{saved_carts_recurring} = '';

  foreach my $var (split("\n",$Tag->value('carts'))) {
    my($name,$last_update,$type) = split(':',$var);

    my($day,$month,$year) = (localtime($last_update))[3,4,5];
    $last_update = sprintf("%04d-%02d-%02d",$year+1900,$month+1,$day);
    my $delink = $Tag->page({
        href => "@@MV_PAGE@@",
        extra => 'title="' . errmsg('Delete this saved cart') . '"',
        form => "
            delete_cart=$var
            mv_action=return
        ",
    });

    my $golink = $Tag->page({
        href => "@@MV_PAGE@@",
        extra => 'title="' . errmsg('Restore this saved cart') . '"',
        form => "
            retrieve_cart=$var
            mv_action=return
        ",
    });


my $myimagedir = $Scratch->{myimagedir};
my $row = <<"END";

<tr class="">
  <td valign=top class="titletab_small">
    $delink<img src="${myimagedir}delsm.gif" border=0></a>&nbsp;&nbsp;
  </td>
  <td valign=top class="contentbar1">$golink$name</A></td>
  <td valign=top class="titletab_small" nowrap><small>$last_update</small></td>
</tr>
END

    if($type eq 'c') {
        $Scratch->{saved_carts_carts} .= $row;
    } elsif($type eq 'r') {
        $Scratch->{saved_carts_recurring} .= $row;
    }
  }
  return '';
 [/perl]

 [loop list="saved_carts_carts saved_carts_recurring"]
 [if scratch [loop-code]]

<tr> 
  <td valign="top">
  <div padding="2" align="center">
	<div align="center" class="carttiny_title">	  
		[if explicit]
	       	[condition]'[loop-code]' eq 'saved_carts_carts'[/condition]
       		[L]Saved Carts[/L]
        	[else]
              	[L]Recurring Orders[/L]
            	[/else]
            	[/if]
	</div>
  	<div class="carttiny">
  		<table width="100%" cellspacing="0" cellpadding="2">
      			<tr>
          			<td align="left" class=ctiny_heading>&nbsp;X</td>
          			<td align="center" class=ctiny_heading>&nbsp;[L]Name[/L]</td>
	  			<td align="right" class=ctiny_heading>[L]Modified[/L]&nbsp;</td>
        		</tr>
			<tr>
				<td colspan="3">
					[scratch [loop-code]]
				</td>
			</tr>
  		</table>
	</div>
  </div>
  </td>
</tr>

 [/if]
 [/loop]

[/if]
</table>
[/if]
<!-- END COMPONENT [control component saved_carts_list_small] -->
