Bladeren bron

Move Stripe invoice details for a test to its own card

Alan Lam 1 jaar geleden
bovenliggende
commit
408182c951
1 gewijzigde bestanden met toevoegingen van 54 en 7 verwijderingen
  1. 54 7
      views/test_verify_form.php

+ 54 - 7
views/test_verify_form.php

@@ -39,13 +39,6 @@ $get_test_details = static function(Test $test) use ($project, $location, $user)
 	$test_details["Location"] = "<a href=\"/account/locations/$location->id\" target=\"_blank\">" . htmlspecialchars($location->name) . "</a>";
 	$test_details["Address"] = htmlspecialchars($location->getDisplayAddress(["address_1", "address_2", "city", "postal_code"]));
 
-	if($test->stripe_invoice_id) {
-		$stripe_helper = StripeHelper::getInstance();
-		$stripe_invoice = $stripe_helper->createInvoice($test, "0.00");
-
-		$test_details["Stripe Invoice"] = sprintf("<a href=\"%s\" target=\"_blank\">View</a>", htmlspecialchars($stripe_invoice->hosted_invoice_url));
-	}
-
 	$previous_test = $test->getPreviousTest();
 	$next_test = $test->getNextTest();
 
@@ -285,6 +278,60 @@ function render_card_list_group($details) {
 							?>
 						</div>
 					</div>
+					<?php
+					if($test->stripe_invoice_id) {
+						$stripe_details = [];
+
+						$stripe_helper = StripeHelper::getInstance();
+						$stripe_invoice = $stripe_helper->createInvoice($test, "0.00");
+
+						$stripe_details["Invoice"] = sprintf("<a href=\"%s\" target=\"_blank\">View</a>", htmlspecialchars($stripe_invoice->hosted_invoice_url));
+
+						$status_class = "badge-secondary";
+						$status_text = __("N/A");
+
+						switch($stripe_invoice->status) {
+							case "draft": {
+								$status_class = "badge-warning";
+								$status_text = __("Draft");
+								break;
+							}
+							case "open": {
+								$status_class = "badge-danger";
+								$status_text = __("Open");
+								break;
+							}
+							case "paid": {
+								$status_class = "badge-success";
+								$status_text = __("Paid");
+								break;
+							}
+							case "uncollectible": {
+								$status_text = __("Uncollectible");
+								break;
+							}
+							case "void":
+								$status_text = __("Void");
+								break;
+						}
+
+						$stripe_details["Status"] = sprintf("<span class=\"badge badge-lg %s\">%s</span>", $status_class, $status_text);
+
+						?>
+						<div class="col-md col-xl-12">
+							<div class="card mb-3">
+								<div class="card-header">
+									Stripe
+								</div>
+								<?php
+								render_card_list_group($stripe_details);
+								?>
+							</div>
+						</div>
+						<?php
+					}
+					?>
+
 					<div class="col-md col-xl-12">
 						<div class="card mb-3">
 							<div class="card-header">