public function create_contact($r) { global $OUTPUT; $mail = $r['record']['email']; require_once dirname(__FILE__) . '/epesi_contacts_addressbook_backend.php'; $contacts = new epesi_contacts_addressbook_backend('CRM Contacts'); $ret = $contacts->search('email', $mail, true, false); if (count($ret->records)) { $OUTPUT->show_message('contactexists', 'warning'); } else { require_once dirname(__FILE__) . '/epesi_companies_addressbook_backend.php'; $companies = new epesi_companies_addressbook_backend('CRM Companies'); $ret = $companies->search('email', $mail, true, false); if (count($ret->records)) { $OUTPUT->show_message('contactexists', 'warning'); } else { if (isset($r['record']['firstname']) && $r['record']['firstname'] !== "" && isset($r['record']['surname']) && $r['record']['surname'] !== "") { $name = array($r['record']['firstname'], $r['record']['surname']); } else { $name = explode(' ', $r['record']['name'], 2); } if (count($name) < 2) { $OUTPUT->show_message('errorsavingcontact', 'warning'); } else { $loc = Base_RegionalSettingsCommon::get_default_location(); Utils_RecordBrowserCommon::new_record('contact', array('first_name' => $name[0], 'last_name' => $name[1], 'email' => $mail, 'permission' => 0, 'country' => $loc['country'])); $OUTPUT->show_message('addedsuccessfully', 'confirmation'); } } } $OUTPUT->send(); // return array('abort'=>true); }
public function mail_addresses_addon($arg, $rb) { $type = $rb->tab; $loc = Base_RegionalSettingsCommon::get_default_location(); $rb = $this->init_module('Utils/RecordBrowser', 'rc_multiple_emails'); $order = array(array('record_type' => $type, 'record_id' => $arg['id']), array('record_type' => false, 'record_id' => false), array()); $rb->set_defaults(array('record_type' => $type, 'record_id' => $arg['id'])); $rb->enable_quick_new_records(); $this->display_module($rb, $order, 'show_data'); }
public static function post_install() { $loc = Base_RegionalSettingsCommon::get_default_location(); $ret = array(array('type' => 'text', 'name' => 'cname', 'label' => __('Company Name'), 'default' => '', 'param' => array('maxlength' => 64), 'rule' => array(array('type' => 'required', 'message' => __('Field required')))), array('type' => 'text', 'name' => 'sname', 'label' => __('Short company name'), 'default' => '', 'param' => array('maxlength' => 64))); if (Acl::is_user()) { $ret[] = array('type' => 'text', 'name' => 'fname', 'label' => __('Your first name'), 'default' => '', 'param' => array('maxlength' => 64), 'rule' => array(array('type' => 'required', 'message' => __('Field required')))); $ret[] = array('type' => 'text', 'name' => 'lname', 'label' => __('Your last name'), 'default' => '', 'param' => array('maxlength' => 64), 'rule' => array(array('type' => 'required', 'message' => __('Field required')))); } return array_merge($ret, array(array('type' => 'text', 'name' => 'address1', 'label' => __('Address 1'), 'default' => '', 'param' => array('maxlength' => 64)), array('type' => 'text', 'name' => 'address2', 'label' => __('Address 2'), 'default' => '', 'param' => array('maxlength' => 64)), array('type' => 'callback', 'name' => 'country', 'func' => array('CRM_ContactsInstall', 'country_element'), 'default' => $loc['country']), array('type' => 'callback', 'name' => 'state', 'func' => array('CRM_ContactsInstall', 'state_element'), 'default' => $loc['state']), array('type' => 'text', 'name' => 'city', 'label' => __('City'), 'default' => '', 'param' => array('maxlength' => 64), 'rule' => array(array('type' => 'required', 'message' => __('Field required')))), array('type' => 'text', 'name' => 'postal', 'label' => __('Postal Code'), 'default' => '', 'param' => array('maxlength' => 64)), array('type' => 'text', 'name' => 'phone', 'label' => __('Phone'), 'default' => '', 'param' => array('maxlength' => 64)), array('type' => 'text', 'name' => 'fax', 'label' => __('Fax'), 'default' => '', 'param' => array('maxlength' => 64)), array('type' => 'text', 'name' => 'web', 'label' => __('Web address'), 'default' => '', 'param' => array('maxlength' => 64)))); }