 |
vtiger The Honest Open Source CRM
|
| Previous topic :: Next topic |
| Author |
Message |
johnkolbert
Joined: 29 Feb 2008
Posts: 8
|
| Posted: Sat Mar 01, 2008 4:06 pm Post subject: Web to Customer Email Notification |
|
|
Hi,
Is there a way to have the admin account notified via email when a new customer registers via the Web to Customer add-on? This would be handy because I can't figure out how to have vTiger automatically add newly registered people to the portal and have to do it manually.
Thanks for you help! |
|
| Back to top |
|
prasad.a
Joined: 01 Aug 2007
Posts: 968
|
| Posted: Sun Mar 02, 2008 4:49 pm Post subject: Web to Customer Email Notification<br /><a href=&qu |
|
|
Hi johnkolbert,
At present this feature is not available. If you have any specific requirements you can contact us.
There is send_mail API (check SendReminder.php for using it) you can get the initial prototype working for this feature.
Regards,
Prasad
vtiger Team |
|
| Back to top |
|
johnkolbert
Joined: 29 Feb 2008
Posts: 8
|
| Posted: Wed Mar 05, 2008 5:06 am Post subject: Re: Web to Customer Email Notification |
|
|
So I found a work around that seems to fit what I needed. I'll leave what I did here incase anybody else was trying to do this.
To have an email sent to you each time the form the web from is submitted using the "Web Forms" add-on:
First, open the the "send_data.php" file of the webform you want to edit. You are looking for the following line of code:
Code: else
{
echo '<br><br>'.$result.'<br><br><a href="index.php">Home</a>';
}
In the "contacts" send_data.php file this is lines 46-49. Before the echo statement (but after the "else {") we are going to add the following code:
Code:
$to = "admin@yoursite.com";
$subject = "New Contact Added";
$message = "A new contact has been added to vTiger via the Web Form";
//mail headers
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\n";
$headers .= "X-Priority: 3\n";
$headers .= "X-MSMail-Priority: Normal\n";
$headers .= "X-Mailer: php\n";
$headers .= "From: \"Admin\" <admin@yoursite.com>\n";
$headers .= "Return-Path: admin@yoursite.com\n";
$headers .= "Return-Receipt-To: admin@yoursite.com\n";
mail($to,$subject,$message,$headers);
Change the "admin@yoursite.com" to the desired email address, and change the message to whatever you like. Normally this would be enclosed in php tags, but since you're pasting into a php page, there's no need. That's all it takes. It worked fine for me.
I'm not sure how elegant of a solution this is, but it's better then no email I suppose. Hope this helps someone! |
|
| Back to top |
|
lord_alan
Joined: 12 Sep 2006
Posts: 43
Location: United Kingdom
|
| Posted: Fri Apr 04, 2008 10:18 am Post subject: Re: Web to Customer Email Notification |
|
|
Thanks for this tip.
I have just installed the webform inside a Joomla! site and it was the first question I asked: how do I get notified that someone has submitted an entry?
Looking at your solution, I see how it works, but it makes the assumption that the webform is located on a server that supports email sending. This is not always going to be the case; the form could be running on a completely different system to that where vtiger resides. I'd really like vtiger to send the notice, not the webform component.
Anyway - many thanks again for the tip - I'm going to have a go at some hacking now and will publish my results as and when :-)
Cheers
Alan |
|
| Back to top |
|
lord_alan
Joined: 12 Sep 2006
Posts: 43
Location: United Kingdom
|
| Posted: Fri Apr 04, 2008 6:41 pm Post subject: Re: Web to Customer Email Notification |
|
|
O.K.
I've "hacked" the webform for the Lead part so far.
I have done this in several stages.
1. Moved the Stylesheet and Javascript to separate files so that the whole webform is easier to deploy in CMS type applications and elsewhere. You can re-locate the css and js files to a template folder for example.
This means that it is also now easy to remove the "html, head and body tags of the webform index.php which will almost certainly be supplied by your existing web site.
2. Re-built the form so it is done in CSS. No Tables. This makes it more flexible, will pass W3C validation and is better for accessibility.
3. Changed some of the fields of the Lead form to be more "logical" IMHO. The form now collects First Name:, Last Name:, Company:, Email:, Telephone:, Address:, City:, Comments:. In that order. I made the first, last, email and company fields mandatory.
4. Modified the send_data.php file accordingly and added a function which send an email to a designated address on completion.
5. Modified the vtigercrm/soap/webform.php accordingly.
It seems to me that this is all a bit of a dogs dinner. You are required to replicate the form structure and order in several places and at both "ends" of the connection. If I get some more time, I'll take a deeper look and see if it can be streamlined so you only need to define the field list in one place - config.php would be a good location I think.
Anyway, here's my index.php (Leads):
Code: <?php
/*********************************************************************************
** The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
* The Initial Developer of the Original Code is vtiger.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
*
********************************************************************************/
if($error_message != '')
echo '<span class="form_error">'.$error_message.'</span>';
require_once('config.php');
global $default_charset;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $default_charset ?>">
<link rel="stylesheet" href="form.css" type="text/css" />
<script type="text/javascript" language="javascript" src="validateForm.js"></script>
</head>
<body>
<form name="leadform" method="post" action="send_data.php">
<input type="hidden" name="create" value="lead">
<p>Fields marked with a <span style="color:#d40000">*</span> are mandatory. All other fields are optional.</p>
<fieldset><legend>Enter your details</legend>
<div class="notes">
<h4>Enter Information</h4>
<p class="last">Please enter your contact details. Blah Blah Blah...</p>
</div>
<div class="required">
<label for="first_name">First Name:</label>
<input type="text" name="firstname" id="first_name" class="inputText" size="30" maxlength="100" value="<?php echo $_POST['firstname']?>" />
</div>
<div class="required">
<label for="last_name">Last Name:</label>
<input type="text" name="lastname" id="last_name" class="inputText" size="30" maxlength="100" value="<?php echo $_POST['lastname']?>" />
</div>
<div class="required">
<label for="company">Company:</label>
<input type="text" name="company" id="company" class="inputText" size="30" maxlength="100" value="<?php echo $_POST['company']?>">
</div>
<div class="required">
<label for="email">Email:</label>
<input type="text" name="email" id="email" class="inputText" size="30" maxlength="100" value="<?php echo $_POST['email']?>" />
</div>
<div class="optional">
<label for="phone">Telephone:</label>
<input type="text" name="phone" id="phone" class="inputText" size="30" maxlength="30" value="<?php echo $_POST['phone']?>">
</div>
<div class="optional">
<label for="address">Address:</label>
<input type="text" name="lane" id="address_1" class="inputText" size="30" maxlength="100" value="<?php echo $_POST['lane']?>" />
</div>
<div class="optional">
<label for="city">City:</label>
<input type="text" name="city" id="city" class="inputText" size="30" maxlength="100" value="<?php echo $_POST['city']?>" />
</div>
<div class="optional">
<label for="comments">Comments:</label>
<textarea name="description" rows="2" cols="29"><?php echo $_POST['description']?></textarea>
</div>
</fieldset>
<fieldset>
<div class="submit">
<div>
<input type="button" name="Submit" value="Submit »" class="inputSubmit" onClick="ValidateForm();">
<input type="submit" class="inputSubmit" value="Cancel" />
</div>
</div>
</fieldset>
</form>
</body>
</html>
I'll add the send_data.php in the next post to keep the length down. |
|
| Back to top |
|
lord_alan
Joined: 12 Sep 2006
Posts: 43
Location: United Kingdom
|
| Posted: Fri Apr 04, 2008 6:44 pm Post subject: Re: Web to Customer Email Notification: send_data.php |
|
|
Here's the send_data.php (again for the Lead webform)
Code: <?php
/*********************************************************************************
** The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
* The Initial Developer of the Original Code is vtiger.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
*
********************************************************************************/
include("config.php");
require_once('nusoap/lib/nusoap.php');
$client = new soapclient2($Server_Path."/vtigerservice.php?service=webforms", false,
$proxyhost, $proxyport, $proxyusername, $proxypassword);
$err = $client->getError();
if($_REQUEST['create'] == 'lead')
{
if(get_magic_quotes_gpc())
{
$firstname = stripslashes($_POST['firstname']);
$lastname = stripslashes($_POST['lastname']);
$company = stripslashes($_POST['company']);
$email = $_POST['email'];
$phone = stripslashes($_POST['phone']);
$city = stripslashes($_POST['city']);
$description = "WebForm : ".stripslashes($_POST['description']);
}
else
{
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$company = $_POST['company'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$city = $_POST['city'];
$description = "WebForm : ".$_POST['description'];
}
$params = array(
'firstname' => "$firstname",
'lastname' => "$lastname",
'company' => "$company",
'email' => "$email",
'phone' => "$phone",
'city' => "$city",
'description' => "$description",
'assigned_user_id' => "$assigned_user_id"
);
if($lastname != '' && $company != '')
{
$result = $client->call('create_lead_from_webform', $params, $Server_Path, $Server_Path);
if($result['faultstring'] != '' && is_array($result))
{
echo '<br>'.$result['faultstring'];
}
else
{
send_email($params);
echo '<br><br>'.$result.'<br><br><a href="index.php">Home</a>';
}
}
else
{
$error_message = "Last Name and Company must be entered to create a Lead.";
include("index.php");
}
}
else
{
include("index.php");
}
function send_email($arr) {
$to = "yourname@youremail.com";
$subject = "New lead recieved: " . $arr['company'];
$message = "A new lead has been recieved on vTiger via the Web Form \n" .
"--------------------------------------------------------\n" .
"Firstname: " . $arr['firstname'] . "\n" .
"Lastname: " . $arr['lastname'] . "\n" .
"Company: " . $arr['company'] . "\n" .
"email: " . $arr['email'] . "\n" .
"Telephone: " . $arr['phone'] . "\n" .
"City: " . $arr['city'] . "\n" .
"Comments: " . $arr['description'] . "\n\n";
//mail headers
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\n";
$headers .= "X-Priority: 3\n";
$headers .= "X-MSMail-Priority: Normal\n";
$headers .= "X-Mailer: php\n";
$headers .= "From: \"Admin\" <$to>\n";
$headers .= "Return-Path: $to\n";
$headers .= "Return-Receipt-To: $to\n";
mail($to,$subject,$message,$headers);
}
?>
I'll add the form.css next. |
|
| Back to top |
|
lord_alan
Joined: 12 Sep 2006
Posts: 43
Location: United Kingdom
|
| Posted: Fri Apr 04, 2008 6:45 pm Post subject: Re: Web to Customer Email Notification: form.css |
|
|
Here's the form.css
Code: form {
font-family: "Liberation Sans", Tahoma, Arial, sans-serif;
margin: 0;
padding: 0;
min-width: 560px;
max-width: 620px;
width: 590px;
}
form fieldset {
clear: both;
border-color: #000000;
border-width: 1px 0 0 0;
border-style: solid none none none;
padding: 10px;
margin: 0;
}
form fieldset legend {
font-size: 150%;
font-weight: normal;
color: #000000;
margin: 0 0 0 0;
padding: 0 5px;
}
label {
font-size: 100%;
}
textarea {
overflow: auto;
}
form div {
clear: left;
display: block;
width: 354px;
/*height: expression('1%');*/
margin: 5px 0 0 0;
padding: 1px 3px;
}
form fieldset div.notes {
float: right;
width: 158px;
height: auto;
margin: 0 0 10px 10px;
padding: 5px;
border: 1px solid #666666;
background-color: #ffffe1;
color: #666666;
font-size: 88%;
}
form fieldset div.notes h4 {
padding: 3px 0 3px 27px;
border-width: 0 0 1px 0;
border-style: solid;
border-color: #666666;
color: #666666;
font-size: 110%;
}
form fieldset div.notes p {
margin: 0em 0em 1.2em 0em;
color: #666666;
}
form fieldset div.notes p.last {
margin: 0em;
}
form div label {
display: block;
float: left;
width: 130px;
padding: 3px 5px;
margin: 0 0 5px 0;
text-align: right;
}
form div.optional label {
font-weight: normal;
}
form div.required label {
font-weight: bold;
}
form div select, form div textarea, form div input.inputText {
width: 200px;
padding: 1px 3px;
margin: 0 0 0 0;
}
form div.submit {
width: 214px;
padding: 0 0 0 146px;
}
form div.submit div {
display: inline;
float: left;
text-align: left;
width: auto;
padding: 0;
margin: 0;
}
form div input.inputSubmit, form div input.inputButton, input.inputSubmit, input.inputButton {
background-color: #cccccc;
color: #000000;
width: auto;
padding: 0 6px;
margin: 0;
}
form div.submit div input.inputSubmit, form div.submit div input.inputButton {
float: right;
margin: 0 0 0 5px;
}
form fieldset legend {
line-height: 150%;
}
form input, form select, form textarea {
background-color: #fff1ff;
}
form textarea.expanding {
overflow: auto;
overflow-x: auto;
overflow-y: visible;
}
div.optional label:before {
content: '';
}
div.required label:before {
content: '* ';
color:#d40000;
} |
|
| Back to top |
|
macrocosm
Joined: 13 Dec 2007
Posts: 23
|
| Posted: Tue Jul 08, 2008 8:20 am Post subject: Re: Web to Customer Email Notification: form.css |
|
|
| You didnt include the js script you referenced, which was easy enough to solve. The main prob is for some reason the leads generated seem to go into the wrong fields. I get the email fine enough but for instance when viewing the lead in vtiger the email address is in the company field, first name is in last name and the last name is empty! What do you think could be mixing these up. I looked through your send_data.php and couldnt find the error. I am using Vtiger 5.2 |
|
| Back to top |
|
lord_alan
Joined: 12 Sep 2006
Posts: 43
Location: United Kingdom
|
| Posted: Tue Jul 08, 2008 8:44 am Post subject: Re: Web to Customer Email Notification |
|
|
Quote: You didnt include the js script you referenced, which was easy enough to solve. The main prob is for some reason the leads generated seem to go into the wrong fields. I get the email fine enough but for instance when viewing the lead in vtiger the email address is in the company field, first name is in last name and the last name is empty! What do you think could be mixing these up. I looked through your send_data.php and couldnt find the error. I am using Vtiger 5.2
Hi,
IIRC I didn't modify the javascript file. It only does some local field validation anyway.
You must alter the field definitions on the vtiger host too. The file is vtigercrm-root-dir/soap/webforms.php
The order and names of all the field must be identical at each end of the connection.
Regarding 5.2 I am unsure, We are using the up-to-date release 5.04. 5.2 will be some way off I guess ;-)
HTH
Alan |
|
| Back to top |
|
macrocosm
Joined: 13 Dec 2007
Posts: 23
|
| Posted: Tue Jul 08, 2008 8:47 am Post subject: Re: Web to Customer Email Notification: form.css |
|
|
Woops .. I forgot to change the webforms.php accordingly. One thing though, in your send_data.php there is no reference to the address field you added. So if someone gets stuck on that pull the address field out of the form or keep it and reference it in your send_data.php.
I have to agree with your earlier point .. this does seem a bit spread around; but is certainly working. Things could be a bit tighter in a future release I suppose. |
|
| Back to top |
|
| |
|