Browse Source

Merge branch 'develop'

Alan Lam 7 years ago
parent
commit
c764811b11

+ 2 - 1
composer.json

@@ -10,6 +10,7 @@
     "ext-gd": "*",
     "ext-exif": "*",
     "ext-mbstring": "*",
-    "robmorgan/phinx": "^0.11.1"
+    "robmorgan/phinx": "^0.11.1",
+	  "ext-readline": "*"
   }
 }

+ 4 - 1
controllers/account.php

@@ -1,4 +1,4 @@
-<?php
+<?php /** @noinspection PhpUnhandledExceptionInspection */
 
 $page_title = __("Account");
 
@@ -52,6 +52,9 @@ if($user->isTester() || $user->isAdmin()) {
 	$tests_icon->setCounter($tests_remaining);
 
 	$icons[] = $tests_icon;
+}
+
+if($user->isTester() || $user->isAdmin() || $user->isUnverified() || $user->isRegistered()) {
 	$icons[] = new AccountIcon(__("Practice"), "/account/practice", "chalkboard-teacher");
 }
 

+ 2 - 2
controllers/customer_add.php

@@ -1,4 +1,4 @@
-<?php
+<?php /** @noinspection PhpUnhandledExceptionInspection */
 
 $page_title = "Add Customer";
 
