[FIX, IMP] crm/scripts : maintenance of the php script, add a contact form

bzr revid: tfr@openerp.com-20101214153115-bh7sy2ofgt97tvin
This commit is contained in:
Thibault Francois 2010-12-14 16:31:15 +01:00
parent d18f713833
commit cb2c085f9e
3 changed files with 309 additions and 279 deletions

View File

@ -1,17 +1,19 @@
<?php
include("xmlrpc.inc");
$user = "";
$password = "";
$db = "";
$serverUri = "";
//Change to fit your configuration
$user = "admin";
$password = "a";
$db = "db_1";
$serverUri = "http://localhost:8069/xmlrpc/";
$client = new xmlrpc_client($serverUri.'common');
$msg = new xmlrpcmsg('login');
$msg->addParam(new xmlrpcval($db, "string"));
$msg->addParam(new xmlrpcval($user, "string"));
$msg->addParam(new xmlrpcval($pass, "string"));
$msg->addParam(new xmlrpcval($password, "string"));
$res = &$client->send($msg);
@ -31,7 +33,7 @@
$msg = new xmlrpcmsg('execute');
$msg->addParam(new xmlrpcval($db, "string"));
$msg->addParam(new xmlrpcval($id, "int"));
$msg->addParam(new xmlrpcval($pass, "string"));
$msg->addParam(new xmlrpcval($password, "string"));
$msg->addParam(new xmlrpcval("res.country","string"));
$msg->addParam(new xmlrpcval("search", "string"));
$msg->addParam(new xmlrpcval($key, "array"));
@ -59,7 +61,7 @@
$msg = new xmlrpcmsg('execute');
$msg->addParam(new xmlrpcval($db, "string"));
$msg->addParam(new xmlrpcval($id, "int"));
$msg->addParam(new xmlrpcval($pass, "string"));
$msg->addParam(new xmlrpcval($password, "string"));
$msg->addParam(new xmlrpcval("res.country","string"));
$msg->addParam(new xmlrpcval("read", "string"));
$msg->addParam(new xmlrpcval($ides, "array"));
@ -99,5 +101,5 @@
echo "connection not establish";
}
exit;
?>

View File

