(NFC) Update version in header
[civicrm-core.git] / CRM / Case / Form / Task / Delete.php
index 0579065f9007b74175380ff4ca85f2eee0188998..ef6fbf7dc416b96b7a8889d5d1b7aaf2ced3c51d 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.6                                                |
+ | CiviCRM version 5                                                  |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014                                |
+ | Copyright CiviCRM LLC (c) 2004-2018                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
- * $Id$
- *
+ * @copyright CiviCRM LLC (c) 2004-2018
  */
 
 /**
- * This class provides the functionality to delete a group of
- * case records. This class provides functionality for the actual
- * deletion.
+ * This class provides the functionality to delete a group of case records.
  */
 class CRM_Case_Form_Task_Delete extends CRM_Case_Form_Task {
 
@@ -67,28 +63,38 @@ class CRM_Case_Form_Task_Delete extends CRM_Case_Form_Task {
 
   /**
    * Build the form object.
-   *
-   * @return void
    */
   public function buildQuickForm() {
-    $this->addDefaultButtons(ts('Delete Cases'), 'done');
+    $this->addDefaultButtons(ts('Delete cases'), 'done');
   }
 
   /**
    * Process the form after the input has been submitted and validated.
-   *
-   * @return void
    */
   public function postProcess() {
-    $deletedCases = 0;
+    $deleted = $failed = 0;
     foreach ($this->_caseIds as $caseId) {
       if (CRM_Case_BAO_Case::deleteCase($caseId, $this->_moveToTrash)) {
-        $deletedCases++;
+        $deleted++;
+      }
+      else {
+        $failed++;
       }
     }
 
-    CRM_Core_Session::setStatus($deletedCases, ts('Deleted Cases'), 'success');
-    CRM_Core_Session::setStatus('', ts('Total Selected Case(s): %1', array(1 => count($this->_caseIds))), 'info');
+    if ($deleted) {
+      if ($this->_moveToTrash) {
+        $msg = ts('%count case moved to trash.', array('plural' => '%count cases moved to trash.', 'count' => $deleted));
+      }
+      else {
+        $msg = ts('%count case permanently deleted.', array('plural' => '%count cases permanently deleted.', 'count' => $deleted));
+      }
+      CRM_Core_Session::setStatus($msg, ts('Removed'), 'success');
+    }
+
+    if ($failed) {
+      CRM_Core_Session::setStatus(ts('1 could not be deleted.', array('plural' => '%count could not be deleted.', 'count' => $failed)), ts('Error'), 'error');
+    }
   }
 
 }