@@ -29,6 +29,7 @@ if($submit) {
 		$customer->phone = http::value("phone", "trim");
 		$customer->email_after_test = http::value("email_after_test", "int");
 		$customer->email_locations_after_test = http::value("email_locations_after_test", "int");
+		$customer->year_cycle_month = http::value("year_cycle_month", "int");
 
 		if(empty($customer->name)) $form_exception->addError("Name is required.");
 
@@ -51,4 +52,3 @@ View::includeOnce("header", compact("page_title"));
 View::include("customer_form", compact("page_title", "customer"));
 View::includeOnce("footer");
 
-?>

+ 2 - 2
controllers/customer_edit.php

@@ -1,4 +1,4 @@
-<?php
+<?php /** @noinspection PhpUnhandledExceptionInspection */
 
 $customer = Customer::get($id);
 if(!$customer) throw new Exception("Customer not found.");
@@ -29,6 +29,7 @@ if($submit) {
 		$customer->invoice_contact_name = http::value("invoice_contact_name", "trim");
 		$customer->email_after_test = http::value("email_after_test", "int");
 		$customer->email_locations_after_test = http::value("email_locations_after_test", "int");
+		$customer->year_cycle_month = http::value("year_cycle_month", "int");
 
 		if(empty($customer->name)) $form_exception->addError("Name is required.");
 
@@ -51,4 +52,3 @@ View::includeOnce("header", compact("page_title"));
 View::include("customer_form", compact("page_title", "customer"));
 View::includeOnce("footer");
 
-?>

+ 1 - 4
controllers/map_overview.php

@@ -1,4 +1,4 @@
-<?php
+<?php /** @noinspection PhpUnhandledExceptionInspection */
 
 $page_title = "Map Overview";
 
@@ -20,9 +20,6 @@ Customer::load(array_column($projects, "customer_id"));
 
 $customers = Customer::query([], ["sort" => "name"]);
 
-
 View::includeOnce("header", compact("page_title"));
 View::include("map_overview", compact("customers", "projects"));
 View::includeOnce("footer");
-
-?>

+ 25 - 15
controllers/map_overview_ajax.php

@@ -1,4 +1,6 @@
-<?php
+<?php /** @noinspection PhpUnhandledExceptionInspection */
+
+$date_format = "/^2[0-9]{3}\-[0-1][0-9]\-[0-3][0-9]$/";
 
 JSON::header();
 
@@ -14,32 +16,39 @@ if($submit) {
 			// Gets all locations for a customer
 			case "get-customer-locations": {
 
+				// Input
 				$customer_id = http::value("customer_id", "int");
+
+				$min_date = http::value("min_date");
+				$max_date = http::value("max_date");
+
+				// Get customer
 				$customer = Customer::get($customer_id);
 				if(!$customer) throw new Exception("Customer not found.");
 
+				// Get locations
 				$locations = $customer->getLocations();
 
-				$min_date = http::value("min_date");
-				$max_date = http::value("max_date");
-
+				// Get tests
 				$nvp = [
 					"status" => (new Constraint("NOT_EQUALS"))->setValues(Test::STATUS_CANCELLED),
 					"location_id" => array_column($locations, "id")
 				];
 
-				$date_format = "/^2[0-9]{3}\-[0-1][0-9]\-[0-3][0-9]$/";
+				if($min_date && $max_date) {
+					if(preg_match($date_format, $min_date) && preg_match($date_format, $max_date)) {
+						$min_dts = "{$min_date}";
+						$max_dts = "{$max_date}";
 
-				if($min_date && preg_match($date_format, $min_date)) {
-					$min_dts = "{$min_date} 00:00:00";
-					$nvp["dts_start"] = (new Constraint("MORE_THAN_OR_EQUAL"))->setValues($min_dts);
+						$nvp["dts_start"] = (new Constraint("BETWEEN"))->setValues($min_dts, $max_dts);
+					}
 				}
-
-				if($max_date && preg_match($date_format, $max_date)) {
-					$max_dts = "{$max_date} 23:59:59";
-					$nvp["dts_start"] = (new Constraint("LESS_THAN_OR_EQUAL"))->setValues($max_dts);
+				else {
+					list($min_dts, $max_dts) = $customer->getYearCycleDates();
+					$nvp["dts_start"] = (new Constraint("BETWEEN"))->setValues($min_dts, $max_dts);
 				}
 
+
 				$tests = Test::query($nvp);
 
 				$location_test_array = [];
@@ -49,6 +58,7 @@ if($submit) {
 						$location_test_array[$test->location_id] = $test;
 					}
 					else {
+						/** @var Test $existing */
 						$existing = $location_test_array[$test->location_id];
 
 						$unix_start_existing = is_null($existing->dts_start) ? 0 : strtotime($existing->dts_start . " UTC");
@@ -71,6 +81,7 @@ if($submit) {
 
 					$customer_slug = str_replace("-", "_", Util::slug($customer->name));
 
+					/** @var User $tester */
 					$tester = null;
 					$formatted_start_dts = null;
 					$formatted_due_dts = null;
@@ -110,7 +121,6 @@ if($submit) {
 						}
 					}
 
-
 					if($icon_file && file_exists("public/img/markers/$icon_file")) {
 						$icon = $icon_file;
 					}
@@ -148,7 +158,8 @@ if($submit) {
 				}
 
 				JSON::success([
-					"locations" => $output
+					"locations" => $output,
+					"testPeriod" => sprintf("%s to %s", $min_dts, $max_dts)
 				]);
 
 				break;
@@ -252,4 +263,3 @@ if($submit) {
 
 JSON::fail("Invalid request.");
 
-?>

+ 10 - 7
controllers/settings.php

@@ -34,12 +34,6 @@ if($submit) {
 
 		$user->newsletter_consent = http::value("newsletter_content", "int");
 
-		$user->preferred_payment_method = http::value("preferred_payment_method", "int");
-		$user->bank_name = http::value("bank_name", "trim");
-		$user->bank_sort_code = http::value("bank_sort_code", "trim");
-		$user->bank_account_number = http::value("bank_account_number", "trim");
-		$user->paypal_email = http::value("paypal_email", "email");
-
 		$locales = Core::locales();
 
 		if($password && !User::validatePassword($password)) $form_exception->addError(__("Password must be at least 6 characters in length and contain at least one lowercase, uppercase, number and special character."));
@@ -49,9 +43,18 @@ if($submit) {
 		if(empty($user->last_name)) $form_exception->addError(__("Last name is required."));
 		if(empty($user->date_of_birth)) $form_exception->addError(__("Date of birth is required."));
 		if(empty($user->phone)) $form_exception->addError(__("Mobile number is required."));
-		if(!isset(User::PAYMENT_METHODS[$user->preferred_payment_method])) $form_exception->addError(__("Invalid payment method selected."));
 		if(!isset($locales[$user->locale])) $form_exception->addError(__("Invalid language selected."));
 
+		if($user->isTester()) {
+			$user->preferred_payment_method = http::value("preferred_payment_method", "int");
+			$user->bank_name = http::value("bank_name", "trim");
+			$user->bank_sort_code = http::value("bank_sort_code", "trim");
+			$user->bank_account_number = http::value("bank_account_number", "trim");
+			$user->paypal_email = http::value("paypal_email", "email");
+
+			if(!isset(User::PAYMENT_METHODS[$user->preferred_payment_method])) $form_exception->addError(__("Invalid payment method selected."));
+		}
+
 		// Activation
 		$deactivate = http::value("deactivate");
 		if($deactivate && $user->level == User::LEVEL_TESTER) {

+ 15 - 14
controllers/test.php

@@ -1,4 +1,4 @@
-<?php
+<?php /** @noinspection PhpUnhandledExceptionInspection */
 
 /**
  * @var Test $test
@@ -237,7 +237,7 @@ if(Core::$user->level == User::LEVEL_TESTER) {
 else if(Core::$user->level >= User::LEVEL_ADMIN) {
 
 	$json = json_decode($template->getJSON());
-	$fields = array_merge($json->beforeTest, $json->duringTest);
+	$fields = array_merge($json->beforeTest, [(object) ["type" => "hr"]], $json->duringTest);
 	$values = $test->getValues();
 
 	$names = array_map(function($value) { return $value->name; }, $values);
@@ -362,6 +362,17 @@ else if(Core::$user->level >= User::LEVEL_ADMIN) {
 			$success = $test->commit();
 			if(!$success) throw new Exception("Failed to update the test. Please try again later.");
 
+
+			if($retest_project) {
+				$retest = new Test;
+				$retest->project_id = $retest_project->id;
+				$retest->location_id = $location->id;
+				$retest->status = Test::STATUS_UNASSIGNED;
+				$retest->dts_created = Util::getDateTime();
+				$retest->retest = 1;
+				$success = $retest->commit();
+			}
+
 			// If rejected, recreate empty test for the location
 			if($reject) {
 				$new_test = new Test;
@@ -377,16 +388,6 @@ else if(Core::$user->level >= User::LEVEL_ADMIN) {
 				$tester->score++;
 				$tester->commit();
 
-				if(!$test->pass && $retest_project) {
-					$retest = new Test;
-					$retest->project_id = $retest_project->id;
-					$retest->location_id = $location->id;
-					$retest->status = Test::STATUS_UNASSIGNED;
-					$retest->dts_created = Util::getDateTime();
-					$retest->retest = 1;
-					$success = $retest->commit();
-				}
-
 				// Save PDF
 				$mpdf = $test->getMPDF();
 				$pdf_string = $mpdf->Output("", "S");
@@ -445,6 +446,8 @@ else if(Core::$user->level >= User::LEVEL_ADMIN) {
 	}
 
 	$projects = $customer->getProjects();
+
+	/** @var Project[] $future_projects */
 	$future_projects = array_filter($projects, function($p) use ($project) {
 		if($p->id == $project->id) return false;
 		if($p->template_id != $project->template_id) return false;
@@ -465,5 +468,3 @@ else if(Core::$user->level >= User::LEVEL_VENUE) {
 else {
 	throw new Exception(__("Invalid request."));
 }
-
-?>

+ 13 - 0
db/migrations/20191110184617_add_year_cycle_month_field.php

@@ -0,0 +1,13 @@
+<?php
+
+use Phinx\Db\Adapter\MysqlAdapter;
+use Phinx\Migration\AbstractMigration;
+
+class AddYearCycleMonthField extends AbstractMigration {
+	public function change() {
+		$table = $this->table("customer");
+		$table
+			->addColumn("year_cycle_month", "integer", ["limit" => MysqlAdapter::INT_TINY, "signed" => false, "null" => true])
+			->update();
+	}
+}

+ 23 - 0
engine/customer.php

@@ -17,6 +17,7 @@
  * @property string $internal_id_field_name
  * @property string $region_field_name
  * @property string $area_manager_field_name
+ * @property int $year_cycle_month
  */
 
 class Customer extends Model {
@@ -28,6 +29,7 @@ class Customer extends Model {
 		"invoice_contact_name",
 		"email_after_test", "email_locations_after_test",
 		"internal_id_field_name", "region_field_name", "area_manager_field_name",
+		"year_cycle_month",
 	];
 
 	// Static methods
@@ -103,4 +105,25 @@ class Customer extends Model {
 		return $url;
 	}
 
+	public function getYearCycleDates(): array {
+
+		$month = $this->year_cycle_month;
+		if(!$month) $month = 1;
+
+		$current_year = date("Y");
+		$current_month = date("n");
+
+		if($current_month >= $month) {
+			$min_dts = sprintf("%d-%02d-01", $current_year, $month);
+			$max_dts = sprintf("%d-%02d-01", $current_year + 1, $month);
+		}
+		else {
+			$min_dts = sprintf("%d-%02d-01", $current_year - 1, $month);
+			$max_dts = sprintf("%d-%02d-01", $current_year, $month);
+		}
+
+		return [$min_dts, $max_dts];
+
+	}
+
 }

+ 5 - 6
engine/email.php

@@ -48,6 +48,10 @@ class Email {
 		return ob_get_clean();
 	}
 
+	public static function isEnabled(): bool {
+	    return PRODUCTION || defined("DEBUG_MODE");
+    }
+
 	// Object functions
 
 	public function __construct() {
@@ -182,12 +186,7 @@ class Email {
 
 		$instance->Body = $this->htmlContent;
 
-		if(PRODUCTION || defined("DEBUG_MODE")) {
-			return $this->instance->send();
-		}
-		else {
-			return true;
-		}
+		return Email::isEnabled() ? $this->instance->send() : true;
 	}
 
 }

+ 0 - 2
engine/test.php

@@ -37,8 +37,6 @@ use Mpdf\Mpdf;
  * @property string $dts_updated
  * @property string $dts_assigned
  * @property string $dts_verified
- *
- * @method Test get(int $id)
  */
 
 class Test extends Model {

+ 6 - 0
engine/test_value.php

@@ -1,5 +1,11 @@
 <?php
 
+/**
+ * Class TestValue
+ * @property int $test_id
+ * @property string $name
+ * @property string $value
+ */
 class TestValue extends Model {
 
 	protected static $table = "test_value";

+ 8 - 0
engine/user.php

@@ -619,4 +619,12 @@ class User extends Model {
 		return "/account/users/{$this->id}";
 	}
 
+	public function isUnverified() {
+		return $this->level == User::LEVEL_UNVERIFIED;
+	}
+
+	public function isRegistered() {
+		return $this->level == User::LEVEL_REGISTERED;
+	}
+
 }

File diff suppressed because it is too large
+ 0 - 0
public/css/bootstrap.min.css


+ 3 - 0
public/js/app-map-overview.js

@@ -22,6 +22,7 @@ $(function() {
 		if(selected) {
 			$(this).data("selected", false);
 			$(this).find(".badge").removeClass("badge-success").text("");
+			$(this).find("small").text("");
 		}
 		else {
 			loadCustomerLocations(customerId);
@@ -97,6 +98,7 @@ function loadCustomerLocations(customerId) {
 	/**
 	 * @property {Object} response
 	 * @property {Array} response.locations
+	 * @property {String} response.testPeriod
 	 * @property {Boolean} response.success
 	 */
 
@@ -121,6 +123,7 @@ function loadCustomerLocations(customerId) {
 
 		$customerItem.data("selected", true);
 		$customerItem.find(".badge").addClass("badge-danger").text(response.locations.length);
+		$customerItem.find("small").text(response.testPeriod);
 
 	});
 

+ 3 - 3
routes.php

@@ -130,9 +130,9 @@ $routes = [
 	"/^api\/customers\/$id_pattern\/(get-locations)$/" => ["controller" => "customer_ajax", "params" => ["id", "action"], "require_user_level" => User::LEVEL_CUSTOMER],
 
 	// Practice
-	"/^account\/practice$/" => ["controller" => "practice_template_select", "require_user_level" => User::LEVEL_TESTER],
-	"/^account\/practice\/$id_pattern$/" => ["controller" => "practice", "params" => ["id"],  "require_user_level" => User::LEVEL_TESTER],
-	"/^account\/practice\/$id_pattern\/files\/([a-z_]+)$/" => ["controller" => "practice_file", "params" => ["id", "name"], "require_user_level" => User::LEVEL_TESTER],
+	"/^account\/practice$/" => ["controller" => "practice_template_select", "require_user_level" => User::LEVEL_REGISTERED],
+	"/^account\/practice\/$id_pattern$/" => ["controller" => "practice", "params" => ["id"],  "require_user_level" => User::LEVEL_REGISTERED],
+	"/^account\/practice\/$id_pattern\/files\/([a-z_]+)$/" => ["controller" => "practice_file", "params" => ["id", "name"], "require_user_level" => User::LEVEL_REGISTERED],
 
 	// Submit ID
 	"/^account\/submit-id$/" => ["controller" => "submit_id", "require_user_level" => User::LEVEL_REGISTERED],

+ 4 - 4
scss/_main.scss

@@ -102,10 +102,10 @@ ol.breadcrumb {
 	overflow: auto;
 }
 
-input[required], select[required], textarea[required] {
-	background-image: url(/img/bg_required.png);
-	background-position: center right;
-	background-repeat: no-repeat;
+input, select, textarea {
+	&:invalid {
+		border: 1px solid lightcoral;
+	}
 }
 
 .hover-container {

+ 22 - 14
tasks/import_venues.php

@@ -1,17 +1,17 @@
-<?php
+<?php /** @noinspection PhpUnhandledExceptionInspection */
 
 require "../initialise.php";
 
-$path = readline("Type relative path to file, CWD is " . getcwd() . ": ");
+$path = trim(readline("Type relative path to file, CWD is " . getcwd() . ": "));
 if(!file_exists($path)) die($path . " not found.");
 
-$customer_id = readline("Type customer ID: ");
+$customer_id = trim(readline("Type customer ID: "));
 $customer = Customer::get($customer_id);
 if(!$customer) die("Customer not found.");
 
-$region_code = readline("Type region code: ");
+$region_code = trim(readline("Type region code (leave blank to skip geocoding): "));
 
-$confirm = readline($customer->name . ": Confirm Y/N: ");
+$confirm = trim(readline($customer->name . ": Confirm Y/N: "));
 if($confirm != "Y") die("Aborted");
 
 $handle = fopen($path, "r");
@@ -124,20 +124,28 @@ for($i = 0; $data = fgetcsv($handle); $i++) {
 	if(!empty($region)) $location->region = $region;
 	if(!empty($area_manager)) $location->area_manager = $area_manager;
 
-	$hours_parts = [];
-	if($opening_hours) $hours_parts[] = "Opening Hours: $opening_hours";
-	if($closing_hours) $hours_parts[] = "Closing Hours: $closing_hours";
-	$location->opening_hours = implode("\n", $hours_parts);
+	if(!empty($opening_hours) || !empty($closing_hours)) {
+		$hours_parts = [];
+		if($opening_hours) $hours_parts[] = "Opening Hours: $opening_hours";
+		if($closing_hours) $hours_parts[] = "Closing Hours: $closing_hours";
+		$location->opening_hours = implode("\n", $hours_parts);
+	}
+
+
+	if(!empty($name)) {
+		$location->name = $name;
+		if(stripos($name, $city) === false) {
+			$location->name .= " ($city)";
+		}
+	}
 
-	$location->name = $name;
-	if(stripos($name, $city) === false) {
-		$location->name .= " ($city)";
+	if(!empty($address_1) && !empty($city)) {
+		$location->address_1 = str_replace(", $city", "", $address_1);
 	}
 
-	$location->address_1 = str_replace(", $city", "", $address_1);
 	if(!empty($postal_code)) $location->postal_code = $postal_code;
 
-	if(!$location->latitude) {
+	if($region_code && !$location->latitude) {
 
 		for($attempt = 0; $attempt < 2; $attempt++) {
 

+ 33 - 11
views/customer_form.php

@@ -2,43 +2,43 @@
 	<h2><?=htmlspecialchars($page_title)?></h2>
 
 	<form method="post">
-		<div class="row mb-1">
+		<div class="row form-group">
 			<label class="col-sm-4 col-form-label" for="name">Name</label>
 			<div class="col-sm">
 				<input class="form-control" type="text" name="name" id="name" placeholder="Enter name" value="<?=htmlspecialchars($customer->name)?>" required />
 			</div>
 		</div>
-		<div class="row mb-1">
+		<div class="row form-group">
 			<label class="col-sm-4 col-form-label" for="address-1">Address Line 1</label>
 			<div class="col-sm">
 				<input class="form-control" type="text" name="address_1" id="address-1" placeholder="Enter address line 1" value="<?=htmlspecialchars($customer->address_1)?>" />
 			</div>
 		</div>
-		<div class="row mb-1">
+		<div class="row form-group">
 			<label class="col-sm-4 col-form-label" for="address-2">Address Line 2</label>
 			<div class="col-sm">
 				<input class="form-control" type="text" name="address_2" id="address-2" placeholder="Enter address line 2" value="<?=htmlspecialchars($customer->address_2)?>" />
 			</div>
 		</div>
-		<div class="row mb-1">
+		<div class="row form-group">
 			<label class="col-sm-4 col-form-label" for="city">City</label>
 			<div class="col-sm">
 				<input class="form-control" type="text" name="city" id="city" placeholder="Enter city" value="<?=htmlspecialchars($customer->city)?>" />
 			</div>
 		</div>
-		<div class="row mb-1">
+		<div class="row form-group">
 			<label class="col-sm-4 col-form-label" for="county">County</label>
 			<div class="col-sm">
 				<input class="form-control" type="text" name="county" id="county" placeholder="Enter county" value="<?=htmlspecialchars($customer->county)?>" />
 			</div>
 		</div>
-		<div class="row mb-1">
+		<div class="row form-group">
 			<label class="col-sm-4 col-form-label" for="postal-code">Postal Code</label>
 			<div class="col-sm">
 				<input class="form-control" type="text" name="postal_code" id="postal-code" placeholder="Enter postal code" value="<?=htmlspecialchars($customer->postal_code)?>" />
 			</div>
 		</div>
-		<div class="row mb-1">
+		<div class="row form-group">
 			<label class="col-sm-4 col-form-label" for="country">Country</label>
 			<div class="col-sm">
 				<select class="form-control" name="country" id="country">
@@ -46,24 +46,46 @@
 				</select>
 			</div>
 		</div>
-		<div class="row mb-1">
+		<div class="row form-group">
 			<label class="col-sm-4 col-form-label" for="email">Email Address</label>
 			<div class="col-sm">
 				<input class="form-control" type="email" name="email" id="email" placeholder="Enter email address" value="<?=htmlspecialchars($customer->email)?>" />
 			</div>
 		</div>
-		<div class="row mb-1">
+		<div class="row form-group">
 			<label class="col-sm-4 col-form-label" for="phone">Contact Number</label>
 			<div class="col-sm">
 				<input class="form-control" type="text" name="phone" id="phone" placeholder="Enter contact number" value="<?=htmlspecialchars($customer->phone)?>" />
 			</div>
 		</div>
-		<div class="row mb-1">
+		<div class="row form-group">
 			<label class="col-sm-4 col-form-label" for="invoice-contact-name">Invoice Contact Name</label>
 			<div class="col-sm">
 				<input class="form-control" type="text" name="invoice_contact_name" id="invoice-contact-name" placeholder="Enter invoice contact name" value="<?=htmlspecialchars($customer->invoice_contact_name)?>" />
 			</div>
 		</div>
+
+        <div class="row form-group">
+            <label  class="col-sm-4 col-form-label" for="year-cycle-month">
+                Year Cycle Month
+            </label>
+            <div class="col-sm">
+                <select class="form-control" name="year_cycle_month" id="year-cycle-month">
+                    <option value="">Select Month</option>
+                    <?php
+                    foreach(range(1, 12) as $month) {
+                        $display_month = sprintf("%02d", $month);
+                        $selected = ($customer->year_cycle_month == $month) ? "selected" : "";
+                        ?>
+                        <option value="<?=$month?>" <?=$selected?>><?=$display_month?></option>
+                        <?php
+                    }
+                    ?>
+                </select>
+            </div>
+        </div>
+
+
 		<div class="row my-3">
 			<div class="col-sm offset-sm-4">
 				<div class="form-check">
@@ -78,4 +100,4 @@
 			</div>
 		</div>
 	</form>
-</div>
+</div>

+ 10 - 1
views/header.php

@@ -129,7 +129,16 @@ if($print) $body_class = "print";
 			$style = (count(Core::$breadcrumbs) > 1) ? "margin-top: -1rem;" : "";
 			?>
 			<div class="p-2 bg-danger text-white text-center d-print-none" style="<?=$style?>">
-				<strong><?=htmlspecialchars(__("PLEASE NOTE:"))?></strong> <?=htmlspecialchars(__("This is a development version of the site."))?>
+				<strong><?=htmlspecialchars(__("PLEASE NOTE:"))?></strong>
+                <?=htmlspecialchars(__("This is a development version of the site."))?>
+                <?php
+                if(Email::isEnabled()) {
+					echo htmlspecialchars(__("Emails will be sent."));
+                }
+                else {
+					echo htmlspecialchars(__("Emails will not be sent."));
+                }
+                ?>
 			</div>
 			<?php
 		}

+ 9 - 6
views/map_overview.php

@@ -17,13 +17,13 @@
 		<div class="col-3">
 			<div class="form-group">
 				<label for="min-date">Min Test Date</label>
-				<input type="date" class="form-control" id="min-date" placeholder="Type date" value="<?=date("Y")?>-01-01" />
+				<input type="date" class="form-control" id="min-date" placeholder="Type date" />
 			</div>
 		</div>
 		<div class="col-3">
 			<div class="form-group">
-				<label for="min-date">Max Test Date</label>
-				<input type="date" class="form-control" id="min-date" placeholder="Type date" value="<?=date("Y")?>-12-31" />
+				<label for="max-date">Max Test Date</label>
+				<input type="date" class="form-control" id="max-date" placeholder="Type date" />
 			</div>
 		</div>
 	</div>
@@ -50,8 +50,11 @@
 			foreach($customers as $customer) {
 				?>
 				<a class="list-group-item list-group-item-action d-flex justify-content-between" data-customer-id="<?=$customer->id?>" data-selected="false">
-					<div><?=htmlspecialchars($customer->name)?></div>
-					<span class="badge badge-pill badge-lg"></span>
+					<div>
+                        <?=htmlspecialchars($customer->name)?><br />
+                        <small></small>
+                    </div>
+					<span class="badge badge-pill badge-lg align-self-center"></span>
 				</a>
 				<?php
 			}
@@ -97,4 +100,4 @@
 		</div>
 	</div>
 
-</div>
+</div>

+ 1 - 1
views/projects.php

@@ -55,7 +55,7 @@ $report_months = array_reverse(Project::getReportMonths());
 							<label class="col-sm-4 col-form-label" for="year">Year</label>
 							<div class="col-sm">
 								<select class="form-control" type="text" name="year" id="year">
-									<option value="">Select Year</option>
+									<option value="0">Select Year</option>
 									<?php
 									foreach($year_options as $value) {
 										$selected = ($value == $year) ? "selected" : "";

+ 14 - 11
views/register.php

@@ -1,4 +1,4 @@
-<?php
+<?php /** @noinspection PhpVoidFunctionResultUsedInspection */
 
 $newsletter_consent_checked = ($user->newsletter_consent) ? "checked" : "";
 
@@ -22,7 +22,7 @@ $newsletter_consent_checked = ($user->newsletter_consent) ? "checked" : "";
 				<div class="row mb-1">
 					<label class="col-sm-4 col-form-label" for="title"><?=htmlspecialchars(__("Title"))?></label>
 					<div class="col-sm">
-						<select class="form-control" name="title" id="title" required>
+						<select class="form-control w-auto" name="title" id="title" required>
 							<option value=""><?=htmlspecialchars(__("Select title"))?></option>
 							<?php
 							foreach(User::titles() as $value => $display) {
@@ -38,19 +38,19 @@ $newsletter_consent_checked = ($user->newsletter_consent) ? "checked" : "";
 				<div class="row mb-1">
 					<label class="col-sm-4 col-form-label"  for="first-name"><?=htmlspecialchars(__("First Name"))?></label>
 					<div class="col-sm">
-						<input class="form-control" type="text" name="first_name" id="first-name" placeholder="<?=htmlspecialchars(__("Enter first name"))?>" value="<?=htmlspecialchars($user->first_name)?>" required />
+						<input class="form-control w-auto" type="text" name="first_name" id="first-name" placeholder="<?=htmlspecialchars(__("Enter first name"))?>" value="<?=htmlspecialchars($user->first_name)?>" required />
 					</div>
 				</div>
 				<div class="row mb-1">
 					<label class="col-sm-4 col-form-label"  for="last-name"><?=htmlspecialchars(__("Last Name"))?></label>
 					<div class="col-sm">
-						<input class="form-control" type="text" name="last_name" id="last-name" placeholder="<?=htmlspecialchars(__("Enter last name"))?>" value="<?=htmlspecialchars($user->last_name)?>" required />
+						<input class="form-control w-auto" type="text" name="last_name" id="last-name" placeholder="<?=htmlspecialchars(__("Enter last name"))?>" value="<?=htmlspecialchars($user->last_name)?>" required />
 					</div>
 				</div>
 				<div class="row mb-1">
 					<label class="col-sm-4 col-form-label"  for="gender"><?=htmlspecialchars(__("Gender"))?></label>
 					<div class="col-sm">
-						<select class="form-control" name="gender" id="gender" required>
+						<select class="form-control w-auto" name="gender" id="gender" required>
 							<option value=""><?=htmlspecialchars(__("Select gender"))?></option>
 							<?php
 							foreach(User::genders() as $value => $display) {
@@ -73,7 +73,7 @@ $newsletter_consent_checked = ($user->newsletter_consent) ? "checked" : "";
 				<div class="row mb-1">
 					<label class="col-sm-4 col-form-label"  for="phone"><?=htmlspecialchars(__("Mobile Number"))?></label>
 					<div class="col-sm">
-						<input class="form-control" type="phone" name="phone" id="phone" placeholder="<?=htmlspecialchars(__("Enter mobile number"))?>" value="<?=htmlspecialchars($user->phone)?>" required />
+						<input class="form-control w-auto" type="tel" name="phone" id="phone" placeholder="<?=htmlspecialchars(__("Enter mobile number"))?>" value="<?=htmlspecialchars($user->phone)?>" required />
 					</div>
 				</div>
 				<div class="row mb-1">
@@ -96,20 +96,23 @@ $newsletter_consent_checked = ($user->newsletter_consent) ? "checked" : "";
 					</div>
 				</div>
 				<div class="row mb-1">
-					<label class="col-sm-4 col-form-label"  for="date-of-birth"><?=htmlspecialchars(__("Date of Birth"))?></label>
+					<label class="col-sm-4 col-form-label"><?=htmlspecialchars(__("Date of Birth"))?></label>
 					<div class="col-sm">
+                        <label for="date-of-birth-day" class="sr-only"><?=htmlspecialchars(__("Day"))?></label>
 						<select class="form-control w-auto d-inline-block" name="date_of_birth_day" id="date-of-birth-day" required>
 							<option value=""><?=htmlspecialchars(__("Day"))?></option>
 							<?php
 							Form::renderDayOptions();
 							?>
 						</select>
+                        <label for="date-of-birth-month" class="sr-only"><?=htmlspecialchars(__("Month"))?></label>
 						<select class="form-control w-auto d-inline-block" name="date_of_birth_month" id="date-of-birth-month" required>
 							<option value=""><?=htmlspecialchars(__("Month"))?></option>
 							<?php
 							Form::renderMonthOptions();
 							?>
 						</select>
+                        <label for="date-of-birth-year" class="sr-only"><?=htmlspecialchars(__("Year"))?></label>
 						<select class="form-control w-auto d-inline-block" name="date_of_birth_year" id="date-of-birth-year" required>
 							<option value=""><?=htmlspecialchars(__("Year"))?></option>
 							<?php
@@ -119,15 +122,15 @@ $newsletter_consent_checked = ($user->newsletter_consent) ? "checked" : "";
 					</div>
 				</div>
 				<div class="row mb-1">
-					<label class="col-sm-4 col-form-label"  for="postal-code"><?=htmlspecialchars(__("Postal Code"))?></label>
+					<label class="col-sm-4 col-form-label" for="postal-code"><?=htmlspecialchars(__("Postal Code"))?></label>
 					<div class="col-sm">
-						<input class="form-control" type="text" name="postal_code" id="postal-code" placeholder="<?=htmlspecialchars(__("Enter postal code"))?>" value="<?=htmlspecialchars($user_address->postal_code)?>" required />
+						<input class="form-control w-auto" type="text" name="postal_code" id="postal-code" placeholder="<?=htmlspecialchars(__("Enter postal code"))?>" value="<?=htmlspecialchars($user_address->postal_code)?>" required />
 					</div>
 				</div>
 				<div class="row mb-3">
 					<label class="col-sm-4 col-form-label" for="country"><?=htmlspecialchars(__("Country"))?></label>
 					<div class="col-sm">
-						<select class="form-control" name="country" id="country" required>
+						<select class="form-control w-auto" name="country" id="country" required>
 						<?=Form::renderCountryOptions($user_address->country)?>
 						</select>
 					</div>
@@ -164,4 +167,4 @@ $newsletter_consent_checked = ($user->newsletter_consent) ? "checked" : "";
 			</div>
 		</div>
 	</form>
-</div>
+</div>

+ 53 - 43
views/settings.php

@@ -61,7 +61,7 @@ if(is_null($user->locale)) $user->locale = LOCALE;
 					<div class="row mb-1">
 						<label class="col-sm-4 col-form-label"  for="phone"><?=htmlspecialchars(__("Mobile Number"))?></label>
 						<div class="col-sm">
-							<input class="form-control" type="phone" name="phone" id="phone" placeholder="<?=htmlspecialchars(__("Enter mobile number"))?>" value="<?=htmlspecialchars($user->phone)?>" required />
+							<input class="form-control" type="tel" name="phone" id="phone" placeholder="<?=htmlspecialchars(__("Enter mobile number"))?>" value="<?=htmlspecialchars($user->phone)?>" required />
 						</div>
 					</div>
 				</div>
@@ -109,48 +109,58 @@ if(is_null($user->locale)) $user->locale = LOCALE;
 						</div>
 					</div>
 				</div>
-				<div class="card card-body mb-3">
-					<h3><?=htmlspecialchars(__("Payment"))?></h3>
-					<div class="row mb-1">
-						<label class="col-sm-4 col-form-label" for="preferred-payment-method"><?=htmlspecialchars(__("Preferred Payment Method"))?></label>
-						<div class="col-sm">
-							<select class="form-control" name="preferred_payment_method" id="preferred-payment-method">
-								<?php
-								foreach(User::PAYMENT_METHODS as $value => $display) {
-									$selected = ($user->preferred_payment_method == $value) ? "selected" : "";
-									?>
-									<option value="<?=htmlspecialchars($value)?>" <?=$selected?>><?=htmlspecialchars($display)?></option>
+
+
+                <?php
+
+                if($user->isTester()) {
+                    ?>
+                    <div class="card card-body mb-3">
+                        <h3><?=htmlspecialchars(__("Payment"))?></h3>
+                        <div class="row mb-1">
+                            <label class="col-sm-4 col-form-label" for="preferred-payment-method"><?=htmlspecialchars(__("Preferred Payment Method"))?></label>
+                            <div class="col-sm">
+                                <select class="form-control" name="preferred_payment_method" id="preferred-payment-method">
 									<?php
-								}
-								?>
-							</select>
-						</div>
-					</div>
-					<div class="row mb-1">
-						<label class="col-sm-4 col-form-label"  for="bank-name"><?=htmlspecialchars(__("Bank Name"))?></label>
-						<div class="col-sm">
-							<input class="form-control" type="text" name="bank_name" id="bank-name" placeholder="<?=htmlspecialchars(__("Enter bank name"))?>" value="<?=htmlspecialchars($user->bank_name)?>" />
-						</div>
-					</div>
-					<div class="row mb-1">
-						<label class="col-sm-4 col-form-label"  for="bank-sort-code"><?=htmlspecialchars(__("Bank Sort Code"))?></label>
-						<div class="col-sm">
-							<input class="form-control" type="text" name="bank_sort_code" id="bank-sort-code" placeholder="<?=htmlspecialchars(__("Enter bank sort code"))?>" value="<?=htmlspecialchars($user->bank_sort_code)?>" />
-						</div>
-					</div>
-					<div class="row mb-1">
-						<label class="col-sm-4 col-form-label"  for="bank-account-number"><?=htmlspecialchars(__("Bank Account Number"))?></label>
-						<div class="col-sm">
-							<input class="form-control" type="text" name="bank_account_number" id="bank-account-number" placeholder="<?=htmlspecialchars(__("Enter bank account number"))?>" value="<?=htmlspecialchars($user->bank_account_number)?>" />
-						</div>
-					</div>
-					<div class="row mb-1">
-						<label class="col-sm-4 col-form-label" for="paypal-email"><?=htmlspecialchars(__("PayPal Email Address"))?></label>
-						<div class="col-sm">
-							<input class="form-control" type="email" name="paypal_email" id="paypal-email" placeholder="<?=htmlspecialchars(__("Enter PayPal email address"))?>" value="<?=htmlspecialchars($user->paypal_email)?>" />
-						</div>
-					</div>
-				</div>
+									foreach(User::PAYMENT_METHODS as $value => $display) {
+										$selected = ($user->preferred_payment_method == $value) ? "selected" : "";
+										?>
+                                        <option value="<?=htmlspecialchars($value)?>" <?=$selected?>><?=htmlspecialchars($display)?></option>
+										<?php
+									}
+									?>
+                                </select>
+                            </div>
+                        </div>
+                        <div class="row mb-1">
+                            <label class="col-sm-4 col-form-label"  for="bank-name"><?=htmlspecialchars(__("Bank Name"))?></label>
+                            <div class="col-sm">
+                                <input class="form-control" type="text" name="bank_name" id="bank-name" placeholder="<?=htmlspecialchars(__("Enter bank name"))?>" value="<?=htmlspecialchars($user->bank_name)?>" />
+                            </div>
+                        </div>
+                        <div class="row mb-1">
+                            <label class="col-sm-4 col-form-label"  for="bank-sort-code"><?=htmlspecialchars(__("Bank Sort Code"))?></label>
+                            <div class="col-sm">
+                                <input class="form-control" type="text" name="bank_sort_code" id="bank-sort-code" placeholder="<?=htmlspecialchars(__("Enter bank sort code"))?>" value="<?=htmlspecialchars($user->bank_sort_code)?>" />
+                            </div>
+                        </div>
+                        <div class="row mb-1">
+                            <label class="col-sm-4 col-form-label"  for="bank-account-number"><?=htmlspecialchars(__("Bank Account Number"))?></label>
+                            <div class="col-sm">
+                                <input class="form-control" type="text" name="bank_account_number" id="bank-account-number" placeholder="<?=htmlspecialchars(__("Enter bank account number"))?>" value="<?=htmlspecialchars($user->bank_account_number)?>" />
+                            </div>
+                        </div>
+                        <div class="row mb-1">
+                            <label class="col-sm-4 col-form-label" for="paypal-email"><?=htmlspecialchars(__("PayPal Email Address"))?></label>
+                            <div class="col-sm">
+                                <input class="form-control" type="email" name="paypal_email" id="paypal-email" placeholder="<?=htmlspecialchars(__("Enter PayPal email address"))?>" value="<?=htmlspecialchars($user->paypal_email)?>" />
+                            </div>
+                        </div>
+                    </div>
+                    <?php
+                }
+
+                ?>
 
 				<div class="row">
 					<div class="col">
@@ -175,4 +185,4 @@ if(is_null($user->locale)) $user->locale = LOCALE;
 			</div>
 		</div>
 	</form>
-</div>
+</div>

+ 21 - 24
views/test_verify_form.php

@@ -2,6 +2,8 @@
 
 /**
  * @var Test $test
+ * @var Project[] $future_projects
+ * @var string $tester_message
  */
 
 $test_details = [
@@ -131,12 +133,6 @@ function render_card_list_group($details) {
 
 						$field = $template->applyOverridesToField($field);
 
-						if($header_count > 0 && $field->type == "header") {
-							?>
-							<hr />
-							<?php
-						}
-
 						if($field->type == "file") {
 							$path = $test->getDirectory() . "/" . $field->name . ".jpg";
 
@@ -359,7 +355,7 @@ function render_card_list_group($details) {
 						<div class="row mb-1">
 							<label class="col-sm-4 col-form-label" for="verifier-notes">Verifier Notes</label>
 							<div class="col-sm">
-								<textarea class="form-control" name="verifier_notes" id="verifier-notes" placeholder="Enter verifier notes" value="<?=htmlspecialchars($test->verifier_notes)?>" rows="4"></textarea>
+								<textarea class="form-control" name="verifier_notes" id="verifier-notes" placeholder="Enter verifier notes" rows="4"><?=htmlspecialchars($test->verifier_notes)?></textarea>
 							</div>
 						</div>
 
@@ -368,29 +364,30 @@ function render_card_list_group($details) {
 							<div class="col-sm">
 								<div class="form-check">
 									<input class="form-check-input" type="checkbox" name="retest" id="retest" value="1" <?=Form::checked($test->retest)?> />
-									<label class="form-check-label" for="retest">Set As Retest</label>
+									<label class="form-check-label" for="retest">This test was a retest</label>
 								</div>
 							</div>
 						</div>
 
+                        <div class="row mb-1">
+                            <label class="col-sm-4 col-form-label" for="retest-project-id">Create Retest</label>
+                            <div class="col-sm">
+                                <select class="form-control" name="retest_project_id" id="retest-project-id">
+                                    <option value="0">Do not create a new retest</option>
+									<?php
+									foreach($future_projects as $future_project) {
+										?>
+                                        <option value="<?=$future_project->id?>"><?=htmlspecialchars($future_project->name)?></option>
+										<?php
+									}
+									?>
+                                </select>
+                            </div>
+                        </div>
+
 						<?php
 						if($test->status == Test::STATUS_PENDING_VERIFICATION) {
 							?>
-							<div class="row mb-1">
-								<div class="col-sm-4 col-form-label">Create Retest</div>
-								<div class="col-sm">
-									<select class="form-control" name="retest_project_id">
-										<option value="0">None</option>
-										<?php
-										foreach($future_projects as $future_project) {
-											?>
-											<option value="<?=$future_project->id?>"><?=htmlspecialchars($future_project->name)?></option>
-											<?php
-										}
-										?>
-									</select>
-								</div>
-							</div>
 							<?php
 							if($customer->email) {
 								?>
@@ -442,7 +439,7 @@ function render_card_list_group($details) {
 							<div class="row mb-1">
 								<label class="col-sm-4 col-form-label" for="tester-message">Message to Tester (if rejecting)</label>
 								<div class="col-sm">
-									<textarea class="form-control" name="tester_message" id="tester-message" placeholder="Enter message to tester" value="<?=htmlspecialchars($tester_message)?>" rows="4"></textarea>
+									<textarea class="form-control" name="tester_message" id="tester-message" placeholder="Enter message to tester" rows="4"><?=htmlspecialchars($tester_message)?></textarea>
 								</div>
 							</div>
 

Some files were not shown because too many files changed in this diff