Просмотр исходного кода

Add ability to create new standard test from verify test page

Alan Lam 6 лет назад
Родитель
Сommit
81f2ee0fa4
2 измененных файлов с 48 добавлено и 36 удалено
  1. 16 14
      controllers/test.php
  2. 32 22
      views/test_verify_form.php

+ 16 - 14
controllers/test.php

@@ -275,11 +275,12 @@ else if(Core::$user->level >= User::LEVEL_ADMIN) {
 			$test->verifier_notes = http::value("verifier_notes", "trim");
 
 			// Check selected retest project
-			$retest_project = false;
-			$retest_project_id = http::value("retest_project_id", "int");
-			if($retest_project_id) {
-				$retest_project = Project::get($retest_project_id);
-				if(!$retest_project || $retest_project->customer_id != $customer->id) throw new Exception("The retest project selected is invalid.");
+			$new_test_project = false;
+			$new_test_project_id = http::value("new_test_project_id", "int");
+			$new_test_is_retest = http::value("new_test_is_retest", "int");
+			if($new_test_project_id) {
+				$new_test_project = Project::get($new_test_project_id);
+				if(!$new_test_project || $new_test_project->customer_id != $customer->id) throw new Exception("The new test project selected is invalid.");
 			}
 
 			// Modify test values
@@ -362,15 +363,16 @@ 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($new_test_project) {
+				$new_test = new Test;
+				$new_test->project_id = $new_test_project->id;
+				$new_test->location_id = $location->id;
+				$new_test->status = Test::STATUS_UNASSIGNED;
+				$new_test->dts_created = Util::getDateTime();
+				if($new_test_is_retest) {
+					$new_test->retest = 1;
+				}
+				$success = $new_test->commit();
 			}
 
 			// If rejected, recreate empty test for the location

+ 32 - 22
views/test_verify_form.php

@@ -362,26 +362,36 @@ function render_card_list_group($details) {
 						<div class="row mb-1">
 							<div class="col-sm-4">Set As Retest</div>
 							<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">This test was a retest</label>
+								<div class="custom-control custom-checkbox">
+									<input class="custom-control-input" type="checkbox" name="retest" id="retest" value="1" <?=Form::checked($test->retest)?> />
+									<label class="custom-control-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>
+                            <label class="col-sm-4 col-form-label" for="new-test-project-id">Create New Test</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>
+								<div class="input-group">
+									<select class="form-control" name="new_test_project_id" id="new-test-project-id">
+										<option value="0">Do not create</option>
 										<?php
-									}
-									?>
-                                </select>
+										foreach($future_projects as $future_project) {
+											?>
+											<option value="<?=$future_project->id?>"><?=htmlspecialchars($future_project->name)?></option>
+											<?php
+										}
+										?>
+									</select>
+									<div class="input-group-append">
+										<div class="input-group-text">
+											<div class="custom-control custom-checkbox">
+												<input class="custom-control-input" type="checkbox" name="new_test_is_retest" id="new-test-is-retest" value="1" />
+												<label class="custom-control-label" for="new-test-is-retest"><?=htmlspecialchars(__("Retest"))?></label>
+											</div>
+										</div>
+									</div>
+								</div>
                             </div>
                         </div>
 
@@ -396,9 +406,9 @@ function render_card_list_group($details) {
 										<label class="form-check-label" for="email-customer">Email Headquarters</label>
 									</div>
 									<div class="col-sm">
-										<div class="form-check">
-											<input class="form-check-input" type="checkbox" name="email_customer" id="email-customer" value="1" <?=Form::checked($customer->email_after_test)?> />
-											<label class="form-check-label" for="email-customer"><?=htmlspecialchars($customer->email)?></label>
+										<div class="custom-control custom-checkbox">
+											<input class="custom-control-input" type="checkbox" name="email_customer" id="email-customer" value="1" <?=Form::checked($customer->email_after_test)?> />
+											<label class="custom-control-label" for="email-customer"><?=htmlspecialchars($customer->email)?></label>
 										</div>
 									</div>
 								</div>
@@ -411,9 +421,9 @@ function render_card_list_group($details) {
 										<label class="form-check-label" for="email-location">Email Venue</label>
 									</div>
 									<div class="col-sm">
-										<div class="form-check">
-											<input class="form-check-input" type="checkbox" name="email_location" id="email-location" value="1" <?=Form::checked($customer->email_locations_after_test)?> />
-											<label class="form-check-label" for="email-location"><?=htmlspecialchars($location->email)?></label>
+										<div class="custom-control custom-checkbox">
+											<input class="custom-control-input" type="checkbox" name="email_location" id="email-location" value="1" <?=Form::checked($customer->email_locations_after_test)?> />
+											<label class="custom-control-label" for="email-location"><?=htmlspecialchars($location->email)?></label>
 										</div>
 									</div>
 								</div>
@@ -426,9 +436,9 @@ function render_card_list_group($details) {
 										<label class="form-check-label" for="email-location-area-manager">Email Area Manager</label>
 									</div>
 									<div class="col-sm">
-										<div class="form-check">
-											<input class="form-check-input" type="checkbox" name="email_location_area_manager" id="email-location-area-manager" value="1" <?=Form::checked($customer->email_locations_after_test)?> />
-											<label class="form-check-label" for="email-location-area-manager"><?=htmlspecialchars($location->area_manager_email)?></label>
+										<div class="custom-control custom-checkbox">
+											<input class="custom-control-input" type="checkbox" name="email_location_area_manager" id="email-location-area-manager" value="1" <?=Form::checked($customer->email_locations_after_test)?> />
+											<label class="custom-control-label" for="email-location-area-manager"><?=htmlspecialchars($location->area_manager_email)?></label>
 										</div>
 									</div>
 								</div>