/** * Build the form object. */ public function buildQuickForm() { //load form for child blocks if ($this->_addBlockName) { $className = 'CRM_Contact_Form_Edit_' . $this->_addBlockName; return $className::buildQuickForm($this); } if ($this->_action == CRM_Core_Action::UPDATE) { $deleteExtra = json_encode(ts('Are you sure you want to delete contact image.')); $deleteURL = array(CRM_Core_Action::DELETE => array('name' => ts('Delete Contact Image'), 'url' => 'civicrm/contact/image', 'qs' => 'reset=1&cid=%%id%%&action=delete', 'extra' => 'onclick = "' . htmlspecialchars("if (confirm({$deleteExtra})) this.href+='&confirmed=1'; else return false;") . '"')); $deleteURL = CRM_Core_Action::formLink($deleteURL, CRM_Core_Action::DELETE, array('id' => $this->_contactId), ts('more'), FALSE, 'contact.image.delete', 'Contact', $this->_contactId); $this->assign('deleteURL', $deleteURL); } //build contact type specific fields $className = 'CRM_Contact_Form_Edit_' . $this->_contactType; $className::buildQuickForm($this); // build Custom data if Custom data present in edit option $buildCustomData = 'noCustomDataPresent'; if (array_key_exists('CustomData', $this->_editOptions)) { $buildCustomData = "customDataPresent"; } // subtype is a common field. lets keep it here $subtypes = CRM_Contact_BAO_Contact::buildOptions('contact_sub_type', 'create', array('contact_type' => $this->_contactType)); if (!empty($subtypes)) { $this->addField('contact_sub_type', array('label' => ts('Contact Type'), 'options' => $subtypes, 'class' => $buildCustomData, 'multiple' => 'multiple', 'options-url' => FALSE)); } // build edit blocks ( custom data, demographics, communication preference, notes, tags and groups ) foreach ($this->_editOptions as $name => $label) { if ($name == 'Address') { $this->_blocks['Address'] = $this->_editOptions['Address']; continue; } if ($name == 'TagsAndGroups') { continue; } $className = 'CRM_Contact_Form_Edit_' . $name; $className::buildQuickForm($this); } // build tags and groups CRM_Contact_Form_Edit_TagsAndGroups::buildQuickForm($this, 0, CRM_Contact_Form_Edit_TagsAndGroups::ALL, FALSE, NULL, 'Group(s)', 'Tag(s)', NULL, 'select'); // build location blocks. CRM_Contact_Form_Edit_Lock::buildQuickForm($this); CRM_Contact_Form_Location::buildQuickForm($this); // add attachment $this->addField('image_URL', array('maxlength' => '60', 'label' => ts('Browse/Upload Image'))); // add the dedupe button $this->addElement('submit', $this->_dedupeButtonName, ts('Check for Matching Contact(s)')); $this->addElement('submit', $this->_duplicateButtonName, ts('Save Matching Contact')); $this->addElement('submit', $this->getButtonName('next', 'sharedHouseholdDuplicate'), ts('Save With Duplicate Household')); $buttons = array(array('type' => 'upload', 'name' => ts('Save'), 'subName' => 'view', 'isDefault' => TRUE)); if (CRM_Core_Permission::check('add contacts')) { $buttons[] = array('type' => 'upload', 'name' => ts('Save and New'), 'spacing' => ' ', 'subName' => 'new'); } $buttons[] = array('type' => 'cancel', 'name' => ts('Cancel')); if (!empty($this->_values['contact_sub_type'])) { $this->_oldSubtypes = explode(CRM_Core_DAO::VALUE_SEPARATOR, trim($this->_values['contact_sub_type'], CRM_Core_DAO::VALUE_SEPARATOR)); } $this->assign('oldSubtypes', json_encode($this->_oldSubtypes)); $this->addButtons($buttons); }
/** * Function to actually build the form * * @return None * @access public */ public function buildQuickForm() { //load form for child blocks if ($this->_addBlockName) { return eval('CRM_Contact_Form_Edit_' . $this->_addBlockName . '::buildQuickForm( $this );'); } if ($this->_action == CRM_Core_Action::UPDATE) { $deleteExtra = ts('Are you sure you want to delete contact image.'); $deleteURL = array(CRM_Core_Action::DELETE => array('name' => ts('Delete Contact Image'), 'url' => 'civicrm/contact/image', 'qs' => 'reset=1&cid=%%id%%&action=delete', 'extra' => 'onclick = "if (confirm( \'' . $deleteExtra . '\' ) ) this.href+=\'&confirmed=1\'; else return false;"')); $deleteURL = CRM_Core_Action::formLink($deleteURL, CRM_Core_Action::DELETE, array('id' => $this->_contactId)); $this->assign('deleteURL', $deleteURL); } //build contact type specific fields eval('CRM_Contact_Form_Edit_' . $this->_contactType . '::buildQuickForm( $this, $this->_action );'); // build Custom data if Custom data present in edit option $buildCustomData = NULL; if (array_key_exists('CustomData', $this->_editOptions)) { $buildCustomData = "removeDefaultCustomFields( ), highlightTabs( );"; } // subtype is a common field. lets keep it here $subtypes = CRM_Contact_BAO_ContactType::subTypePairs($this->_contactType); if (!empty($subtypes)) { $sel = $this->add('select', 'contact_sub_type', ts('Contact Type'), $subtypes, FALSE, array('id' => 'contact_sub_type', 'multiple' => 'multiple', 'title' => ts('- subtype -'), 'onchange' => $buildCustomData)); } // build edit blocks ( custom data, demographics, communication preference, notes, tags and groups ) foreach ($this->_editOptions as $name => $label) { if ($name == 'Address') { $this->_blocks['Address'] = $this->_editOptions['Address']; continue; } eval('CRM_Contact_Form_Edit_' . $name . '::buildQuickForm( $this );'); } // build location blocks. CRM_Contact_Form_Location::buildQuickForm($this); // add attachment $this->addElement('file', 'image_URL', ts('Browse/Upload Image'), 'size=30 maxlength=60'); $this->addUploadElement('image_URL'); // add the dedupe button $this->addElement('submit', $this->_dedupeButtonName, ts('Check for Matching Contact(s)')); $this->addElement('submit', $this->_duplicateButtonName, ts('Save Matching Contact')); $this->addElement('submit', $this->getButtonName('next', 'sharedHouseholdDuplicate'), ts('Save With Duplicate Household')); $buttons = array(array('type' => 'upload', 'name' => ts('Save'), 'subName' => 'view', 'isDefault' => TRUE), array('type' => 'upload', 'name' => ts('Save and New'), 'spacing' => ' ', 'subName' => 'new'), array('type' => 'cancel', 'name' => ts('Cancel'))); if (CRM_Utils_Array::value('contact_sub_type', $this->_values)) { $this->_oldSubtypes = explode(CRM_Core_DAO::VALUE_SEPARATOR, trim($this->_values['contact_sub_type'], CRM_Core_DAO::VALUE_SEPARATOR)); if (!empty($this->_oldSubtypes)) { $buttons[0]['js'] = array('onclick' => "return warnSubtypeDataLoss()"); } } $this->assign('oldSubtypes', json_encode($this->_oldSubtypes)); $this->addButtons($buttons); }
/** * Function to actually build the form * * @return None * @access public */ public function buildQuickForm() { //load form for child blocks if ($this->_addBlockName) { require_once str_replace('_', DIRECTORY_SEPARATOR, "CRM_Contact_Form_Edit_" . $this->_addBlockName) . ".php"; return eval('CRM_Contact_Form_Edit_' . $this->_addBlockName . '::buildQuickForm( $this );'); } //build contact type specific fields require_once str_replace('_', DIRECTORY_SEPARATOR, "CRM_Contact_Form_Edit_" . $this->_contactType) . ".php"; eval('CRM_Contact_Form_Edit_' . $this->_contactType . '::buildQuickForm( $this, $this->_action );'); // subtype is a common field. lets keep it here require_once 'CRM/Contact/BAO/ContactType.php'; $subtypes = CRM_Contact_BAO_ContactType::subTypePairs($this->_contactType); if (!empty($subtypes)) { $subtypeElem =& $this->addElement('select', 'contact_sub_type', ts('Subtype'), array('' => '') + $subtypes); } $allowEditSubType = true; if ($this->_contactId) { $allowEditSubType = CRM_Contact_BAO_Contact::allowEditSubtype($this->_contactId, $this->_contactSubType, $this->_groupTree); } $this->assign('allowEditSubType', $allowEditSubType); // build edit blocks ( custom data, demographics, communication preference, notes, tags and groups ) foreach ($this->_editOptions as $name => $label) { if ($name == 'Address') { $this->_blocks['Address'] = $this->_editOptions['Address']; continue; } require_once str_replace('_', DIRECTORY_SEPARATOR, "CRM_Contact_Form_Edit_" . $name) . ".php"; eval('CRM_Contact_Form_Edit_' . $name . '::buildQuickForm( $this );'); } // build location blocks. CRM_Contact_Form_Location::buildQuickForm($this); // add the dedupe button $this->addElement('submit', $this->_dedupeButtonName, ts('Check for Matching Contact(s)')); $this->addElement('submit', $this->_duplicateButtonName, ts('Save Matching Contact')); $this->addElement('submit', $this->getButtonName('next', 'sharedHouseholdDuplicate'), ts('Save With Duplicate Household')); $this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'subName' => 'view', 'isDefault' => true), array('type' => 'upload', 'name' => ts('Save and New'), 'subName' => 'new'), array('type' => 'cancel', 'name' => ts('Cancel')))); }
/** * function to build location block * * @return None * @access public */ public function buildQuickForm() { //load form for child blocks if ($this->_addBlockName) { require_once str_replace('_', DIRECTORY_SEPARATOR, "CRM_Contact_Form_Edit_" . $this->_addBlockName) . ".php"; return eval('CRM_Contact_Form_Edit_' . $this->_addBlockName . '::buildQuickForm( $this );'); } $this->applyFilter('__ALL__', 'trim'); //build location blocks. CRM_Contact_Form_Location::buildQuickForm($this); //fix for CRM-1971 $this->assign('action', $this->_action); if ($this->_id) { $this->_oldLocBlockId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_id, 'loc_block_id'); } // get the list of location blocks being used by other events $locationEvents = CRM_Event_BAO_Event::getLocationEvents(); // remove duplicates and make sure that the duplicate entry with key as // loc_block_id of this event (this->_id) is preserved if (CRM_Utils_Array::value($this->_oldLocBlockId, $locationEvents)) { $possibleDuplicate = $locationEvents[$this->_oldLocBlockId]; $locationEvents = array_flip(array_unique($locationEvents)); if (CRM_Utils_Array::value($possibleDuplicate, $locationEvents)) { $locationEvents[$possibleDuplicate] = $this->_oldLocBlockId; } $locationEvents = array_flip($locationEvents); } else { $locationEvents = array_unique($locationEvents); } $events = array(); if (!empty($locationEvents)) { $this->assign('locEvents', true); $optionTypes = array('1' => ts('Create new location'), '2' => ts('Use existing location')); $this->addRadio('location_option', ts("Choose Location"), $optionTypes, array('onclick' => "showLocFields();"), '<br/>', false); if (!isset($locationEvents[$this->_oldLocBlockId]) || !$this->_oldLocBlockId) { $locationEvents = array('' => ts('- select -')) + $locationEvents; } $this->add('select', 'loc_event_id', ts('Use Location'), $locationEvents); } $this->addElement('advcheckbox', 'is_show_location', ts('Show Location?')); parent::buildQuickForm(); }
/** * Function to actually build the form * * @return None * @access public */ public function buildQuickForm() { $this->add('text', 'name', ts('Domain Name'), array('size' => 25), true); $this->add('text', 'description', ts('Description'), array('size' => 25)); $this->add('text', 'email_name', ts('FROM Name'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Email', 'email'), true); $this->add('text', 'email_address', ts('FROM Email Address'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Email', 'email'), true); $this->addRule("email_address", ts('Domain Email Address must use a valid email address format (e.g. \'info@example.org\').'), 'email'); //build location blocks. CRM_Contact_Form_Location::buildQuickForm($this); $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'subName' => 'view', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel')))); if ($this->_action & CRM_Core_Action::VIEW) { $this->freeze(); } $this->assign('emailDomain', true); }
/** * function to build location block. * * @return void */ public function buildQuickForm() { //load form for child blocks if ($this->_addBlockName) { $className = "CRM_Contact_Form_Edit_{$this->_addBlockName}"; return $className::buildQuickForm($this); } $this->applyFilter('__ALL__', 'trim'); //build location blocks. CRM_Contact_Form_Location::buildQuickForm($this); //fix for CRM-1971 $this->assign('action', $this->_action); if ($this->_id) { $this->_oldLocBlockId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_id, 'loc_block_id'); } // get the list of location blocks being used by other events $locationEvents = CRM_Event_BAO_Event::getLocationEvents(); // remove duplicates and make sure that the duplicate entry with key as // loc_block_id of this event (this->_id) is preserved if (!empty($locationEvents[$this->_oldLocBlockId])) { $possibleDuplicate = $locationEvents[$this->_oldLocBlockId]; $locationEvents = array_flip(array_unique($locationEvents)); if (!empty($locationEvents[$possibleDuplicate])) { $locationEvents[$possibleDuplicate] = $this->_oldLocBlockId; } $locationEvents = array_flip($locationEvents); } else { $locationEvents = array_unique($locationEvents); } $events = array(); if (!empty($locationEvents)) { $this->assign('locEvents', TRUE); $optionTypes = array('1' => ts('Create new location'), '2' => ts('Use existing location')); $this->addRadio('location_option', ts("Choose Location"), $optionTypes); if (!isset($locationEvents[$this->_oldLocBlockId]) || !$this->_oldLocBlockId) { $locationEvents = array('' => ts('- select -')) + $locationEvents; } $this->add('select', 'loc_event_id', ts('Use Location'), $locationEvents); } $this->addElement('advcheckbox', 'is_show_location', ts('Show Location?')); parent::buildQuickForm(); }
/** * Fix what blocks to show/hide based on the default values set * * @param CRM_Core_ShowHideBlocks $showHide the showHide object * @param array @defaults the array of default values * * @return void */ function updateShowHide(&$showHide, &$values, $maxLocationBlocks) { if (empty($values)) { return; } $locationKeys = array_keys($values); foreach ($locationKeys as $locationId) { /*if( empty( $values[$locationId])){ continue; }*/ $location = $values[$locationId]; $locationFlag = false; foreach ($location as $locationKey => $locationEntity) { if (is_array($locationEntity)) { foreach ($locationEntity as $entityKey => $entity) { if (is_array($entity)) { foreach ($entity as $subkey => $subEntity) { if ($subEntity != '') { $locationFlag = true; } } } else { if ($entity != '' and $entityKey != 'country_id') { $locationFlag = true; } } } } } if (!$locationFlag) { continue; } $showHide->addShow("location[{$locationId}]"); if ($locationId != 1) { $showHide->addHide("location[{$locationId}][show]"); } if ($locationId < $maxLocationBlocks) { $nextLocationId = $locationId + 1; $showHide->addShow("location[{$nextLocationId}][show]"); } $commPrefs = array('phone', 'email', 'im'); foreach ($GLOBALS['_CRM_CONTACT_FORM_LOCATION']['_commPrefs'] as $block) { $tmpArray = CRM_Utils_Array::value($block, $values[$locationId]); CRM_Contact_Form_Location::updateShowHideSubBlocks($showHide, $block, "location[{$locationId}]", $tmpArray); } } }
/** * Function to actually build the form * * @return None * @access public */ function buildQuickForm() { // assign a few constants used by all display elements // we can obsolete this when smarty can access class constans directly $this->assign('locationCount', CRM_CONTACT_FORM_EDIT_LOCATION_BLOCKS + 1); $this->assign('blockCount', CRM_CONTACT_FORM_LOCATION_BLOCKS + 1); $this->assign('contact_type', $this->_contactType); require_once str_replace('_', DIRECTORY_SEPARATOR, "CRM_Contact_Form_" . $this->_contactType) . ".php"; eval('CRM_Contact_Form_' . $this->_contactType . '::buildQuickForm( $this );'); // add the communications block CRM_Contact_Form_Edit::buildCommunicationBlock($this); /* Entering the compact location engine */ $location =& CRM_Contact_Form_Location::buildLocationBlock($this, CRM_CONTACT_FORM_EDIT_LOCATION_BLOCKS); /* End of locations */ // add note block if ($this->_action & CRM_CORE_ACTION_ADD) { $note =& CRM_Contact_Form_Note::buildNoteBlock($this); } //add tags and groups block $groupTag =& CRM_Contact_Form_GroupTag::buildGroupTagBlock($this, $this->_contactId, CRM_CONTACT_FORM_GROUPTAG_ALL); //Custom Group Inline Edit form $this->_groupTree =& CRM_Core_BAO_CustomGroup::getTree($this->_contactType, $this->_contactId); CRM_Core_BAO_CustomGroup::buildQuickForm($this, $this->_groupTree, 'showBlocks1', 'hideBlocks1'); $config =& CRM_Core_Config::singleton(); CRM_Core_ShowHideBlocks::links($this, 'notes', '', ''); // add the dedupe button $this->addElement('submit', $this->_dedupeButtonName, ts('Check for Matching Contact(s)')); $this->addElement('submit', $this->_duplicateButtonName, ts('Save Duplicate Contact')); $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'subName' => 'view', 'isDefault' => true), array('type' => 'next', 'name' => ts('Save and New'), 'subName' => 'new'), array('type' => 'cancel', 'name' => ts('Cancel')))); }
/** * Function to actually build the form * * @return None * @access public */ function buildQuickForm() { $this->add('text', 'name', ts('Name:'), array('size' => 25)); $this->add('text', 'description', ts('Description:'), array('size' => 25)); $this->add('text', 'contact_name', ts('Contact Name:'), array('size' => 25)); $this->add('text', 'email_domain', ts('Email Domain:'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Email', 'email')); $this->addRule("email_domain", ts('Email is not valid.'), 'domain'); $this->add('text', 'email_return_path', ts('Send Emails RETURN-PATH:'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Email', 'email')); $this->addRule("email_return_path", ts('Email is not valid.'), 'email'); $this->assign('locationCount', CRM_CONTACT_FORM_DOMAIN_LOCATION_BLOCKS + 1); $location =& CRM_Contact_Form_Location::buildLocationBlock($this, CRM_CONTACT_FORM_DOMAIN_LOCATION_BLOCKS); $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'subName' => 'view', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel')))); if ($this->_action & CRM_CORE_ACTION_VIEW) { $this->freeze(); } $this->assign('emailDomain', true); }
/** * Function to actually build the form * * @return None * @access public */ public function buildQuickForm() { //load form for child blocks if ($this->_addBlockName) { require_once str_replace('_', DIRECTORY_SEPARATOR, "CRM_Contact_Form_Edit_" . $this->_addBlockName) . ".php"; return eval('CRM_Contact_Form_Edit_' . $this->_addBlockName . '::buildQuickForm( $this );'); } if ($this->_action == CRM_Core_Action::UPDATE) { $deleteExtra = ts('Are you sure you want to delete contact image.'); $deleteURL = array(CRM_Core_Action::DELETE => array('name' => ts('Delete Contact Image'), 'url' => 'civicrm/contact/image', 'qs' => 'reset=1&cid=%%id%%&action=delete', 'extra' => 'onclick = "if (confirm( \'' . $deleteExtra . '\' ) ) this.href+=\'&confirmed=1\'; else return false;"')); $deleteURL = CRM_Core_Action::formLink($deleteURL, CRM_Core_Action::DELETE, array('id' => $this->_contactId)); $this->assign('deleteURL', $deleteURL); } //build contact type specific fields require_once str_replace('_', DIRECTORY_SEPARATOR, "CRM_Contact_Form_Edit_" . $this->_contactType) . ".php"; eval('CRM_Contact_Form_Edit_' . $this->_contactType . '::buildQuickForm( $this, $this->_action );'); // build Custom data if Custom data present in edit option $buildCustomData = null; if (array_key_exists('CustomData', $this->_editOptions)) { $buildCustomData = "removeDefaultCustomFields( ), buildCustomData('{$this->_contactType}',this.value), highlightTabs( );"; } // subtype is a common field. lets keep it here $typeLabel = CRM_Contact_BAO_ContactType::getLabel($this->_contactType); $subtypes = CRM_Contact_BAO_ContactType::subTypePairs($this->_contactType); $subtypeElem =& $this->addElement('select', 'contact_sub_type', ts('Contact Type'), array('' => $typeLabel) + $subtypes, array('onchange' => $buildCustomData)); $allowEditSubType = true; if ($this->_contactId && $this->_contactSubType) { $allowEditSubType = CRM_Contact_BAO_ContactType::isAllowEdit($this->_contactId, $this->_contactSubType); } if (!$allowEditSubType) { $subtypeElem->freeze(); } // build edit blocks ( custom data, demographics, communication preference, notes, tags and groups ) foreach ($this->_editOptions as $name => $label) { if ($name == 'Address') { $this->_blocks['Address'] = $this->_editOptions['Address']; continue; } require_once str_replace('_', DIRECTORY_SEPARATOR, "CRM_Contact_Form_Edit_" . $name) . ".php"; eval('CRM_Contact_Form_Edit_' . $name . '::buildQuickForm( $this );'); } // build location blocks. CRM_Contact_Form_Location::buildQuickForm($this); // add attachment $this->addElement('file', 'image_URL', ts('Browse/Upload Image'), 'size=30 maxlength=60'); $this->addUploadElement('image_URL'); // add the dedupe button $this->addElement('submit', $this->_dedupeButtonName, ts('Check for Matching Contact(s)')); $this->addElement('submit', $this->_duplicateButtonName, ts('Save Matching Contact')); $this->addElement('submit', $this->getButtonName('next', 'sharedHouseholdDuplicate'), ts('Save With Duplicate Household')); $this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'subName' => 'view', 'isDefault' => true), array('type' => 'upload', 'name' => ts('Save and New'), 'spacing' => ' ', 'subName' => 'new'), array('type' => 'cancel', 'name' => ts('Cancel')))); }