|
@@ -1,4 +1,45 @@
|
|
|
-<?php
|
|
|
|
|
|
|
+<?php /** @noinspection HtmlDeprecatedTag */
|
|
|
|
|
+/** @noinspection HtmlDeprecatedAttribute */
|
|
|
|
|
+
|
|
|
|
|
+use Mpdf\Mpdf;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * @property int $id
|
|
|
|
|
+ * @property int $project_id
|
|
|
|
|
+ * @property int $location_id
|
|
|
|
|
+ * @property int $tester_id
|
|
|
|
|
+ * @property int $status
|
|
|
|
|
+ * @property int $status_tester_invoice
|
|
|
|
|
+ * @property float $customer_fee
|
|
|
|
|
+ * @property float $test_fee
|
|
|
|
|
+ * @property string $test_time
|
|
|
|
|
+ * @property float $test_travel_cost
|
|
|
|
|
+ * @property string $shop_left
|
|
|
|
|
+ * @property string $shop_right
|
|
|
|
|
+ * @property string $attire
|
|
|
|
|
+ * @property int $challenge_stage
|
|
|
|
|
+ * @property string $challenge_description
|
|
|
|
|
+ * @property string $challenger_name
|
|
|
|
|
+ * @property string $challenger_description
|
|
|
|
|
+ * @property string $challenger_gender
|
|
|
|
|
+ * @property string $challenger_eye_contact
|
|
|
|
|
+ * @property string $additional_notes
|
|
|
|
|
+ * @property string $dts_due
|
|
|
|
|
+ * @property string $dts_start
|
|
|
|
|
+ * @property string $dts_end
|
|
|
|
|
+ * @property string $dts_tester_invoice_generated
|
|
|
|
|
+ * @property string $dts_tester_invoice_paid
|
|
|
|
|
+ * @property int $verifier_id
|
|
|
|
|
+ * @property string $verifier_notes
|
|
|
|
|
+ * @property bool $pass
|
|
|
|
|
+ * @property bool $retest
|
|
|
|
|
+ * @property string $dts_created
|
|
|
|
|
+ * @property string $dts_updated
|
|
|
|
|
+ * @property string $dts_assigned
|
|
|
|
|
+ * @property string $dts_verified
|
|
|
|
|
+ *
|
|
|
|
|
+ * @method Test get(int $id)
|
|
|
|
|
+ */
|
|
|
|
|
|
|
|
class Test extends Model {
|
|
class Test extends Model {
|
|
|
|
|
|
|
@@ -52,7 +93,12 @@ class Test extends Model {
|
|
|
const TEST_TIME_NIGHT = 3;
|
|
const TEST_TIME_NIGHT = 3;
|
|
|
|
|
|
|
|
// Static methods
|
|
// Static methods
|
|
|
- public static function getStatusTesterInvoiceText($status) {
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @param int $status
|
|
|
|
|
+ * @return string
|
|
|
|
|
+ */
|
|
|
|
|
+ public static function getStatusTesterInvoiceText(int $status): string {
|
|
|
switch($status) {
|
|
switch($status) {
|
|
|
case Test::STATUS_TESTER_INVOICE_NONE:
|
|
case Test::STATUS_TESTER_INVOICE_NONE:
|
|
|
return __("No Invoice Generated");
|
|
return __("No Invoice Generated");
|
|
@@ -64,7 +110,11 @@ class Test extends Model {
|
|
|
return __("Unknown");
|
|
return __("Unknown");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public static function getStatusTesterInvoiceClass($status) {
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @param int $status
|
|
|
|
|
+ * @return string
|
|
|
|
|
+ */
|
|
|
|
|
+ public static function getStatusTesterInvoiceClass(int $status): string {
|
|
|
switch($status) {
|
|
switch($status) {
|
|
|
case Test::STATUS_TESTER_INVOICE_NONE:
|
|
case Test::STATUS_TESTER_INVOICE_NONE:
|
|
|
return "secondary";
|
|
return "secondary";
|
|
@@ -76,8 +126,38 @@ class Test extends Model {
|
|
|
return "";
|
|
return "";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @param string $processing_file
|
|
|
|
|
+ * @param array $tests
|
|
|
|
|
+ * @throws Exception
|
|
|
|
|
+ */
|
|
|
|
|
+ public static function exportCSV(string $processing_file, array $tests = []): void {
|
|
|
|
|
+
|
|
|
|
|
+ // Preload
|
|
|
|
|
+ Project::load(array_column($tests, "project_id"));
|
|
|
|
|
+ Location::load(array_column($tests, "location_id"));
|
|
|
|
|
+ User::load(array_column($tests, "tester_id"));
|
|
|
|
|
+
|
|
|
|
|
+ // Get processing file
|
|
|
|
|
+ $processing_file_path = ROOT_DIR . "/export_processing/{$processing_file}";
|
|
|
|
|
+ if(!file_exists($processing_file_path)) throw new Exception("Processing file not found.");
|
|
|
|
|
+
|
|
|
|
|
+ // Output
|
|
|
|
|
+ HTTP::setDownloadHeaders("export.csv");
|
|
|
|
|
+
|
|
|
|
|
+ $handle = fopen("php://output", "w");
|
|
|
|
|
+ require $processing_file_path;
|
|
|
|
|
+ fclose($handle);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// Object methods
|
|
// Object methods
|
|
|
- public function sendAssignEmail($message) {
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @param string $message
|
|
|
|
|
+ * @return bool
|
|
|
|
|
+ * @throws Exception
|
|
|
|
|
+ */
|
|
|
|
|
+ public function sendAssignEmail(string $message): bool {
|
|
|
|
|
|
|
|
$tester = $this->getTester();
|
|
$tester = $this->getTester();
|
|
|
$location = $this->getLocation();
|
|
$location = $this->getLocation();
|
|
@@ -138,9 +218,15 @@ class Test extends Model {
|
|
|
$mail->addAddress($tester->email, $tester->getDisplayName());
|
|
$mail->addAddress($tester->email, $tester->getDisplayName());
|
|
|
$mail->setSubject(__("You have been allocated a test"));
|
|
$mail->setSubject(__("You have been allocated a test"));
|
|
|
$mail->send();
|
|
$mail->send();
|
|
|
|
|
+
|
|
|
|
|
+ return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function sendClaimedEmail() {
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @return bool
|
|
|
|
|
+ * @throws Exception
|
|
|
|
|
+ */
|
|
|
|
|
+ public function sendClaimedEmail(): bool {
|
|
|
|
|
|
|
|
$tester = $this->getTester();
|
|
$tester = $this->getTester();
|
|
|
$location = $this->getLocation();
|
|
$location = $this->getLocation();
|
|
@@ -170,10 +256,8 @@ class Test extends Model {
|
|
|
'<b>', '</b>',
|
|
'<b>', '</b>',
|
|
|
'<b>', '</b>'
|
|
'<b>', '</b>'
|
|
|
));
|
|
));
|
|
|
- $builder->addParagraph(sprintf(__("If you have any questions please send them to %s or call %s on %s."),
|
|
|
|
|
- "<a href=\"mailto:tests@check-policy.com\">tests@check-policy.com</a>",
|
|
|
|
|
- "<b>$admin_first_name</b>",
|
|
|
|
|
- "<b>$admin_phone</b>"
|
|
|
|
|
|
|
+ $builder->addParagraph(sprintf(__("If you have any questions please send them to %s."),
|
|
|
|
|
+ "<a href=\"mailto:tests@check-policy.com\">tests@check-policy.com</a>"
|
|
|
));
|
|
));
|
|
|
$builder->addParagraph(__("If you are unable to submit the results via the web-based app please contact us and we can send you an offline form to complete."));
|
|
$builder->addParagraph(__("If you are unable to submit the results via the web-based app please contact us and we can send you an offline form to complete."));
|
|
|
$content = $builder->build();
|
|
$content = $builder->build();
|
|
@@ -185,9 +269,15 @@ class Test extends Model {
|
|
|
$mail->addAddress($tester->email, $tester->getDisplayName());
|
|
$mail->addAddress($tester->email, $tester->getDisplayName());
|
|
|
$mail->setSubject(__("You have claimed a test"));
|
|
$mail->setSubject(__("You have claimed a test"));
|
|
|
$mail->send();
|
|
$mail->send();
|
|
|
|
|
+
|
|
|
|
|
+ return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function sendDeclineEmail() {
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @return bool
|
|
|
|
|
+ * @throws Exception
|
|
|
|
|
+ */
|
|
|
|
|
+ public function sendDeclineEmail(): bool {
|
|
|
|
|
|
|
|
$tester = $this->getTester();
|
|
$tester = $this->getTester();
|
|
|
$location = $this->getLocation();
|
|
$location = $this->getLocation();
|
|
@@ -219,9 +309,16 @@ class Test extends Model {
|
|
|
$mail->addAddress(EMAIL_CONTACT, APP_NAME . " Contact");
|
|
$mail->addAddress(EMAIL_CONTACT, APP_NAME . " Contact");
|
|
|
$mail->setSubject("Test declined: $project->name / $location->name");
|
|
$mail->setSubject("Test declined: $project->name / $location->name");
|
|
|
$mail->send();
|
|
$mail->send();
|
|
|
|
|
+
|
|
|
|
|
+ return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function sendResultEmail($to_address) {
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @param string $to_address
|
|
|
|
|
+ * @return bool
|
|
|
|
|
+ * @throws Exception
|
|
|
|
|
+ */
|
|
|
|
|
+ public function sendResultEmail(string $to_address): bool {
|
|
|
|
|
|
|
|
$location = $this->getLocation();
|
|
$location = $this->getLocation();
|
|
|
$project = $this->getProject();
|
|
$project = $this->getProject();
|
|
@@ -281,9 +378,15 @@ class Test extends Model {
|
|
|
$mail->setSubject($subject);
|
|
$mail->setSubject($subject);
|
|
|
|
|
|
|
|
$mail->send();
|
|
$mail->send();
|
|
|
|
|
+
|
|
|
|
|
+ return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function decline() {
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @return bool
|
|
|
|
|
+ * @throws Exception
|
|
|
|
|
+ */
|
|
|
|
|
+ public function decline(): bool {
|
|
|
$this->sendDeclineEmail();
|
|
$this->sendDeclineEmail();
|
|
|
|
|
|
|
|
$this->status = Test::STATUS_UNASSIGNED;
|
|
$this->status = Test::STATUS_UNASSIGNED;
|
|
@@ -294,16 +397,25 @@ class Test extends Model {
|
|
|
return $this->commit();
|
|
return $this->commit();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function getChallengeStageText() {
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @return string
|
|
|
|
|
+ */
|
|
|
|
|
+ public function getChallengeStageText(): string {
|
|
|
if(is_null($this->challenge_stage)) return "";
|
|
if(is_null($this->challenge_stage)) return "";
|
|
|
return Test::STAGES[$this->challenge_stage];
|
|
return Test::STAGES[$this->challenge_stage];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function getStatusText() {
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @return string
|
|
|
|
|
+ */
|
|
|
|
|
+ public function getStatusText(): string {
|
|
|
return Test::STATUSES[$this->status];
|
|
return Test::STATUSES[$this->status];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function getStatusClass() {
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @return string
|
|
|
|
|
+ */
|
|
|
|
|
+ public function getStatusClass(): string {
|
|
|
switch($this->status) {
|
|
switch($this->status) {
|
|
|
case Test::STATUS_CANCELLED:
|
|
case Test::STATUS_CANCELLED:
|
|
|
return "secondary";
|
|
return "secondary";
|
|
@@ -318,25 +430,47 @@ class Test extends Model {
|
|
|
case Test::STATUS_COMPLETED:
|
|
case Test::STATUS_COMPLETED:
|
|
|
return "success";
|
|
return "success";
|
|
|
}
|
|
}
|
|
|
|
|
+ return "";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function getProject() {
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @return Project|null
|
|
|
|
|
+ * @throws Exception
|
|
|
|
|
+ */
|
|
|
|
|
+ public function getProject(): ?Project {
|
|
|
return Project::get($this->project_id);
|
|
return Project::get($this->project_id);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function getLocation() {
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @return Location
|
|
|
|
|
+ * @throws Exception
|
|
|
|
|
+ */
|
|
|
|
|
+ public function getLocation(): ?Location {
|
|
|
return Location::get($this->location_id);
|
|
return Location::get($this->location_id);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function getTester() {
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @return User
|
|
|
|
|
+ * @throws Exception
|
|
|
|
|
+ */
|
|
|
|
|
+ public function getTester(): ?User {
|
|
|
return User::get($this->tester_id);
|
|
return User::get($this->tester_id);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function getVerifier() {
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @return User
|
|
|
|
|
+ * @throws Exception
|
|
|
|
|
+ */
|
|
|
|
|
+ public function getVerifier(): ?User {
|
|
|
return User::get($this->verifier_id);
|
|
return User::get($this->verifier_id);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function getValues($as_assoc_array = false) {
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @param bool $as_assoc_array
|
|
|
|
|
+ * @return array
|
|
|
|
|
+ * @throws Exception
|
|
|
|
|
+ */
|
|
|
|
|
+ public function getValues(bool $as_assoc_array = false): array {
|
|
|
$rows = TestValue::query(["test_id" => $this->id]);
|
|
$rows = TestValue::query(["test_id" => $this->id]);
|
|
|
|
|
|
|
|
if($as_assoc_array) {
|
|
if($as_assoc_array) {
|
|
@@ -351,22 +485,28 @@ class Test extends Model {
|
|
|
return $values;
|
|
return $values;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function getDirectory() {
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @return string
|
|
|
|
|
+ */
|
|
|
|
|
+ public function getDirectory(): string {
|
|
|
$directory = ROOT_DIR . "/files/tests/" . $this->id;
|
|
$directory = ROOT_DIR . "/files/tests/" . $this->id;
|
|
|
- if($this->project_id == "PRACTICE") {
|
|
|
|
|
- $directory = ROOT_DIR . "/files/users/$this->tester_id/practice_tests/$this->template_id";
|
|
|
|
|
- }
|
|
|
|
|
if(!file_exists($directory)) mkdir($directory, 0777, true);
|
|
if(!file_exists($directory)) mkdir($directory, 0777, true);
|
|
|
return $directory;
|
|
return $directory;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @return bool|float|int
|
|
|
|
|
+ */
|
|
|
public function getDuration() {
|
|
public function getDuration() {
|
|
|
if(is_null($this->dts_end)) return false;
|
|
if(is_null($this->dts_end)) return false;
|
|
|
$seconds = Util::getDurationFromDTS($this->dts_start, $this->dts_end);
|
|
$seconds = Util::getDurationFromDTS($this->dts_start, $this->dts_end);
|
|
|
return $seconds;
|
|
return $seconds;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function getDisplayDuration() {
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @return string
|
|
|
|
|
+ */
|
|
|
|
|
+ public function getDisplayDuration(): string {
|
|
|
$secs = $this->getDuration();
|
|
$secs = $this->getDuration();
|
|
|
$mins = floor($secs / 60);
|
|
$mins = floor($secs / 60);
|
|
|
$secs = $secs % 60;
|
|
$secs = $secs % 60;
|
|
@@ -374,29 +514,44 @@ class Test extends Model {
|
|
|
return "$mins min. $secs sec.";
|
|
return "$mins min. $secs sec.";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function getPassClass() {
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @return string Bootstrap class name
|
|
|
|
|
+ */
|
|
|
|
|
+ public function getPassClass(): string {
|
|
|
if(is_null($this->pass)) return "secondary";
|
|
if(is_null($this->pass)) return "secondary";
|
|
|
return $this->pass ? "success" : "danger";
|
|
return $this->pass ? "success" : "danger";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function getPassIcon() {
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @return string FA icon name without prefix
|
|
|
|
|
+ */
|
|
|
|
|
+ public function getPassIcon(): string {
|
|
|
if(is_null($this->pass)) return "clock";
|
|
if(is_null($this->pass)) return "clock";
|
|
|
return $this->pass ? "check-circle" : "times-circle";
|
|
return $this->pass ? "check-circle" : "times-circle";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function getPassText() {
|
|
|
|
|
- if(is_null($this->pass)) return "Pending";
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @return string Pending, Pass or Fail
|
|
|
|
|
+ */
|
|
|
|
|
+ public function getPassText(): string {
|
|
|
|
|
+ if(is_null($this->pass)) return __("Pending");
|
|
|
return $this->pass ? __("Pass") : __("Fail");
|
|
return $this->pass ? __("Pass") : __("Fail");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function getMPDF() {
|
|
|
|
|
|
|
+ public function getMPDF(): Mpdf {
|
|
|
|
|
+ /** @var Mpdf $mpdf */
|
|
|
$id = $this->id;
|
|
$id = $this->id;
|
|
|
$output = false;
|
|
$output = false;
|
|
|
require ROOT_DIR . "/controllers/test_pdf.php";
|
|
require ROOT_DIR . "/controllers/test_pdf.php";
|
|
|
return $mpdf;
|
|
return $mpdf;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function assignTester($tester) {
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @param User $tester
|
|
|
|
|
+ * @return bool
|
|
|
|
|
+ * @throws Exception
|
|
|
|
|
+ */
|
|
|
|
|
+ public function assignTester(User $tester): bool {
|
|
|
$this->tester_id = $tester->id;
|
|
$this->tester_id = $tester->id;
|
|
|
$this->dts_assigned = Util::getDateTime();
|
|
$this->dts_assigned = Util::getDateTime();
|
|
|
$success = $this->commit();
|
|
$success = $this->commit();
|
|
@@ -407,7 +562,11 @@ class Test extends Model {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function getPreviousTest() {
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @return Test|null
|
|
|
|
|
+ * @throws Exception
|
|
|
|
|
+ */
|
|
|
|
|
+ public function getPreviousTest(): ?Test {
|
|
|
|
|
|
|
|
$nvp = [
|
|
$nvp = [
|
|
|
"dts_start" => (new Constraint("LESS_THAN"))->setValues($this->dts_start),
|
|
"dts_start" => (new Constraint("LESS_THAN"))->setValues($this->dts_start),
|
|
@@ -420,30 +579,87 @@ class Test extends Model {
|
|
|
"order" => "desc",
|
|
"order" => "desc",
|
|
|
]);
|
|
]);
|
|
|
|
|
|
|
|
- return $tests ? $tests[0] : false;
|
|
|
|
|
|
|
+ return $tests ? $tests[0] : null;
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function unassignTester() {
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @return bool
|
|
|
|
|
+ * @throws Exception
|
|
|
|
|
+ */
|
|
|
|
|
+ public function unassignTester(): bool {
|
|
|
$this->status = Test::STATUS_UNASSIGNED;
|
|
$this->status = Test::STATUS_UNASSIGNED;
|
|
|
$this->tester_id = null;
|
|
$this->tester_id = null;
|
|
|
$this->dts_due = null;
|
|
$this->dts_due = null;
|
|
|
$this->dts_assigned = null;
|
|
$this->dts_assigned = null;
|
|
|
- $success = $this->commit();
|
|
|
|
|
|
|
+ return $this->commit();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- return $success;
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @return bool
|
|
|
|
|
+ */
|
|
|
|
|
+ public function isPass(): bool {
|
|
|
|
|
+ if(is_null($this->pass)) return false;
|
|
|
|
|
+ return !empty($this->pass);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @return bool
|
|
|
|
|
+ */
|
|
|
|
|
+ public function isPending(): bool {
|
|
|
|
|
+ return is_null($this->pass);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @return bool
|
|
|
|
|
+ */
|
|
|
|
|
+ public function isFail(): bool {
|
|
|
|
|
+ if(is_null($this->pass)) return false;
|
|
|
|
|
+ return empty($this->pass);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @return bool
|
|
|
|
|
+ */
|
|
|
|
|
+ public function isCompleted() {
|
|
|
|
|
+ return $this->status == Test::STATUS_COMPLETED;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @return bool
|
|
|
|
|
+ */
|
|
|
public function isPendingVerification() {
|
|
public function isPendingVerification() {
|
|
|
return $this->status == Test::STATUS_PENDING_VERIFICATION;
|
|
return $this->status == Test::STATUS_PENDING_VERIFICATION;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function hasTesterInvoicePDF() {
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @return bool
|
|
|
|
|
+ */
|
|
|
|
|
+ public function hasPDF(): bool {
|
|
|
|
|
+ $directory = $this->getDirectory();
|
|
|
|
|
+ return file_exists($directory . "/pdf.pdf");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @return string
|
|
|
|
|
+ */
|
|
|
|
|
+ public function getPDFUrl(): string {
|
|
|
|
|
+ return "/account/tests/{$this->id}/files/pdf";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @return bool
|
|
|
|
|
+ */
|
|
|
|
|
+ public function hasTesterInvoicePDF(): bool {
|
|
|
$directory = $this->getDirectory();
|
|
$directory = $this->getDirectory();
|
|
|
return file_exists($directory . "/tester_invoice.pdf");
|
|
return file_exists($directory . "/tester_invoice.pdf");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function markTesterInvoicePaid() {
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @return bool
|
|
|
|
|
+ * @throws Exception
|
|
|
|
|
+ */
|
|
|
|
|
+ public function markTesterInvoicePaid(): bool {
|
|
|
|
|
|
|
|
if($this->status_tester_invoice == Test::STATUS_TESTER_INVOICE_PENDING) {
|
|
if($this->status_tester_invoice == Test::STATUS_TESTER_INVOICE_PENDING) {
|
|
|
$this->status_tester_invoice = Test::STATUS_TESTER_INVOICE_PAID;
|
|
$this->status_tester_invoice = Test::STATUS_TESTER_INVOICE_PAID;
|
|
@@ -454,7 +670,11 @@ class Test extends Model {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function rejectTesterInvoice() {
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @return bool
|
|
|
|
|
+ * @throws Exception
|
|
|
|
|
+ */
|
|
|
|
|
+ public function rejectTesterInvoice(): bool {
|
|
|
if($this->status_tester_invoice == Test::STATUS_TESTER_INVOICE_PENDING) {
|
|
if($this->status_tester_invoice == Test::STATUS_TESTER_INVOICE_PENDING) {
|
|
|
$this->status_tester_invoice = Test::STATUS_TESTER_INVOICE_NONE;
|
|
$this->status_tester_invoice = Test::STATUS_TESTER_INVOICE_NONE;
|
|
|
$this->dts_tester_invoice_generated = null;
|
|
$this->dts_tester_invoice_generated = null;
|
|
@@ -468,5 +688,19 @@ class Test extends Model {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @return string
|
|
|
|
|
+ * @throws Exception
|
|
|
|
|
+ */
|
|
|
|
|
+ public function getTesterInvoiceReference(): string {
|
|
|
|
|
+
|
|
|
|
|
+ $location = $this->getLocation();
|
|
|
|
|
+ $tester = $this->getTester();
|
|
|
|
|
+
|
|
|
|
|
+ return
|
|
|
|
|
+ "T" . str_pad($this->id, 3, "0", STR_PAD_LEFT) .
|
|
|
|
|
+ "/L" . str_pad($location->id, 3, "0", STR_PAD_LEFT) .
|
|
|
|
|
+ "/U" . str_pad($tester->id, 3, "0", STR_PAD_LEFT);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
-?>
|
|
|