3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2014
37 * Auxilary class to provide support to the Contact Form class. Does this by implementing
38 * a small set of static methods
41 class CRM_Contact_Form_Edit_Organization
{
44 * This function provides the HTML form elements that are specific
45 * to the Organization Contact Type
47 * @param object $form form object
48 * @param int $inlineEditMode ( 1 for contact summary
49 * top bar form and 2 for display name edit )
54 public static function buildQuickForm(&$form, $inlineEditMode = NULL) {
55 $attributes = CRM_Core_DAO
::getAttribute('CRM_Contact_DAO_Contact');
57 $form->applyFilter('__ALL__', 'trim');
59 if ( !$inlineEditMode ||
$inlineEditMode == 1 ) {
61 $form->add('text', 'organization_name', ts('Organization Name'), $attributes['organization_name']);
64 if ( !$inlineEditMode ||
$inlineEditMode == 2 ) {
66 $form->addElement('text', 'legal_name', ts('Legal Name'), $attributes['legal_name']);
69 $form->addElement('text', 'nick_name', ts('Nickname'),
70 CRM_Core_DAO
::getAttribute('CRM_Contact_DAO_Contact', 'nick_name')
74 $form->addElement('text', 'sic_code', ts('SIC Code'), $attributes['sic_code']);
76 $form->addElement('text', 'contact_source', ts('Source'), CRM_Utils_Array
::value('source', $attributes));
79 if ( !$inlineEditMode ) {
80 $form->add('text', 'external_identifier', ts('External ID'), CRM_Core_DAO
::getAttribute('CRM_Contact_DAO_Contact', 'external_identifier'), FALSE);
81 $form->addRule('external_identifier',
82 ts('External ID already exists in Database.'),
84 array('CRM_Contact_DAO_Contact', $form->_contactId
, 'external_identifier')
92 * @param null $contactID
96 static function formRule($fields, $files, $contactID = NULL) {
98 $primaryID = CRM_Contact_Form_Contact
::formRule($fields, $errors, $contactID);
100 // make sure that organization name is set
101 if (empty($fields['organization_name'])) {
102 $errors['organization_name'] = 'Organization Name should be set.';
105 //check for duplicate - dedupe rules
106 CRM_Contact_Form_Contact
::checkDuplicateContacts($fields, $errors, $contactID, 'Organization');
108 // add code to make sure that the uniqueness criteria is satisfied
109 return empty($errors) ?
TRUE : $errors;