vtiger Forum Index vtiger
The Honest Open Source CRM
 

Need more help with a Form? Easy for some Hard for me!!
Click here to go to the original topic

 
       vtiger Forum Index -> Web Forms
Previous topic :: Next topic  
Author Message
Worsin



Joined: 12 Sep 2007
Posts: 6

Posted: Thu Sep 13, 2007 3:34 am    Post subject: Need more help with a Form? Easy for some Hard for me!!  

Im making a form and need some help if someone has some time. I have successfully changed the fields to what i want only i would like to change around what fields are required. I have noticed that for leads inside vtiger only the lastname and company name are required.

Is there a reason why that is so? Anyway, if i can change that and also make my form reflect having a first name and it being required as well as email.

Basically i need a form like posted below only with the required fields being:

firstname
lastname
email
phone

Another problem this current form has is if i dont put in a last name or company name instead of getting an error message saying i need to put those in im getting an actual php error message
Code:
Fatal error: Cannot redeclare checkinputarray() (previously declared in G:\wamp\www\globals.php:32) in G:\wamp\www\globals.php on line 48


Here is the Index.php
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 '<h6><font color="purple">'.$error_message.'</font></h6>';

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<style>
   h3{margin:0; font-size: 14px;}
   hr{color: #EEE; background-color: #EEE; margin: 0; height:1px; }
   body {
   color: #333333;
   font-size: 11px;
   font-family: verdana, sans-serif;
   background-color: #f0f0f0;
}
   table#perfect         { background-color: #F0F0F0; border: 0px solid #CCC;}
   table#perfect caption { color: yellow; font-size: 110%; font-weight: bold;
                           background-color: black; padding: 3px;
                           margin-left: auto; margin-right: auto }
   table#perfect th      { text-align: right; font-weight: bold }
   table#perfect div     { text-align: center; margin-top: 6px }
   table#perfect span    { float: right; font-size: 65% }
   table#perfect a       { color: darkslategray; text-decoration: none }
   input.click           { cursor: pointer }
