Exemple #1
1
	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;
 }
Exemple #3
0
 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 = '';
     }
 }
Exemple #4
0
 function execute(&$bean)
 {
     if ($bean->sales_stage == "completed") {
         $realty_list = $bean->get_linked_beans("realty_opportunities", "Realty");
         if (!empty($bean->contact_id)) {
             $contact = new Contact();
             $contact->retrieve($bean->contact_id);
             foreach ($realty_list as $realty) {
                 if ($realty->operation == 'rent') {
                     $contact->load_relationship("realty_contacts_rent");
                     $contact->realty_contacts_rent->add($realty->id);
                 } elseif ($realty->operation == 'buying') {
                     $contact->load_relationship("realty_contacts_buying");
                     $contact->realty_contacts_buying->add($realty->id);
                 }
             }
         }
         if (!empty($bean->account_id)) {
             $account = new Account();
             $account->retrieve($bean->account_id);
             foreach ($realty_list as $realty) {
                 if ($realty->operation == 'rent') {
                     $account->load_relationship("realty_accounts_rent");
                     $account->realty_accounts_rent->add($realty->id);
                 } elseif ($realty->operation == 'buying') {
                     $account->load_relationship("realty_accounts_buying");
                     $account->realty_accounts_buying->add($realty->id);
                 }
             }
         }
     }
 }
