public function company_addon_new_contact($id) { $x = ModuleManager::get_instance('/Base_Box|0'); if (!$x) { trigger_error('There is no base box module instance', E_USER_ERROR); } $x->push_main(CRM_Contacts::module_name(), 'new_contact', $id, array()); return false; }
<?php defined("_VALID_ACCESS") || die('Direct access forbidden'); if (ModuleManager::is_installed('Utils_RecordBrowser') == -1) { return; } if (Utils_RecordBrowserCommon::delete_addon('company', CRM_Contacts::module_name(), 'company_attachment_addon')) { Utils_AttachmentCommon::new_addon('company'); } if (Utils_RecordBrowserCommon::delete_addon('contact', CRM_Contacts::module_name(), 'contact_attachment_addon')) { Utils_AttachmentCommon::new_addon('contact'); } if (Utils_RecordBrowserCommon::delete_addon('crm_assets', CRM_Assets::module_name(), 'assets_attachment_addon')) { Utils_AttachmentCommon::new_addon('crm_assets'); } if (Utils_RecordBrowserCommon::delete_addon('crm_meeting', CRM_Meeting::module_name(), 'meeting_attachment_addon')) { Utils_AttachmentCommon::new_addon('crm_meeting'); } if (Utils_RecordBrowserCommon::delete_addon('phonecall', CRM_PhoneCall::module_name(), 'phonecall_attachment_addon')) { Utils_AttachmentCommon::new_addon('phonecall'); } if (Utils_RecordBrowserCommon::delete_addon('task', CRM_Tasks::module_name(), 'task_attachment_addon')) { Utils_AttachmentCommon::new_addon('task'); } if (Utils_RecordBrowserCommon::delete_addon('premium_projects', 'Premium/Projects', 'premium_projects_attachment_addon')) { Utils_AttachmentCommon::new_addon('premium_projects'); } /** PREMIUM **/ if (Utils_RecordBrowserCommon::delete_addon('cades_diagnosis', 'Custom/CADES/Diagnosis', 'attachment_addon')) { Utils_AttachmentCommon::new_addon('cades_diagnosis'); }
private static function copy_company_data_subroutine($values) { $access = Utils_RecordBrowserCommon::get_access('contact', 'edit', $values); if (!$access) { return; } /* First click should generate html code for leightbox and show it. * This function is rarely used and we don't want to increase page size. * To do this we use REQUEST variable UCD. * * We use module variable UCD to indicate that form was shown and we * must check if it was submitted. If yes - do action. If it wasn't * we should come back to initial state - do not print LB. */ if (!(isset($_REQUEST['UCD']) || Module::static_get_module_variable(CRM_Contacts::module_name(), 'UCD', 0))) { if (isset($values['company_name']) && $values['company_name']) { Base_ActionBarCommon::add('edit', __('Copy company data'), Module::create_href(array('UCD' => true))); } } if (isset($_REQUEST['UCD']) || Module::static_get_module_variable(CRM_Contacts::module_name(), 'UCD', 0)) { $ucd = Module::static_get_module_variable(CRM_Contacts::module_name(), 'UCD', 0); $ucd++; if ($ucd > 1) { Module::static_unset_module_variable(CRM_Contacts::module_name(), 'UCD'); } else { Module::static_set_module_variable(CRM_Contacts::module_name(), 'UCD', $ucd); } $lid = 'UCDprompt'; $form = ModuleManager::new_instance('Libs_QuickForm', null, 'QFUCDprompt'); $form->construct(); $sel_val = array(); foreach (array_merge(array($values['company_name']), is_array($values['related_companies']) ? $values['related_companies'] : array()) as $id) { $sel_val[$id] = self::company_format_default(self::get_company($id), true); } $form->addElement('select', 'company', __('Select company:'), $sel_val); unset($sel_val); $form->addElement('html', __('Select which fields should be copied:')); $data = array(array('sid' => 'address_1', 'tid' => 'address_1', 'text' => __('Address 1'), 'checked' => true), array('sid' => 'address_2', 'tid' => 'address_2', 'text' => __('Address 2'), 'checked' => true), array('sid' => 'city', 'tid' => 'city', 'text' => __('City'), 'checked' => true), array('sid' => 'country', 'tid' => 'country', 'text' => __('Country'), 'checked' => true), array('sid' => 'zone', 'tid' => 'zone', 'text' => __('Zone'), 'checked' => true), array('sid' => 'postal_code', 'tid' => 'postal_code', 'text' => __('Postal Code'), 'checked' => true), array('sid' => 'phone', 'tid' => 'work_phone', 'text' => __('Phone as Work Phone'), 'checked' => false), array('sid' => 'fax', 'tid' => 'fax', 'text' => __('Fax'), 'checked' => false)); foreach ($data as $row) { if (is_array($access) && isset($access[$row['tid']]) && $access[$row['tid']]) { $form->addElement('checkbox', $row['sid'], $row['text'], '', $row['checked'] ? array('checked' => 'checked') : array()); } } $ok = $form->createElement('submit', 'submit', __('Confirm'), array('onclick' => 'leightbox_deactivate("' . $lid . '")')); $cancel = $form->createElement('button', 'cancel', __('Cancel'), array('onclick' => 'leightbox_deactivate("' . $lid . '")')); $form->addGroup(array($ok, $cancel)); if ($form->validate()) { $Uvalues = $form->exportValues(); $fields = array(); foreach ($data as $row) { if (array_key_exists($row['sid'], $Uvalues)) { $fields[$row['tid']] = $row['sid']; } } if (isset($Uvalues['company'])) { $company = CRM_ContactsCommon::get_company($Uvalues['company']); $new_data = array(); foreach ($fields as $k => $v) { $new_data[$k] = $company[$v]; } Utils_RecordBrowserCommon::update_record('contact', $values['id'], $new_data); } Module::static_unset_module_variable(CRM_Contacts::module_name(), 'UCD'); location(array()); } // set default to main company if ($mc = self::get_main_company()) { $form->setDefaults(array('company' => $mc)); } $html = $form->toHtml(); Libs_LeightboxCommon::display($lid, $html); Base_ActionBarCommon::add('edit', __('Copy company data'), Libs_LeightboxCommon::get_open_href($lid)); if (isset($_REQUEST['UCD'])) { eval_js('leightbox_activate(\'' . $lid . '\')'); } unset($_REQUEST['UCD']); } }