.style1 {
   font-family: Verdana, Arial, Helvetica, sans-serif;
   font-size: 16px;
   font-weight: bold;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
<body>
<div align="center" class="style1">
  <p>For a free quote on your project fill in the form below</p>
</div>
<form method=post action="index.php?option=com_vtwebform&module=Lead&task=send_data">
<input type="hidden" name="create" value="lead">

<table width="50%" align="center">
   <tr>
      <td width="75%"></td>
   </tr>
</table>

<table width="50%" border="0" align="center" cellpadding="5" cellspacing="0" bgcolor="F0F0F0" id="perfect">
      <tr><th bgcolor="E6E6E6">First Name:<font color="#CC0000"><sup>*</sup></font> </th>
            <td bgcolor="E6E6E6"><input type=text name=firstname size=30 value="<?php echo $_POST['firstname']?>"></td>
      </tr>
      <tr><th bgcolor="E6E6E6">Last Name:<font color="#CC0000"><sup>*</sup></font> </th>
            <td bgcolor="E6E6E6"><input type=text name=lastname size=30 value="<?php echo $_POST['lastname']?>"></td>
      </tr>
      <tr><th bgcolor="E6E6E6">Your E-Mail:<font color="#CC0000"><sup>*</sup></th>
            <td bgcolor="E6E6E6"><input type=text name=email size=30 value="<?php echo $_POST['email']?>"></td>
      </tr>
      <tr><th bgcolor="E6E6E6">Phone:</th>
            <td bgcolor="E6E6E6"><input type=text name=phone size=30 value="<?php echo $_POST['phone']?>"></td>
      </tr>
      <tr><th bgcolor="E6E6E6">Company:<font color="#CC0000"><sup>*</sup></font> </th>
            <td bgcolor="E6E6E6"><input type=text name=company size=30 value="<?php echo $_POST['company']?>"></td>
      </tr>
      <tr><th bgcolor="E6E6E6">Description:</th>
         <td bgcolor="E6E6E6"><textarea name=description rows=2 cols=29><?php echo $_POST['description']?></textarea></td>
      </tr>

   <tr><td colspan="2" align="center" bgcolor="E6E6E6">
      <input type=submit value="Submit" class=click></td></tr>
  </table>
</form>

</body>
</html>
<?php


?>

send_data.php
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 soapclient($Server_Path."/vtigerservice.php?service=webforms", false,
                                                $proxyhost, $proxyport, $proxyusername, $proxypassword);
$err = $client->getError();

if($_REQUEST['create'] == 'lead')
{
   $firstname = $_POST['firstname'];
   $lastname = $_POST['lastname'];
   $email = $_POST['email'];
   $phone = $_POST['phone'];
   $company = $_POST['company'];
   $country = $_POST['country'];
   $description = "WebForm : ".$_POST['description'];

   $params = array(
            'firstname' => "$firstname",
            'lastname' => "$lastname",
                      'email'=>"$email",
                      'phone'=>"$phone",
                      'company'=>"$company",
                      'country'=>"$country",
                      '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
      {
         echo '<br><br>'.$result.'<br><br><a href="index.php">Home</a>';
      }
   }
   else
   {
      $error_message = "<h3>Last Name and Company must be entered to create a Lead.</h3>";
      include("index.php");
   }
}
else
{
   include("index.php");
}

?>

webforms.php
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.
*
 ********************************************************************************/

require_once("config.php");
require_once('include/logging.php');
require_once('include/nusoap/nusoap.php');
require_once('include/database/PearDatabase.php');
require_once('modules/HelpDesk/HelpDesk.php');

$log = &LoggerManager::getLogger('webforms');

//$serializer = new XML_Serializer();
$NAMESPACE = 'http://www.vtiger.com/vtigercrm/';
$server = new soap_server;

$server->configureWSDL('vtigersoap');


$server->register(
   'create_lead_from_webform',
   array(
      'firstname'=>'xsd:string',
      'lastname'=>'xsd:string',
      'email'=>'xsd:string',
      'phone'=>'xsd:string',
      'company'=>'xsd:string',
      'country'=>'xsd:string',
      'description'=>'xsd:string',
      'assigned_user_id'=>'xsd:string'
        ),
   array('return'=>'xsd:string'),
   $NAMESPACE);

$server->register(
   'create_contact_from_webform',
   array(
      'first_name'=>'xsd:string',
      'last_name'=>'xsd:string',
      'email_address'=>'xsd:string',
      'home_phone'=>'xsd:string',
      'department'=>'xsd:string',
      'description'=>'xsd:string',
      'assigned_user_id'=>'xsd:string'
        ),
   array('return'=>'xsd:string'),
   $NAMESPACE);

$server->register(
   'unsubscribe_email',
   array(
      'email_address'=>'xsd:string'
        ),
   array('return'=>'xsd:string'),
   $NAMESPACE);


/**   function used to create lead from webform from the passed details
 *   @param string $lastname   - last name of the lead
 *   @param string $email - email of the lead
 *   @param string $phone - phone number of the lead
 *   @param string $company - company name of the lead
 *   @param string $country - country name of the lead
 *   @param string $description - description to create a lead
 *   @param int $assigned_user_id - assigned to user for the lead
 *   return message success or failure about the lead creation
 */
function create_lead_from_webform($firstname,$lastname, $email, $phone, $company, $country, $description, $assigned_user_id)
{
   global $adb;
   $adb->println("Create New Lead from Web Form - Starts");

   if($assigned_user_id == '')
   {
      //if the user id is empty then assign it to the admin user
      $assigned_user_id = $adb->query_result($adb->query("select id from vtiger_users where user_name='admin'"),0,'id');
   }

   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['company'] = $company;
   $focus->column_fields['country'] = $country;
   $focus->column_fields['description'] = $description;
   $focus->column_fields['assigned_user_id'] = $assigned_user_id;

   $focus->save("Leads");
   //$focus->retrieve_entity_info($focus->id,"Leads");

   $adb->println("Create New Lead from Web Form - Ends");

   if($focus->id != '')
      $msg = 'Thank you for your interest. Your information has been successfully added and you will be contacted shortly.';
   else
      $msg = "Lead creation failed. Please try again";

   return $msg;
}

/**   function used to create contact from webform from the passed details
 *   @param string $first_name   - first name to create contact
 *   @param string $last_name   - last name to create contact
 *   @param string $email_address - email address to create contact
 *   @param string $home_phone - phone number of home to create contact
 *   @param string $department - department to create contact
 *   @param string $description - description to create contact
 *   @param int $assigned_user_id - assigned to user for the contact
 *   return message success or failure about the contact creation
 */
function create_contact_from_webform($first_name, $last_name, $email_address, $home_phone, $department,$description, $assigned_user_id)
{
   global $adb;

   $adb->println("Create New Contact from Web Form - Starts");
   if($assigned_user_id == '')
   {
      //if the user id is empty then assign it to the admin user
      $assigned_user_id = $adb->query_result($adb->query("select id from vtiger_users where user_name='admin'"),0,'id');
   }

   require_once('modules/Contacts/Contacts.php');
   $focus = new Contacts();

   $focus->column_fields['firstname'] = $first_name;
   $focus->column_fields['lastname'] = $last_name;
   $focus->column_fields['email'] = $email_address;
   $focus->column_fields['homephone'] = $home_phone;
   $focus->column_fields['department'] = $department;
   $focus->column_fields['description'] = $description;
   $focus->column_fields['assigned_user_id'] = $assigned_user_id;

   $focus->save("Contacts");
   //$focus->retrieve_entity_info($focus->id,"Contacts");

   $adb->println("Create New Contact from Web Form - Ends");

   if($focus->id != '')
      $msg = 'Thank you for your interest. Information has been successfully added as Contact in vtigerCRM.';
   else
      $msg = "Contact creation failed. Please try again";

   return $msg;
}

/**   function used to unsubscribe the mail
 *   @param string $emailid - email address to unsubscribe
 *   return message about the success or failure status about the unsubscribe
 */
function unsubscribe_email($emailid)
{
   global $adb;
   $adb->println("Enter into the function unsubscribe_email($emailid)");
   
   $contact_res = $adb->query("select emailoptout from vtiger_contactdetails where email=\"$emailid\"");
   $contact_noofrows = $adb->num_rows($contact_res);
   $emailoptout = $adb->query_result($contact_res,0,'emailoptout');

   if($contact_noofrows > 0)
   {
      if($emailoptout != 1)
      {
         $adb->query("update vtiger_contactdetails set emailoptout=1 where email=\"$emailid\"");
         $msg = "You have been unsubscribed.";
      }
      else
      {
         $msg = "You are already unsubscribed.";
      }
   }
   else
   {
      $msg = "There are no record available for this mail address.";
   }

   $adb->println("Exit from the function unsubscribe_email($emailid)");
   return $msg;
}


//$log->fatal("In soap.php");

/* Begin the HTTP listener service and exit. */
$server->service($HTTP_RAW_POST_DATA);

exit();



?>
Back to top  
 
       vtiger Forum Index -> Web Forms
Page 1 of 1


Powered by phpBB Search Engine Indexer
Powered by phpBB 2.0.15 © 2001, 2002 phpBB Group