@ -12,57 +12,6 @@ class Contact
$this->subject = $sub;
}
function mailTo($post)
{
if (!empty($post))
{
if (empty($this->to))
{
$this->to = 'sales@tinyerp.com';
}
if (empty($this->subject))
{
$this->subject = 'Contact form information';
}
$body = '<table width="90%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td width="25%"></td>
<td width="2%"></td>
<td></td>
</tr>';
foreach ($post as $key => $value)
{
$body .= "<tr>
<td align='right'>$key</td>
<td align='center'><b>:</b></td>
<td align='left'>$value</td>
</tr>";
}
$body .= '</table>';
$header = 'MEME-version : 1.0'."\r\n";
$header .= 'Content-type: text/html; charset=iso-8859-1'."\r\n";
$header .= 'From: '.$post['name'].' <'.$post['email'].'>'."\r\n";
$header .= 'Reply-To: '.$post['name'].' <'.$post['email'].'>'."\r\n";
$header .= 'Return-Path: '.$post['name'].' <'.$post['email'].'>'."\r\n";
if (mail($this->to, $this->subject, $body, $header))
{
echo "<br /><h3>Thank You, Your information has been successfully submitted.</h3><br /><p><b>We will be in touch very soon.</b></p>";
}
else
{
echo "<br /><h4>Sorry, Due to some problem Your information has not been submitted.</h4>";
}
}
}
function xmlCallTo($usr, $password, $database, $server, $post)
{
@ -94,7 +43,6 @@ class Contact
else
{
$client2 = new xmlrpc_client($server_url.'object');
$key = array(new xmlrpcval(array(new xmlrpcval("code", "string"), new xmlrpcval("=", "string"), new xmlrpcval($post['country'], "string")),"array"),);
$msg = new xmlrpcmsg('execute');
$msg->addParam(new xmlrpcval($db, "string"));
@ -113,18 +61,17 @@ class Contact
$countryId = $val[0]->scalarval();
$val = array ("name" => new xmlrpcval($post['company'],"string"),
"title" => new xmlrpcval($post['salutation'], "string"),
"email_from" => new xmlrpcval($post['email'], "string"),
"phone" => new xmlrpcval($post['phone'], "string"),
"partner_name" => new xmlrpcval($post['name'], "string"),
"function" => new xmlrpcval($post["jobtitle"], "string"),
"zip" => new xmlrpcval($post['zip'], "string"),
"stage_id" => new xmlrpcval(6, "int"),
"stage_id" => new xmlrpcval(2, "int"),
"city" => new xmlrpcval($post['city'], "string"),
"country_id" => new xmlrpcval($countryId, "int"),
"state" => new xmlrpcval("draft", "string"),
"user_id" => new xmlrpcval(false, "boolean"),
"description" => new xmlrpcval("No.of Employees: ".$post['employees']."\nState: ".$post['state']."\nIndustry: ".$post['industry']."\nReasons: ".$post['reasons']."\nAbout: ".$post['about']."\nQuestions: ".stripslashes($post['questions'])."\nUpdate: ".$post['update'], "string")
"description" => new xmlrpcval("No.of Employees: ".$post['employees']."\nState: ".$post['state']."\nIndustry: ".$post['industry']."\nAbout: ".$post['about'], "string")
);
$msg = new xmlrpcmsg('execute');
@ -144,7 +91,7 @@ class Contact
if (!empty($readVal))
{
$val = array ( "description" => new xmlrpcval("About: ".$post['about']."\nQuestions: ".$post['questions']),
$val = array ( "description" => new xmlrpcval("About: ".$post['about']),
"model_id" => new xmlrpcval(276, "int"),
"res_id" => new xmlrpcval($readVal,"int"),
"email_from" => new xmlrpcval($post['email'], "string"),
@ -186,6 +133,7 @@ class Contact
}
}
if(isset($_POST['country']) && $_POST['country'] != '') {
$arrData = array();
$arrData = array_merge($arrData, (array)$_POST);
@ -195,7 +143,13 @@ class Contact
/*$cnt->mailTo($arrData); */
/* This function use ceating lead in crm of opener erp database */
$cnt->xmlCallTo('<username>', '<password>', '<db>', '<server>', $arrData);
//Change to fit your configuration
$cnt->xmlCallTo('admin', 'a', 'db_1', 'http://localhost:8069/xmlrpc/', $arrData);
}
else {
echo 'please fill the form at <a href="form.php">form.php</a>';
}
exit;
?>

View File

@ -0,0 +1,74 @@
<html>
<head>
<title>Contact form</title>
</head>
<body>
<h4>Contact Form</h4>
<form method="post" action="crmlead.php">
<label for="firstname">Firstname</label>
<input type="text" name="name" value="" id="firstname" class="required text" title="Please, fill in your firstname" data-required="true"><br />
<label for="company">Company</label>
<input type="text" name="company" value="" id="company" class="required text" title="Please, fill in your company name" data-required="true"><br />
<label for="jobtitle">Jobtitle</label>
<input type="text" name="jobtitle" value="" id="jobtitle" class="required text" title="Please, fill in your job title" data-required="true"><br />
<label for="email">Email</label>
<input type="text" name="email" value="" id="email" class="required email text" title="Please, enter a valid email address" data-required="true"><br />
<label for="phone">Phone</label>
<input type="text" name="phone" value="" id="phone" class="required phone text" title="Please use international format (eg: +32...)" data-required="true">
<label for="city">City</label>
<input type="text" name="city" value="" id="city" class="required text" title="Please, fill in your city" data-required="true"><br />
<label for="zip">Zipcode</label>
<td><input type="text" name="zip" value="" id="zip" class="required text" title="Please, fill in your zipcode" data-required="true"><br />
<label for="state">State</label><input type="text" name="state" value="" id="state" class="text" title="Please, fill in your state"> <br />
<label> Country : <?php include('countrylist.php'); ?></label> <br />
<label for="employees">No.of employees</label>
<select class="required" name="employees" title="Please, select the No. of employees" data-required="true">
<option value=""> -- select an option -- </option>
<option value="1-5">1-5</option>
<option value="5-10">5-10</option>
<option value="10-20">10-20</option>
<option value="20-100">20-100</option>
<option value="100-500">100-500</option>
<option value="500+">500+</option>
</select><br />
<label for="industry">Industry expertise</label>
<select class="required select" name="industry" title="Please, select an industry" data-required="true">
<option value=""> -- select an option -- </option>
<option value="auction">Auction Houses</option>
<option value="bank">Bank</option>
<option value="distribution">Distribution</option>
<option value="education">Education</option>
<option value="entertainment">Entertainment</option>
<option value="erp_integrator">ERP Integrator</option>
<option value="food_industries">Food industries</option>
<option value="hotels_restaurants">Hotels &amp; restaurants</option>
<option value="insurance">Insurance</option>
<option value="manufacturing">Manufacturing</option>
<option value="non_profit">Non-Profit</option>
<option value="public">Public</option>
<option value="services">Services</option>
<option value="telecommunication">Telecommunication</option>
<option value="others">Others</option>
</select><br />
<p>
<label> About : <textarea name="about"></textarea></textarea></label>
</p>
<p>
<input type="submit" value="Send"/> <input type="reset" />
</p>
</form>
</body>
</html>