[ic] loading arbitrary, un-templated page in Admin UI

Stewart Barnett stewbarnett at wsac.com
Tue Aug 17 13:58:41 EDT 2004


On 16 Aug 2004 at 18:48, david yee wrote:

> so....
> 
> i have cobbled together a nicely laid-out receipt to display after an
> order has been shipped, so that our shipping folk may print it out and
> include it in the box to be delivered, but i don't want it to have all
> the standard UI stuff around it (i've written a separate stylesheet to
> handle just the items on the receipt).
> 
> what i *do* want is for it to be loadable only from within the Admin
> UI by authorized users.  what part of the UI_STD_HEAD will perform
> that test for me?
> 
> best
> david
> 
> 
> -- 
> david yee
> iamyee at gmail.com
> 
> 

David,
Here is a solution for printing shipping labels that I'm sure alot of people have to 
reinvent.

I just add this line
[print_label [loop-code] labeldef]
to my orderview page near the shipping address. That generates a "Print Label" button.


add this usertag to the catalog

UserTag print_label Order ordernum template
UserTag print_label Routine <<EOR
sub {
my ($ordernum, $template) = @_;
$ordernum ||= 1;
$template ||= 'labeldef.html';
my $href = $Tag->area({
href => $template,
arg => $ordernum,
});
return qq{<input type="button" value="Print Label" 
onclick="window.open('$href','windowName','width=400,height=300');">};
}
EOR

create a template using the example at the end of this message


Tag Overview
print_label
Prints a shipping label using the browser.
Summary
[print_label ordernum template]
[print_label ordernum=1000 template=admin/labeldef]
Positional parameters: The first line shows the usage with positional parameters (given 
in order). The second line shows usage with named parameters.
Parameters Description Default
ordernum The ordernumber to print from none
template The filename of layout to print labeldef.html
Other_Charactreristics
Invalidates cache No
Macro No
Has end tag No
Tag expansion example:
[print_label 1000 shiplabel.html]
[print_label ordernum=1000 template=shiplabel.html]
------------------------------------------------------
ASP-like Perl call:
$Tag->print_label( { ordernum => 1000,
template => shiplabel.html} );

Description
Quickly adds a print labelbutton to your pages without having to type the html each 
time. The template name can be passed by setting the appropriate parameter. The 
button launches a child window that will auto print itself and close itself when the print 
dialog is clear.
ordernum
Pass the ordernumber of the order you want to call the print function.
template
Set to the filename that the print function should use as a template for the information 
you want to print.

Template example: labeldef.html
<head><title>Label Print</title></head>
[loop list="[cgi mv_arg]"]
__COMPANY__<br>
__ADDRESS__<br>
__CITY__ __STATE__ __ZIP__<br>
<br>
<br>
<br><center>
[loop-data transactions fname] [loop-data transactions lname]<br>
[loop-data transactions address1]<br>
[if-loop-data transactions address2]
[loop-data transactions address2]<br>
[/if-loop-data]
[loop-data transactions city], [loop-data transactions state] [loop-data transactions 
zip]<br>
</center>
[/loop]
<script language=JavaScript><!-- //
if (window.print) self.print();
setTimeout('self.close()',3000);
//--></script>

*** usertag, print_label


More information about the interchange-users mailing list