Bläddra i källkod

Add "Send Test Assigned Email" batch action

Alan Lam 4 år sedan
förälder
incheckning
fb6895b2e1
2 ändrade filer med 19 tillägg och 8 borttagningar
  1. 18 8
      controllers/tests_admin_list.php
  2. 1 0
      views/test_list.php

+ 18 - 8
controllers/tests_admin_list.php

@@ -16,24 +16,22 @@ if($submit) {
 		$tests = Test::load($test_ids);
 		$test_count = count($tests);
 
+		$actioned_count = 0;
+
 		switch($batch_action) {
 			case "unassign":
 
-				$test_unassigned_count = 0;
-
 				foreach($tests as $test) {
 					$success = $test->unassignTester();
-					$test_unassigned_count += $success;
+					$actioned_count += $success;
 				}
 
-				Core::addAlert("success", "$test_unassigned_count of $test_count test(s) unassigned successfully.");
+				Core::addAlert("success", "$actioned_count of $test_count test(s) unassigned successfully.");
 
 				break;
 
 			case "mark_tester_invoice_paid":
 
-				$actioned_count = 0;
-
 				foreach($tests as $test) {
 					$actioned_count += ($test->markTesterInvoicePaid()) ? 1 : 0;
 				}
@@ -43,8 +41,6 @@ if($submit) {
 
 			case "reject_tester_invoice":
 
-				$actioned_count = 0;
-
 				foreach($tests as $test) {
 					$actioned_count += ($test->rejectTesterInvoice()) ? 1 : 0;
 				}
@@ -52,6 +48,20 @@ if($submit) {
 				Core::addAlert("success", "{$actioned_count} of {$test_count} invoices rejected successfully.");
 				break;
 
+			case "send_test_assigned_email":
+
+				foreach($tests as $test) {
+					$tester = $test->getTester();
+					if($tester) {
+						$test->sendAssignEmail("");
+						$actioned_count++;
+					}
+				}
+
+				Core::addAlert("success", "{$actioned_count} of {$test_count} emails sent successfully.");
+
+				break;
+
 			default:
 				throw new RuntimeException("Invalid action.");
 		}

+ 1 - 0
views/test_list.php

@@ -437,6 +437,7 @@ $custom_filters = [
 								<option value="unassign">Unassign</option>
 								<option value="mark_tester_invoice_paid">Mark Tester Invoice as Paid</option>
 								<option value="reject_tester_invoice">Reject Tester Invoices</option>
+								<option value="send_test_assigned_email">Send Test Assigned Email</option>
 							</select>
 							<div class="input-group-append">
 								<button type="submit" class="btn btn-primary" name="submit" value="<?=htmlspecialchars($_SESSION["csrf_token"])?>">