public function searchByModule($searchParams = array(), $module = 'Leads') { $soapclient = new SoapClient($this->settings['wsdl_address']); $result_array = $soapclient->login(array('user_name' => $this->settings['wsdl_username'], 'password' => $this->settings['wsdl_password'], 'version' => '0.1'), 'soaplhcsugarcrm'); $session_id = $result_array->id; $db = ezcDbInstance::get(); // format filter $filterSQLParams = array(); foreach ($searchParams as $field => $param) { $filterSQLParams[] = $field . ' = ' . $db->quote($param); } $results = $soapclient->get_entry_list($session_id, $module, '(' . implode(" OR ", $filterSQLParams) . ')', "", 0, array(), 1); if ($results->result_count == 1) { return $results->entry_list[0]; } return false; }
define("sugar_uri", 'http://sugar.gastronomicainternacional.com/'); if (!defined('sugarEntry')) { define('sugarEntry', true); } //host connection $options = array("location" => sugar_location, "uri" => sugar_uri, "trace" => 1); //user connection $user_auth = array("user_name" => 'admin', "password" => MD5('martin2013'), "version" => '.01'); $client = new SoapClient(NULL, $options); //login sugar $client_res = $client->login($user_auth, "admin"); $session_id = $client_res->id; # START VALIDAR DUPLICADOS @author: Nathaly $emailLead = trim($email); # $emailLead = "*****@*****.**"; $getDuplicados = $client->get_entry_list($session_id, 'Opportunities', 'trim(email_c) like "' . $emailLead . '"', 'email_c', 0, array('id', 'name', 'email_c')); $duplicados = $getDuplicados->entry_list; if (count($duplicados) > 0) { $nombre = "- D - " . $nombre; } # END VALIDAR DUPLICADOS // create a new contact record, assigned to this account, and grab the contact ID $response = $client->set_entry($session_id, 'Opportunities', array(array("name" => 'name', "value" => $nombre . ' ' . $apellido), array("name" => 'nombre_c', "value" => $nombre), array("name" => 'apellidos_c', "value" => $apellido), array("name" => 'email_c', "value" => $email), array("name" => $tipo_tel == 'Celular' ? 'telfalternativo_c' : 'telf_c', "value" => $tel), array("name" => 'cursosinteres_c', "value" => $area), array("name" => 'objetoestudio_c', "value" => $objeto), array("name" => 'edad_c', "value" => $edad), array("name" => 'horario_contacto_c', "value" => $horario), array("name" => 'comentario_c', "value" => $comentario), array("name" => 'viene_de_c', "value" => $vieneDe))); $leadCreado = $response->error->number == 0 ? 1 : 0; sendDebugMail('step leadCreado', $leadCreado); // SEND MAIL if ($leadCreado == 1) { // sendDebugMail('step leadCreado 2', $leadCreado); $to = $myemail; $email_subject = "Registro recibido - Gastronómica Internacional"; // sendDebugMail('step semi semi final', $myemail . " " . $email_subject);