|
|
@@ -53,12 +53,10 @@ if($submit) {
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
- throw new Exception("Invalid action.");
|
|
|
+ throw new RuntimeException("Invalid action.");
|
|
|
}
|
|
|
|
|
|
HTTP::redirect($_SERVER["REQUEST_URI"]);
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
catch(Exception $e) {
|
|
|
Core::addAlert("danger", $e->getMessage());
|
|
|
@@ -75,6 +73,7 @@ $test_id = http::value("test_id", "int");
|
|
|
$tester_id = http::value("tester_id", "int");
|
|
|
$location_internal_id = http::value("location_internal_id", "int");
|
|
|
$pass = http::value("pass", "int");
|
|
|
+$min_days_overdue = http::value("min_days_overdue", "int");
|
|
|
$custom = http::value("custom");
|
|
|
|
|
|
$filter_count_offset = 0;
|
|
|
@@ -84,7 +83,7 @@ $nvp = [];
|
|
|
// Status
|
|
|
if(strlen($status) > 0) $nvp["status"] = $status;
|
|
|
else {
|
|
|
- $nvp["status"] = (new Constraint("NOT_EQUALS"))->setValues(Test::STATUS_CANCELLED);
|
|
|
+ $nvp["status"] = Constraint::notEquals(Test::STATUS_CANCELLED);
|
|
|
$filter_count_offset--;
|
|
|
}
|
|
|
|
|
|
@@ -140,26 +139,63 @@ $projects = Project::load(array_column($tests, "project_id"));
|
|
|
|
|
|
switch($custom) {
|
|
|
case "overdue_project":
|
|
|
- $tests = array_filter($tests, function($test) {
|
|
|
- if($test->status == Test::STATUS_CANCELLED) return false;
|
|
|
+ $tests = array_filter($tests, static function(Test $test) use ($min_days_overdue) {
|
|
|
+ if($test->isCancelled()) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if($test->isCompleted()) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
$project = $test->getProject();
|
|
|
|
|
|
- $unix_deadline = Util::getUnixTimeFromUTC($project->dts_deadline);
|
|
|
+ $dt_deadline = $project->getDateTimeDeadline();
|
|
|
+ if(!$dt_deadline) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!$project->isOverdue()) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
- return ($test->status != Test::STATUS_COMPLETED && time() > $unix_deadline);
|
|
|
+ $days_overdue = $dt_deadline->diffInDays(null, true);
|
|
|
+ if($min_days_overdue > 0 && $days_overdue > $min_days_overdue) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
});
|
|
|
|
|
|
$filter_count++;
|
|
|
|
|
|
break;
|
|
|
- case "overdue_test":
|
|
|
- $tests = array_filter($tests, function($test) {
|
|
|
- if($test->status == Test::STATUS_CANCELLED) return false;
|
|
|
- if(is_null($test->dts_due)) return false;
|
|
|
|
|
|
- $unix_due = Util::getUnixTimeFromUTC($test->dts_due);
|
|
|
-
|
|
|
- return ($test->status < Test::STATUS_STARTED && time() > $unix_due);
|
|
|
+ case "overdue_test":
|
|
|
+ $tests = array_filter($tests, static function(Test $test) use ($min_days_overdue) {
|
|
|
+ if($test->isCancelled()) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if($test->hasDueDateTime() === false) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ $dt_due = $test->getDateTimeDue();
|
|
|
+ if(!$dt_due) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!($test->hasNotStarted() && $test->isOverdue())) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ $days_overdue = $dt_due->diffInDays(null, true);
|
|
|
+ if($min_days_overdue > 0 && $days_overdue < $min_days_overdue) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
});
|
|
|
|
|
|
$filter_count++;
|
|
|
@@ -176,7 +212,7 @@ $tests = array_slice($tests, $pagination_object->offset, $pagination_object->pag
|
|
|
$testers = User::load(array_column($tests, "tester_id"));
|
|
|
$customers = Customer::query([], ["sort" => "name"]);
|
|
|
|
|
|
-usort($projects, function($a, $b) {
|
|
|
+usort($projects, static function(Project $a, Project $b): int {
|
|
|
return $a->name <=> $b->name;
|
|
|
});
|
|
|
|
|
|
@@ -189,4 +225,4 @@ $sorts = [
|
|
|
Core::addScript("public/js/app-test-list.js");
|
|
|
|
|
|
View::includeOnce("header", compact("page_title"));
|
|
|
-View::include("test_list", compact("tests", "pagination_object", "sort", "sorts", "projects", "customers", "customer_id", "project_id", "location_id", "location_internal_id", "pass", "custom", "test_id", "tester_id", "filter_count", "status", "status_tester_invoice"));
|
|
|
+View::include("test_list", compact("tests", "pagination_object", "sort", "sorts", "projects", "customers", "customer_id", "project_id", "location_id", "location_internal_id", "pass", "min_days_overdue", "custom", "test_id", "tester_id", "filter_count", "status", "status_tester_invoice"));
|