[if cgi showactive]
[value name=showinactive set=""]
[/if]
[value name=mv_data_table set=userdb hide=1]
[if-mm !tables]
[set ui_error]
Not authorized for customer administration. Contact administrator?
[/set]
[bounce page="__UI_BASE__/error"]
[/if-mm]
[set ui_class]Customers[/set]
[set page_perm]userdb[/set]
[tag flag write]userdb[/tag]
[perl tables=userdb]
delete $Scratch->{ui_location};
$Config->{NoSearch} = '';
my $db = $Db{userdb};
if(! $db) {
$Scratch->{error_message} = "Error: no userdb database.
";
$Scratch->{ui_location} = "__UI_BASE__/error";
return;
}
my ($value, $action_col, $delete);
if($CGI->{activate}) {
$value = 0;
$action_col = 'inactive';
}
elsif($CGI->{deactivate}) {
$value = 1;
$action_col = 'inactive';
}
elsif($CGI->{deletecustomer}) {
$delete = 1;
}
elsif($CGI->{viewcustomer} and ! $CGI->{viewnext}) {
#Log("viewcustomer and !viewnext");
$CGI->{customer} =~ s/^\0+//;
$CGI->{customer} =~ s/\0+$//;
$Scratch->{ui_location} = $Tag->area('__UI_BASE__/customer_view', $CGI->{customer});
}
elsif($CGI->{xload}) {
$Scratch->{ui_location} = $Tag->area('__UI_BASE__/dbdownload');
}
else {
$CGI->{customer} =~ s/^\0+//;
$CGI->{customer} =~ s/\0.*//s;
$Scratch->{start_at} = "sm=$CGI->{customer}";
}
if($action_col) {
for(grep $_, @{$CGI_array->{customer}}) {
$db->set_field($_, $action_col, $value);
}
}
elsif ($delete) {
for(grep $_, @{$CGI_array->{customer}}) {
$db->delete_record($_);
}
}
if(@errors) {
my $plural = @errors > 1 ? 's' : '';
return "Error$plural:
";
}
if($CGI->{viewnext}) {
#Log("viewnext");
$Scratch->{message} = "Wanted to view next.";
my $custnum = $CGI->{customer};
$custnum =~ s/[\0,\s].*//;
return if ! $custnum;
$custnum++;
CHECKNEXT: {
if (! $db->record_exists($custnum) ) {
undef $custnum;
last CHECKNEXT;
}
if ($db->field($custnum, 'deleted') ) {
$custnum++;
next CHECKNEXT;
}
if ($Values->{showinactive} and ! $db->field($custnum, 'active') ) {
undef $custnum;
last CHECKNEXT;
}
else {
last CHECKNEXT;
}
}
if ($custnum) {
$Scratch->{message} = "Wanted to view customer.";
$Scratch->{ui_location} = $Tag->area(
{
href => '__UI_BASE__/customer_view',
form => "customer=$custnum",
}
);
}
else {
$Scratch->{message} = "No next customer.";
}
}
return;
[/perl]
[if scratch ui_location]
[bounce href=`delete $Scratch->{ui_location}`]
[/if]
[set icon_name]icon_people.gif[/set]
[seti page_title]
[if value showinactive]
Customers: Inactive customers
[else]
Customers: Active customers
[/else]
[/if]
[/seti]
[set help_name]customer[/set]
[update values]
@_UI_STD_HEAD_@
[if scratch message]
[scratch message][set message][/set] [/if] @_UI_STD_FOOTER_@