$Server_Path =
$portalserver; //This is the path where have you run the vtiger
server.
$proxyhost
= '';
//This is the proxy host
$proxyport
= '';
//This is proxy port
$proxyusername =
''; //This is
the proxy setting user name
$proxypassword =
''; //This is
the proxy setting password
//Default (1) is admin user id.
if you want to assign the contacts to a vtiger user then you can give
the user id
$assigned_user_id = 1;
index.php - adding new fields
add a new text/numeric field
<p class="label_field_pair"><label for="firstname">First Name</label>
<input type=text name=firstname size=30 value="<?php echo $_POST['firstname']?>">
<?php echo "$firstnameerror" ?></p>
add a new dropdown
<?php
$propertytypelist = array ('Co-op', 'Condo', 'Duplex', 'Triplex', 'Fourplex', 'SFR-attached',
'SFR-detached', 'PUD-attached', 'PUD-detached');
$sticky = '';
if(isset($_POST['create'])) // use the name of the form action...
$sticky = $_POST['propertytype'];
echo '<p class="label_field_pair"><label for="propertytype">Property Type<sup>*</sup>
</label><select name="propertytype">';
for( $i=0; $i < sizeof($propertytypelist); $i++)
{
$index = key($propertytypelist);
$valueshowing = current($propertytypelist);
if($propertytypelist[$i] == $sticky)
{
echo '<option value="' . $propertytypelist[$index] .'" selected>' . $valueshowing . '</option>';
}
else
{
echo '<option value="' . $propertytypelist[$index] .'">' . $valueshowing . '</option>';
}
next($propertytypelist);
}
echo '</select></p>';
?>
send_data.php
- add the new
field, validation, and email notification
/* configuration
of
unix path for the Lead index.php, NO TRAILING SLASH */
/* If the path is
/home/user/domain.com/Joomla/Lead/index.php */
/* then enter
"/home/user/domain.com/Joomla/Lead" with NO TRAILING SLASH*/
$fullunixpath =
"/home/user/some/path/to/this/Lead";
add the new field in
send_data.php
if($_REQUEST['create']
==
'lead')
{ /* config: list of fields showing in the form */
... existing fields for name, phone, email
$propertytype =
$_POST['propertytype'];
... more new fields
/* config: these are values sent to webforms.php every field sent must
be in this list */
/* last entry does NOT end with a "," */
$params = array(
... existing fields
'propertytype'=>"$propertytype",
);
/* validation of a numeric
field,
every field gets a unique formerror id */
if
(!$check->is_allnumbers($loanamount)) { $loanamounterror="<div
id=formerror6 class='fade-FF0000'>! Numbers 0-9 only</div>";
$formerror='yep';}
// Verify that the dropdown
data
was not altered to something evil - change if was.
$propertytype=$check->strip_metas($propertytype);
// ----- Send email to site
admin, etc. ----------------------
$headersep = (!isset( $uself ) || ($uself == 0)) ?
"\r\n" : "\n" ;
$http_referrer = getenv( "HTTP_REFERER" );
$messageproper =
"A new mortgage lead from $website: $firstname
$lastname\n" .
"------------------------------------------------------------\n\n" .
"Date:
$today\n" .
"First:
$firstname\n" .
"Last:
$lastname\n" .
"Email: $email\n"
.
"Phone: $phone\n"
.
"City:
$city\n" .
"State: $state\n"
.
"Property Type:
$propertytype\n" .
"Loan purpose: $loanpurpose\n" .
"Loan
amount $loanamount\n" .
"Loan
balance $currentbalance\n" .
"Credit Rating: $creditrating\n" .
"Time to call:
$timetocall\n" .
"Comments: $description\n" .
"\n\n------------------------------------------------------------\n" ;
webforms.php - adding new fields and edit the thank you message
/* last entry does NOT end in "," */
$server->register(
'create_lead_from_webform',
array(
'country'=>'xsd:string',
'firstname'=>'xsd:string',
'lastname'=>'xsd:string',
'email'=>'xsd:string',
'phone'=>'xsd:string',
'city'=>'xsd:string',
'state'=>'xsd:string',
'description'=>'xsd:string',
'company'=>'xsd:string',
'assigned_user_id'=>'xsd:string',
'leadsource'=>'xsd:string',
'propertytype'=>'xsd:string',
'loanpurpose'=>'xsd:string',
'loanamount'=>'xsd:string',
'currentbalance'=>'xsd:string',
'creditrating'=>'xsd:string',
'timetocall'=>'xsd:string'
),
array('return'=>'xsd:string'),
$NAMESPACE);
function create_lead_from_webform($firstname, $lastname, $email, $phone, $city, $state,
$description, $company, $assigned_user_id, $leadsource, $propertytype, $loanpurpose,
$loanamount, $currentbalance, $creditrating, $timetocall )
/* Below is where webforms.php maps vtiger db fields to webform fields */
/* One may use normal names in index.php and send_data.php, webforms.php maps */
/* them here to the vtiger db fields. */
require_once("modules/Leads/Leads.php");
$focus = new Leads();
$focus->column_fields['firstname'] = $firstname;
$focus->column_fields['lastname'] = $lastname;
$focus->column_fields['email'] = $email;
$focus->column_fields['phone'] = $phone;
$focus->column_fields['city'] = $city;
$focus->column_fields['state'] = $state;
$focus->column_fields['description'] = $description;
$focus->column_fields['company'] = $company;
$focus->column_fields['assigned_user_id'] = $assigned_user_id;
$focus->column_fields['leadsource'] = $leadsource;
$focus->column_fields['cf_459'] = $propertytype;
$focus->column_fields['cf_453'] = $loanpurpose;
$focus->column_fields['cf_457'] = $loanamount;
$focus->column_fields['cf_461'] = $currentbalance;
$focus->column_fields['cf_455'] = $creditrating;
$focus->column_fields['cf_463'] = $timetocall;
Here is a chunk of the webforms.php file with the coonfirmation message:
if($focus->id !=
'')
$msg = "<head><link
href='/cms/components/com_vtwebform/Lead/style.css'
rel='stylesheet'
type='text/css'></head><script type='text/javascript'
src='http://domain.com/cms/components/com_vtwebform/Lead/fat.js'></script><br><br><center>
<div id='thanks'
class='fade-5B90F6'><p id='formthankyou'>Thank you for your
application.
<br><br>An copy of
the details you submitted has been sent to your email at $email.
<br>One of our officers
will be contacting you within 24 hours. <br><br>We may be
contacted anytime at
415-555-1212 or via email at
<a
href=mailto:sales@domain.com>sales@domain.com</a><br></p></div></center><br><br>";
com_vtwebform - Joomla VTiger webforms component config
Edit the file vtwebform.php
Edit the lines shwon below in the file. Ensure $portalserver is set for your
Joomla install dir, NO TRAILING SLASH.
Ensure $module is set to
"Lead"
$portalserver =
"http://mochabomb.com/Demo/cms";
$module="Lead";
Webforms has been modified to be more flexible, stylish and robust -
listed below are changes made to bring VTiger webforms closer to the
UI standard of VTiger version 5.0.
- The table layout has been replaced with css
- CSS with many classes for plenty of flexibility
- Any field can be validated using the PHP Validator class
- Forms retain all values when reloaded, including drop-downs
- PHP Server-side validation responds with error messages
adjacent
to
the field in error
- Error messages use the "fade anything technique" for more
stylish
feedback
- All fields are filtered of meta-characters to ensure more
security against code injection attacks
- Email domains are verified to be real
- Email notification of new lead sent with
lead information
- Distinct email format for the email lead notification
and for the site visitor
- HTML added to the existing "thank you" message to show
About the Validatator class:
Using this
class your programs can validate a wide variety of data types common to
forms and the internet in general. Included with the various data
validation routines are several ``common'' string and array
manipulation
routines. In short, this is a PHP class designed to conduct grunt work
on
submitted data. This version of Validator contains 19 data tests, 9
data
manipulation methods, and one array debugging tool.
- The site visitor lands on index.php
and completes the information, which is submitted to send_data.php .
- send_data.php validates
the data using class.Validator.php3.
- Error messages are sent by send_data.php to be displayed
in index.php
that styles errors
with fat.js.
- The index.php<->send_data.php loop continues until the form
has no validation errors.
- Form data is sent by send_data.php
to webforms.php where
each data element is mapped to vtiger db fields and populated into the
database. Also, send_data.php
sends out the email messages to the site admin and visitor with the
format as defined in send_data.php.
- Lastly, webforms.php
displays the "thank you" message with fade effect styling by fat.js
This document was written for webforms
Lead for this specific version, dated Feb 22, 2007. Any
changes made since then may have introduced errors into this document -
allowing you the reader to put to use your excellent problem solving
skills - this is not intentional nor considered a "feature".
The forms will not work correctly without some changes to integrate
your customized form with your vtiger installation.
- If using this form as is - for collecting mortage leads and
the
same fields, create the custom fields listed below in VTiger and add
the values for the dropdown lists.
- propertytype - dropdown select
- loanpurpose - dropdown select
- loanamount - currency
- currentbalance - currency
- creditrating - drodown select
- timetocall - dropdown select
- Next, using phpmyadmin, look at the vtiger_cf tables and vtiger_leadcf table
and see what the cf value
is for each field - should be something like cf_467
- In webforms.php
around line 105, edit the lines that contain the mapping of custom
fields to your cf values to correctly match your mapping. A
sample is below.
/* Below is where webforms.php maps vtiger db fields to webform fields
*/
/* One may use normal names
in
index.php and send_data.php, webforms.php maps */
/* them here to the vtiger
db
fields. */
require_once("modules/Leads/Leads.php");
$focus =
new
Leads();
$focus->column_fields['firstname'] = $firstname;
$focus->column_fields['lastname'] = $lastname;
$focus->column_fields['email'] = $email;
$focus->column_fields['phone'] = $phone;
$focus->column_fields['city'] = $city;
$focus->column_fields['state'] = $state;
$focus->column_fields['description'] = $description;
$focus->column_fields['company'] = $company;
$focus->column_fields['assigned_user_id'] = $assigned_user_id;
$focus->column_fields['leadsource'] = $leadsource;
$focus->column_fields['cf_459'] = $propertytype;
$focus->column_fields['cf_453'] = $loanpurpose;
$focus->column_fields['cf_457'] = $loanamount;
$focus->column_fields['cf_461'] = $currentbalance;
$focus->column_fields['cf_455'] = $creditrating;
$focus->column_fields['cf_463'] = $timetocall;
- Edit index.php around
line 28 and 31 for the path of where style.css and fat.js are
located. If this is not configured correctly, forms will have no
css or fade effects.
- In send_data.php
around line 19, edit the path to the webform Lead index.php using the format
shown in the file comments. If you encounter a parse error, it's
most likely because this
path is configured wrong - send_data.php
will call the wrong index.php.
The email notification is
configured in send_data.php starting
around line 125 and there are are detailed comments there.
- Back in webforms.php,
edit these lines around line 102:
$leadsource = "Web
Site"; /* config: the lead source */
$company
=
"domain.com"; /*
config: set this to your company or domain name*/
- In config.php
around line - edit the full HTTP path of your vtiger install.
- In the class.Validator.php3
file, ensure yours domain of interest added around line 677 is in the
list. Email validation actually ensures the domain
exists. Originally the Validator class had all 243 or so top
level domains, but my PHP install did not like the large array, so for
brevity I altered the code (see code for comments) and now only check
for a few domains. Feel free to alter as needed for your
installation.
- Copy the <vtiger
installdir>/soap/webforms.php file to webforms.php.orig and replace
it with the one that came with this package. This is verified to
work with 5.0.3-RC2.
- Test it out and please post back at thevtiger form forum ( http://forums.vtiger.com/viewforum.php?f=21
) your results and
work-around (if any).