Gossamer Forum
Home : Products : DBMan : Customization :

email search result ...

Quote Reply
email search result ...
Hi, I have two question:
1. Is it possible to email the search result to someone's mailbox?
( something like add a email field to let the admin to enter, then clink and email to result out.)
2. Is it possible to result (in list all feature) from the latest to earliest?
make it default for "list all" and search by field(s)

Thanks,
george


Quote Reply
Re: email search result ... In reply to
I moved this from the "DBMan Discussion" forum because it belongs here and not there. Smile

I'm sure it would be possible to send the results of a search by email.

In Reply To:
2. Is it possible to result (in list all feature) from the latest to earliest?
make it default for "list all" and search by field(s)
Yes to both.

In the "List All" link add

&sb=the number of your "date added" field&so=descend

or, if you have a counter as your key field

&sb=the number of your key field&so=descend

As for the searches, did you want to require all searches to be in this order, or would the user be able to change the order?

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: email search result ... In reply to
JPD,

Thank you for your kind help.
And the search result will all email to target user in descend order.

Regards,
george


Quote Reply
Re: email search result ... In reply to
Do you want to send the full records by email? This could get pretty long.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: email search result ... In reply to
JPD,

Sure.
So I will narrow the search criteria first, then send the result to my mail box.

Thanks,
george


Quote Reply
Re: email search result ... In reply to
First, you have to set up the following in your .cfg file:

Code:

# Full path to sendmail on your system
$mailprog = "|/usr/lib/sendmail -t";
# Your email address
$admin_email = 'you@yourserver.com';
In sub html_view_search, after

&html_search_options;

add

Code:

if ($per_admin) {
print qq|Send results of search to <input type="text" name="to_email">|;
}
You may also want to add this to sub html_view_failure.

In sub html_view_success, after

my ($maxhits); $in{'mh'} ? ($maxhits = $in{'mh'}) : ($maxhits = $db_max_hits);

add

Code:

if ($in{'to_email'} =~ /.+\@.+\..+/) {
open (MAIL, "$mailprog") || &cgierr("Can't start mail program");
print MAIL "To: $in{'to_email'}\n";
print MAIL "From: $admin_email\n";
print MAIL "Subject: $html_title Search Results\n\n";
for (0 .. $numhits - 1) {
my (%rec) = &array_to_hash($_, @hits);
print MAIL qq|how you want the record to be displayed.
use $rec{'FieldName'} variables to print
out the values
|;
}
close (MAIL);
}
JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: email search result ... In reply to
JPD,

Thank you very much for your help.
It works.

george