Gossamer Forum
Home : Products : DBMan : Customization :

email notification

Quote Reply
email notification
I am looking for a mod which will send an email to admin whenever a record is added to any of the databases.

Also Is it possible to send an email to different people (ADMINs) depending on the Input selection in one of the "Select" form field so that one can have set of Admins assigned to different function. eg. zonewise etc.

Thanks


Regards

Vijay
Quote Reply
Re: email notification In reply to
Search the forum for sendmail and Validate Mod...and search for Mass Mailer.

Regards,

Eliot Lee
Quote Reply
Re: email notification In reply to
Thanks Eliot !

I tried to search but with different keywords.

I will try the mod and may be comeback here again.



Regards

Vijay
Quote Reply
Re: email notification In reply to
I have installed a validation Mod Certain things such as sending email to webmaster works. I have not checked the full functionality as yet.

I have a Problem in the sense I use Long/Short as well as Relational Mod, What hppens is that, after submission screen shows Record Added and A sHORT Link to my Long record. This short linbk is incorrect. It takes default.db as well as default html.pl thereafter. What I am missing ?? a short relavent code here

<html>
<head>
<title>$html_title: Purchase Order Added.</title>
</head>

<body bgcolor="#DDDDDD">
<center>
<table border=1 bgcolor="#FFFFFF" cellpadding=5 cellspacing=3 width="100%" align=center valign=top>
<tr><td colspan=2 bgcolor="navy">
<FONT FACE="MS Sans Serif, arial,helvetica" size=1 COLOR="#FFFFFF">
<b>$html_title: Purchase Order Added</b>
</td></tr>
<tr><td>
<p><center><$font_title><b>
Purchase Order Added
</b></font></center>

<$font>
<P><center><Font face="Verdana, Arial, Helvetica" Color="Red" Size=2>The following purchase order was successfully added to the database:</center></FONT>
|;
&html_record(&get_record($in{$db_key}));
print qq|
</font></p>
|; &html_footer; print qq|
</td></tr>
</table>
</center>
</body>
</html>
|;
}

Thanks

Regards

Vijay
Quote Reply
Re: email notification In reply to
The best thing to do is show the long display after a record is added. Instead of

Code:
&html_record(&get_record($in{$db_key}));
use

Code:
&html_record_long(&get_record($in{$db_key}));
JPD
Quote Reply
Re: email notification In reply to
Thanks JPDeni,

The long record display works perfectly. It is also I think better practice to show long record.

BTW Smile is there a MOD for thr Preview of the Record before someone adds it.



Regards

Vijay
Quote Reply
Re: email notification In reply to
Yes...Read the following Threads:

http://www.gossamer-threads.com/...=25&Old=allposts

http://www.gossamer-threads.com/...=25&Old=allposts

http://www.gossamer-threads.com/...=25&Old=allposts

Found these Threads in less than a minute using the
following search criteria:

Keywords: Preview Records
Match: And
Forum: DBMAN Customization Forum

Regards,

Eliot Lee
Quote Reply
Re: email notification In reply to
Hi Eliot,

Sorry again ! I will make sure I search the forum before I post here. ( I suppose it is a good practice Smile)

Thanks


Regards

Vijay
Quote Reply
Re: email notification In reply to
I looked at these threads but did not figure out much. I have also come across a thread which says JP Deni had written a mod for this. I could not locate. Can anyone help ? I need a simple preview mod.

Thanks



Regards

Vijay
Quote Reply
Re: email notification In reply to
The mod was within one of the messages, but I have made a text file of it so it will be easier to find. You can pick it up at http://www.jpdeni.com/dbman/Mods/preview.txt. I'll go add it to the Resource Center now.


JPD
Quote Reply
Re: email notification In reply to
Vijay:

Here's a link to the preview record mod. You will need to scroll down in the thread to find where that topic appears.

http://www.gossamer-threads.com/scripts/forum/resources/Forum12/HTML/000387.html

Hope this helps :)

Quote Reply
Re: email notification In reply to
Here's how I handled that:

In the .cfg file, under Files and Url's, I added the following:

# Full path to sendmail on your system
$mailprog = "/usr/sbin/sendmail";
# Your email address
$email_admin_email = "you\@yourdomain.com";
# Fieldname that contains the email address list
$email_list = "email1\@domain1.com,email2\@domain2.com";

Then, in the db.cgi file, in sub add_record, change:

print DB &join_encode(%in);
close DB; # automatically removes file lock

to:

print DB &join_encode(%in);
&email;
close DB; # automatically removes file lock

and create a new routine:

sub email {
# --------------------------------------------------------
# Sends email to specified addresses when record added.

open (MAIL, "|$mailprog -t -eog") || &cgierr("unable to open mail program");

print MAIL "To: $email_list\n";
print MAIL "From: $email_admin_email\n";
print MAIL "Subject: New Database Record\n\n";
print MAIL "The following record was added to the database: $in{$db_cols[2]}";
close (MAIL);
}