Exemple #5
0
 /**
  * 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'.");
 }
Exemple #6
0
 function Request_sugar()
 {
     parent::Basic();
     $cont = new Contact();
     $cont->retrieve('f0552f45-5d45-b8cd-b32c-521730a146f2');
     /*$rabbit = new SugarRabbit();
       $rabbit->CreateContact($cont);*/
 }
 function send_email($module, $module_type, $printable, $file_name, $attach)
 {
     require_once 'modules/Emails/Email.php';
     global $current_user, $mod_strings, $sugar_config;
     //First Create e-mail draft
     $email = new Email();
     // set the id for relationships
     $email->id = create_guid();
     $email->new_with_id = true;
     //subject
     $email->name = $mod_strings['LBL_EMAIL_NAME'] . ' ' . $module->name;
     //body
     $email->description_html = $printable;
     //type is draft
     $email->type = "draft";
     $email->status = "draft";
     if (!empty($module->billing_contact_id) && $module->billing_contact_id != "") {
         require_once 'modules/Contacts/Contact.php';
         $contact = new Contact();
         $contact->retrieve($module->billing_contact_id);
         $email->parent_type = 'Contacts';
         $email->parent_id = $contact->id;
         if (!empty($contact->email1)) {
             $email->to_addrs_emails = $contact->email1 . ";";
             $email->to_addrs = $module->billing_contact_name . " <" . $contact->email1 . ">";
         }
     }
     //team id
     $email->team_id = $current_user->default_team;
     //assigned_user_id
     $email->assigned_user_id = $current_user->id;
     //Save the email object
     global $timedate;
     $email->date_start = $timedate->to_display_date_time(gmdate($GLOBALS['timedate']->get_db_date_time_format()));
     $email->save(FALSE);
     $email_id = $email->id;
     if ($attach) {
         $note = new Note();
         $note->modified_user_id = $current_user->id;
         $note->created_by = $current_user->id;
         $note->name = $file_name;
         $note->parent_type = 'Emails';
         $note->parent_id = $email_id;
         $note->file_mime_type = 'application/pdf';
         $note->filename = $file_name;
         $note->save();
         rename($sugar_config['upload_dir'] . 'attachfile.pdf', $sugar_config['upload_dir'] . $note->id);
     }
     //redirect
     if ($email_id == "") {
         echo "Unable to initiate Email Client";
         exit;
     } else {
         header("Location: index.php?action=Compose&module=Emails&return_module=" . $module_type . "&return_action=DetailView&return_id=" . $_REQUEST['record'] . "&recordId=" . $email_id);
     }
 }
 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();
 }
 /**
  * @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}'");
 }
Exemple #10
0
function loadRel($module, $module_id, $linked_module_id)
{
    if ($module == 'Accounts') {
        $Accounts = new Account();
        $Accounts->retrieve($linked_module_id);
        $Accounts->load_relationships('realty_accounts_interest');
        $Accounts->realty_accounts_interest->add($module_id);
    } elseif ($module == 'Contacts') {
        $Contacts = new Contact();
        $Contacts->retrieve($linked_module_id);
        $Contacts->load_relationships('realty_contacts_interest');
        $Contacts->realty_contacts_interest->add($module_id);
    } elseif ($module == 'Request') {
        $Request = new Request();
        $Request->retrieve($linked_module_id);
        $Request->load_relationships('realty_requests_interest');
        $Request->realty_requests_interest->add($module_id);
    }
}
Exemple #11
0
 function action_editview()
 {
     global $mod_string;
     $this->view = 'edit';
     $GLOBALS['view'] = $this->view;
     if (isset($_REQUEST['aos_quotes_id'])) {
         $query = "SELECT * FROM aos_quotes WHERE id = '{$_REQUEST['aos_quotes_id']}'";
         $result = $this->bean->db->query($query, true);
         $row = $this->bean->db->fetchByAssoc($result);
         $this->bean->name = $row['name'];
         $this->bean->total_contract_value = $row['total_amount'];
         if (isset($row['billing_account_id'])) {
             $_REQUEST['account_id'] = $row['billing_account_id'];
         }
         if (isset($row['billing_contact_id'])) {
             $_REQUEST['contact_id'] = $row['billing_contact_id'];
         }
         if (isset($row['opportunity_id'])) {
             $_REQUEST['opportunity_id'] = $row['opportunity_id'];
         }
     }
     if (isset($_REQUEST['account_id'])) {
         $query = "SELECT id,name FROM accounts WHERE id = '{$_REQUEST['account_id']}'";
         $result = $this->bean->db->query($query, true);
         $row = $this->bean->db->fetchByAssoc($result);
         $this->bean->contract_account = $row['name'];
         $this->bean->contract_account_id = $row['id'];
     }
     if (isset($_REQUEST['contact_id'])) {
         $contact = new Contact();
         $contact->retrieve($_REQUEST['contact_id']);
         $this->bean->contact = $contact->name;
         $this->bean->contact_id = $contact->id;
     }
     if (isset($_REQUEST['opportunity_id'])) {
         $query = "SELECT id,name FROM opportunities WHERE id = '{$_REQUEST['opportunity_id']}'";
         $result = $this->bean->db->query($query, true);
         $row = $this->bean->db->fetchByAssoc($result);
         $this->bean->opportunity = $row['name'];
         $this->bean->opportunity_id = $row['id'];
     }
 }
Exemple #12
0
//First Create e-mail draft
$email = new Email();
// set the id for relationships
$email->id = create_guid();
$email->new_with_id = true;
//subject
$email->name = "Quote For " . $quote->name . "";
//body
$email->description_html = $printable;
//type is draft
$email->type = "draft";
$email->status = "draft";
if (!empty($quote->billing_contact_id) && $quote->billing_contact_id != "") {
    require_once 'modules/Contacts/Contact.php';
    $contact = new Contact();
    $contact->retrieve($quote->billing_contact_id);
    if (!empty($contact->email1)) {
        $email->to_addrs_emails = $contact->email1 . ";";
        $email->to_addrs = $quote->billing_contact_name . " <" . $contact->email1 . ">";
    }
}
//team id
$email->team_id = $current_user->default_team;
//assigned_user_id
$email->assigned_user_id = $current_user->id;
//Save the email object
global $timedate;
$email->date_start = $timedate->to_display_date_time(gmdate($GLOBALS['timedate']->get_db_date_time_format()));
$email->save(FALSE);
$email_id = $email->id;
//redirect
Exemple #13
0
 function fill_in_additional_detail_fields()
 {
     global $app_list_strings, $mod_strings;
     // Fill in the assigned_user_name
     $this->assigned_user_name = get_assigned_user_name($this->assigned_user_id, '');
     //if ($this->parent_type == 'Contacts') {
     $query = "SELECT contacts.first_name, contacts.last_name, contacts.phone_work, contacts.id, contacts.assigned_user_id contact_name_owner, 'Contacts' contact_name_mod FROM contacts, emails_beans ";
     $query .= "WHERE emails_beans.email_id='{$this->id}' AND emails_beans.bean_id=contacts.id AND emails_beans.bean_module = 'Contacts' AND emails_beans.deleted=0 AND contacts.deleted=0";
     if (!empty($this->parent_id)) {
         $query .= " AND contacts.id= '" . $this->parent_id . "' ";
     } else {
         if (!empty($_REQUEST['record'])) {
             $query .= " AND contacts.id= '" . $_REQUEST['record'] . "' ";
         }
     }
     $result = $this->db->query($query, true, " Error filling in additional detail fields: ");
     // Get the id and the name.
     $row = $this->db->fetchByAssoc($result);
     if ($row != null) {
         $contact = new Contact();
         $contact->retrieve($row['id']);
         $this->contact_name = $contact->full_name;
         $this->contact_phone = $row['phone_work'];
         $this->contact_id = $row['id'];
         $this->contact_email = $contact->emailAddress->getPrimaryAddress($contact);
         $this->contact_name_owner = $row['contact_name_owner'];
         $this->contact_name_mod = $row['contact_name_mod'];
         $GLOBALS['log']->debug("Call({$this->id}): contact_name = {$this->contact_name}");
         $GLOBALS['log']->debug("Call({$this->id}): contact_phone = {$this->contact_phone}");
         $GLOBALS['log']->debug("Call({$this->id}): contact_id = {$this->contact_id}");
         $GLOBALS['log']->debug("Call({$this->id}): contact_email1 = {$this->contact_email}");
     } else {
         $this->contact_name = '';
         $this->contact_phone = '';
         $this->contact_id = '';
         $this->contact_email = '';
         $this->contact_name_owner = '';
         $this->contact_name_mod = '';
         $GLOBALS['log']->debug("Call({$this->id}): contact_name = {$this->contact_name}");
         $GLOBALS['log']->debug("Call({$this->id}): contact_phone = {$this->contact_phone}");
         $GLOBALS['log']->debug("Call({$this->id}): contact_id = {$this->contact_id}");
         $GLOBALS['log']->debug("Call({$this->id}): contact_email1 = {$this->contact_email}");
     }
     //}
     $this->created_by_name = get_assigned_user_name($this->created_by);
     $this->modified_by_name = get_assigned_user_name($this->modified_user_id);
     $this->link_action = 'DetailView';
     if (!empty($this->type)) {
         if ($this->type == 'out' && $this->status == 'send_error') {
             $this->type_name = $mod_strings['LBL_NOT_SENT'];
         } else {
             $this->type_name = $app_list_strings['dom_email_types'][$this->type];
         }
         if ($this->type == 'out' && $this->status == 'send_error' || $this->type == 'draft') {
             $this->link_action = 'EditView';
         }
     }
     //todo this  isset( $app_list_strings['dom_email_status'][$this->status]) is hack for 3261.
     if (!empty($this->status) && isset($app_list_strings['dom_email_status'][$this->status])) {
         $this->status_name = $app_list_strings['dom_email_status'][$this->status];
     }
     if (empty($this->name) && empty($_REQUEST['record'])) {
         $this->name = $mod_strings['LBL_NO_SUBJECT'];
     }
     $this->fill_in_additional_parent_fields();
 }
    $result1 = sendSugarPHPMail($emails, 'Презентация ', $body, $file_name, $nameToSend, $assigned_user_id, 'Realty');
    if ($result1) {
        echo "<br/><span style='color: green; font-size: 14px'>Письмо отправлено</span><br/>";
    } else {
        echo "<br/><span style='color: red; font-size: 14px'>Что-то пошло не так. Обратитесь к администратору!</span><br/>";
    }
    $db1 = DBManagerFactory::getInstance();
    $sql2 = "UPDATE realty_accounts_m_to_m_table\n\t\t\tSET presentation_checked = 0, SET presentation_text = 'Презентация отправлена'\n\t\t\tWHERE realty_id = '{$_GET['id']}' AND account_id = '{$account->id}'";
    $db2->query($sql2);
}
$sql = "SELECT contact_id FROM realty_contacts_table WHERE presentation_checked=1 AND realty_id = '{$_GET['id']}' AND deleted = 0";
$result = $db->query($sql);
while ($row = $db->fetchByAssoc($result)) {
    $emails = array();
    $contact = new Contact();
    $contact->retrieve($row['contact_id']);
    $assigned_user_id = $contact->assigned_user_id;
    $ass = new User();
    $ass->retrieve($assigned_user_id);
    //----- сбор ответственных для контактов
    //    $k = 0;
    //    $assigned['contacts'][$k]['id'] = $contact->id;
    //    $assigned['contacts'][$k]['assigned_user_id'] = $contact->assigned_user_id;
    //    $k++;
    // -------------------------------------
    /*$sms = new sms();
      $sms->retrieve_settings();
      $resp = $sms->send_message($ass->phone_mobile, 'Презентация отправлена');
      $resp = $sms->send_message($contact->phone_office, 'Вам на почту отправлена презентация');*/
    /*$presentations = new Presentations();
      $presentations->contact_id = $contact->id;
Exemple #15
0
 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;
 }
Exemple #16
0
 function fill_in_additional_detail_fields()
 {
     parent::fill_in_additional_detail_fields();
     global $app_strings;
     if (isset($this->contact_id)) {
         $contact = new Contact();
         $contact->retrieve($this->contact_id);
         if ($contact->id != "") {
             $this->contact_name = $contact->full_name;
             $this->contact_name_owner = $contact->assigned_user_id;
             $this->contact_name_mod = 'Contacts';
             $this->contact_phone = $contact->phone_work;
             $this->contact_email = $contact->emailAddress->getPrimaryAddress($contact);
         } else {
             $this->contact_name_mod = '';
             $this->contact_name_owner = '';
             $this->contact_name = '';
             $this->contact_email = '';
             $this->contact_id = '';
         }
     }
     $this->fill_in_additional_parent_fields();
 }
Exemple #17
0
/**
 * Return a list of modules related to the specifed contact record
 *
 * This function does not require a session be created first.
 *
 * @param string $user_name -- User name to authenticate with
 * @param string $password -- MD5 of the user password
 * @param string $id -- the id of the record
 * @return contact detail array along with associated objects.
 */
