7 private $subject = '', $to = '';
9 function __construct($to, $sub)
12 $this->subject = $sub;
16 function xmlCallTo($usr, $password, $database, $server, $post)
21 $server_url = $server; //'http://localhost:8069/xmlrpc/'
23 $client = new xmlrpc_client($server_url.'common');
25 $msg = new xmlrpcmsg('login');
26 $msg->addParam(new xmlrpcval($db, "string"));
27 $msg->addParam(new xmlrpcval($user, "string"));
28 $msg->addParam(new xmlrpcval($pass, "string"));
31 $res = &$client->send($msg);
33 if(!$res->faultCode()){
36 $id = $val->scalarval();
40 echo "Connection error = ";
45 $client2 = new xmlrpc_client($server_url.'object');
46 $key = array(new xmlrpcval(array(new xmlrpcval("code", "string"), new xmlrpcval("=", "string"), new xmlrpcval($post['country'], "string")),"array"),);
47 $msg = new xmlrpcmsg('execute');
48 $msg->addParam(new xmlrpcval($db, "string"));
49 $msg->addParam(new xmlrpcval($id, "int"));
50 $msg->addParam(new xmlrpcval($pass, "string"));
51 $msg->addParam(new xmlrpcval("res.country","string"));
52 $msg->addParam(new xmlrpcval("search", "string"));
53 $msg->addParam(new xmlrpcval($key, "array"));
54 $msg->addParam(new xmlrpcval(0, "int"));
55 $msg->addParam(new xmlrpcval(1, "int"));
57 $res = &$client2->send($msg);
59 $val = $res->value()->scalarval();
61 $countryId = $val[0]->scalarval();
63 $val = array ("name" => new xmlrpcval($post['company'],"string"),
64 "email_from" => new xmlrpcval($post['email'], "string"),
65 "phone" => new xmlrpcval($post['phone'], "string"),
66 "partner_name" => new xmlrpcval($post['name'], "string"),
67 "function" => new xmlrpcval($post["jobtitle"], "string"),
68 "zip" => new xmlrpcval($post['zip'], "string"),
69 "stage_id" => new xmlrpcval(2, "int"),
70 "city" => new xmlrpcval($post['city'], "string"),
71 "country_id" => new xmlrpcval($countryId, "int"),
72 "state" => new xmlrpcval("draft", "string"),
73 "user_id" => new xmlrpcval(false, "boolean"),
74 "description" => new xmlrpcval("No.of Employees: ".$post['employees']."\nState: ".$post['state']."\nIndustry: ".$post['industry']."\nAbout: ".$post['about'], "string")
77 $msg = new xmlrpcmsg('execute');
78 $msg->addParam(new xmlrpcval($db, "string"));
79 $msg->addParam(new xmlrpcval($id, "int"));
80 $msg->addParam(new xmlrpcval($pass, "string"));
81 $msg->addParam(new xmlrpcval("crm.lead", "string"));
82 $msg->addParam(new xmlrpcval("create", "string"));
83 $msg->addParam(new xmlrpcval($val, "struct"));
86 $res2 = &$client2->send($msg);
88 if(!$res2->faultCode())
90 $readVal = $res2->value()->scalarval();
94 $val = array ( "description" => new xmlrpcval("About: ".$post['about']),
95 "model_id" => new xmlrpcval(276, "int"),
96 "res_id" => new xmlrpcval($readVal,"int"),
97 "email_from" => new xmlrpcval($post['email'], "string"),
98 "email_to" => new xmlrpcval("sales@openerp.com", "string")
102 $msg = new xmlrpcmsg('execute');
103 $msg->addParam(new xmlrpcval($db, "string"));
104 $msg->addParam(new xmlrpcval($id, "int"));
105 $msg->addParam(new xmlrpcval($pass, "string"));
106 $msg->addParam(new xmlrpcval("crm.case.history", "string"));
107 $msg->addParam(new xmlrpcval("create", "string"));
108 $msg->addParam(new xmlrpcval($val, "struct"));
110 $res2 = &$client2->send($msg);
112 //echo "<br />Successfully created lead";
113 echo "<br /><h3>Thank You for your interest in openerp, we'll respond to your request shortly.</h3><br />";
114 if(strstr($post["about"],"Book")) {
115 echo '<script>window.location="http://www.openerp.com/index.php?option=com_content&id=54"</script>';
120 echo "<br />Lead is not created";
125 echo "<br />Problem in message sending for create lead";
131 echo "<br />Connection not established";
136 if(isset($_POST['country']) && $_POST['country'] != '') {
138 $arrData = array_merge($arrData, (array)$_POST);
140 $cnt = new Contact('sales5@openerp.com', 'Country: '.$arrData['country']. ' About: ' .$arrData['about']);
142 /* This function use for sending mail on perticular mail account */
143 /*$cnt->mailTo($arrData); */
145 /* This function use ceating lead in crm of opener erp database */
146 //Change to fit your configuration
147 $cnt->xmlCallTo('admin', 'a', 'db_1', 'http://localhost:8069/xmlrpc/', $arrData);
150 echo 'please fill the form at <a href="form.php">form.php</a>';