|
|
@@ -4,7 +4,7 @@ class Test extends Model {
|
|
|
|
|
|
protected static $table = "test";
|
|
|
protected static $id_field = "id";
|
|
|
- protected static $fillable_fields = ["project_id", "location_id", "tester_id", "status", "test_fee", "test_time", "test_travel_cost", "shop_left", "shop_right", "attire", "challenge_stage", "challenge_description", "challenger_name", "challenger_description", "challenger_gender", "challenger_eye_contact", "additional_notes", "dts_due", "dts_start", "dts_end", "verifier_id", "verifier_notes", "pass", "retest", "dts_created", "dts_updated", "dts_assigned", "dts_verified"];
|
|
|
+ protected static $fillable_fields = ["project_id", "location_id", "tester_id", "status", "status_tester_invoice", "test_fee", "test_time", "test_travel_cost", "shop_left", "shop_right", "attire", "challenge_stage", "challenge_description", "challenger_name", "challenger_description", "challenger_gender", "challenger_eye_contact", "additional_notes", "dts_due", "dts_start", "dts_end", "dts_tester_invoice_generated", "dts_tester_invoice_paid", "verifier_id", "verifier_notes", "pass", "retest", "dts_created", "dts_updated", "dts_assigned", "dts_verified"];
|
|
|
|
|
|
const TEST_FIELDS = ["shop_left", "shop_right", "attire", "challenge_stage", "challenge_description", "challenger_name", "challenger_description", "challenger_gender", "challenger_eye_contact", "additional_notes"];
|
|
|
|
|
|
@@ -18,6 +18,10 @@ class Test extends Model {
|
|
|
const STATUS_PENDING_VERIFICATION = 8;
|
|
|
const STATUS_COMPLETED = 16;
|
|
|
|
|
|
+ const STATUS_TESTER_INVOICE_NONE = 0;
|
|
|
+ const STATUS_TESTER_INVOICE_PENDING = 100;
|
|
|
+ const STATUS_TESTER_INVOICE_PAID = 200;
|
|
|
+
|
|
|
const STATUSES = [
|
|
|
0 => "Cancelled",
|
|
|
1 => "Unassigned",
|
|
|
@@ -28,6 +32,12 @@ class Test extends Model {
|
|
|
16 => "Completed",
|
|
|
];
|
|
|
|
|
|
+ const STATUSES_TESTER_INVOICE = [
|
|
|
+ Test::STATUS_TESTER_INVOICE_NONE,
|
|
|
+ Test::STATUS_TESTER_INVOICE_PENDING,
|
|
|
+ Test::STATUS_TESTER_INVOICE_PAID
|
|
|
+ ];
|
|
|
+
|
|
|
const STAGES = [
|
|
|
0 => "",
|
|
|
1 => "Challenge on entry",
|
|
|
@@ -41,6 +51,31 @@ class Test extends Model {
|
|
|
const TEST_TIME_DAY = 2;
|
|
|
const TEST_TIME_NIGHT = 3;
|
|
|
|
|
|
+ // Static methods
|
|
|
+ public static function getStatusTesterInvoiceText($status) {
|
|
|
+ switch($status) {
|
|
|
+ case Test::STATUS_TESTER_INVOICE_NONE:
|
|
|
+ return _("No Invoice Generated");
|
|
|
+ case Test::STATUS_TESTER_INVOICE_PENDING:
|
|
|
+ return _("Pending Payment");
|
|
|
+ case Test::STATUS_TESTER_INVOICE_PAID:
|
|
|
+ return _("Paid");
|
|
|
+ }
|
|
|
+ return _("Unknown");
|
|
|
+ }
|
|
|
+
|
|
|
+ public static function getStatusTesterInvoiceClass($status) {
|
|
|
+ switch($status) {
|
|
|
+ case Test::STATUS_TESTER_INVOICE_NONE:
|
|
|
+ return "secondary";
|
|
|
+ case Test::STATUS_TESTER_INVOICE_PENDING:
|
|
|
+ return "warning";
|
|
|
+ case Test::STATUS_TESTER_INVOICE_PAID:
|
|
|
+ return "success";
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
// Object methods
|
|
|
public function sendAssignEmail($message) {
|
|
|
|
|
|
@@ -395,5 +430,36 @@ class Test extends Model {
|
|
|
public function isPendingVerification() {
|
|
|
return $this->status == Test::STATUS_PENDING_VERIFICATION;
|
|
|
}
|
|
|
+
|
|
|
+ public function hasTesterInvoicePDF() {
|
|
|
+ $directory = $this->getDirectory();
|
|
|
+ return file_exists($directory . "/tester_invoice.pdf");
|
|
|
+ }
|
|
|
+
|
|
|
+ public function markTesterInvoicePaid() {
|
|
|
+
|
|
|
+ if($this->status_tester_invoice == Test::STATUS_TESTER_INVOICE_PENDING) {
|
|
|
+ $this->status_tester_invoice = Test::STATUS_TESTER_INVOICE_PAID;
|
|
|
+ $this->dts_tester_invoice_paid = Util::getDateTime();
|
|
|
+ return $this->commit();
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function rejectTesterInvoice() {
|
|
|
+ if($this->status_tester_invoice == Test::STATUS_TESTER_INVOICE_PENDING) {
|
|
|
+ $this->status_tester_invoice = Test::STATUS_TESTER_INVOICE_NONE;
|
|
|
+ $this->dts_tester_invoice_generated = null;
|
|
|
+
|
|
|
+ $pdf_filepath = $this->getDirectory() . "/tester_invoice.pdf";
|
|
|
+ unlink($pdf_filepath);
|
|
|
+
|
|
|
+ return $this->commit();
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
?>
|