function get_contact_relationships($user_name, $password, $id)
{
    if (!validate_user($user_name, $password)) {
        return array();
    }
    $seed_contact = new Contact();
    // Verify that the user has permission to see Contact list views
    if (!$seed_contact->ACLAccess('ListView')) {
        return;
    }
    $msi_id = 1;
    $seed_contact->retrieve($id);
    $output_list[] = array("name1" => $seed_contact->first_name, "name2" => $seed_contact->last_name, "association" => $seed_contact->account_name, "type" => 'Contact', "id" => $seed_contact->id, "msi_id" => $msi_id, "email_address" => $seed_contact->email1);
    $accounts = $seed_contact->get_linked_beans('accounts', 'Account');
    foreach ($accounts as $account) {
        $output_list[] = get_account_array($account, $msi_id);
    }
    $opps = $seed_contact->get_linked_beans('opportunities', 'Opportunity');
    foreach ($opps as $opp) {
        $output_list[] = get_opportunity_array($opp, $msi_id);
    }
    $cases = $seed_contact->get_linked_beans('cases', 'aCase');
    foreach ($cases as $case) {
        $output_list[] = get_case_array($case, $msi_id);
    }
    $bugs = $seed_contact->get_linked_beans('bugs', 'Bug');
    foreach ($bugs as $bug) {
        $output_list[] = get_bean_array($bug, $msi_id, 'Bug');
    }
    $projects = $seed_contact->get_linked_beans('project', 'Project');
    foreach ($projects as $project) {
        $output_list[] = get_bean_array($project, $msi_id, 'Project');
    }
    return $output_list;
}
Exemple #18
0
 function get_list_view_data()
 {
     $note_fields = $this->get_list_view_array();
     global $app_list_strings, $focus, $action, $currentModule, $mod_strings, $sugar_config;
     if (isset($this->parent_type)) {
         $note_fields['PARENT_MODULE'] = $this->parent_type;
     }
     if (!empty($this->filename)) {
         if (file_exists("upload://{$this->id}")) {
             $note_fields['FILENAME'] = $this->filename;
             $note_fields['FILE_URL'] = UploadFile::get_upload_url($this);
         }
     }
     if (isset($this->contact_id) && $this->contact_id != '') {
         $contact = new Contact();
         $contact->retrieve($this->contact_id);
         if (isset($contact->id)) {
             $this->contact_name = $contact->full_name;
         }
     }
     if (isset($this->contact_name)) {
         $note_fields['CONTACT_NAME'] = $this->contact_name;
     }
     global $current_language;
     $mod_strings = return_module_language($current_language, 'Notes');
     $note_fields['STATUS'] = $mod_strings['LBL_NOTE_STATUS'];
     return $note_fields;
 }
