[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
[ic] Partial search
Hi list;
I am trying to inplement my search in such way that I do not have to
enter full search text just partial text, ie. for example I want to be
able to enter just alm not full text alma and still get some results.
Do you guys have any ideas how to do this???
I tried following (whcih works fine with full text match),, but not with
partial text match:
[value name=mv_data_table set=evaluationdb hide=1]
[tag flag write]evaluationdb[/tag]
[perl tables=evaluationdb]
delete $Scratch->{location};
$Config->{NoSearch} = '';
my $db = $Db{evaluationdb};
if(! $db) {
$Scratch->{error} = errmsg('no %s database', 'evaluationdb');
$Scratch->{location} = $Tag->area("[area @@MV_PAGE]");
return;
}
my ($value, $action_col, $delete);
if($CGI->{deletecustomer}) {
$delete = 1;
}
elsif($CGI->{viewcustomer} and ! $CGI->{viewnext}) {
#Log("viewcustomer and !viewnext");
$CGI->{customer} =~ s/^\0+//;
$CGI->{customer} =~ s/\0+$//;
$Scratch->{location} = $Tag->area('license_details_report',
$CGI->{customer});
}
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 "<FONT CLASS=error>Error$plural:<UL><LI>" .
join ("<LI>", @errors) .
"</UL></FONT><BR>";
}
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->{location} = $Tag->area(
{
href => 'license_details_report',
form => "customer=$custnum",
}
);
}
else {
$Scratch->{message} = "No next customer.";
}
}
return;
[/perl]
[calc]
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 $Config->{Database}{transactions}{LARGE};
$Scratch->{ui_location} = $Tag->area( {
href => '/flex_select',
form => q(
mv_data_table=evaluationdb
page_title=Customer select
page_banner=Customer select
ui_searchpage= reg_lic_customers_report
),
},
);
return;
[/calc]
[update values]
[if scratch message]
<BLOCKQUOTE>
[scratch message]
</BLOCKQUOTE>
[set message][/set]
[/if]
<FORM ACTION="[area @@MV_PAGE@@]">
<SMALL><INPUT TYPE=text NAME=ui_text_qualification VALUE="">
[button text="[L]Search for customer[/L]"]
mv_nextpage=@@MV_PAGE@@
[/button]
</form>
</SMALL>
<!-- ----- Show the customer list box ----- -->
[if cgi ui_text_qualification]
[if !cgi mv_like_spec]
<H4>[msg arg.0="[cgi ui_text_qualification]"]Entries containing
"%s"[/msg]</H$>
[/if]
[/if]
<!-- ----- BEGIN REAL STUFF ----- -->
<FORM ACTION="[process]">
<INPUT TYPE=hidden NAME=mv_nextpage VALUE="@@MV_PAGE@@">
<INPUT TYPE=hidden NAME=mv_todo VALUE=back>
[search-region more=1 search="
fi=evaluationdb
ml=20
md=1
st=db
[if cgi mv_like_spec]
[cgi ui_text_qualification]
[elsif cgi ui_text_qualification]
se=[cgi ui_text_qualification]
[/elsif]
[else]
co=yes
sf=company
se=1
op=ne
[/else]
[/if]
[if cgi ui_sort_field]
tf=[cgi ui_sort_field]
to=[cgi ui_sort_option]
[else]
tf=0
[/else]
[/if]
[scratch start_at][set start_at][/set]
rf=evaluation_id,company,address1,city,state,country,zip,license_type,licencekey
"]
[calc]
my $so = $CGI->{ui_sort_option};
my $fld = $CGI->{ui_sort_field};
$fld =~ s/[\s,\0].*//;
sub sortrev {
my ($f, $n) = @_;
my $out = 'ui_sort_option=';
$out .= 'n' if $n;
return $out unless ($fld eq $f) || ($f eq 'evaluation_id');
return $out if $so =~ /r/;
return $out . 'r';
}
return;
[/calc]
<TABLE border=0 width="100%" cellpadding="3" cellspacing="3">
<tr bgcolor="#000000" height=1><td colspan=8></td></tr>
<TR BGCOLOR="#ffdd99">
<th ALIGN=left><FONT COLOR="#134582">Delete Customer</th>
<TH ALIGN=left><FONT COLOR="#134582">[page href=@@MV_PAGE@@ form=`
$qual = '';
if($CGI->{ui_text_qualification}) {
$qual .= "ui_text_qualification=$CGI->{ui_text_qualification}";
}
return "ui_sort_field=evaluation_id\n" . sortrev('evaluation_id');
`][L]ID[/L]</a></TH>
<TH ALIGN=left><FONT COLOR="#134582">[page href=@@MV_PAGE@@ form=`
return "$qual\nui_sort_field=company,lname\n" . sortrev('company');
`][L]Company[/L]</A></TH>
<TH ALIGN=left><FONT COLOR="#134582">[page href=@@MV_PAGE@@ form=`
return "$qual\nui_sort_field=adddress1,country,state,city,zip\n" .
sortrev('country');
`][L]Address[/L]</A></TH>
<TH ALIGN=left><FONT COLOR="#134582">[page href=@@MV_PAGE@@ form=`
return "$qual\nui_sort_field=license_type\n" .
sortrev('license_type');
`][L]License Type[/L]</A></TH>
<TH ALIGN=left><FONT COLOR="#134582">[page href=@@MV_PAGE@@ form=`
return "$qual\nui_sort_field=licencekey\n" . sortrev('licencekey');
`][L]License Key[/L]</A></TH>
</TR>
<tr bgcolor="#000000" height=1><td colspan=8></td></tr>
<tr bgcolor="#FFFFFF" height=2><td colspan=8></td></tr>
[search-list]
<TR [item-alternate
2]BGCOLOR="#C0C0C0"[else]BGCOLOR="#Ffffff"[/else][/item-alternate]>
<td><A HREF="[area
href='@@MV_PAGE@@'
form='
deletecustomer=1
customer=[item-param evaluation_id]
']"
onClick="return confirm('Are you sure you want to delete customer
[item-param evaluation_id]?')"><IMG src="__THEME_IMG_DIR__delsm.gif"
ALT="DELETE [item-param evaluation_id]" BORDER=0></A>
</td><td>
[page href=license_details_report
form="
customer=[item-param evaluation_id]
"][item-param evaluation_id]</A>
[comment]
These non-breaking spaces make sure the table background color appears
so there's a full line across the page even if table cells are blank.
[/comment]
</TD>
<TD>[item-param company] </TD>
<TD>[item-param address1] [item-param city] [item-param state]
[item-param country] [item-param zip] </TD>
<td>[item-param license_type] </TD>
<td>[item-param licencekey] </TD>
</TR>
[/search-list]
<TR><TD COLSPAN=4>
[no-match]
[L]No active customers found[/L]</td></tr>
[/no-match]
[more-list]
<TR>
<TD COLSPAN=4>
[msg arg.0="[matches]" arg.1="[value
mv_search_match_count]"]Customers %s of %s[/msg]:[more]
</td>
</tr>
[/more-list]
<tr bgcolor="#000000" height=1><td colspan=8></td></tr>
<tr bgcolor="#FFFFFF" height=8><td colspan=8></td></tr>
</table>
</FORM>
[/search-region]
Any ideas??? Any help would be welcome.
Thanks
Alma