function get_notification_recipients() { if($this->special_notification) { return parent::get_notification_recipients(); } // $GLOBALS['log']->debug('Call.php->get_notification_recipients():'.print_r($this,true)); $list = array(); if(!is_array($this->contacts_arr)) { $this->contacts_arr = array(); } if(!is_array($this->users_arr)) { $this->users_arr = array(); } if(!is_array($this->leads_arr)) { $this->leads_arr = array(); } foreach($this->users_arr as $user_id) { $notify_user = new User(); $notify_user->retrieve($user_id); $notify_user->new_assigned_user_name = $notify_user->full_name; $GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name"); $list[$notify_user->id] = $notify_user; } foreach($this->contacts_arr as $contact_id) { $notify_user = new Contact(); $notify_user->retrieve($contact_id); $notify_user->new_assigned_user_name = $notify_user->full_name; $GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name"); $list[$notify_user->id] = $notify_user; } foreach($this->leads_arr as $lead_id) { $notify_user = new Lead(); $notify_user->retrieve($lead_id); $notify_user->new_assigned_user_name = $notify_user->full_name; $GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name"); $list[$notify_user->id] = $notify_user; } global $sugar_config; if(isset($sugar_config['disable_notify_current_user']) && $sugar_config['disable_notify_current_user']) { global $current_user; if(isset($list[$current_user->id])) unset($list[$current_user->id]); } // $GLOBALS['log']->debug('Call.php->get_notification_recipients():'.print_r($list,true)); return $list; }
/** * get recipients of reminding email for specific activity * @param string $id * @param string $module * @return array */ protected function getRecipients($id, $module = "Meetings") { global $db; switch ($module) { case "Meetings": $field_part = "meeting"; break; case "Calls": $field_part = "call"; break; default: return array(); } $emails = array(); // fetch users $query = "SELECT user_id FROM {$field_part}s_users WHERE {$field_part}_id = '{$id}' AND accept_status != 'decline' AND deleted = 0\n "; $re = $db->query($query); while ($row = $db->fetchByAssoc($re)) { $user = new User(); $user->retrieve($row['user_id']); if (!empty($user->email1)) { $arr = array('type' => 'Users', 'name' => $user->full_name, 'email' => $user->email1); $emails[] = $arr; } } // fetch contacts $query = "SELECT contact_id FROM {$field_part}s_contacts WHERE {$field_part}_id = '{$id}' AND accept_status != 'decline' AND deleted = 0"; $re = $db->query($query); while ($row = $db->fetchByAssoc($re)) { $contact = new Contact(); $contact->retrieve($row['contact_id']); if (!empty($contact->email1)) { $arr = array('type' => 'Contacts', 'name' => $contact->full_name, 'email' => $contact->email1); $emails[] = $arr; } } // fetch leads $query = "SELECT lead_id FROM {$field_part}s_leads WHERE {$field_part}_id = '{$id}' AND accept_status != 'decline' AND deleted = 0"; $re = $db->query($query); while ($row = $db->fetchByAssoc($re)) { $lead = new Lead(); $lead->retrieve($row['lead_id']); if (!empty($lead->email1)) { $arr = array('type' => 'Leads', 'name' => $lead->full_name, 'email' => $lead->email1); $emails[] = $arr; } } return $emails; }
function update_tilkee_tilk(&$bean, $event, $arguments = null) { if ($event != 'before_save') { return; } global $beanFiles; $tilk_name = '[TILK] '; // Email initialisation if ($bean->contacts_id != '') { require_once $beanFiles['Contact']; $the_contact = new Contact(); $the_contact->retrieve($bean->contacts_id); $bean->contact_email = $the_contact->emailAddress->getPrimaryAddress($the_contact); $bean->name = $tilk_name . $the_contact->name; } if ($bean->leads_id != '') { require_once $beanFiles['Lead']; $the_lead = new Lead(); $the_lead->retrieve($bean->leads_id); $bean->contact_email = $the_lead->emailAddress->getPrimaryAddress($the_lead); $bean->name = $tilk_name . $the_lead->name; } // delete URL if tilk is archived if ($bean->archived == 'true') { $bean->tilk_url = ''; } }
/** * Create a lead and convert it to an existing Account and Contact */ public function testConvertLinkingExistingContact() { // Create records $lead = SugarTestLeadUtilities::createLead(); $account = SugarTestAccountUtilities::createAccount(); $contact = SugarTestContactUtilities::createContact(); // ConvertLead to an existing Contact and Account $_REQUEST = array('module' => 'Leads', 'record' => $lead->id, 'isDuplicate' => 'false', 'action' => 'ConvertLead', 'convert_create_Contacts' => 'false', 'report_to_name' => $contact->name, 'reports_to_id' => $contact->id, 'convert_create_Accounts' => 'false', 'account_name' => $account->name, 'account_id' => $account->id, 'handle' => 'save'); // Call display to trigger conversion $vc = new ViewConvertLead(); $vc->display(); // Refresh Lead $leadId = $lead->id; $lead = new Lead(); $lead->retrieve($leadId); // Refresh Contact $contactId = $contact->id; $contact = new Contact(); $contact->retrieve($contactId); // Check if contact it's linked properly $this->assertEquals($contact->id, $lead->contact_id, 'Contact not linked with Lead successfully.'); // Check if account is linked with lead properly $this->assertEquals($account->id, $lead->account_id, 'Account not linked with Lead successfully.'); // Check if account is linked with contact properly $this->assertEquals($account->id, $contact->account_id, 'Account not linked with Contact successfully.'); // Check Lead Status, should be converted $this->assertEquals('Converted', $lead->status, "Lead status should be 'Converted'."); }
/** * Load data into info_box_contents array to show array later. * * @param int $max of records to load * * @return void */ public function loadBox($max = 5) { global $conf, $user, $langs, $db; $this->max = $max; dol_include_once('/lead/class/lead.class.php'); $lead = new Lead($db); $lead->fetch_all('DESC', 't.date_closure', $max, 0, array('t.date_closure<' => dol_now())); $text = $langs->trans("LeadLate", $max); $this->info_box_head = array('text' => $text, 'limit' => dol_strlen($text)); $i = 0; foreach ($lead->lines as $line) { // FIXME: line is an array, not an object $line->fetch_thirdparty(); // Ref $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => $this->boximg, 'url' => dol_buildpath('/lead/lead/card.php', 1) . '?id=' . $line->id); $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $line->ref, 'url' => dol_buildpath('/lead/lead/card.php', 1) . '?id=' . $line->id); $this->info_box_contents[$i][2] = array('td' => 'align="left" width="16"', 'logo' => 'company', 'url' => DOL_URL_ROOT . "/comm/fiche.php?socid=" . $line->fk_soc); $this->info_box_contents[$i][3] = array('td' => 'align="left"', 'text' => dol_trunc($line->thirdparty->name, 40), 'url' => DOL_URL_ROOT . "/comm/fiche.php?socid=" . $line->fk_soc); // Amount Guess $this->info_box_contents[$i][4] = array('td' => 'align="left"', 'text' => price($line->amount_prosp, 'HTML') . $langs->getCurrencySymbol($conf->currency)); // Amount real $this->info_box_contents[$i][5] = array('td' => 'align="left"', 'text' => $line->getRealAmount() . $langs->getCurrencySymbol($conf->currency)); $i++; } }
function display() { if (isset($this->bean->lead_id) && !empty($this->bean->lead_id)) { //get lead name $lead = new Lead(); $lead->retrieve($this->bean->lead_id); $this->ss->assign('lead', $lead); } parent::display(); }
function display() { global $mod_strings, $app_strings, $app_list_strings, $sugar_config, $beanFiles; $this->ss->assign("MOD", $mod_strings); $this->ss->assign("APP_LIST", $app_list_strings); // Init default name $this->bean->name = '[TILK] '; // IF THE TILK IS CREATED FROM AN CONTACT if (isset($_REQUEST['CreateFromContact']) && $_REQUEST['CreateFromContact'] == 'true') { // CREATE DEFAULT TILK LINK WITH CONTACT require_once $beanFiles['Contact']; $link_contact = new Contact(); $link_contact->retrieve($_REQUEST['return_id']); $this->bean->contacts_id = $link_contact->id; $this->bean->contacts_name = $link_contact->name; $this->bean->contact_email = $link_contact->emailAddress->getPrimaryAddress($link_contact); $this->bean->name = '[TILK] ' . $link_contact->name; //$this->bean->id = $this->bean->save(); $_REQUEST['record'] = $this->bean->id; // TILKEE API - CREATE PROJECT AND SYNCH IT } // IF THE TILK IS CREATED FROM AN LEAD if (isset($_REQUEST['CreateFromLead']) && $_REQUEST['CreateFromLead'] == 'true') { // CREATE DEFAULT TILK LINK WITH LEAD require_once $beanFiles['Lead']; $link_lead = new Lead(); $link_lead->retrieve($_REQUEST['return_id']); $this->bean->leads_name = $link_lead->name; $this->bean->leads_id = $link_lead->id; $this->bean->contact_email = $link_lead->emailAddress->getPrimaryAddress($link_lead); $this->bean->name = '[TILK] ' . $link_lead->name; //$this->bean->id = $this->bean->save(); $_REQUEST['record'] = $this->bean->id; // TILKEE API - CREATE PROJECT AND SYNCH IT } // IF THE TILK IS CREATED FROM AN PROJECT if (isset($_REQUEST['CreateFromProject']) && $_REQUEST['CreateFromProject'] == 'true') { // CREATE DEFAULT TILK LINK WITH PROJECT require_once $beanFiles['TILKEE_PROJECTS']; $link_tilkee_project = new TILKEE_PROJECTS(); $link_tilkee_project->retrieve($_REQUEST['return_id']); $this->bean->tilkee_projects_name = $link_tilkee_project->name; $this->bean->tilkee_projects_id = $link_tilkee_project->id; //$this->bean->id = $this->bean->save(); $_REQUEST['record'] = $this->bean->id; // TILKEE API - CREATE PROJECT AND SYNCH IT } parent::display(); }
public function show($id) { $lead = Lead::with('leadstatus', array('users' => function ($query) { $query->orderBy('created_at', 'desc'); }))->findOrFail($id); return Response::json($lead); }
/** * @group bug40629 */ public function testImportedVcardAccountLink() { $filename = dirname(__FILE__) . "/SimpleVCard.vcf"; $vcard = new vCard(); $contact_id = $vcard->importVCard($filename, 'Contacts'); $contact_record = new Contact(); $contact_record->retrieve($contact_id); $this->assertFalse(empty($contact_record->account_id), "Contact should have an account record associated"); $GLOBALS['db']->query("delete from contacts where id = '{$contact_id}'"); $vcard = new vCard(); $lead_id = $vcard->importVCard($filename, 'Leads'); $lead_record = new Lead(); $lead_record->retrieve($lead_id); $this->assertTrue(empty($lead_record->account_id), "Lead should not have an account record associated"); $GLOBALS['db']->query("delete from leads where id = '{$lead_id}'"); }
public static function createLead($id = '') { $time = mt_rand(); $first_name = 'SugarLeadFirst'; $last_name = 'SugarLeadLast'; $email1 = '*****@*****.**'; $lead = new Lead(); $lead->first_name = $first_name . $time; $lead->last_name = $last_name; $lead->email1 = 'lead@' . $time . 'sugar.com'; if (!empty($id)) { $lead->new_with_id = true; $lead->id = $id; } $lead->save(); self::$_createdLeads[] = $lead; return $lead; }
} elseif ($tmp == 'NotConfigured') { print $langs->trans($tmp); } else { print $tmp; } print '</td>' . "\n"; print '<td align="center">'; if ($conf->global->LEAD_ADDON == "{$file}") { print img_picto($langs->trans("Activated"), 'switch_on'); } else { print '<a href="' . $_SERVER["PHP_SELF"] . '?action=setmod&value=' . $file . '">'; print img_picto($langs->trans("Disabled"), 'switch_off'); print '</a>'; } print '</td>'; $businesscase = new Lead($db); $businesscase->initAsSpecimen(); // Info $htmltooltip = ''; $htmltooltip .= '' . $langs->trans("Version") . ': <b>' . $module->getVersion() . '</b><br>'; $nextval = $module->getNextValue($user->id, $mysoc, $propal); if ("{$nextval}" != $langs->trans("NotAvailable")) { $htmltooltip .= '' . $langs->trans("NextValue") . ': '; if ($nextval) { $htmltooltip .= $nextval . '<br>'; } else { $htmltooltip .= $langs->trans($module->error) . '<br>'; } } print '<td align="center">'; print $form->textwithpicto('', $htmltooltip, 1, 0);
function converted_lead($leadid, $contactid, $accountid, $opportunityid) { $query = "UPDATE leads set converted='1', contact_id={$contactid}, account_id={$accountid}, opportunity_id={$opportunityid} where id={$leadid} and deleted=0"; $this->db->query($query, true, "Error converting lead: "); //we must move the status out here in order to be able to capture workflow conditions $leadid = str_replace("'", "", $leadid); $lead = new Lead(); $lead->retrieve($leadid); $lead->status = 'Converted'; $lead->save(); }
protected function get_notification_recipients() { if ($this->special_notification) { return parent::get_notification_recipients(); } $list = []; if (!is_array($this->contacts_arr)) { $this->contacts_arr = []; } if (!is_array($this->users_arr)) { $this->users_arr = []; } if (!is_array($this->leads_arr)) { $this->leads_arr = []; } foreach ($this->users_arr as $user_id) { $notify_user = new User(); $notify_user->retrieve($user_id); $notify_user->new_assigned_user_name = $notify_user->full_name; Log::info("Notifications: recipient is {$notify_user->new_assigned_user_name}"); $list[$notify_user->id] = $notify_user; } foreach ($this->contacts_arr as $contact_id) { $notify_user = new Contact(); $notify_user->retrieve($contact_id); $notify_user->new_assigned_user_name = $notify_user->full_name; Log::info("Notifications: recipient is {$notify_user->new_assigned_user_name}"); $list[$notify_user->id] = $notify_user; } foreach ($this->leads_arr as $lead_id) { $notify_user = new Lead(); $notify_user->retrieve($lead_id); $notify_user->new_assigned_user_name = $notify_user->full_name; Log::info("Notifications: recipient is {$notify_user->new_assigned_user_name}"); $list[$notify_user->id] = $notify_user; } global $sugar_config; if (isset($sugar_config['disable_notify_current_user']) && $sugar_config['disable_notify_current_user']) { global $current_user; if (isset($list[$current_user->id])) { unset($list[$current_user->id]); } } return $list; }
function getInvitationHash(&$focus, $event) { global $sugar_config; global $system_config; global $timedate; $date_start_in_db_fmt = $timedate->swap_formats($focus->date_start, $timedate->get_date_time_format(true, $current_user), $timedate->get_db_date_time_format()); $date_start_array = split(" ", trim($date_start_in_db_fmt)); $date_time_start = DateTimeUtil::get_time_start($date_start_array[0], $date_start_array[1]); $date_start_timestamp = mktime($date_time_start->hour, $date_time_start->min, $date_time_start->sec, $date_time_start->month, $date_time_start->day); $startDateString = date("d.m.Y", $date_start_timestamp); //dd.mm.yyyy $startTimeString = date("H:i", $date_start_timestamp); $date_end_timestamp = $date_start_timestamp + ($focus->duration_hours * 3600 + $focus->duration_minutes * 60); $endDateString = date("d.m.Y", $date_end_timestamp); //dd.mm.yyyy $endTimeString = date("H:i", $date_end_timestamp); /* echo '<pre>'; echo $startDateString; echo "\n"; echo $startTimeString; echo "\n"; echo $date_start_in_db_fmt; echo "\n"; echo "endDateString ". $endDateString; echo "\n"; echo "endTimeString ". $endTimeString; echo "\n"; exit(); echo '</pre>'; */ if ($focus->online_meeting_url_c == "" && $focus->is_openmeetings_c == true && $_REQUEST['send_invites'] == "1") { $_REQUEST['send_invites'] = '0'; $openmeetings_gateway = new openmeetings_gateway(); if ($openmeetings_gateway->openmeetings_loginuser()) { $admin = new Administration(); $admin->retrieveSettings(); //$notify_user = $focus->get_notification_recipients(); foreach ($focus->users_arr as $user_id) { $notify_user = new User(); $notify_user->retrieve($user_id); $notify_user->new_assigned_user_name = $notify_user->full_name; $GLOBALS['log']->info("Notifications: recipient is {$notify_user->new_assigned_user_name}"); $invitation_hash = $openmeetings_gateway->getInvitationHash($notify_user->name, $focus->openmeetings_roomid_c, false, "123", 2, $startDateString, $startTimeString, $endDateString, $endTimeString); $notify_user->online_meeting_url_temp = "http://" . $system_config->settings[info_openmeetings_url] . ":" . $system_config->settings[info_openmeetings_http_port] . "/openmeetings/?" . "invitationHash=" . $invitation_hash; //$admin = new Administration(); //$admin->retrieveSettings(); $focus->send_assignment_notifications($notify_user, $admin); } foreach ($focus->contacts_arr as $contact_id) { $notify_user = new Contact(); $notify_user->retrieve($contact_id); $notify_user->new_assigned_user_name = $notify_user->name; $GLOBALS['log']->info("Notifications: recipient is {$notify_user->new_assigned_user_name}"); $invitation_hash = $openmeetings_gateway->getInvitationHash($notify_user->name, $focus->openmeetings_roomid_c, false, "123", 2, $startDateString, $startTimeString, $endDateString, $endTimeString); $notify_user->online_meeting_url_temp = "http://" . $system_config->settings[info_openmeetings_url] . ":" . $system_config->settings[info_openmeetings_http_port] . "/openmeetings/?" . "invitationHash=" . $invitation_hash; //$admin = new Administration(); //$admin->retrieveSettings(); $focus->send_assignment_notifications($notify_user, $admin); } foreach ($focus->leads_arr as $lead_id) { $notify_user = new Lead(); $notify_user->retrieve($lead_id); $notify_user->new_assigned_user_name = $notify_user->full_name; $GLOBALS['log']->info("Notifications: recipient is {$notify_user->new_assigned_user_name}"); $invitation_hash = $openmeetings_gateway->getInvitationHash($notify_user->name, $focus->openmeetings_roomid_c, false, "123", 2, $startDateString, $startTimeString, $endDateString, $endTimeString); $notify_user->online_meeting_url_temp = "http://" . $system_config->settings[info_openmeetings_url] . ":" . $system_config->settings[info_openmeetings_http_port] . "/openmeetings/?" . "invitationHash=" . $invitation_hash; //$admin = new Administration(); //$admin->retrieveSettings(); $focus->send_assignment_notifications($notify_user, $admin); } } else { echo "Could not login User to OpenMeetings, check your OpenMeetings Module Configuration"; //exit(); } } }
/** * @see SugarView::display() */ public function display() { global $current_user, $mod_strings, $app_strings, $app_list_strings, $sugar_config, $locale; $configurator = new Configurator(); $sugarConfig = SugarConfig::getInstance(); $focus = new Administration(); $configurator->parseLoggerSettings(); $focus->retrieveSettings(); if (!empty($_POST['restore'])) { $configurator->restoreConfig(); } $this->ss->assign('MOD', $mod_strings); $this->ss->assign('APP', $app_strings); $this->ss->assign('APP_LIST', $app_list_strings); $this->ss->assign('config', $configurator->config); $this->ss->assign('error', $configurator->errors); $this->ss->assign("AUTO_REFRESH_INTERVAL_OPTIONS", get_select_options_with_id($app_list_strings['dashlet_auto_refresh_options_admin'], isset($configurator->config['dashlet_auto_refresh_min']) ? $configurator->config['dashlet_auto_refresh_min'] : 30)); $this->ss->assign('LANGUAGES', get_languages()); $this->ss->assign("JAVASCRIPT", get_set_focus_js() . get_configsettings_js()); $this->ss->assign('company_logo', SugarThemeRegistry::current()->getImageURL('company_logo.png')); $this->ss->assign("settings", $focus->settings); $this->ss->assign("mail_sendtype_options", get_select_options_with_id($app_list_strings['notifymail_sendtype'], $focus->settings['mail_sendtype'])); if (!empty($focus->settings['proxy_on'])) { $this->ss->assign("PROXY_CONFIG_DISPLAY", 'inline'); } else { $this->ss->assign("PROXY_CONFIG_DISPLAY", 'none'); } if (!empty($focus->settings['proxy_auth'])) { $this->ss->assign("PROXY_AUTH_DISPLAY", 'inline'); } else { $this->ss->assign("PROXY_AUTH_DISPLAY", 'none'); } if (!empty($configurator->config['logger']['level'])) { $this->ss->assign('log_levels', get_select_options_with_id(LoggerManager::getLoggerLevels(), $configurator->config['logger']['level'])); } else { $this->ss->assign('log_levels', get_select_options_with_id(LoggerManager::getLoggerLevels(), '')); } if (!empty($configurator->config['lead_conv_activity_opt'])) { $this->ss->assign('lead_conv_activities', get_select_options_with_id(Lead::getActivitiesOptions(), $configurator->config['lead_conv_activity_opt'])); } else { $this->ss->assign('lead_conv_activities', get_select_options_with_id(Lead::getActivitiesOptions(), '')); } if (!empty($configurator->config['logger']['file']['suffix'])) { $this->ss->assign('filename_suffix', get_select_options_with_id(SugarLogger::$filename_suffix, $configurator->config['logger']['file']['suffix'])); } else { $this->ss->assign('filename_suffix', get_select_options_with_id(SugarLogger::$filename_suffix, '')); } if (isset($configurator->config['logger_visible'])) { $this->ss->assign('logger_visible', $configurator->config['logger_visible']); } else { $this->ss->assign('logger_visible', true); } $ebay_site_ids = array('0' => 'eBay United States', '2' => 'eBay Canada (English)', '3' => 'eBay UK', '15' => 'eBay Australia', '16' => 'eBay Austria', '23' => 'eBay Belgium (French)', '71' => 'eBay France', '77' => 'eBay Germany', '100' => 'eBay Motors', '101' => 'eBay Italy', '123' => 'eBay Belgium (Dutch)', '146' => 'eBay Netherlands', '186' => 'eBay Spain', '193' => 'eBay Switzerland', '201' => 'eBay Hong Kong', '203' => 'eBay India', '205' => 'eBay Ireland', '207' => 'eBay Malaysia', '210' => 'eBay Canada (French)', '211' => 'eBay Philippines', '212' => 'eBay Poland', '216' => 'eBay Singapore'); $this->ss->assign("EBAY_SITE_ID_OPTIONS", get_select_options_with_id($ebay_site_ids, isset($configurator->config['ebay_primary_site_id']) ? $configurator->config['ebay_primary_site_id'] : 0)); require_once 'modules/xeBayOrders/xeBayOrder.php'; $this->ss->assign("EBAY_SHIPPING_SERVICE_OPTIONS", get_select_options_with_id(getShippingServiceDropDown(), isset($configurator->config['ebay_shipping_service']) ? $configurator->config['ebay_shipping_service'] : 'HKBAM')); $this->ss->assign("EBAY_EXPRESS_CARRIER_OPTIONS", get_select_options_with_id(getExpressCarrierDropDown(), isset($configurator->config['ebay_express_carrier']) ? $configurator->config['ebay_express_carrier'] : 'default')); echo $this->getModuleTitle(false); $this->ss->display('modules/Configurator/tpls/EditView.tpl'); $javascript = new javascript(); $javascript->setFormName("ConfigureSettings"); $javascript->addFieldGeneric("notify_fromaddress", "email", $mod_strings['LBL_NOTIFY_FROMADDRESS'], TRUE, ""); $javascript->addFieldGeneric("notify_subject", "varchar", $mod_strings['LBL_NOTIFY_SUBJECT'], TRUE, ""); $javascript->addFieldGeneric("proxy_host", "varchar", $mod_strings['LBL_PROXY_HOST'], TRUE, ""); $javascript->addFieldGeneric("proxy_port", "int", $mod_strings['LBL_PROXY_PORT'], TRUE, ""); $javascript->addFieldGeneric("proxy_password", "varchar", $mod_strings['LBL_PROXY_PASSWORD'], TRUE, ""); $javascript->addFieldGeneric("proxy_username", "varchar", $mod_strings['LBL_PROXY_USERNAME'], TRUE, ""); echo $javascript->getScript(); }
<option value="100">100</option> <option value="200">200</option> <option value="300">300</option> <option value="400">400</option> <option value="500">500</option> <option value="1000">1000</option> </select> <input type="submit" class="main-but" name="Filter" value="filter"> </form> <?php if (isset($_POST['Filter']) == 'filter') { Yii::app()->Session['datepick'] = $_POST['limit']; $lead = Lead::Model()->findAllByAttributes(array(), array('order' => 'id desc', 'limit' => Yii::app()->Session['datepick'])); } else { $lead = Lead::Model()->findAll(); } ?> <span class="excel"> <a href="<?php echo Yii::app()->baseurl; ?> /lead/generateExcel"><span style="color: #333333;font-size:17px;font-weight:bold;font: bold 11px Arial;background-color: #EEEEEE;padding: 2px 6px 2px 6px;border-top: 1px solid #CCCCCC;border-right: 1px solid #333333;border-bottom: 1px solid #333333;border-left: 1px solid #CCCCCC;">Save as Excel</span></a></span> <table class="tab"> <tr> <th>S.NO</th> <th>Name</th> <th>First Name</th>
/** * Saves a new Contact as well as any related items passed in. * * @return null */ protected function handleSave() { require_once "include/formbase.php"; $lead = false; if (!empty($_REQUEST['record'])) { $lead = new Lead(); $lead->retrieve($_REQUEST['record']); } global $beanList; $this->loadDefs(); $beans = array(); $selectedBeans = array(); $selects = array(); //Make sure the contact object is availible for relationships. $beans['Contacts'] = new Contact(); $beans['Contacts']->id = create_guid(); $beans['Contacts']->new_with_id = true; // Bug 39287 - Check for Duplicates on selected modules before save if (!empty($_REQUEST['selectedContact'])) { $beans['Contacts']->retrieve($_REQUEST['selectedContact']); if (!empty($beans['Contacts']->id)) { $beans['Contacts']->new_with_id = false; unset($_REQUEST["convert_create_Contacts"]); unset($_POST["convert_create_Contacts"]); } } elseif (!empty($_REQUEST["convert_create_Contacts"]) && $_REQUEST["convert_create_Contacts"] != "false" && !isset($_POST['ContinueContact'])) { require_once 'modules/Contacts/ContactFormBase.php'; $contactForm = new ContactFormBase(); $duplicateContacts = $contactForm->checkForDuplicates('Contacts'); if (isset($duplicateContacts)) { echo $contactForm->buildTableForm($duplicateContacts, 'Contacts'); return; } } if (!empty($_REQUEST['selectedAccount'])) { $_REQUEST['account_id'] = $_REQUEST['selectedAccount']; unset($_REQUEST["convert_create_Accounts"]); unset($_POST["convert_create_Accounts"]); } elseif (!empty($_REQUEST["convert_create_Accounts"]) && $_REQUEST["convert_create_Accounts"] != "false" && empty($_POST['ContinueAccount'])) { require_once 'modules/Accounts/AccountFormBase.php'; $accountForm = new AccountFormBase(); $duplicateAccounts = $accountForm->checkForDuplicates('Accounts'); if (isset($duplicateAccounts)) { echo $accountForm->buildTableForm($duplicateAccounts); return; } } foreach ($this->defs as $module => $vdef) { //Create a new record if "create" was selected if (!empty($_REQUEST["convert_create_{$module}"]) && $_REQUEST["convert_create_{$module}"] != "false") { //Save the new record $bean = $beanList[$module]; if (empty($beans[$module])) { $beans[$module] = new $bean(); } $this->populateNewBean($module, $beans[$module], $beans['Contacts'], $lead); } else { if (!empty($vdef['ConvertLead']['select'])) { //Save the new record $select = $vdef['ConvertLead']['select']; $fieldDef = $beans['Contacts']->field_defs[$select]; if (!empty($fieldDef['id_name']) && !empty($_REQUEST[$fieldDef['id_name']])) { $beans['Contacts']->{$fieldDef}['id_name'] = $_REQUEST[$fieldDef['id_name']]; $selects[$module] = $_REQUEST[$fieldDef['id_name']]; if (!empty($_REQUEST[$select])) { $beans['Contacts']->{$select} = $_REQUEST[$select]; } // Bug 39268 - Add the existing beans to a list of beans we'll potentially add the lead's activities to $bean = loadBean($module); $bean->retrieve($_REQUEST[$fieldDef['id_name']]); $selectedBeans[$module] = $bean; } } } } $this->handleActivities($lead, $beans); // Bug 39268 - Add the lead's activities to the selected beans $this->handleActivities($lead, $selectedBeans); //link selected account to lead if it exists if (!empty($selectedBeans['Accounts'])) { $lead->account_id = $selectedBeans['Accounts']->id; } //Handle non-contacts relationships foreach ($beans as $bean) { if (!empty($lead)) { if (empty($bean->assigned_user_id)) { $bean->assigned_user_id = $lead->assigned_user_id; } $leadsRel = $this->findRelationship($bean, $lead); if (!empty($leadsRel)) { $bean->load_relationship($leadsRel); $relObject = $bean->{$leadsRel}->getRelationshipObject(); if ($relObject->relationship_type == "one-to-many" && $bean->{$leadsRel}->_get_bean_position()) { $id_field = $relObject->rhs_key; $lead->{$id_field} = $bean->id; } else { $bean->{$leadsRel}->add($lead->id); } } } //Special case code for opportunities->Accounts if ($bean->object_name == "Opportunity" && empty($bean->account_id)) { if (isset($beans['Accounts'])) { $bean->account_id = $beans['Accounts']->id; $bean->account_name = $beans['Accounts']->name; } else { if (!empty($selects['Accounts'])) { $bean->account_id = $selects['Accounts']; } } } $this->copyAddressFields($bean, $beans['Contacts']); $bean->save(); } if (!empty($lead)) { //Mark the original Lead converted $lead->status = "Converted"; $lead->converted = '1'; $lead->in_workflow = true; $lead->save(); } $this->displaySaveResults($beans); }
if (key($sugar_demodata['email_seed_data_types']) === null) { reset($sugar_demodata['email_seed_data_types']); } $email->type = current($sugar_demodata['email_seed_data_types']); next($sugar_demodata['email_seed_data_types']); $email->save(); $email->load_relationship('contacts'); $email->contacts->add($contact); $email->load_relationship('accounts'); $email->accounts->add($contacts_account); if ($i % 10 === 0) { echo '.'; } } for ($i = 0; $i < $number_leads; $i++) { $lead = new Lead(); $lead->account_name = $sugar_demodata['company_name_array'][mt_rand(0, $company_name_count - 1)]; $lead->first_name = $sugar_demodata['first_name_array'][mt_rand(0, $first_name_max)]; $lead->last_name = $sugar_demodata['last_name_array'][mt_rand(0, $last_name_max)]; $lead->primary_address_street = $sugar_demodata['street_address_array'][mt_rand(0, $street_address_max)]; $lead->primary_address_city = $sugar_demodata['city_array'][mt_rand(0, $city_array_max)]; $lead->lead_source = array_rand($app_list_strings['lead_source_dom']); $lead->title = $sugar_demodata['titles'][mt_rand(0, $title_max)]; $lead->phone_work = create_phone_number(); $lead->phone_home = create_phone_number(); $lead->phone_mobile = create_phone_number(); $lead->emailAddress->addAddress(createEmailAddress(), true); // Fill in a bogus address $lead->primary_address_state = $sugar_demodata['primary_address_state']; $leads_account = $accounts[$account_number]; $lead->primary_address_state = $leads_account->billing_address_state;
/** * @see SugarView::display() */ public function display() { global $current_user, $mod_strings, $app_strings, $app_list_strings, $sugar_config, $locale; $configurator = new Configurator(); $sugarConfig = SugarConfig::getInstance(); $configurator->parseLoggerSettings(); $focus = Administration::getSettings(); /* if(!empty($_POST['restore'])){ $configurator->restoreConfig(); } */ $this->ss->assign('MOD', $mod_strings); $this->ss->assign('APP', $app_strings); $this->ss->assign('APP_LIST', $app_list_strings); $this->ss->assign('config', $configurator->config); $this->ss->assign('error', $configurator->errors); $this->ss->assign("AUTO_REFRESH_INTERVAL_OPTIONS", get_select_options_with_id($app_list_strings['dashlet_auto_refresh_options_admin'], isset($configurator->config['dashlet_auto_refresh_min']) ? $configurator->config['dashlet_auto_refresh_min'] : 30)); $this->ss->assign('LANGUAGES', get_languages()); $this->ss->assign("JAVASCRIPT", get_set_focus_js() . get_configsettings_js()); $this->ss->assign('company_logo', SugarThemeRegistry::current()->getImageURL('company_logo.png', true, true)); $this->ss->assign("settings", $focus->settings); $this->ss->assign("mail_sendtype_options", get_select_options_with_id($app_list_strings['notifymail_sendtype'], $focus->settings['mail_sendtype'])); if (!empty($focus->settings['proxy_on'])) { $this->ss->assign("PROXY_CONFIG_DISPLAY", 'inline'); } else { $this->ss->assign("PROXY_CONFIG_DISPLAY", 'none'); } if (!empty($focus->settings['proxy_auth'])) { $this->ss->assign("PROXY_AUTH_DISPLAY", 'inline'); } else { $this->ss->assign("PROXY_AUTH_DISPLAY", 'none'); } $ini_session_val = ini_get('session.gc_maxlifetime'); if (!empty($focus->settings['system_session_timeout'])) { $this->ss->assign("SESSION_TIMEOUT", $focus->settings['system_session_timeout']); } else { $this->ss->assign("SESSION_TIMEOUT", $ini_session_val); } if (!empty($configurator->config['logger']['level'])) { $this->ss->assign('log_levels', get_select_options_with_id(LoggerManager::getLoggerLevels(), $configurator->config['logger']['level'])); } else { $this->ss->assign('log_levels', get_select_options_with_id(LoggerManager::getLoggerLevels(), '')); } if (!empty($configurator->config['lead_conv_activity_opt'])) { $this->ss->assign('lead_conv_activities', get_select_options_with_id(Lead::getActivitiesOptions(), $configurator->config['lead_conv_activity_opt'])); } else { $this->ss->assign('lead_conv_activities', get_select_options_with_id(Lead::getActivitiesOptions(), '')); } if (!empty($configurator->config['logger']['file']['suffix'])) { $this->ss->assign('filename_suffix', get_select_options_with_id(SugarLogger::$filename_suffix, $configurator->config['logger']['file']['suffix'])); } else { $this->ss->assign('filename_suffix', get_select_options_with_id(SugarLogger::$filename_suffix, '')); } if (isset($configurator->config['logger_visible'])) { $this->ss->assign('logger_visible', $configurator->config['logger_visible']); } else { $this->ss->assign('logger_visible', true); } $this->ss->assign('list_entries_per_listview_help', str_replace('{{listEntriesNum}}', '50', $mod_strings['TPL_LIST_ENTRIES_PER_LISTVIEW_HELP'])); $this->ss->assign('list_entries_per_subpanel_help', str_replace('{{subpanelEntriesNum}}', '25', $mod_strings['TPL_LIST_ENTRIES_PER_SUBPANEL_HELP'])); echo $this->getModuleTitle(false); $this->ss->display('modules/Configurator/tpls/EditView.tpl'); $javascript = new javascript(); $javascript->setFormName("ConfigureSettings"); $javascript->addFieldGeneric("notify_fromaddress", "email", $mod_strings['LBL_NOTIFY_FROMADDRESS'], TRUE, ""); $javascript->addFieldGeneric("notify_subject", "varchar", $mod_strings['LBL_NOTIFY_SUBJECT'], TRUE, ""); $javascript->addFieldGeneric("proxy_host", "varchar", $mod_strings['LBL_PROXY_HOST'], TRUE, ""); $javascript->addFieldGeneric("proxy_port", "int", $mod_strings['LBL_PROXY_PORT'], TRUE, ""); $javascript->addFieldGeneric("proxy_password", "varchar", $mod_strings['LBL_PROXY_PASSWORD'], TRUE, ""); $javascript->addFieldGeneric("proxy_username", "varchar", $mod_strings['LBL_PROXY_USERNAME'], TRUE, ""); $javascript->addFieldRange("system_session_timeout", "int", $mod_strings['SESSION_TIMEOUT'], TRUE, "", 0, $ini_session_val); echo $javascript->getScript(); }
$email->status = 'sent'; $email->parent_id = $account_id; $email->parent_type = 'Accounts'; $email->to_addrs = $contact->emailAddress->getPrimaryAddress($contact); $email->from_addr = $assignedUser->emailAddress->getPrimaryAddress($assignedUser); $email->from_addr_name = $email->from_addr; $email->to_addrs_names = $email->to_addrs; $email->type = 'out'; $email->save(); $email->load_relationship('contacts'); $email->contacts->add($contact->id); $email->load_relationship('accounts'); $email->contacts->add($account_id); } for ($i = 0; $i < $number_leads; $i++) { $lead = new Lead(); $lead->account_name = $company_name_array[mt_rand(0, $company_name_count - 1)] . ' ' . mt_rand(1, 1000000); $lead->first_name = $first_name_array[mt_rand(0, $first_name_max)]; $lead->last_name = $last_name_array[mt_rand(0, $last_name_max)]; $lead->primary_address_street = $street_address_array[mt_rand(0, $street_address_max)]; $lead->primary_address_city = $city_array[mt_rand(0, $city_array_max)]; $lead->lead_source = $app_list_strings['lead_source_dom'][array_rand($app_list_strings['lead_source_dom'])]; $lead->title = $titles[mt_rand(0, $title_max)]; $lead->phone_work = create_phone_number(); $lead->phone_home = create_phone_number(); $lead->phone_mobile = create_phone_number(); $lead->emailAddress->addAddress(createEmailAddress(), true); // Fill in a bogus address $lead->primary_address_state = "CA"; $leads_account = $accounts[$account_number]; $lead->primary_address_state = $leads_account->billing_address_state;
public function actiongenerateExcel() { header("Content-Type: application/vnd.ms-excel;"); header("Content-Disposition: attachment; filename=export.xls"); header("Pragma: no-cache"); header("Expires: 0"); $countModel = Lead::Model()->findAllByAttributes(array(), array('order' => 'id desc', 'limit' => Yii::app()->Session['datepick'])); ?> <table> <tr> <th>S.NO</th> <th>Lead Title</th> <th>Use</th> <th>Retailer Website</th> <th>Tenant Rep</th> <th>First Name</th> <th>Last Name</th> <th>Phone No</th> <th>Email Id</th> <th>Title</th> <th>High End</th> <th>Min Size</th> <th>Max Size</th> <th>State</th> <th>Message</th> <th>Broker</th> <th>Broker First Name</th> <th>Broker Last Name</th> <th>Broker Phone Number</th> <th>Broker Cell Number</th> <th>Broker email</th> <th>Broker Company</th> <th>Broker territory</th> </tr> <?php $k = 1; foreach ($countModel as $data) { ?> <tr> <td><?php echo $k++; ?> </td> <td><?php echo $data['retail']; ?> </td> <td><?php echo $data['uses']; ?> </td> <td><?php echo $data['retailer_webiste']; ?> </td> <td><?php echo $data['tenant _rep']; ?> </td> <td><?php echo $data['first_name']; ?> </td> <td><?php echo $data['last_name']; ?> </td> <td><?php echo $data['phone_1']; ?> </td> <td><?php echo $data['email_id']; ?> </td> <td><?php echo $data['title']; ?> </td> <td><?php echo $data['high_end']; ?> </td> <td><?php echo $data['min_size']; ?> </td> <td><?php echo $data['max_size']; ?> </td> <td><?php echo $data['state']; ?> </td> <td><?php echo $data['message']; ?> </td> <td><?php echo $data['repersented_by_broker']; ?> </td> <td><?php echo $data['broker_firstname']; ?> </td> <td><?php echo $data['broker_lastname']; ?> </td> <td><?php echo $data['broker_phone_no']; ?> </td> <td><?php echo $data['broker_cell_no']; ?> </td> <td><?php echo $data['broker_email']; ?> </td> <td><?php echo $data['broker_company']; ?> </td> <td><?php echo $data['broker_territory']; ?> </td> </tr> <?php } ?> </table> <?php exit; }
/** * handles linking contacts, accounts, etc. to an email * * @param object Email bean to be linked against * @return string contactAddr is the email address of the sender */ function handleLinking(&$email) { // link email to an User if emails match TO addr if ($userIds = $this->getRelatedId($email->to_addrs, 'users')) { $GLOBALS['log']->debug('I-E linking email to User'); // link the user to the email $email->load_relationship('users'); $email->users->add($userIds); } // link email to a Contact, Lead, or Account if the emails match // give precedence to REPLY-TO above FROM if (!empty($email->reply_to_email)) { $contactAddr = $email->reply_to_email; } else { $contactAddr = $email->from_addr; } // Samir Gandhi : 12/06/07 // This changes has been done because the linking was done only with the from address and // not with to address $relationShipAddress = $contactAddr; if (empty($relationShipAddress)) { $relationShipAddress .= $email->to_addrs; } else { $relationShipAddress = $relationShipAddress . "," . $email->to_addrs; } if ($leadIds = $this->getRelatedId($relationShipAddress, 'leads')) { $GLOBALS['log']->debug('I-E linking email to Lead'); $email->load_relationship('leads'); $email->leads->add($leadIds); foreach ($leadIds as $leadId) { $lead = new Lead(); $lead->retrieve($leadId); $lead->load_relationship('emails'); $lead->emails->add($email->id); } } if ($contactIds = $this->getRelatedId($relationShipAddress, 'contacts')) { $GLOBALS['log']->debug('I-E linking email to Contact'); // link the contact to the email $email->load_relationship('contacts'); $email->contacts->add($contactIds); } if ($accountIds = $this->getRelatedId($relationShipAddress, 'accounts')) { $GLOBALS['log']->debug('I-E linking email to Account'); // link the account to the email $email->load_relationship('accounts'); $email->accounts->add($accountIds); /* cn: bug 9171 another cause of dying I-E - bad linking foreach($accountIds as $accountId) { $GLOBALS['log']->debug('I-E reverse-linking Accounts to Emails'); $acct = new Account(); $acct->retrieve($accountId); $acct->load_relationship('emails'); $acct->account_emails->add($email->id); } */ } return $contactAddr; }
} elseif ($tmp == 'NotConfigured') { print $langs->trans($tmp); } else { print $tmp; } print '</td>' . "\n"; print '<td align="center">'; if ($conf->global->LEAD_ADDON == "{$file}") { print img_picto($langs->trans("Activated"), 'switch_on'); } else { print '<a href="' . $_SERVER["PHP_SELF"] . '?action=setmod&value=' . $file . '">'; print img_picto($langs->trans("Disabled"), 'switch_off'); print '</a>'; } print '</td>'; $businesscase = new Lead($db); $businesscase->initAsSpecimen(); // Info $htmltooltip = ''; $htmltooltip .= '' . $langs->trans("Version") . ': <b>' . $module->getVersion() . '</b><br>'; $nextval = $module->getNextValue($user->id, $mysoc, $businesscase); if ("{$nextval}" != $langs->trans("NotAvailable")) { $htmltooltip .= '' . $langs->trans("NextValue") . ': '; if ($nextval) { $htmltooltip .= $nextval . '<br>'; } else { $htmltooltip .= $langs->trans($module->error) . '<br>'; } } print '<td align="center">'; print $form->textwithpicto('', $htmltooltip, 1, 0);
/** * Load object in memory from database * * @param int $id ID * @param string $tablename Name of the table * * @return int if KO, >0 if OK */ public function fetchLeadLink($id, $tablename) { global $langs; $this->doclines = array(); $sql = "SELECT"; $sql .= " t.rowid,"; $sql .= " t.fk_source,"; $sql .= " t.sourcetype,"; $sql .= " t.fk_target,"; $sql .= " t.targettype"; $sql .= " FROM " . MAIN_DB_PREFIX . "element_element as t"; $sql .= " WHERE t.fk_source = " . $id; $sql .= " AND t.targettype='lead'"; if (!empty($tablename)) { $sql .= " AND t.sourcetype='" . $tablename . "'"; } $sql .= " ORDER BY t.sourcetype"; dol_syslog(get_class($this) . "::fetchDocumentLink sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { while ($obj = $this->db->fetch_object($resql)) { $line = new Lead($this->db); $line->fetch($obj->fk_target); $this->doclines[] = $line; } $this->db->free($resql); return 1; } else { $this->error = "Error " . $this->db->lasterror(); dol_syslog(get_class($this) . "::fetchDocumentLink " . $this->error, LOG_ERR); return -1; } }
function create_lead($user_name, $password, $first_name, $last_name, $email_address) { if (!validate_user($user_name, $password)) { return 0; } //todo make the activity body not be html encoded $seed_user = new User(); $user_id = $seed_user->retrieve_user_id($user_name); $lead = new Lead(); if (!$lead->ACLAccess('Save')) { return -1; } $lead->first_name = $first_name; $lead->last_name = $last_name; $lead->email1 = $email_address; $lead->assigned_user_id = $user_id; $lead->assigned_user_name = $user_name; return $lead->save(); }
die("The user id doesn't exist"); } $current_entity = $current_user; } else { if (!empty($_REQUEST['contact_id'])) { $current_entity = new Contact(); $current_entity->disable_row_level_security = true; $result = $current_entity->retrieve($_REQUEST['contact_id']); if ($result == null) { session_destroy(); sugar_cleanup(); die("The contact id doesn't exist"); } } else { if (!empty($_REQUEST['lead_id'])) { $current_entity = new Lead(); $current_entity->disable_row_level_security = true; $result = $current_entity->retrieve($_REQUEST['lead_id']); if ($result == null) { session_destroy(); sugar_cleanup(); die("The lead id doesn't exist"); } } } } $bean = $beanList[clean_string($_REQUEST['module'])]; require_once $beanFiles[$bean]; $focus = new $bean(); $focus->disable_row_level_security = true; $result = $focus->retrieve($_REQUEST['record']);
/** * Change the parent id and parent type of an activity * @param $activity Activity to be modified * @param $bean New parent bean of the activity */ protected function moveActivity($activity, $bean) { global $beanList; $lead = null; if (!empty($_REQUEST['record'])) { $lead = new Lead(); $lead->retrieve($_REQUEST['record']); } // delete the old relationship to the old parent (lead) if ($rel = $this->findRelationship($activity, $lead)) { $activity->load_relationship($rel); if ($activity->parent_id && $activity->id) { $activity->{$rel}->delete($activity->id, $activity->parent_id); } } // add the new relationship to the new parent (contact, account, etc) if ($rel = $this->findRelationship($activity, $bean)) { $activity->load_relationship($rel); $relObj = $activity->{$rel}->getRelationshipObject(); if ($relObj->relationship_type == 'one-to-one' || $relObj->relationship_type == 'one-to-many') { $key = $relObj->rhs_key; $activity->{$key} = $bean->id; } $activity->{$rel}->add($bean); } // set the new parent id and type $activity->parent_id = $bean->id; $activity->parent_type = $bean->module_dir; $activity->save(); }
* All copies of the Covered Code must include on each user interface screen: * (i) the "Powered by SugarCRM" logo and * (ii) the SugarCRM copyright notice * in the same form as they appear in the distribution. See full license for * requirements. * * The Original Code is: SugarCRM Open Source * The Initial Developer of the Original Code is SugarCRM, Inc. * Portions created by SugarCRM are Copyright (C) 2004-2006 SugarCRM, Inc.; * All Rights Reserved. * Contributor(s): ______________________________________. ********************************************************************************/ /********************************************************************************* * Description: TODO: To be written. * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. * All Rights Reserved. * Contributor(s): ______________________________________.. ********************************************************************************/ require_once 'modules/Leads/Lead.php'; global $mod_strings; $focus = new Lead(); if (!isset($_REQUEST['record'])) { sugar_die($mod_strings['ERR_DELETE_RECORD']); } $focus->retrieve($_REQUEST['record']); if (!$focus->ACLAccess('Delete')) { ACLController::displayNoAccess(true); sugar_cleanup(true); } $focus->mark_deleted($_REQUEST['record']); header("Location: index.php?module=" . $_REQUEST['return_module'] . "&action=" . $_REQUEST['return_action'] . "&record=" . $_REQUEST['return_id']);
public function testConversionAndDoNothing() { global $sugar_config; // init $lead = SugarTestLeadUtilities::createLead(); $account = SugarTestAccountUtilities::createAccount(); $meeting = SugarTestMeetingUtilities::createMeeting(); SugarTestMeetingUtilities::addMeetingParent($meeting->id, $lead->id); $relation_id = SugarTestMeetingUtilities::addMeetingLeadRelation($meeting->id, $lead->id); $_REQUEST['record'] = $lead->id; // set the request/post parameters before converting the lead $_REQUEST['module'] = 'Leads'; $_REQUEST['action'] = 'ConvertLead'; $_REQUEST['record'] = $lead->id; $_REQUEST['handle'] = 'save'; $_REQUEST['selectedAccount'] = $account->id; $sugar_config['lead_conv_activity_opt'] = 'none'; // call display to trigger conversion $vc = new ViewConvertLead(); $vc->display(); // refresh meeting $meeting_id = $meeting->id; $meeting = new Meeting(); $meeting->retrieve($meeting_id); // refresh lead $lead_id = $lead->id; $lead = new Lead(); $lead->retrieve($lead_id); // retrieve the new contact id from the conversion $contact_id = $lead->contact_id; // 1. Lead's contact_id should not be null $this->assertNotNull($contact_id, 'Lead has null contact id after conversion.'); // 2. Lead status should be 'Converted' $this->assertEquals('Converted', $lead->status, "Lead atatus should be 'Converted'."); // 3. parent_type of the original meeting should be Leads $this->assertEquals('Leads', $meeting->parent_type, 'Meeting parent should be Leads'); // 4. parent_id of the original meeting should be contact id $this->assertEquals($lead_id, $meeting->parent_id, 'Meeting parent id should be lead id.'); // 5. record should NOT be deleted from meetings_leads table $sql = "select id from meetings_leads where meeting_id='{$meeting->id}' and lead_id='{$lead->id}' and deleted=0"; $result = $GLOBALS['db']->query($sql); $row = $GLOBALS['db']->fetchByAssoc($result); $this->assertFalse(empty($row), "Meeting-Lead relationship is removed."); // 6. record should NOT be added to meetings_contacts table $sql = "select meeting_id from meetings_contacts where contact_id='{$contact_id}' and deleted=0"; $result = $GLOBALS['db']->query($sql); $row = $GLOBALS['db']->fetchByAssoc($result); $this->assertFalse($row, "Meeting-Contact relationship should not be added."); // clean up unset($_REQUEST['record']); $GLOBALS['db']->query("delete from meetings where parent_id='{$lead->id}' and parent_type= 'Leads'"); $GLOBALS['db']->query("delete from meetings where parent_id='{$contact_id}' and parent_type= 'Contacts'"); $GLOBALS['db']->query("delete from contacts where id='{$contact_id}'"); $GLOBALS['db']->query("delete from meetings_leads where meeting_id='{$meeting->id}' and lead_id= '{$lead_id}'"); $GLOBALS['db']->query("delete from meetings_contacts where contact_id= '{$contact_id}'"); SugarTestMeetingUtilities::deleteMeetingLeadRelation($relation_id); SugarTestMeetingUtilities::removeMeetingContacts(); SugarTestMeetingUtilities::removeAllCreatedMeetings(); SugarTestAccountUtilities::removeAllCreatedAccounts(); SugarTestLeadUtilities::removeAllCreatedLeads(); }
function get_notification_recipients() { if ($this->special_notification) { return parent::get_notification_recipients(); } $list = array(); if (!is_array($this->contacts_arr)) { $this->contacts_arr = array(); } if (!is_array($this->users_arr)) { $this->users_arr = array(); } if (!is_array($this->leads_arr)) { $this->leads_arr = array(); } foreach ($this->users_arr as $user_id) { $notify_user = new User(); $notify_user->retrieve($user_id); $notify_user->new_assigned_user_name = $notify_user->full_name; $GLOBALS['log']->info("Notifications: recipient is {$notify_user->new_assigned_user_name}"); $list[$notify_user->id] = $notify_user; } foreach ($this->contacts_arr as $contact_id) { $notify_user = new Contact(); $notify_user->retrieve($contact_id); $notify_user->new_assigned_user_name = $notify_user->full_name; $GLOBALS['log']->info("Notifications: recipient is {$notify_user->new_assigned_user_name}"); $list[$notify_user->id] = $notify_user; } foreach ($this->leads_arr as $lead_id) { $notify_user = new Lead(); $notify_user->retrieve($lead_id); $notify_user->new_assigned_user_name = $notify_user->full_name; $GLOBALS['log']->info("Notifications: recipient is {$notify_user->new_assigned_user_name}"); $list[$notify_user->id] = $notify_user; } return $list; }