3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * This class provides the functionality to delete a group of case records.
21 class CRM_Case_Form_Task_Delete
extends CRM_Case_Form_Task
{
24 * Are we operating in "single mode", i.e. deleting one
29 protected $_single = FALSE;
32 * Are we moving case to Trash.
36 public $_moveToTrash = TRUE;
39 * Build all the data structures needed to build the form.
41 * @throws \CRM_Core_Exception
43 public function preProcess() {
44 if (!CRM_Core_Permission
::checkActionPermission('CiviCase', CRM_Core_Action
::DELETE
)) {
45 CRM_Core_Error
::statusBounce(ts('You do not have permission to access this page.'));
51 * Build the form object.
53 public function buildQuickForm() {
54 $this->addDefaultButtons(ts('Delete cases'), 'done');
58 * Process the form after the input has been submitted and validated.
60 public function postProcess() {
61 $deleted = $failed = 0;
62 foreach ($this->_entityIds
as $caseId) {
63 if (CRM_Case_BAO_Case
::deleteCase($caseId, $this->_moveToTrash
)) {
72 if ($this->_moveToTrash
) {
73 $msg = ts('%count case moved to trash.', ['plural' => '%count cases moved to trash.', 'count' => $deleted]);
76 $msg = ts('%count case permanently deleted.', ['plural' => '%count cases permanently deleted.', 'count' => $deleted]);
78 CRM_Core_Session
::setStatus($msg, ts('Removed'), 'success');
82 CRM_Core_Session
::setStatus(ts('1 could not be deleted.', ['plural' => '%count could not be deleted.', 'count' => $failed]), ts('Error'), 'error');