9ed6b745972ea934972297315d12473d2b382638
[civicrm-core.git] / CRM / Contact / Form / Inline / ContactInfo.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
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. |
13 | |
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. |
18 | |
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 +--------------------------------------------------------------------+
26 */
27
28 /**
29 *
30 * @package CRM
31 * @copyright CiviCRM LLC (c) 2004-2015
32 */
33
34 /**
35 * Form helper class for contact info section.
36 */
37 class CRM_Contact_Form_Inline_ContactInfo extends CRM_Contact_Form_Inline {
38
39 /**
40 * Build the form object elements.
41 */
42 public function buildQuickForm() {
43 parent::buildQuickForm();
44
45 // Build contact type specific fields
46 $class = 'CRM_Contact_Form_Edit_' . $this->_contactType;
47 $class::buildQuickForm($this, 2);
48 }
49
50 /**
51 * Set defaults for the form.
52 *
53 * @return array
54 */
55 public function setDefaultValues() {
56 return parent::setDefaultValues();
57 }
58
59 /**
60 * Process the form.
61 */
62 public function postProcess() {
63 $params = $this->exportValues();
64
65 // Process / save contact info
66 $params['contact_type'] = $this->_contactType;
67 $params['contact_id'] = $this->_contactId;
68
69 if (!empty($this->_contactSubType)) {
70 $params['contact_sub_type'] = $this->_contactSubType;
71 }
72
73 CRM_Contact_BAO_Contact::create($params);
74
75 // Saving current employer affects relationship tab, and possibly related memberships and contributions
76 $this->ajaxResponse['updateTabs'] = array(
77 '#tab_rel' => CRM_Contact_BAO_Contact::getCountComponent('rel', $this->_contactId),
78 );
79 if (CRM_Core_Permission::access('CiviContribute')) {
80 $this->ajaxResponse['updateTabs']['#tab_contribute'] = CRM_Contact_BAO_Contact::getCountComponent('contribution', $this->_contactId);
81 }
82 if (CRM_Core_Permission::access('CiviMember')) {
83 $this->ajaxResponse['updateTabs']['#tab_member'] = CRM_Contact_BAO_Contact::getCountComponent('membership', $this->_contactId);
84 }
85
86 $this->response();
87 }
88
89 }