Exemple #19
0
 function get_list_view_data()
 {
     $note_fields = $this->get_list_view_array();
     global $app_list_strings, $focus, $action, $currentModule, $mod_strings, $sugar_config;
     if (isset($this->parent_type)) {
         $note_fields['PARENT_MODULE'] = $this->parent_type;
     }
     if (!isset($this->filename) || $this->filename != '') {
         $file_path = UploadFile::get_file_path($this->filename, $this->id);
         if (file_exists($file_path)) {
             $save_file = urlencode(basename(UploadFile::get_url($this->filename, $this->id)));
             $note_fields['FILENAME'] = $this->filename;
             $note_fields['FILE_URL'] = "index.php?entryPoint=download&id=" . $save_file . "&type=Notes";
         }
     }
     if (isset($this->contact_id) && $this->contact_id != '') {
         $contact = new Contact();
         $contact->retrieve($this->contact_id);
         if (isset($contact->id)) {
             $this->contact_name = $contact->full_name;
         }
     }
     if (isset($this->contact_name)) {
         $note_fields['CONTACT_NAME'] = $this->contact_name;
     }
     global $current_language;
     $mod_strings = return_module_language($current_language, 'Notes');
     $note_fields['STATUS'] = $mod_strings['LBL_NOTE_STATUS'];
     return $note_fields;
 }
