Browse Source

Add travel cost description and photo upload; update packages

Alan Lam 6 năm trước cách đây
mục cha
commit
8cc0215768

+ 1 - 1
composer.json

@@ -2,7 +2,7 @@
   "require": {
   "require": {
     "phpmailer/phpmailer": "^6.0",
     "phpmailer/phpmailer": "^6.0",
     "phpoffice/phppresentation": "dev-master",
     "phpoffice/phppresentation": "dev-master",
-    "mpdf/mpdf": "^7.1",
+    "mpdf/mpdf": "^8.0",
     "gettext/gettext": "^4.6",
     "gettext/gettext": "^4.6",
     "ext-mysqli": "*",
     "ext-mysqli": "*",
     "ext-json": "*",
     "ext-json": "*",

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 437 - 160
composer.lock


+ 22 - 0
controllers/test_invoice.php

@@ -20,7 +20,29 @@ $fee = floatval($test->test_fee) > 0 ? $test->test_fee : $project->default_teste
 $fee = (float) $fee;
 $fee = (float) $fee;
 
 
 $travel_cost = (float) http::value("travel_cost", "float");
 $travel_cost = (float) http::value("travel_cost", "float");
+$description = http::value("description", "trim");
+
+$photo = (object) $_FILES["photo"];
+switch($photo->error) {
+	case UPLOAD_ERR_OK:
+		$is_jpeg = Image::isJPEG($photo->tmp_name);
+		if(!$is_jpeg) throw new Exception(__("The file uploaded was not a JPEG. Please try again."));
+
+		$dst = $test->getDirectory() . "/travel_costs.jpg";
+		move_uploaded_file($photo->tmp_name, $dst);
+		break;
+	case UPLOAD_ERR_NO_FILE:
+		throw new Exception(__("No file was uploaded. Please try again."));
+		break;
+	default:
+		// Upload error
+		throw new Exception(__("An upload error has occurred. Please try again."));
+		break;
+}
+
+
 $test->test_travel_cost = $travel_cost;
 $test->test_travel_cost = $travel_cost;
+$test->test_travel_cost_description = $description;
 
 
 $invoice_total = $fee + $travel_cost;
 $invoice_total = $fee + $travel_cost;
 
 

+ 11 - 0
db/migrations/20200730200043_add_travel_cost_description_field_to_test_table.php

@@ -0,0 +1,11 @@
+<?php
+
+use Phinx\Migration\AbstractMigration;
+
+class AddTravelCostDescriptionFieldToTestTable extends AbstractMigration {
+	public function change() {
+		$this->table("test")
+			->addColumn("test_travel_cost_description", "string", ["null" => true, "after" => "test_travel_cost"])
+			->update();
+	}
+}

+ 2 - 1
engine/test.php

@@ -14,6 +14,7 @@ use Mpdf\Mpdf;
  * @property float $test_fee
  * @property float $test_fee
  * @property string $test_time
  * @property string $test_time
  * @property float $test_travel_cost
  * @property float $test_travel_cost
+ * @property string $test_travel_cost_description
  * @property string $shop_left
  * @property string $shop_left
  * @property string $shop_right
  * @property string $shop_right
  * @property string $attire
  * @property string $attire
@@ -43,7 +44,7 @@ class Test extends Model {
 
 
 	protected static $table = "test";
 	protected static $table = "test";
 	protected static $id_field = "id";
 	protected static $id_field = "id";
-	protected static $fillable_fields = ["project_id", "location_id", "tester_id", "status", "status_tester_invoice", "customer_fee", "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"];
+	protected static $fillable_fields = ["project_id", "location_id", "tester_id", "status", "status_tester_invoice", "customer_fee", "test_fee", "test_time", "test_travel_cost", "test_travel_cost_description", "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"];
 	const TEST_FIELDS = ["shop_left", "shop_right", "attire", "challenge_stage", "challenge_description", "challenger_name", "challenger_description", "challenger_gender", "challenger_eye_contact", "additional_notes"];
 
 

+ 26 - 3
public/js/app-completed-tests.js

@@ -1,12 +1,35 @@
 $(function() {
 $(function() {
 
 
-	$("#modal-test-invoice").on("show.bs.modal", function(event) {
+	const $travelCostsQuestionContainer = $("#travel-costs-question-container");
+	const $travelCostsApprovedContainer = $("#travel-costs-approved-container");
+	const $travelCostsNotApprovedContainer = $("#travel-costs-not-approved-container");
+
+	const $approvedButton = $(".btn-costs-approved");
+	$approvedButton.on("click", () => {
+		$travelCostsQuestionContainer.collapse("hide");
+		$travelCostsApprovedContainer.collapse("show");
+	});
+
+	const $notApprovedButton = $(".btn-costs-not-approved");
+	$notApprovedButton.on("click", () => {
+		$travelCostsQuestionContainer.collapse("hide");
+		$travelCostsNotApprovedContainer.collapse("show");
+	});
+
+	const $invoiceModal = $("#modal-test-invoice");
+
+	$invoiceModal.on("show.bs.modal", function(event) {
 		var a = $(event.relatedTarget);
 		var a = $(event.relatedTarget);
 		var id = $(a).data("id");
 		var id = $(a).data("id");
 
 
 		$(this).find("form").attr("action", "/account/tests/" + id + "/invoice");
 		$(this).find("form").attr("action", "/account/tests/" + id + "/invoice");
 		$(this).find("input[name=travel_cost]").val("0.00");
 		$(this).find("input[name=travel_cost]").val("0.00");
-
+	});
+	$invoiceModal.on("hidden.bs.modal", () => {
+		$travelCostsQuestionContainer.collapse("show");
+		$travelCostsApprovedContainer.collapse("hide");
+		$travelCostsNotApprovedContainer.collapse("hide");
+		$invoiceModal.find("form").get(0).reset();
 	});
 	});
 
 
-});
+});

+ 35 - 9
views/modal_test_invoice.php

@@ -1,7 +1,7 @@
 <div class="modal fade" id="modal-test-invoice" tabindex="-1" role="dialog">
 <div class="modal fade" id="modal-test-invoice" tabindex="-1" role="dialog">
 	<div class="modal-dialog modal-lg" role="document">
 	<div class="modal-dialog modal-lg" role="document">
 		<div class="modal-content">
 		<div class="modal-content">
-			<form method="get" action="" target="_blank">
+			<form method="post" target="_blank" enctype="multipart/form-data">
 
 
 				<div class="modal-header">
 				<div class="modal-header">
 					<h5 class="modal-title"><strong><?=htmlspecialchars(__("Download Invoice"))?></strong></h5>
 					<h5 class="modal-title"><strong><?=htmlspecialchars(__("Download Invoice"))?></strong></h5>
@@ -10,11 +10,16 @@
 					</button>
 					</button>
 				</div>
 				</div>
 				<div class="modal-body">
 				<div class="modal-body">
-					<div class="row mb-3">
-						<div class="col-sm-4 col-form-label">
+
+					<div id="travel-costs-question-container" class="collapse show text-center">
+						<label><?=htmlspecialchars(__("Were travel costs pre-approved?"))?></label><br />
+						<button type="button" class="btn btn-lg btn-success btn-costs-approved"><?=htmlspecialchars(__("Yes"))?></button>
+						<button type="button" class="btn btn-lg btn-danger btn-costs-not-approved"><?=htmlspecialchars(__("No"))?></button>
+					</div>
+
+					<div id="travel-costs-approved-container" class="collapse">
+						<div class="form-group">
 							<label for="travel-cost"><?=htmlspecialchars(__("Travel Costs"))?></label>
 							<label for="travel-cost"><?=htmlspecialchars(__("Travel Costs"))?></label>
-						</div>
-						<div class="col-sm">
 							<div class="input-group">
 							<div class="input-group">
 								<div class="input-group-prepend">
 								<div class="input-group-prepend">
 									<span class="input-group-text"><?=htmlspecialchars(__("£"))?></span>
 									<span class="input-group-text"><?=htmlspecialchars(__("£"))?></span>
@@ -23,15 +28,36 @@
 							</div>
 							</div>
 							<small class="form-text text-muted"><?=htmlspecialchars(__("You may be contacted for verification purposes."))?></small>
 							<small class="form-text text-muted"><?=htmlspecialchars(__("You may be contacted for verification purposes."))?></small>
 						</div>
 						</div>
-					</div>
-					<div class="row">
-						<div class="col-sm offset-sm-4">
+
+						<div class="form-group">
+							<label for="travel-cost-description"><?=htmlspecialchars(__("Description"))?></label>
+							<input class="form-control" type="text" name="description" id="travel-cost-description" placeholder="<?=htmlspecialchars(__("Enter description"))?>" />
+						</div>
+
+						<div class="form-group">
+							<label for="travel-cost-photo"><?=htmlspecialchars(__("Receipt/Ticket Photo"))?></label>
+							<input class="form-control-file" type="file" name="photo" id="travel-cost-photo" />
+							<small class="form-text text-muted"><?=htmlspecialchars(__("JPEG photos only."))?></small>
+						</div>
+
+						<div class="form-group">
 							<button class="btn btn-primary" type="submit"><?=htmlspecialchars(__("Download Invoice"))?></button>
 							<button class="btn btn-primary" type="submit"><?=htmlspecialchars(__("Download Invoice"))?></button>
 							<small class="form-text text-danger"><?=htmlspecialchars(__("Travel costs are locked after downloading for the first time, please ensure it is correct!"))?></small>
 							<small class="form-text text-danger"><?=htmlspecialchars(__("Travel costs are locked after downloading for the first time, please ensure it is correct!"))?></small>
 						</div>
 						</div>
+
+					</div>
+
+					<div id="travel-costs-not-approved-container" class="collapse">
+						<div class="alert alert-info">
+							<i class="fa fa-fw fa-info-circle"></i>
+							<?=htmlspecialchars(__("Please contact your tester manager before submitting invoice."))?>
+						</div>
 					</div>
 					</div>
+
+
+
 				</div>
 				</div>
 			</form>
 			</form>
 		</div>
 		</div>
 	</div>
 	</div>
-</div>
+</div>

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác