|
|
@@ -9,6 +9,7 @@ use Mpdf\Mpdf;
|
|
|
* @property int $project_id
|
|
|
* @property int $location_id
|
|
|
* @property int $tester_id
|
|
|
+ * @property int $previous_test_id
|
|
|
* @property int $stripe_invoice_id
|
|
|
* @property int $status
|
|
|
* @property int $status_tester_invoice
|
|
|
@@ -631,9 +632,16 @@ class Test extends Model {
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public function getPreviousTest(): ?Test {
|
|
|
+ if($this->previous_test_id) {
|
|
|
+ return self::get($this->previous_test_id);
|
|
|
+ }
|
|
|
+
|
|
|
+ if($this->dts_start === null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
$nvp = [
|
|
|
- "dts_start" => (new Constraint("LESS_THAN"))->setValues($this->dts_start),
|
|
|
+ "dts_start" => Constraint::lessThan($this->dts_start),
|
|
|
"location_id" => $this->location_id,
|
|
|
"status" => self::STATUS_COMPLETED,
|
|
|
];
|
|
|
@@ -644,7 +652,33 @@ class Test extends Model {
|
|
|
]);
|
|
|
|
|
|
return $tests ? $tests[0] : null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return Test|null
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public function getNextTest(): ?Test {
|
|
|
+ $test = self::queryOne(["previous_test_id" => $this->id]);
|
|
|
+ if($test) {
|
|
|
+ return $test;
|
|
|
+ }
|
|
|
|
|
|
+ if($this->dts_start === null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ $nvp = [
|
|
|
+ "dts_start" => Constraint::moreThan($this->dts),
|
|
|
+ "location_id" => $this->location_id,
|
|
|
+ ];
|
|
|
+
|
|
|
+ $tests = self::query($nvp, [
|
|
|
+ "sort" => "dts_start",
|
|
|
+ "order" => "asc",
|
|
|
+ ]);
|
|
|
+
|
|
|
+ return $tests ? $tests[0] : null;
|
|
|
}
|
|
|
|
|
|
/**
|