3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
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-2013
37 * This class assigns the current case to another client
40 class CRM_Case_Form_EditClient
extends CRM_Core_Form
{
43 * build all the data structures needed to build the form
48 public function preProcess() {
49 $this->_contactId
= CRM_Utils_Request
::retrieve('cid', 'Positive', $this);
50 $this->_caseId
= CRM_Utils_Request
::retrieve('id', 'Positive', $this);
51 $context = CRM_Utils_Request
::retrieve('context', 'String', $this);
53 //get current client name.
54 $this->assign('currentClientName', CRM_Contact_BAO_Contact
::displayName($this->_contactId
));
57 $url = CRM_Utils_System
::url('civicrm/contact/view', "reset=1&force=1&cid={$this->_contactId}&selectedChild=case");
58 if ($context == 'search') {
59 $qfKey = CRM_Utils_Request
::retrieve('key', 'String', $this);
61 $urlParams = 'force=1';
62 if (CRM_Utils_Rule
::qfKey($qfKey)) {
63 $urlParams .= "&qfKey=$qfKey";
65 $url = CRM_Utils_System
::url('civicrm/case/search', $urlParams);
67 elseif ($context == 'dashboard') {
68 $url = CRM_Utils_System
::url('civicrm/case', 'reset=1');
70 elseif (in_array($context, array(
71 'dashlet', 'dashletFullscreen'))) {
72 $url = CRM_Utils_System
::url('civicrm/dashboard', 'reset=1');
74 $session = CRM_Core_Session
::singleton();
75 $session->pushUserContext($url);
79 * Function to build the form
84 public function buildQuickForm() {
85 $this->add('text', 'change_client_id', ts('Select Contact'));
86 $this->add('hidden', 'contact_id', '', array('id' => 'contact_id'));
87 $this->addElement('submit',
88 $this->getButtonName('next', 'edit_client'),
91 'class' => 'form-submit-inline',
92 'onclick' => "return checkSelection( this );",
96 $this->addElement('submit',
97 $this->getButtonName('cancel', 'edit_client'),
99 array('class' => 'form-submit-inline')
102 $this->assign('contactId', $this->_contactId
);
111 public function postProcess() {
112 $params = $this->controller
->exportValues($this->_name
);
114 //assign case to another client.
115 $mainCaseId = CRM_Case_BAO_Case
::mergeCases($params['contact_id'], $this->_caseId
, $this->_contactId
, NULL, TRUE);
118 $url = CRM_Utils_System
::url('civicrm/contact/view/case',
119 "reset=1&action=view&cid={$params['contact_id']}&id={$mainCaseId[0]}&show=1"
121 $session = CRM_Core_Session
::singleton();
122 $session->pushUserContext($url);