Exemple #20
0
     $resultSet = $cUser->db->query($query, false);
     if ($cUser->db->checkError()) {
         trigger_error("Update setContactId-Query failed: {$query}");
     }
     // Adds the new relationship!  (This must be done here in case the call has already been hungup as that's when asteriskLogger sets relations)
     $focus = new Call();
     $focus->retrieve($callRecord);
     $focus->load_relationship('contacts');
     // Remove any contacts already associated with call (if there are any)
     foreach ($focus->contacts->getBeans() as $contact) {
         $focus->contacts->delete($callRecord, $contact->id);
     }
     $focus->contacts->add($contactId);
     // Add the new one!
     $contactBean = new Contact();
     $contactBean->retrieve($contactId);
     $focus->parent_id = $contactBean->account_id;
     $focus->parent_type = "Accounts";
     $focus->save();
 } else {
     if ($_REQUEST['action'] == "call") {
         // TODO: For some reason this code isn't working... I think it's getting the extension.
         // For the time being, callCreate is still being used.
         /*
         	$cUser = new User();
         	$cUser->retrieve($_SESSION['authenticated_user_id']);
         	$extension = $cUser->asterisk_ext_c;
         	
         	//$extension = $current_user->asterisk_ext_c;
         	$context = $sugar_config['asterisk_context'];
         
Exemple #21
0
 /**
  * Prepares the Edit Contact mini-form via template assignment
  * @param string id ID of contact in question
  * @param string module Module in focus
  * @return array
  */
 function getEditContact($id, $module)
 {
     global $app_strings;
     if (!class_exists("Contact")) {
     }
     $contact = new Contact();
     $contact->retrieve($_REQUEST['id']);
     $ret = array();
     if ($contact->ACLAccess('edit')) {
         $contactMeta = array();
         $contactMeta['id'] = $contact->id;
         $contactMeta['module'] = $contact->module_dir;
         $contactMeta['first_name'] = $contact->first_name;
         $contactMeta['last_name'] = $contact->last_name;
         $this->smarty->assign("app_strings", $app_strings);
         $this->smarty->assign("contact_strings", return_module_language($_SESSION['authenticated_user_language'], 'Contacts'));
         $this->smarty->assign("contact", $contactMeta);
         $ea = new SugarEmailAddress();
         $newEmail = $ea->getEmailAddressWidgetEditView($id, $module, true);
         $this->smarty->assign("emailWidget", $newEmail['html']);
         $ret['form'] = $this->smarty->fetch("modules/Emails/templates/editContact.tpl");
         $ret['prefillData'] = $newEmail['prefillData'];
     } else {
         $id = "";
         $ret['form'] = $app_strings['LBL_EMAIL_ERROR_NO_ACCESS'];
         $ret['prefillData'] = '{}';
     }
     $ret['id'] = $id;
     $ret['contactName'] = $contact->full_name;
     return $ret;
 }
Exemple #22
0
 protected function checkForDuplicates($lead)
 {
     if ($lead->status == "Converted") {
         echo "<span class='error'>" . translate('LBL_CONVERTLEAD_WARNING');
         $dupes = array();
         $q = "SELECT id, first_name, last_name FROM contacts WHERE first_name LIKE '{$lead->first_name}' AND last_name LIKE '{$lead->last_name}' AND deleted = 0";
         $result = $lead->db->query($q);
         while ($row = $lead->db->fetchByAssoc($result)) {
             $contact = new Contact();
             $contact->retrieve($row['id']);
             $dupes[$row['id']] = $contact->name;
         }
         if (!empty($dupes)) {
             foreach ($dupes as $id => $name) {
                 echo translate('LBL_CONVERTLEAD_WARNING_INTO_RECORD') . "<a href='index.php?module=Contacts&action=DetailView&record={$id}'>{$name}</a>";
                 break;
             }
         }
         echo "</span>";
     }
     return false;
 }
Exemple #23
0
/**
 * Generate the compose data package consumed by the full and quick compose screens.
 *
 * @param Array $data
 * @param Bool $forFullCompose If full compose is set to TRUE, then continue execution and include the full Emails UI.  Otherwise
 *             the data generated is returned.
 * @param SugarBean $bean Optional - parent object with data
 */
function generateComposeDataPackage($data, $forFullCompose = TRUE, $bean = null)
{
    // we will need the following:
    if (isset($data['parent_type']) && !empty($data['parent_type']) && isset($data['parent_id']) && !empty($data['parent_id']) && !isset($data['ListView']) && !isset($data['replyForward'])) {
        if (empty($bean)) {
            global $beanList;
            global $beanFiles;
            global $mod_strings;
            $parentName = '';
            $class = $beanList[$data['parent_type']];
            require_once $beanFiles[$class];
            $bean = new $class();
            $bean->retrieve($data['parent_id']);
        }
        if (isset($bean->full_name)) {
            $parentName = $bean->full_name;
        } elseif (isset($bean->name)) {
            $parentName = $bean->name;
        } else {
            $parentName = '';
        }
        $parentName = from_html($parentName);
        $namePlusEmail = '';
        if (isset($data['to_email_addrs'])) {
            $namePlusEmail = $data['to_email_addrs'];
            $namePlusEmail = from_html(str_replace("&nbsp;", " ", $namePlusEmail));
        } else {
            if (isset($bean->full_name)) {
                $namePlusEmail = from_html($bean->full_name) . " <" . from_html($bean->emailAddress->getPrimaryAddress($bean)) . ">";
            } else {
                if (isset($bean->emailAddress)) {
                    $namePlusEmail = "<" . from_html($bean->emailAddress->getPrimaryAddress($bean)) . ">";
                }
            }
        }
        $subject = "";
        $body = "";
        $email_id = "";
        $attachments = array();
        if ($bean->module_dir == 'Cases') {
            $subject = str_replace('%1', $bean->case_number, $bean->getEmailSubjectMacro() . " " . from_html($bean->name));
            //bug 41928
            $bean->load_relationship("contacts");
            $contact_ids = $bean->contacts->get();
            $contact = new Contact();
            foreach ($contact_ids as $cid) {
                $contact->retrieve($cid);
                $namePlusEmail .= empty($namePlusEmail) ? "" : ", ";
                $namePlusEmail .= from_html($contact->full_name) . " <" . from_html($contact->emailAddress->getPrimaryAddress($contact)) . ">";
            }
        }
        if ($bean->module_dir == 'KBDocuments') {
            require_once "modules/Emails/EmailUI.php";
            $subject = $bean->kbdocument_name;
            $article_body = str_replace('/cache/images/', $GLOBALS['sugar_config']['site_url'] . '/cache/images/', KBDocument::get_kbdoc_body_without_incrementing_count($bean->id));
            $body = from_html($article_body);
            $attachments = KBDocument::get_kbdoc_attachments_for_newemail($bean->id);
            $attachments = $attachments['attachments'];
        }
        // if
        if ($bean->module_dir == 'Quotes' && isset($data['recordId'])) {
            $quotesData = getQuotesRelatedData($bean, $data);
            global $current_language;
            $namePlusEmail = $quotesData['toAddress'];
            $subject = $quotesData['subject'];
            $body = $quotesData['body'];
            $attachments = $quotesData['attachments'];
            $email_id = $quotesData['email_id'];
        }
        // if
        $ret = array('to_email_addrs' => $namePlusEmail, 'parent_type' => $data['parent_type'], 'parent_id' => $data['parent_id'], 'parent_name' => $parentName, 'subject' => $subject, 'body' => $body, 'attachments' => $attachments, 'email_id' => $email_id);
    } else {
        if (isset($_REQUEST['ListView'])) {
            $email = new Email();
            $namePlusEmail = $email->getNamePlusEmailAddressesForCompose($_REQUEST['action_module'], explode(",", $_REQUEST['uid']));
            $ret = array('to_email_addrs' => $namePlusEmail);
        } else {
            if (isset($data['replyForward'])) {
                require_once "modules/Emails/EmailUI.php";
                $ret = array();
                $ie = new InboundEmail();
                $ie->email = new Email();
                $ie->email->email2init();
                $replyType = $data['reply'];
                $email_id = $data['record'];
                $ie->email->retrieve($email_id);
                $emailType = "";
                if ($ie->email->type == 'draft') {
                    $emailType = $ie->email->type;
                }
                $ie->email->from_addr = $ie->email->from_addr_name;
                $ie->email->to_addrs = to_html($ie->email->to_addrs_names);
                $ie->email->cc_addrs = to_html($ie->email->cc_addrs_names);
                $ie->email->bcc_addrs = $ie->email->bcc_addrs_names;
                $ie->email->from_name = $ie->email->from_addr;
                $preBodyHTML = "&nbsp;<div><hr></div>";
                if ($ie->email->type != 'draft') {
                    $email = $ie->email->et->handleReplyType($ie->email, $replyType);
                } else {
                    $email = $ie->email;
                    $preBodyHTML = "";
                }
                // else
                if ($ie->email->type != 'draft') {
                    $emailHeader = $email->description;
                }
                $ret = $ie->email->et->displayComposeEmail($email);
                if ($ie->email->type != 'draft') {
                    $ret['description'] = $emailHeader;
                }
                if ($replyType == 'forward' || $emailType == 'draft') {
                    $ret = $ie->email->et->getDraftAttachments($ret);
                }
                $return = $ie->email->et->getFromAllAccountsArray($ie, $ret);
                if ($replyType == "forward") {
                    $return['to'] = '';
                } else {
                    if ($email->type != 'draft') {
                        $return['to'] = from_html($ie->email->from_addr);
                    }
                }
                // else
                $ret = array('to_email_addrs' => $return['to'], 'parent_type' => $return['parent_type'], 'parent_id' => $return['parent_id'], 'parent_name' => $return['parent_name'], 'subject' => $return['name'], 'body' => $preBodyHTML . $return['description'], 'attachments' => isset($return['attachments']) ? $return['attachments'] : array(), 'email_id' => $email_id, 'fromAccounts' => $return['fromAccounts']);
                // If it's a 'Reply All' action, append the CC addresses
                if ($data['reply'] == 'replyAll') {
                    $ret['cc_addrs'] = from_html($ie->email->to_addrs);
                }
            } else {
                $ret = array('to_email_addrs' => '');
            }
        }
    }
    if ($forFullCompose) {
        initFullCompose($ret);
    } else {
        return $ret;
    }
}
function portal_set_newsletters($session, $subscribe_ids, $unsubscribe_ids)
{
    global $beanList, $beanFiles;
    $error = new SoapError();
    if (!portal_validate_authenticated($session)) {
        $error->set_error('invalid_session');
        return array('result_count' => -1, 'entry_list' => array(), 'error' => $error->get_soap_array());
    }
    require_once 'modules/Campaigns/utils.php';
    $contact = new Contact();
    $contact->retrieve($_SESSION['user_id']);
    if (!empty($contact->id)) {
        foreach ($subscribe_ids as $campaign_id) {
            subscribe($campaign_id, null, $contact, true);
        }
        foreach ($unsubscribe_ids as $campaign_id) {
            unsubscribe($campaign_id, $contact);
        }
    }
    return $error->get_soap_array();
}
 function handleSave($prefix, $redirect = true, $useRequired = false)
 {
     global $theme, $current_user;
     require_once 'include/formbase.php';
     global $timedate;
     $focus = new Contact();
     if ($useRequired && !checkRequired($prefix, array_keys($focus->required_fields))) {
         return null;
     }
     if (!empty($_POST[$prefix . 'new_reports_to_id'])) {
         $focus->retrieve($_POST[$prefix . 'new_reports_to_id']);
         $focus->reports_to_id = $_POST[$prefix . 'record'];
     } else {
         $focus = populateFromPost($prefix, $focus);
         if (!empty($focus->portal_password) && $focus->portal_password != $_POST[$prefix . 'old_portal_password']) {
             $focus->portal_password = md5($focus->portal_password);
         }
         if (!isset($_POST[$prefix . 'email_opt_out'])) {
             $focus->email_opt_out = 0;
         }
         if (!isset($_POST[$prefix . 'do_not_call'])) {
             $focus->do_not_call = 0;
         }
     }
     if (!$focus->ACLAccess('Save')) {
         ACLController::displayNoAccess(true);
         sugar_cleanup(true);
     }
     if ($_REQUEST['action'] != 'BusinessCard' && $_REQUEST['action'] != 'ConvertLead' && $_REQUEST['action'] != 'ConvertProspect') {
         if (!empty($_POST[$prefix . 'sync_contact'])) {
             $focus->contacts_users_id = $current_user->id;
         } else {
             if (!isset($focus->users)) {
                 $focus->load_relationship('user_sync');
             }
             $focus->contacts_users_id = null;
             $focus->user_sync->delete($focus->id, $current_user->id);
         }
     }
     if (isset($GLOBALS['check_notify'])) {
         $check_notify = $GLOBALS['check_notify'];
     } else {
         $check_notify = FALSE;
     }
     if (empty($_POST['dup_checked'])) {
         $duplicateContacts = $this->checkForDuplicates($prefix);
         if (isset($duplicateContacts)) {
             $location = 'module=Contacts&action=ShowDuplicates';
             $get = '';
             if (isset($_POST['inbound_email_id']) && !empty($_POST['inbound_email_id'])) {
                 $get .= '&inbound_email_id=' . $_POST['inbound_email_id'];
             }
             // Bug 25311 - Add special handling for when the form specifies many-to-many relationships
             if (isset($_POST['relate_to']) && !empty($_POST['relate_to'])) {
                 $get .= '&Contactsrelate_to=' . $_POST['relate_to'];
             }
             if (isset($_POST['relate_id']) && !empty($_POST['relate_id'])) {
                 $get .= '&Contactsrelate_id=' . $_POST['relate_id'];
             }
             //add all of the post fields to redirect get string
             foreach ($focus->column_fields as $field) {
                 if (!empty($focus->{$field}) && !is_object($focus->{$field})) {
                     $get .= "&Contacts{$field}=" . urlencode($focus->{$field});
                 }
             }
             foreach ($focus->additional_column_fields as $field) {
                 if (!empty($focus->{$field})) {
                     $get .= "&Contacts{$field}=" . urlencode($focus->{$field});
                 }
             }
             if ($focus->hasCustomFields()) {
                 foreach ($focus->field_defs as $name => $field) {
                     if (!empty($field['source']) && $field['source'] == 'custom_fields') {
                         $get .= "&Contacts{$name}=" . urlencode($focus->{$name});
                     }
                 }
             }
             $emailAddress = new SugarEmailAddress();
             $get .= $emailAddress->getFormBaseURL($focus);
             //create list of suspected duplicate contact id's in redirect get string
             $i = 0;
             foreach ($duplicateContacts as $contact) {
                 $get .= "&duplicate[{$i}]=" . $contact['id'];
                 $i++;
             }
             //add return_module, return_action, and return_id to redirect get string
             $get .= "&return_module=";
             if (!empty($_POST['return_module'])) {
                 $get .= $_POST['return_module'];
             } else {
                 $get .= "Contacts";
             }
             $get .= "&return_action=";
             if (!empty($_POST['return_action'])) {
                 $get .= $_POST['return_action'];
             }
             //else $get .= "DetailView";
             if (!empty($_POST['return_id'])) {
                 $get .= "&return_id=" . $_POST['return_id'];
             }
             if (!empty($_POST['popup'])) {
                 $get .= '&popup=' . $_POST['popup'];
             }
             if (!empty($_POST['create'])) {
                 $get .= '&create=' . $_POST['create'];
             }
             // for InboundEmail flow
             if (!empty($_POST['start'])) {
                 $get .= '&start=' . $_POST['start'];
             }
             $_SESSION['SHOW_DUPLICATES'] = $get;
             //now redirect the post to modules/Contacts/ShowDuplicates.php
             if (!empty($_POST['is_ajax_call']) && $_POST['is_ajax_call'] == '1') {
                 ob_clean();
                 $json = getJSONobj();
                 echo $json->encode(array('status' => 'dupe', 'get' => $location));
             } else {
                 if (!empty($_REQUEST['ajax_load'])) {
                     echo "<script>SUGAR.ajaxUI.loadContent('index.php?{$location}');</script>";
                 } else {
                     if (!empty($_POST['to_pdf'])) {
                         $location .= '&to_pdf=' . $_POST['to_pdf'];
                     }
                     header("Location: index.php?{$location}");
                 }
             }
             return null;
         }
     }
     global $current_user;
     if (is_admin($current_user)) {
         if (!isset($_POST[$prefix . 'portal_active'])) {
             $focus->portal_active = '0';
         }
         //if no password is set set account to inactive for portal
         if (empty($_POST[$prefix . 'portal_name'])) {
             $focus->portal_active = '0';
         }
     }
     ///////////////////////////////////////////////////////////////////////////////
     ////	INBOUND EMAIL HANDLING
     ///////////////////////////////////////////////////////////////////////////////
     if (isset($_REQUEST['inbound_email_id']) && !empty($_REQUEST['inbound_email_id'])) {
         // fake this case like it's already saved.
         $focus->save($check_notify);
         $email = new Email();
         $email->retrieve($_REQUEST['inbound_email_id']);
         $email->parent_type = 'Contacts';
         $email->parent_id = $focus->id;
         $email->assigned_user_id = $current_user->id;
         $email->status = 'read';
         $email->save();
         $email->load_relationship('contacts');
         $email->contacts->add($focus->id);
         header("Location: index.php?&module=Emails&action=EditView&type=out&inbound_email_id=" . $_REQUEST['inbound_email_id'] . "&parent_id=" . $email->parent_id . "&parent_type=" . $email->parent_type . '&start=' . $_REQUEST['start'] . '&assigned_user_id=' . $current_user->id);
         exit;
     }
     ////	END INBOUND EMAIL HANDLING
     ///////////////////////////////////////////////////////////////////////////////
     $focus->save($check_notify);
     $return_id = $focus->id;
     $GLOBALS['log']->debug("Saved record with id of " . $return_id);
     if (!empty($_POST['is_ajax_call']) && $_POST['is_ajax_call'] == '1') {
         $json = getJSONobj();
         echo $json->encode(array('status' => 'success', 'get' => ''));
         $trackerManager = TrackerManager::getInstance();
         $timeStamp = TimeDate::getInstance()->nowDb();
         if ($monitor = $trackerManager->getMonitor('tracker')) {
             $monitor->setValue('action', 'detailview');
             $monitor->setValue('user_id', $GLOBALS['current_user']->id);
             $monitor->setValue('module_name', 'Contacts');
             $monitor->setValue('date_modified', $timeStamp);
             $monitor->setValue('visible', 1);
             if (!empty($this->bean->id)) {
                 $monitor->setValue('item_id', $return_id);
                 $monitor->setValue('item_summary', $focus->get_summary_text());
             }
             $trackerManager->saveMonitor($monitor, true, true);
         }
         return null;
     }
     if (isset($_POST['popup']) && $_POST['popup'] == 'true') {
         $get = '&module=';
         if (!empty($_POST['return_module'])) {
             $get .= $_POST['return_module'];
         } else {
             $get .= 'Contacts';
         }
         $get .= '&action=';
         if (!empty($_POST['return_action'])) {
             $get .= $_POST['return_action'];
         } else {
             $get .= 'Popup';
         }
         if (!empty($_POST['return_id'])) {
             $get .= '&return_id=' . $_POST['return_id'];
         }
         if (!empty($_POST['popup'])) {
             $get .= '&popup=' . $_POST['popup'];
         }
         if (!empty($_POST['create'])) {
             $get .= '&create=' . $_POST['create'];
         }
         if (!empty($_POST['to_pdf'])) {
             $get .= '&to_pdf=' . $_POST['to_pdf'];
         }
         $get .= '&first_name=' . urlencode($focus->first_name);
         $get .= '&last_name=' . urlencode($focus->last_name);
         $get .= '&query=true';
         header("Location: index.php?{$get}");
         return;
     }
     if ($redirect) {
         $this->handleRedirect($return_id);
     } else {
         return $focus;
     }
 }
         return;
     }
 }
 if (isset($_POST['newopportunity']) && $_POST['newopportunity'] == 'on' && !isset($_POST['selectedOpportunity']) && !isset($_POST['ContinueOpportunity'])) {
     $duplicateOpps = $oppForm->checkForDuplicates('Opportunities');
     if (isset($duplicateOpps)) {
         $xtpl->assign('FORMBODY', $oppForm->buildTableForm($duplicateOpps));
         $xtpl->parse('main.formnoborder');
         $xtpl->parse('main');
         $xtpl->out('main');
         return;
     }
 }
 if (!empty($_POST['selectedContact'])) {
     $contact = new Contact();
     $contact->retrieve($_POST['selectedContact']);
 } else {
     $contact = $contactForm->handleSave('Contacts', false, false);
 }
 if (!empty($_POST['selectedAccount'])) {
     $account = new Account();
     $account->retrieve($_POST['selectedAccount']);
 } else {
     if (isset($_POST['newaccount']) && $_POST['newaccount'] == 'on') {
         $account = $accountForm->handleSave('Accounts', false, false);
     }
 }
 if (isset($_POST['newopportunity']) && $_POST['newopportunity'] == 'on') {
     if (!empty($_POST['selectedOpportunity'])) {
         $opportunity = new Opportunity();
         $opportunity->retrieve($_POST['selectedOpportunity']);
 function _create_proper_name_field()
 {
     global $locale;
     if (isset($this->contact_id) && $this->contact_id != '') {
         $contact = new Contact();
         $contact->retrieve($this->contact_id);
         if (isset($contact->first_name, $contact->last_name)) {
             global $locale;
             $full_name = $locale->getLocaleFormattedName($contact->first_name, $contact->last_name, $contact->salutation, $contact->title);
             $this->contact_name = $full_name;
         }
     }
 }
Exemple #28
-1
 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;
 }
Exemple #29
-1
 * or write to the Free Software Foundation,Inc., 51 Franklin Street,
 * Fifth Floor, Boston, MA 02110-1301  USA
 *
 * @author Salesagility Ltd <*****@*****.**>
 */
if (!defined('sugarEntry')) {
    define('sugarEntry', true);
}
require_once 'modules/AOP_Case_Updates/util.php';
if (!isAOPEnabled()) {
    return;
}
global $sugar_config, $mod_strings;
require_once 'modules/Contacts/Contact.php';
$bean = new Contact();
$bean->retrieve($_REQUEST['record']);
if (array_key_exists("aop", $sugar_config) && array_key_exists("joomla_url", $sugar_config['aop'])) {
    $portalURL = $sugar_config['aop']['joomla_url'];
    $wbsv = file_get_contents($portalURL . '/index.php?option=com_advancedopenportal&task=enable_user&sug=' . $_REQUEST['record'] . '&uid=' . $bean->joomla_account_id);
    $res = json_decode($wbsv);
    if (!$res->success) {
        $msg = $res->error ? $res->error : $mod_strings['LBL_ENABLE_PORTAL_USER_FAILED'];
        SugarApplication::appendErrorMessage($msg);
    } else {
        $bean->portal_account_disabled = 0;
        $bean->save(false);
        SugarApplication::appendErrorMessage($mod_strings['LBL_ENABLE_PORTAL_USER_SUCCESS']);
    }
} else {
    SugarApplication::appendErrorMessage($mod_strings['LBL_NO_JOOMLA_URL']);
}
require_once 'modules/Contacts/Forms.php';
require_once 'include/TimeDate.php';
global $timedate;
global $mod_strings;
global $app_list_strings;
global $app_strings;
global $current_user;
global $sugar_version, $sugar_config;
// Unimplemented until jscalendar language files are fixed
// global $current_language;
// global $default_language;
// global $cal_codes;
$focus = new Contact();
if (isset($_REQUEST['record'])) {
    $GLOBALS['log']->debug("In contact edit view, about to retrieve record: " . $_REQUEST['record']);
    $result = $focus->retrieve($_REQUEST['record']);
    if ($result == null) {
        sugar_die($app_strings['ERROR_NO_RECORD']);
    }
}
if (isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
    $focus->id = "";
}
//needed when creating a new contact with a default account value passed in
if (isset($_REQUEST['account_name']) && is_null($focus->account_name)) {
    $focus->account_name = $_REQUEST['account_name'];
}
if (isset($_REQUEST['account_id']) && is_null($focus->account_id)) {
    $focus->account_id = $_REQUEST['account_id'];
}
$prefillArray = array('account_name' => 'account_name', 'account_id' => 'account_id', 'first_name' => 'first_name', 'last_name' => 'last_name', 'phone_work' => 'phone_work', 'email1' => 'email1', 'salutation' => 'salutation');