示例#1
0
/**
 * Convenience function for MVC (Mystique)
 * @param object $focus SugarBean
 * @param string $field unused
 * @param string $value unused
 * @param string $view DetailView or EditView
 * @return string
 */
function getEmailAddressWidget($focus, $field, $value, $view, $tabindex = '0')
{
    $sea = new SugarEmailAddress();
    $sea->setView($view);
    if ($view == 'EditView' || $view == 'QuickCreate' || $view == 'ConvertLead') {
        $module = $focus->module_dir;
        if ($view == 'ConvertLead' && $module == "Contacts") {
            $module = "Leads";
        }
        return $sea->getEmailAddressWidgetEditView($focus->id, $module, false, '', $tabindex);
    }
    return $sea->getEmailAddressWidgetDetailView($focus);
}
示例#2
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;
 }
    function getWideFormBody($prefix, $mod = '', $formname = '', $contact = '', $portal = true)
    {
        if (!ACLController::checkAccess('Contacts', 'edit', true)) {
            return '';
        }
        if (empty($contact)) {
            $contact = new Contact();
        }
        global $mod_strings;
        $temp_strings = $mod_strings;
        if (!empty($mod)) {
            global $current_language;
            $mod_strings = return_module_language($current_language, $mod);
        }
        global $app_strings;
        global $current_user;
        global $app_list_strings;
        $primary_address_country_options = get_select_options_with_id($app_list_strings['countries_dom'], $contact->primary_address_country);
        $lbl_required_symbol = $app_strings['LBL_REQUIRED_SYMBOL'];
        $lbl_first_name = $mod_strings['LBL_FIRST_NAME'];
        $lbl_last_name = $mod_strings['LBL_LAST_NAME'];
        $lbl_phone = $mod_strings['LBL_OFFICE_PHONE'];
        $lbl_address = $mod_strings['LBL_PRIMARY_ADDRESS'];
        if (isset($contact->assigned_user_id)) {
            $user_id = $contact->assigned_user_id;
        } else {
            $user_id = $current_user->id;
        }
        //Retrieve Email address and set email1, email2
        $sugarEmailAddress = new SugarEmailAddress();
        $sugarEmailAddress->handleLegacyRetrieve($contact);
        if (!isset($contact->email1)) {
            $contact->email1 = '';
        }
        if (!isset($contact->email2)) {
            $contact->email2 = '';
        }
        if (!isset($contact->email_opt_out)) {
            $contact->email_opt_out = '';
        }
        $lbl_email_address = $mod_strings['LBL_EMAIL_ADDRESS'];
        $salutation_options = get_select_options_with_id($app_list_strings['salutation_dom'], $contact->salutation);
        if (isset($contact->lead_source)) {
            $lead_source_options = get_select_options_with_id($app_list_strings['lead_source_dom'], $contact->lead_source);
        } else {
            $lead_source_options = get_select_options_with_id($app_list_strings['lead_source_dom'], '');
        }
        $form = "";
        if ($formname == 'ConvertProspect') {
            $lead_source_label = "<td class='dataLabel'>&nbsp;</td>";
            $lead_source_field = "<td class='dataField'>&nbsp;</td>";
        } else {
            $lead_source_label = "<td class='dataLabel' nowrap>{$mod_strings['LBL_LEAD_SOURCE']}</td>";
            $lead_source_field = "<td class='dataField'><select name='{$prefix}lead_source'>{$lead_source_options}</select></td>";
        }
        $form .= <<<EOQ
\t\t<input type="hidden" name="{$prefix}record" value="">
\t\t<input type="hidden" name="{$prefix}assigned_user_id" value='{$user_id}'>
\t\t<table border='0' celpadding="0" cellspacing="0" width='100%'>
\t\t<tr>
\t\t<td nowrap class='dataLabel'>{$lbl_first_name}</td>
\t\t<td class='dataLabel'>{$lbl_last_name}&nbsp;<span class="required">{$lbl_required_symbol}</span></td>
\t\t<td class='dataLabel' nowrap>{$mod_strings['LBL_TITLE']}</td>
\t\t<td class='dataLabel' nowrap>{$mod_strings['LBL_DEPARTMENT']}</td>
\t\t</tr>
\t\t<tr>
\t\t<td class='dataField'><select name='{$prefix}salutation'>{$salutation_options}</select>&nbsp;<input name="{$prefix}first_name" type="text" value="{$contact->first_name}"></td>
\t\t<td class='dataField'><input name='{$prefix}last_name' type="text" value="{$contact->last_name}"></td>
\t\t<td class='dataField' nowrap><input name='{$prefix}title' type="text" value="{$contact->title}"></td>
\t\t<td class='dataField' nowrap><input name='{$prefix}department' type="text" value="{$contact->department}"></td>
\t\t</tr>
\t\t<tr>
\t\t<td nowrap colspan='4' class='dataLabel'>{$lbl_address}</td>
\t\t</tr>

\t\t<tr>
\t\t<td nowrap colspan='4' class='dataField'><textarea cols='80' rows='2' name='{$prefix}primary_address_street'>{$contact->primary_address_street}</textarea></td>
\t\t</tr>

\t\t<tr>
\t\t<td class='dataLabel'>{$mod_strings['LBL_CITY']}</td>
\t\t<td class='dataLabel'>{$mod_strings['LBL_STATE']}</td>
\t\t<td class='dataLabel'>{$mod_strings['LBL_POSTAL_CODE']}</td>
\t\t<td class='dataLabel'>{$mod_strings['LBL_COUNTRY']}</td>
\t\t</tr>

\t\t<tr>
\t\t<td class='dataField'><input name='{$prefix}primary_address_city'  maxlength='100' value='{$contact->primary_address_city}'></td>
\t\t<td class='dataField'><input name='{$prefix}primary_address_state'  maxlength='100' value='{$contact->primary_address_state}'></td>
\t\t<td class='dataField'><input name='{$prefix}primary_address_postalcode'  maxlength='100' value='{$contact->primary_address_postalcode}'></td>
\t\t<td class='dataField'><select name='{$prefix}primary_address_country' size='1' selected='{$contact->primary_address_country}'>{$primary_address_country_options}</select></td>
\t\t</tr>


\t\t<tr>
\t\t<td nowrap class='dataLabel'>{$lbl_phone}</td>
\t\t<td nowrap class='dataLabel'>{$mod_strings['LBL_MOBILE_PHONE']}</td>
\t\t<td nowrap class='dataLabel'>{$mod_strings['LBL_FAX_PHONE']}</td>
\t\t<td nowrap class='dataLabel'>{$mod_strings['LBL_HOME_PHONE']}</td>
\t\t</tr>

\t\t<tr>
\t\t<td nowrap class='dataField'><input name='{$prefix}phone_work' type="text" value="{$contact->phone_work}"></td>
\t\t<td nowrap class='dataField'><input name='{$prefix}phone_mobile' type="text" value="{$contact->phone_mobile}"></td>
\t\t<td nowrap class='dataField'><input name='{$prefix}phone_fax' type="text" value="{$contact->phone_fax}"></td>
\t\t<td nowrap class='dataField'><input name='{$prefix}phone_home' type="text" value="{$contact->phone_home}"></td>
\t\t</tr>

\t\t<tr>
\t\t<td class='dataLabel' nowrap>{$mod_strings['LBL_OTHER_PHONE']}</td>
\t\t{$lead_source_label}
\t\t</tr>

\t\t<tr>
\t\t<td class='dataField' nowrap><input name='{$prefix}phone_other' type="text" value="{$contact->phone_other}"></td>
\t\t{$lead_source_field}
\t\t</tr>
EOQ;
        $form .= $sugarEmailAddress->getEmailAddressWidgetEditView($contact->id, $_REQUEST['action'] == 'ConvertLead' ? 'Leads' : 'Contacts', false, 'include/SugarEmailAddress/templates/forWideFormBodyView.tpl');
        $form .= <<<EOQ
\t\t<tr>
\t\t<td nowrap colspan='4' class='dataLabel'>{$mod_strings['LBL_DESCRIPTION']}</td>
\t\t</tr>
\t\t<tr>
\t\t<td nowrap colspan='4' class='dataField'><textarea cols='80' rows='4' name='{$prefix}description' >{$contact->description}</textarea></td>
\t\t</tr>
EOQ;
        //carry forward custom lead fields common to contacts during Lead Conversion
        $tempContact = new Contact();
        if (method_exists($contact, 'convertCustomFieldsForm')) {
            $contact->convertCustomFieldsForm($form, $tempContact, $prefix);
        }
        unset($tempContact);
        $form .= <<<EOQ
\t\t</table>
\t\t<input type='hidden' name='{$prefix}alt_address_street'  value='{$contact->alt_address_street}'>
\t\t<input type='hidden' name='{$prefix}alt_address_city' value='{$contact->alt_address_city}'><input type='hidden' name='{$prefix}alt_address_state'   value='{$contact->alt_address_state}'><input type='hidden' name='{$prefix}alt_address_postalcode'   value='{$contact->alt_address_postalcode}'><input type='hidden' name='{$prefix}alt_address_country'  value='{$contact->alt_address_country}'>
\t\t<input type='hidden' name='{$prefix}do_not_call'  value='{$contact->do_not_call}'>
\t\t<input type='hidden' name='{$prefix}email_opt_out'  value='{$contact->email_opt_out}'>
EOQ;
        if ($portal == true) {
            if (isset($contact->portal_name)) {
                $form .= "<input type='hidden' name='{$prefix}portal_name'  value='{$contact->portal_name}'>";
            } else {
                $form .= "<input type='hidden' name='{$prefix}portal_name'  value=''>";
            }
            if (isset($contact->portal_app)) {
                $form .= "<input type='hidden' name='{$prefix}portal_app'  value='{$contact->portal_app}'>";
            } else {
                $form .= "<input type='hidden' name='{$prefix}portal_app'  value=''>";
            }
            if (!empty($contact->portal_name) && !empty($contact->portal_app)) {
                $form .= "<input name='{$prefix}portal_active' type='hidden' size='25'  value='1' >";
            }
            if (isset($contact->portal_password)) {
                $form .= "<input type='password' name='{$prefix}portal_password1'  value='{$contact->portal_password}'>";
                $form .= "<input type='password' name='{$prefix}portal_password'  value='{$contact->portal_password}'>";
                $form .= "<input name='{$prefix}old_portal_password' type='hidden' size='25'  value='{$contact->portal_password}' >";
            } else {
                $form .= "<input type='password' name='{$prefix}portal_password1'  value=''>";
                $form .= "<input type='password' name='{$prefix}portal_password'  value=''>";
                $form .= "<input name='{$prefix}old_portal_password' type='hidden' size='25'  value='' >";
            }
        }
        $javascript = new javascript();
        $javascript->setFormName($formname);
        $javascript->setSugarBean(new Contact());
        $javascript->addField('email1', 'false', $prefix);
        $javascript->addField('email2', 'false', $prefix);
        $javascript->addRequiredFields($prefix);
        $form .= $javascript->getScript();
        $mod_strings = $temp_strings;
        return $form;
    }
    function getWideFormBody($prefix, $mod = '', $formname = '', $contact = '', $portal = true)
    {
        if (!ACLController::checkAccess('Contacts', 'edit', true)) {
            return '';
        }
        if (empty($contact)) {
            $contact = new Contact();
        }
        global $mod_strings;
        $temp_strings = $mod_strings;
        if (!empty($mod)) {
            global $current_language;
            $mod_strings = return_module_language($current_language, $mod);
        }
        global $app_strings;
        global $current_user;
        global $app_list_strings;
        $primary_address_country_options = get_select_options_with_id($app_list_strings['countries_dom'], $contact->primary_address_country);
        $lbl_required_symbol = $app_strings['LBL_REQUIRED_SYMBOL'];
        $lbl_first_name = $mod_strings['LBL_FIRST_NAME'];
        $lbl_last_name = $mod_strings['LBL_LAST_NAME'];
        $lbl_phone = $mod_strings['LBL_OFFICE_PHONE'];
        $lbl_address = $mod_strings['LBL_PRIMARY_ADDRESS'];
        if (isset($contact->assigned_user_id)) {
            $user_id = $contact->assigned_user_id;
        } else {
            $user_id = $current_user->id;
        }
        //Retrieve Email address and set email1, email2
        $sugarEmailAddress = new SugarEmailAddress();
        $sugarEmailAddress->handleLegacyRetrieve($contact);
        if (!isset($contact->email1)) {
            $contact->email1 = '';
        }
        if (!isset($contact->email2)) {
            $contact->email2 = '';
        }
        if (!isset($contact->email_opt_out)) {
            $contact->email_opt_out = '';
        }
        $lbl_email_address = $mod_strings['LBL_EMAIL_ADDRESS'];
        $salutation_options = get_select_options_with_id($app_list_strings['salutation_dom'], $contact->salutation);
        if (isset($contact->lead_source)) {
            $lead_source_options = get_select_options_with_id($app_list_strings['lead_source_dom'], $contact->lead_source);
        } else {
            $lead_source_options = get_select_options_with_id($app_list_strings['lead_source_dom'], '');
        }
        $form = "";
        if ($formname == 'ConvertProspect') {
            $lead_source_label = "<td scope='row'>&nbsp;</td>";
            $lead_source_field = "<td >&nbsp;</td>";
        } else {
            $lead_source_label = "<td scope='row' nowrap>{$mod_strings['LBL_LEAD_SOURCE']}</td>";
            $lead_source_field = "<td ><select name='{$prefix}lead_source'>{$lead_source_options}</select></td>";
        }
        global $timedate;
        $birthdate = '';
        if (!empty($_REQUEST['birthdate'])) {
            $birthdate = $_REQUEST['birthdate'];
        }
        $jsCalendarImage = SugarThemeRegistry::current()->getImageURL('jscalendar.gif');
        $ntc_date_format = $timedate->get_user_date_format();
        $cal_dateformat = $timedate->get_cal_date_format();
        $lbl_required_symbol = $app_strings['LBL_REQUIRED_SYMBOL'];
        $form .= <<<EOQ
\t\t<input type="hidden" name="{$prefix}record" value="">
\t\t<input type="hidden" name="{$prefix}assigned_user_id" value='{$user_id}'>
\t\t<table border='0' celpadding="0" cellspacing="0" width='100%'>
\t\t<tr>
\t\t<td nowrap scope='row'>{$lbl_first_name}</td>
\t\t<td scope='row'>{$lbl_last_name}&nbsp;<span class="required">{$lbl_required_symbol}</span></td>
\t\t<td scope='row' nowrap>{$mod_strings['LBL_TITLE']}</td>
\t\t<td scope='row' nowrap>{$mod_strings['LBL_DEPARTMENT']}</td>
\t\t</tr>
\t\t<tr>
\t\t<td ><select name='{$prefix}salutation'>{$salutation_options}</select>&nbsp;<input name="{$prefix}first_name" type="text" value="{$contact->first_name}"></td>
\t\t<td ><input name='{$prefix}last_name' type="text" value="{$contact->last_name}"></td>
\t\t<td  nowrap><input name='{$prefix}title' type="text" value="{$contact->title}"></td>
\t\t<td  nowrap><input name='{$prefix}department' type="text" value="{$contact->department}"></td>
\t\t</tr>
\t\t<tr>
\t\t<td nowrap colspan='4' scope='row'>{$lbl_address}</td>
\t\t</tr>

\t\t<tr>
\t\t<td nowrap colspan='4' ><textarea cols='80' rows='2' name='{$prefix}primary_address_street'>{$contact->primary_address_street}</textarea></td>
\t\t</tr>

\t\t<tr>
\t\t<td scope='row'>{$mod_strings['LBL_CITY']}</td>
\t\t<td scope='row'>{$mod_strings['LBL_STATE']}</td>
\t\t<td scope='row'>{$mod_strings['LBL_POSTAL_CODE']}</td>
\t\t<td scope='row'>{$mod_strings['LBL_COUNTRY']}</td>
\t\t</tr>

\t\t<tr>
\t\t<td ><input name='{$prefix}primary_address_city'  maxlength='100' value='{$contact->primary_address_city}'></td>
\t\t<td ><input name='{$prefix}primary_address_state'  maxlength='100' value='{$contact->primary_address_state}'></td>
\t\t<td ><input name='{$prefix}primary_address_postalcode'  maxlength='100' value='{$contact->primary_address_postalcode}'></td>
\t\t<td ><input name='{$prefix}primary_address_country'  maxlength='100' value='{$contact->primary_address_country}'></td>
\t\t</tr>


\t\t<tr>
\t\t<td nowrap scope='row'>{$lbl_phone}</td>
\t\t<td nowrap scope='row'>{$mod_strings['LBL_MOBILE_PHONE']}</td>
\t\t<td nowrap scope='row'>{$mod_strings['LBL_FAX_PHONE']}</td>
\t\t<td nowrap scope='row'>{$mod_strings['LBL_HOME_PHONE']}</td>
\t\t</tr>

\t\t<tr>
\t\t<td nowrap ><input name='{$prefix}phone_work' type="text" value="{$contact->phone_work}"></td>
\t\t<td nowrap ><input name='{$prefix}phone_mobile' type="text" value="{$contact->phone_mobile}"></td>
\t\t<td nowrap ><input name='{$prefix}phone_fax' type="text" value="{$contact->phone_fax}"></td>
\t\t<td nowrap ><input name='{$prefix}phone_home' type="text" value="{$contact->phone_home}"></td>
\t\t</tr>

\t\t<tr>
\t\t<td scope='row' nowrap>{$mod_strings['LBL_OTHER_PHONE']}</td>
\t\t{$lead_source_label}

\t\t<td scope="row">{$mod_strings['LBL_BIRTHDATE']}&nbsp;</td>
\t\t</tr>


\t\t<tr>
\t\t<td  nowrap><input name='{$prefix}phone_other' type="text" value="{$contact->phone_other}"></td>
\t\t{$lead_source_field}

\t\t<td  nowrap>
\t\t\t<input name='{$prefix}birthdate' onblur="parseDate(this, '{$cal_dateformat}');" size='12' maxlength='10' id='{$prefix}jscal_field' type="text" value="{$birthdate}">&nbsp;
\t\t\t<img src="{$jsCalendarImage}" alt="{$app_strings['LBL_ENTER_DATE']}"  id="{$prefix}jscal_trigger" align="absmiddle">
\t\t</td>\t\t
\t\t</tr>

EOQ;
        $form .= $sugarEmailAddress->getEmailAddressWidgetEditView($contact->id, $_REQUEST['action'] == 'ConvertLead' ? 'Leads' : 'Contacts', false, 'include/SugarEmailAddress/templates/forWideFormBodyView.tpl');
        require_once 'include/SugarFields/Fields/Text/SugarFieldText.php';
        $sugarfield = new SugarFieldText('Text');
        $description_text = $sugarfield->getClassicEditView('description', $contact->description, $prefix, true);
        $form .= <<<EOQ
\t\t<tr>
\t\t<td nowrap colspan='4' scope='row'>{$mod_strings['LBL_DESCRIPTION']}</td>
\t\t</tr>
\t\t<tr>
\t\t<td nowrap colspan='4' >{$description_text}</td>
\t\t</tr>
EOQ;
        //carry forward custom lead fields common to contacts during Lead Conversion
        $tempContact = new Contact();
        if (method_exists($contact, 'convertCustomFieldsForm')) {
            $contact->convertCustomFieldsForm($form, $tempContact, $prefix);
        }
        unset($tempContact);
        $form .= <<<EOQ
\t\t</table>
\t\t
\t\t<input type='hidden' name='{$prefix}alt_address_street'  value='{$contact->alt_address_street}'>
\t\t<input type='hidden' name='{$prefix}alt_address_city' value='{$contact->alt_address_city}'><input type='hidden' name='{$prefix}alt_address_state'   value='{$contact->alt_address_state}'><input type='hidden' name='{$prefix}alt_address_postalcode'   value='{$contact->alt_address_postalcode}'><input type='hidden' name='{$prefix}alt_address_country'  value='{$contact->alt_address_country}'>
\t\t<input type='hidden' name='{$prefix}do_not_call'  value='{$contact->do_not_call}'>
\t\t<input type='hidden' name='{$prefix}email_opt_out'  value='{$contact->email_opt_out}'>
EOQ;
        if ($portal == true) {
            if (isset($contact->portal_name)) {
                $form .= "<input type='hidden' name='{$prefix}portal_name'  value='{$contact->portal_name}'>";
            } else {
                $form .= "<input type='hidden' name='{$prefix}portal_name'  value=''>";
            }
            if (isset($contact->portal_app)) {
                $form .= "<input type='hidden' name='{$prefix}portal_app'  value='{$contact->portal_app}'>";
            } else {
                $form .= "<input type='hidden' name='{$prefix}portal_app'  value=''>";
            }
            if (!empty($contact->portal_name) && !empty($contact->portal_app)) {
                $form .= "<input name='{$prefix}portal_active' type='hidden' size='25'  value='1' >";
            }
            if (isset($contact->portal_password)) {
                $form .= "<input type='password' name='{$prefix}portal_password1'  value='{$contact->portal_password}'>";
                $form .= "<input type='password' name='{$prefix}portal_password'  value='{$contact->portal_password}'>";
                $form .= "<input name='{$prefix}old_portal_password' type='hidden' size='25'  value='{$contact->portal_password}' >";
            } else {
                $form .= "<input type='password' name='{$prefix}portal_password1'  value=''>";
                $form .= "<input type='password' name='{$prefix}portal_password'  value=''>";
                $form .= "<input name='{$prefix}old_portal_password' type='hidden' size='25'  value='' >";
            }
        }
        $form .= <<<EOQ
\t\t\t<script type="text/javascript">
\t\t\t\tCalendar.setup ({
\t\t\t\tinputField : "{$prefix}jscal_field", daFormat : "{$cal_dateformat}", ifFormat : "{$cal_dateformat}", showsTime : false, button : "{$prefix}jscal_trigger", singleClick : true, step : 1, weekNumbers:false
\t\t\t\t});
\t\t\t</script>
EOQ;
        $javascript = new javascript();
        $javascript->setFormName($formname);
        $javascript->setSugarBean(new Contact());
        $javascript->addField('email1', 'false', $prefix);
        $javascript->addField('email2', 'false', $prefix);
        $javascript->addRequiredFields($prefix);
        $form .= $javascript->getScript();
        $mod_strings = $temp_strings;
        return $form;
    }
/**
 * Convenience function for MVC (Mystique)
 * @param object $focus SugarBean
 * @param string $field unused
 * @param string $value unused
 * @param string $view DetailView or EditView
 * @return string
 */
function getEmailAddressWidget($focus, $field, $value, $view)
{
    $sea = new SugarEmailAddress();
    $sea->setView($view);
    if ($view == 'EditView' || $view == 'QuickCreate') {
        return $sea->getEmailAddressWidgetEditView($focus->id, $focus->module_dir, false);
    }
    return $sea->getEmailAddressWidgetDetailView($focus);
}