[ Index ] |
|
Code source de vtiger CRM 5.0.2 |
1 <?php 2 /********************************************************************************* 3 ** The contents of this file are subject to the vtiger CRM Public License Version 1.0 4 * ("License"); You may not use this file except in compliance with the License 5 * The Original Code is: vtiger CRM Open Source 6 * The Initial Developer of the Original Code is vtiger. 7 * Portions created by vtiger are Copyright (C) vtiger. 8 * All Rights Reserved. 9 * 10 ********************************************************************************/ 11 12 require_once ("config.php"); 13 require_once ('include/logging.php'); 14 require_once ('include/nusoap/nusoap.php'); 15 require_once ('include/database/PearDatabase.php'); 16 require_once ('modules/HelpDesk/HelpDesk.php'); 17 18 $log = &LoggerManager::getLogger('webforms'); 19 20 //$serializer = new XML_Serializer(); 21 $NAMESPACE = 'http://www.vtiger.com/vtigercrm/'; 22 $server = new soap_server; 23 24 $server->configureWSDL('vtigersoap'); 25 26 27 $server->register( 28 'create_lead_from_webform', 29 array( 30 'lastname'=>'xsd:string', 31 'email'=>'xsd:string', 32 'phone'=>'xsd:string', 33 'company'=>'xsd:string', 34 'country'=>'xsd:string', 35 'description'=>'xsd:string', 36 'assigned_user_id'=>'xsd:string' 37 ), 38 array('return'=>'xsd:string'), 39 $NAMESPACE); 40 41 $server->register( 42 'create_contact_from_webform', 43 array( 44 'first_name'=>'xsd:string', 45 'last_name'=>'xsd:string', 46 'email_address'=>'xsd:string', 47 'home_phone'=>'xsd:string', 48 'department'=>'xsd:string', 49 'description'=>'xsd:string', 50 'assigned_user_id'=>'xsd:string' 51 ), 52 array('return'=>'xsd:string'), 53 $NAMESPACE); 54 55 $server->register( 56 'unsubscribe_email', 57 array( 58 'email_address'=>'xsd:string' 59 ), 60 array('return'=>'xsd:string'), 61 $NAMESPACE); 62 63 64 /** function used to create lead from webform from the passed details 65 * @param string $lastname - last name of the lead 66 * @param string $email - email of the lead 67 * @param string $phone - phone number of the lead 68 * @param string $company - company name of the lead 69 * @param string $country - country name of the lead 70 * @param string $description - description to create a lead 71 * @param int $assigned_user_id - assigned to user for the lead 72 * return message success or failure about the lead creation 73 */ 74 function create_lead_from_webform($lastname, $email, $phone, $company, $country, $description, $assigned_user_id) 75 { 76 global $adb; 77 $adb->println("Create New Lead from Web Form - Starts"); 78 79 if($assigned_user_id == '') 80 { 81 //if the user id is empty then assign it to the admin user 82 $assigned_user_id = $adb->query_result($adb->query("select id from vtiger_users where user_name='admin'"),0,'id'); 83 } 84 85 require_once ("modules/Leads/Leads.php"); 86 $focus = new Leads(); 87 $focus->column_fields['lastname'] = $lastname; 88 $focus->column_fields['email'] = $email; 89 $focus->column_fields['phone'] = $phone; 90 $focus->column_fields['company'] = $company; 91 $focus->column_fields['country'] = $country; 92 $focus->column_fields['description'] = $description; 93 $focus->column_fields['assigned_user_id'] = $assigned_user_id; 94 95 $focus->save("Leads"); 96 //$focus->retrieve_entity_info($focus->id,"Leads"); 97 98 $adb->println("Create New Lead from Web Form - Ends"); 99 100 if($focus->id != '') 101 $msg = 'Thank you for your interest. Information has been successfully added as Lead in vtigerCRM.'; 102 else 103 $msg = "Lead creation failed. Please try again"; 104 105 return $msg; 106 } 107 108 /** function used to create contact from webform from the passed details 109 * @param string $first_name - first name to create contact 110 * @param string $last_name - last name to create contact 111 * @param string $email_address - email address to create contact 112 * @param string $home_phone - phone number of home to create contact 113 * @param string $department - department to create contact 114 * @param string $description - description to create contact 115 * @param int $assigned_user_id - assigned to user for the contact 116 * return message success or failure about the contact creation 117 */ 118 function create_contact_from_webform($first_name, $last_name, $email_address, $home_phone, $department,$description, $assigned_user_id) 119 { 120 global $adb; 121 122 $adb->println("Create New Contact from Web Form - Starts"); 123 if($assigned_user_id == '') 124 { 125 //if the user id is empty then assign it to the admin user 126 $assigned_user_id = $adb->query_result($adb->query("select id from vtiger_users where user_name='admin'"),0,'id'); 127 } 128 129 require_once ('modules/Contacts/Contacts.php'); 130 $focus = new Contacts(); 131 132 $focus->column_fields['firstname'] = $first_name; 133 $focus->column_fields['lastname'] = $last_name; 134 $focus->column_fields['email'] = $email_address; 135 $focus->column_fields['homephone'] = $home_phone; 136 $focus->column_fields['department'] = $department; 137 $focus->column_fields['description'] = $description; 138 $focus->column_fields['assigned_user_id'] = $assigned_user_id; 139 140 $focus->save("Contacts"); 141 //$focus->retrieve_entity_info($focus->id,"Contacts"); 142 143 $adb->println("Create New Contact from Web Form - Ends"); 144 145 if($focus->id != '') 146 $msg = 'Thank you for your interest. Information has been successfully added as Contact in vtigerCRM.'; 147 else 148 $msg = "Contact creation failed. Please try again"; 149 150 return $msg; 151 } 152 153 /** function used to unsubscribe the mail 154 * @param string $emailid - email address to unsubscribe 155 * return message about the success or failure status about the unsubscribe 156 */ 157 function unsubscribe_email($emailid) 158 { 159 global $adb; 160 $adb->println("Enter into the function unsubscribe_email($emailid)"); 161 162 $contact_res = $adb->query("select emailoptout from vtiger_contactdetails where email=\"$emailid\""); 163 $contact_noofrows = $adb->num_rows($contact_res); 164 $emailoptout = $adb->query_result($contact_res,0,'emailoptout'); 165 166 if($contact_noofrows > 0) 167 { 168 if($emailoptout != 1) 169 { 170 $adb->query("update vtiger_contactdetails set emailoptout=1 where email=\"$emailid\""); 171 $msg = "You have been unsubscribed."; 172 } 173 else 174 { 175 $msg = "You are already unsubscribed."; 176 } 177 } 178 else 179 { 180 $msg = "There are no record available for this mail address."; 181 } 182 183 $adb->println("Exit from the function unsubscribe_email($emailid)"); 184 return $msg; 185 } 186 187 188 //$log->fatal("In soap.php"); 189 190 /* Begin the HTTP listener service and exit. */ 191 $server->service($HTTP_RAW_POST_DATA); 192 193 exit(); 194 195 196 197 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 10:22:19 2007 | par Balluche grâce à PHPXref 0.7 |