/** * Build the form object elements for an address object. * * @return void */ public function buildQuickForm() { parent::buildQuickForm(); CRM_Contact_Form_Edit_Address::buildQuickForm($this, $this->_locBlockNo, TRUE, TRUE); }
/** * Build form for related contacts / on behalf of organization. * * @param CRM_Core_Form $form * @param string $contactType * contact type. * @param int $countryID * @param int $stateID * @param string $title * fieldset title. * */ public static function buildOnBehalfForm(&$form, $contactType, $countryID, $stateID, $title) { $config = CRM_Core_Config::singleton(); $form->assign('contact_type', $contactType); $form->assign('fieldSetTitle', $title); $form->assign('contactEditMode', TRUE); $attributes = CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact'); if ($form->_contactId) { $form->assign('orgId', $form->_contactId); } switch ($contactType) { case 'Organization': $form->add('text', 'organization_name', ts('Organization Name'), $attributes['organization_name'], TRUE); break; case 'Household': $form->add('text', 'household_name', ts('Household Name'), $attributes['household_name']); break; default: // individual $form->addElement('select', 'prefix_id', ts('Prefix'), array('' => ts('- prefix -')) + CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id')); $form->addElement('text', 'first_name', ts('First Name'), $attributes['first_name']); $form->addElement('text', 'middle_name', ts('Middle Name'), $attributes['middle_name']); $form->addElement('text', 'last_name', ts('Last Name'), $attributes['last_name']); $form->addElement('select', 'suffix_id', ts('Suffix'), array('' => ts('- suffix -')) + CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id')); } $addressSequence = $config->addressSequence(); $form->assign('addressSequence', array_fill_keys($addressSequence, 1)); //Primary Phone $form->addElement('text', 'phone[1][phone]', ts('Primary Phone'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Phone', 'phone')); //Primary Email $form->addElement('text', 'email[1][email]', ts('Primary Email'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Email', 'email')); //build the address block CRM_Contact_Form_Edit_Address::buildQuickForm($form); }
/** * Function to build form for related contacts / on behalf of organization. * * @param $form object invoking Object * @param $contactType string contact type * @param $title string fieldset title * @param $maxLocationBlocks int number of location blocks * * @static * */ static function buildOnBehalfForm(&$form, $contactType = 'Individual', $countryID = null, $stateID = null, $title = 'Contact Information', $contactEditMode = false, $maxLocationBlocks = 1) { if ($title == 'Contact Information') { $title = ts('Contact Information'); } require_once 'CRM/Contact/Form/Location.php'; $config = CRM_Core_Config::singleton(); $form->assign('contact_type', $contactType); $form->assign('fieldSetTitle', $title); $form->assign('contactEditMode', $contactEditMode); $attributes = CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact'); switch ($contactType) { case 'Organization': $session = CRM_Core_Session::singleton(); $contactID = $session->get('userID'); if ($contactID) { require_once 'CRM/Contact/BAO/Relationship.php'; $employers = CRM_Contact_BAO_Relationship::getPermissionedEmployer($contactID); } if (!$contactEditMode && $contactID && count($employers) >= 1) { $locDataURL = CRM_Utils_System::url('civicrm/ajax/permlocation', "cid=", false, null, false); $form->assign('locDataURL', $locDataURL); $dataURL = CRM_Utils_System::url('civicrm/ajax/employer', "cid=" . $contactID, false, null, false); $form->assign('employerDataURL', $dataURL); $form->add('text', 'organization_id', ts('Select an existing related Organization OR Enter a new one')); $form->add('hidden', 'onbehalfof_id', '', array('id' => 'onbehalfof_id')); $orgOptions = array('0' => ts('Create new organization'), '1' => ts('Select existing organization')); $orgOptionExtra = array('onclick' => "showHideByValue('org_option','true','select_org','table-row','radio',true);showHideByValue('org_option','true','create_org','table-row','radio',false);"); $form->addRadio('org_option', ts('options'), $orgOptions, $orgOptionExtra); $form->assign('relatedOrganizationFound', true); } $isRequired = false; if (CRM_Utils_Array::value('is_for_organization', $form->_values) == 2) { $isRequired = true; } $form->add('text', 'organization_name', ts('Organization Name'), $attributes['organization_name'], $isRequired); break; case 'Household': $form->add('text', 'household_name', ts('Household Name'), $attributes['household_name']); break; default: // individual $form->addElement('select', 'prefix_id', ts('Prefix'), array('' => ts('- prefix -')) + CRM_Core_PseudoConstant::individualPrefix()); $form->addElement('text', 'first_name', ts('First Name'), $attributes['first_name']); $form->addElement('text', 'middle_name', ts('Middle Name'), $attributes['middle_name']); $form->addElement('text', 'last_name', ts('Last Name'), $attributes['last_name']); $form->addElement('select', 'suffix_id', ts('Suffix'), array('' => ts('- suffix -')) + CRM_Core_PseudoConstant::individualSuffix()); } $addressSequence = $config->addressSequence(); $form->assign('addressSequence', array_fill_keys($addressSequence, 1)); //Primary Phone $form->addElement('text', "phone[1][phone]", ts('Primary Phone'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Phone', 'phone')); //Primary Email $form->addElement('text', "email[1][email]", ts('Primary Email'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Email', 'email')); //build the address block require_once 'CRM/Contact/Form/Edit/Address.php'; CRM_Contact_Form_Edit_Address::buildQuickForm($form); // also fix the state country selector CRM_Contact_Form_Edit_Address::fixStateSelect($form, "address[1][country_id]", "address[1][state_province_id]", $countryID); }
/** * build the form elements for an email object * * @return void * @access public */ public function buildQuickForm() { CRM_Contact_Form_Edit_Address::buildQuickForm($this, $this->_locBlockNo, TRUE, TRUE); $buttons = array(array('type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))); $this->addButtons($buttons); }
/** * Build the form object elements for an address object. */ public function buildQuickForm() { parent::buildQuickForm(); CRM_Contact_Form_Edit_Address::buildQuickForm($this, $this->_locBlockNo, TRUE, TRUE); $this->addFormRule(array('CRM_Contact_Form_Edit_Address', 'formRule'), $this); }