|
@@ -26,6 +26,10 @@
|
|
|
|
|
|
|
|
class Project extends Model {
|
|
class Project extends Model {
|
|
|
|
|
|
|
|
|
|
+ const TOD_ANYTIME = "A";
|
|
|
|
|
+ const TOD_DAYTIME = "D";
|
|
|
|
|
+ const TOD_NIGHTTIME = "N";
|
|
|
|
|
+
|
|
|
protected static $table = "project";
|
|
protected static $table = "project";
|
|
|
protected static $id_field = "id";
|
|
protected static $id_field = "id";
|
|
|
protected static $fillable_fields = ["customer_id", "template_id", "name", "test_count", "min_age", "max_age", "default_customer_fee", "default_tester_fee", "time_of_day", "tester_can_claim", "template_overrides_json", "dts_start", "dts_deadline", "dts_created", "dts_updated", "dts_report", "dts_finished", "user_id_finished"];
|
|
protected static $fillable_fields = ["customer_id", "template_id", "name", "test_count", "min_age", "max_age", "default_customer_fee", "default_tester_fee", "time_of_day", "tester_can_claim", "template_overrides_json", "dts_start", "dts_deadline", "dts_created", "dts_updated", "dts_report", "dts_finished", "user_id_finished"];
|
|
@@ -94,6 +98,15 @@ class Project extends Model {
|
|
|
return $count;
|
|
return $count;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public function getPassRate(): string {
|
|
|
|
|
+ $pass_count = $this->getPassCount();
|
|
|
|
|
+ $fail_count = $this->getFailCount();
|
|
|
|
|
+ $pass_fail_count = $pass_count + $fail_count;
|
|
|
|
|
+ if($pass_fail_count == 0) return "0%";
|
|
|
|
|
+
|
|
|
|
|
+ return (number_format($pass_count / $pass_fail_count, 4) * 100) . "%";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public function getLocations() {
|
|
public function getLocations() {
|
|
|
$tests = $this->getTests();
|
|
$tests = $this->getTests();
|
|
|
return Location::query(["id" => array_column($tests, "location_id")]);
|
|
return Location::query(["id" => array_column($tests, "location_id")]);
|
|
@@ -115,6 +128,18 @@ class Project extends Model {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public function getNameHtml(): string {
|
|
|
|
|
+
|
|
|
|
|
+ if($this->isAnytime()) {
|
|
|
|
|
+ return htmlspecialchars($this->name);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $icon = $this->getTimeOfDayIcon();
|
|
|
|
|
+ $time_of_day = $this->getTimeOfDayText();
|
|
|
|
|
+
|
|
|
|
|
+ return htmlspecialchars($this->name) . " <i class=\"fa fa-fw fa-{$icon}\" data-toggle=\"tooltip\" title=\"{$time_of_day}\"></i>";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public function getCompletedPercentage() {
|
|
public function getCompletedPercentage() {
|
|
|
|
|
|
|
|
$test_count = $this->test_count;
|
|
$test_count = $this->test_count;
|
|
@@ -143,17 +168,17 @@ class Project extends Model {
|
|
|
|
|
|
|
|
public function getTimeOfDayText() {
|
|
public function getTimeOfDayText() {
|
|
|
switch($this->time_of_day) {
|
|
switch($this->time_of_day) {
|
|
|
- case "A": return "Any";
|
|
|
|
|
- case "D": return "Day";
|
|
|
|
|
- case "N": return "Night";
|
|
|
|
|
|
|
+ case self::TOD_ANYTIME: return "Any";
|
|
|
|
|
+ case self::TOD_DAYTIME: return "Day";
|
|
|
|
|
+ case self::TOD_NIGHTTIME: return "Night";
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function getTimeOfDayIcon() {
|
|
public function getTimeOfDayIcon() {
|
|
|
switch($this->time_of_day) {
|
|
switch($this->time_of_day) {
|
|
|
- case "A": return "adjust";
|
|
|
|
|
- case "D": return "sun";
|
|
|
|
|
- case "N": return "moon";
|
|
|
|
|
|
|
+ case self::TOD_ANYTIME: return "adjust";
|
|
|
|
|
+ case self::TOD_DAYTIME: return "sun";
|
|
|
|
|
+ case self::TOD_NIGHTTIME: return "moon";
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -173,15 +198,15 @@ class Project extends Model {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function isAnytime() {
|
|
public function isAnytime() {
|
|
|
- return $this->time_of_day == "A";
|
|
|
|
|
|
|
+ return $this->time_of_day == self::TOD_ANYTIME;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function isDaytime() {
|
|
public function isDaytime() {
|
|
|
- return $this->time_of_day == "D";
|
|
|
|
|
|
|
+ return $this->time_of_day == self::TOD_DAYTIME;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function isNighttime() {
|
|
public function isNighttime() {
|
|
|
- return $this->time_of_day == "N";
|
|
|
|
|
|
|
+ return $this->time_of_day == self::TOD_NIGHTTIME;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function isPastDeadline() {
|
|
public function isPastDeadline() {
|