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 public function preProcess() {
42 if (!CRM_Core_Permission
::checkActionPermission('CiviCase', CRM_Core_Action
::DELETE
)) {
43 CRM_Core_Error
::fatal(ts('You do not have permission to access this page.'));
49 * Build the form object.
51 public function buildQuickForm() {
52 $this->addDefaultButtons(ts('Delete cases'), 'done');
56 * Process the form after the input has been submitted and validated.
58 public function postProcess() {
59 $deleted = $failed = 0;
60 foreach ($this->_entityIds
as $caseId) {
61 if (CRM_Case_BAO_Case
::deleteCase($caseId, $this->_moveToTrash
)) {
70 if ($this->_moveToTrash
) {
71 $msg = ts('%count case moved to trash.', ['plural' => '%count cases moved to trash.', 'count' => $deleted]);
74 $msg = ts('%count case permanently deleted.', ['plural' => '%count cases permanently deleted.', 'count' => $deleted]);
76 CRM_Core_Session
::setStatus($msg, ts('Removed'), 'success');
80 CRM_Core_Session
::setStatus(ts('1 could not be deleted.', ['plural' => '%count could not be deleted.', 'count' => $failed]), ts('Error'), 'error');