In the above example, $in{$db_cols[2]}"; refers to the field name I want displayed in the email message. In my case, it is the name of a new contact.

Alan Pollenz
Quote Reply
Re: email notification In reply to
Thanks ! Mod works fine.

Still....I have a little problem. My submission form has some calculations to be done. As per your suggestion JP Deni, I had put the code in db.cgi ( The calculation part) Now My purpose of Preview gets defeated because it does not do calculations before actual submission nor at a previw stage.

Any Clue ? Smile

Regards

Vijay
Quote Reply
Re: email notification In reply to
I would have to look at the calculation code to know where to put it. My guess would be that you would add it to the beginning of sub html_preview.


JPD
Quote Reply
Re: email notification In reply to
Here Is a Code

sub add_record {
# --------------------------------------------------------
# Adds a record to the database. First, validate_record is called
# to make sure the record is ok to add. If it is, then the record is
# encoded and added to the database and the user is sent to
# html_add_success, otherwise the user is sent to html_add_failure with
# an error message explaining why. The counter file is also updated to the
# next number.

my ($output, $status, $counter);
# Set the userid to the logged in user.
($auth_user_field >= 0) and ($in{$db_cols[$auth_user_field]} = $db_userid);
(!$per_admin) and ($in{'Validated'} = "No");

if ($db_setup eq "po") {
$in{'Amount1'} = $in{'Quantity1'} * $in{'Price1'};
$in{'Amount2'} = $in{'Quantity2'} * $in{'Price2'};
$in{'Amount3'} = $in{'Quantity3'} * $in{'Price3'};
$in{'Amount4'} = $in{'Quantity4'} * $in{'Price4'};
$in{'Amount5'} = $in{'Quantity5'} * $in{'Price5'};
$in{'Amount6'} = $in{'Quantity6'} * $in{'Price6'};
$in{'Amount7'} = $in{'Quantity7'} * $in{'Price7'};
$in{'Amount8'} = $in{'Quantity8'} * $in{'Price8'};
$in{'Amount9'} = $in{'Quantity9'} * $in{'Price9'};
$in{'Sub_Total'} = $in{'Amount1'} + $in{'Amount2'} + $in{'Amount3'} + $in{'Amount4'} + $in{'Amount5'} + $in{'Amount6'} + $in{'Amount7'} + $in{'Amount8'} + $in{'Amount9'};
$in{'Sale_Tax'} = $in{'Sub_Total'} * $in{'tax_rate'};
$in{'Octroi'} = ($in{'Sub_Total'} + $in{'Sale_Tax'}) * $in{'octroi_rate'};
$in{'Shipment'} = $in{'ship_charge'};
$in{'PO_value'} = $in{'Sub_Total'} + $in{'Sale_Tax'} + $in{'Octroi'} + $in{'Shipment'};}




# First we validate the record to make sure the addition is ok.
(!$per_admin) and ($in{'Validated'} = "No");
$status = &validate_record;


You are too quick....... (and Great) Smile



Regards

Vijay
Quote Reply
Re: email notification In reply to
Yes, you'll want to add the code to the beginning of sub html_preview.

Just copy all of the calculation code and paste it into sub html_preview, before

&html_print_headers;

Or you could put it into sub preview_record, just after

$auth_user_field >= 0) and ($in{$db_cols[$auth_user_field]} = $db_userid);

Either way will have the same effect.


JPD
Quote Reply
Re: email notification In reply to
Yes ! It works very well.

One small problem still......I have given the result of the calculation as "Required" field. I am passing these fields as Hidden fields. I had to make them non mandatory for this to work.

Any Clue ?



Regards

Vijay
Quote Reply
Re: email notification In reply to
I would think that, since these fields are not entered by the user, it would be better not to make them mandatory. However, if you want to make them mandatory, move the calculations to sub preview in the db.cgi file, before the line to validate the record.


JPD
Quote Reply
Re: email notification In reply to
I have just added the mod it looks great. :)
I have also installed the upload mod, but when it previews the result the graphic which they have just upload does not show up, instead it uses the default graphic...

is this the limitation of the mod? or i have done wrong some where??




Quote Reply
Re: email notification In reply to
I don't know why this would happen. It doesn't happen with the database that I set up to test it.

Are you sure you entered the code correctly? Are you sure your graphic directory is not within your cgi-bin? Those are the two things I can think of that might cause the problem.

You say it doesn't show up immediately after the upload. Does it show up when you view the record?


JPD
Quote Reply
Re: email notification In reply to
yes it did after i go search for the record....
but now since i have screwed up witht he new upload mod...i might have to fix that first, but sure will report back here after i solve that matter..
thanks! :)