@_UI_STD_INIT_@[calcn]
if ( $CGI->{showactive} ) {
delete $Values->{showinactive};
$Values->{showactive} = 1;
$Scratch->{active_sense} = 'ne';
$Scratch->{active_img} = 'right.gif';
$Scratch->{active_nm} = 'deactivate';
}
elsif($CGI->{showinactive}) {
delete $Values->{showactive};
$Values->{showinactive} = 1;
$Scratch->{active_sense} = 'eq';
$Scratch->{active_img} = 'left.gif';
$Scratch->{active_nm} = 'activate';
}
elsif(! $Values->{showactive} and ! $Values->{showinactive}) {
delete $Values->{showinactive};
$Values->{showactive} = 1;
$Scratch->{active_sense} = 'ne';
$Scratch->{active_img} = 'right.gif';
$Scratch->{active_nm} = 'deactivate';
}
return;
[/calcn]
[value name=mv_data_table set=userdb hide=1]
[if-mm !tables]
[set ui_error]
[L]Not authorized for customer administration. Contact administrator?[/L]
[/set]
[bounce page="__UI_BASE__/error"]
[/if-mm]
[tmp can_delete][if-mm advanced userdb=d]1[/if-mm][/tmp]
[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->{ui_error} = errmsg('no %s database', 'userdb');
$Scratch->{ui_location} = $Tag->area("__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} and $Scratch->{can_delete}) {
$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->{ui_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->{ui_message} = "Wanted to view customer.";
$Scratch->{ui_location} = $Tag->area(
{
href => '__UI_BASE__/customer_view',
form => "customer=$custnum",
}
);
}
else {
$Scratch->{ui_message} = "No next customer.";
}
}
return;
[/perl]
[calcn]
if ($CGI->{mv_like_spec}) {
my @f = split /\0/, $CGI->{mv_like_field};
my @s = split /\0/, $CGI->{mv_like_spec};
my @q = 'ra=yes';
my $found;
for(my $i = 0; $i < @f; $i++) {
next unless length $s[$i];
$found++;
push @q, "lf=$f[$i]";
push @q, "ls=$s[$i]";
}
if($found) { $CGI->{ui_text_qualification} = join "\n", @q; }
else { $CGI->{ui_text_qualification} = "" }
}
return if $CGI->{ui_text_qualification};
return unless
$Variable->{CUSTOMER_VIEW_LARGE} or $Config->{Database}{userdb}{LARGE};
$Scratch->{ui_location} = $Tag->area( {
href => '__UI_BASE__/flex_select',
form => q(
mv_data_table=userdb
page_title=Customer select
page_banner=Customer select
ui_searchpage=__UI_BASE__/customer
),
},
);
return;
[/calcn]
[if scratch ui_location]
[bounce href=`delete $Scratch->{ui_location}`]
[/if]
[set icon_name]icon_people.gif[/set]
[seti page_title]
[if value showinactive]
[L]Customers[/L]: [L]Inactive Customers[/L]
[else]
[L]Customers[/L]: [L]Active Customers[/L]
[/else]
[/if]
[/seti]
[set help_name]customer[/set]
[update values]
@_UI_STD_HEAD_@
[output name=search_box]