[if cgi showpending]
[value name=showarchive set=""]
[/if]
[value name=mv_data_table set=transactions hide=1]
[if-mm !tables]
[set ui_error]
Not authorized for order administration. Contact administrator?
[/set]
[bounce page="__UI_BASE__/error"]
[/if-mm]
[set page_perm]order[/set]
[set meta_header]
[/set]
[tag flag write]transactions[/tag]
[perl tables=transactions]
delete $Scratch->{ui_location};
my $db = $Db{transactions};
if(! $db) {
$Scratch->{error_message} = "Error: no transactions database.
";
$Scratch->{ui_location} = "__UI_BASE__/error";
return;
}
my ($value, $action_col);
if($CGI->{archiveorder}) {
$value = 1;
$action_col = 'archived';
}
elsif($CGI->{unarchiveorder}) {
$value = 0;
$action_col = 'archived';
}
elsif($CGI->{deleteorder}) {
$value = 1;
$action_col = 'deleted';
}
elsif($CGI->{vieworder} and ! $CGI->{viewnext}) {
$CGI->{order} =~ s/^\0+//;
$CGI->{order} =~ s/\0+$//;
$Scratch->{ui_location} = $Tag->area('__UI_BASE__/order_view', $CGI->{order});
}
elsif($CGI->{xload}) {
$Scratch->{ui_location} = $Tag->area('__UI_BASE__/dbdownload');
}
else {
$CGI->{order} =~ s/^\0+//;
$CGI->{order} =~ s/\0.*//s;
$Scratch->{start_at} = "sm=$CGI->{order}";
}
if($action_col) {
for(grep $_, @{$CGI_array->{order}}) {
$db->set_field($_, $action_col, $value);
}
}
if(@errors) {
my $plural = @errors > 1 ? 's' : '';
return "Error$plural:
";
}
if($CGI->{viewnext}) {
my $ordnum = $CGI->{order};
$ordnum =~ s/[\0,\s].*//;
return if ! $ordnum;
$ordnum++;
CHECKNEXT: {
if (! $db->record_exists($ordnum) ) {
undef $ordnum;
last CHECKNEXT;
}
if ($db->field($ordnum, 'deleted') ) {
$ordnum++;
next CHECKNEXT;
}
if ($Values->{showarchive} and ! $db->field($ordnum, 'archived') ) {
undef $ordnum;
last CHECKNEXT;
}
else {
last CHECKNEXT;
}
}
if ($ordnum) {
$Scratch->{ui_location} = $Tag->area(
{
href => '__UI_BASE__/order_view',
form => "order=$ordnum",
}
);
}
else {
$Scratch->{message} = "[L]No next order.[/L]";
}
}
return;
[/perl]
[if scratch ui_location]
[bounce href=`delete $Scratch->{ui_location}`]
[/if]
[set icon_name]admin/icon_orders.gif[/set]
[seti page_title]
[if value showarchive]
Orders: archived orders
[set help_name]order.main.archived[/set]
[else]
Orders: pending orders
[set help_name]order.main.pending[/set]
[/else]
[/if]
[/seti]
[update values]
@_UI_STD_HEAD_@
[if scratch message]
[scratch message][set message][/set] [/if]