Add formatAddress function and replace all addresses with it

This commit is contained in:
johnnyq
2026-07-23 18:10:39 -04:00
parent 9c65644adc
commit 41b118ab87
17 changed files with 60 additions and 40 deletions

View File

@@ -338,10 +338,12 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
$location_city = escapeHtml($row['location_city']);
$location_state = escapeHtml($row['location_state']);
$location_zip = escapeHtml($row['location_zip']);
if (empty($location_address) && empty($location_city) && empty($location_state) && empty($location_zip)) {
$location_address_lines = formatAddress($location_address, $location_city, $location_state, $location_zip, '', '<br>');
if ($location_address_lines === '') {
$location_address_display = "-";
} else {
$location_address_display = "<div class='media'><i class='fa fa-fw fa-map-marker-alt text-secondary mt-1 mr-2'></i><div class='media-body'>$location_address<div>$location_city $location_state $location_zip</div><div><small>$location_country</small></div></div></div>";
$location_country_line = $location_country ? "<div><small>$location_country</small></div>" : '';
$location_address_display = "<div class='media'><i class='fa fa-fw fa-map-marker-alt text-secondary mt-1 mr-2'></i><div class='media-body'>$location_address_lines$location_country_line</div></div>";
}
$contact_id = intval($row['contact_id']);
$contact_name = escapeHtml($row['contact_name']);

View File

@@ -74,7 +74,7 @@
<a href="//maps.<?php echo $session_map_source; ?>.com/?q=<?php echo "$location_address $location_zip"; ?>" target="_blank">
<i class="fa fa-fw fa-map-marker-alt text-secondary ml-1 mr-2"></i><?php echo $location_address; ?>
<div>
<i class="fa fa-fw ml-1 mr-2"></i><?php echo "$location_city $location_state $location_zip"; ?>
<i class="fa fa-fw ml-1 mr-2"></i><?php echo formatAddress('', $location_city, $location_state, $location_zip, '', ' '); ?>
</div>
<div>
<i class="fa fa-fw ml-1 mr-2"></i><small><?php echo $location_country; ?></small>

View File

@@ -329,8 +329,7 @@ if (isset($_GET['invoice_id'])) {
<div class="col-sm-6 <?php if (!file_exists("../uploads/settings/$company_logo")) { echo "col-sm-8"; } ?>">
<ul class="list-unstyled">
<li><h4><strong><?php echo $company_name; ?></strong></h4></li>
<li><?php echo $company_address; ?></li>
<li><?php echo "$company_city $company_state $company_zip, $company_country"; ?></li>
<li><?php echo formatAddress($company_address, $company_city, $company_state, $company_zip, $company_country, '<br>'); ?></li>
<li><?php echo "$company_email | $company_phone"; ?></li>
<li><?php echo $company_website; ?></li>
<?php if ($company_tax_id_display) { ?>
@@ -366,8 +365,7 @@ if (isset($_GET['invoice_id'])) {
<h6><strong>Bill To:</strong></h6>
<ul class="list-unstyled mb-0">
<li><?php echo $client_name; ?></li>
<li><?php echo $location_address; ?></li>
<li><?php echo "$location_city $location_state $location_zip, $location_country"; ?></li>
<li><?php echo formatAddress($location_address, $location_city, $location_state, $location_zip, $location_country, '<br>'); ?></li>
<li><?php echo "$contact_email | $contact_phone $contact_extension"; ?></li>
</ul>
</div>

View File

@@ -349,7 +349,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
</div>
</a>
</td>
<td><a href="//maps.<?php echo $session_map_source; ?>.com?q=<?php echo "$location_address $location_zip"; ?>" target="_blank"><?php echo $location_address; ?><br><?php echo "$location_city $location_state $location_zip<br><small>$location_country</small>"; ?></a></td>
<td><a href="//maps.<?php echo $session_map_source; ?>.com?q=<?php echo "$location_address $location_zip"; ?>" target="_blank"><?php echo formatAddress($location_address, $location_city, $location_state, $location_zip, '', '<br>'); ?><?php echo $location_country ? "<br><small>$location_country</small>" : ''; ?></a></td>
<td>
<?php echo $location_phone_display; ?>
<?php echo $location_fax_display; ?>

View File

@@ -277,7 +277,7 @@ ob_start();
<div class="font-weight-bold"><?= $location_name ?></div>
<div class="text-muted">
<?= $location_address ?><br>
<?= "$location_city $location_state $location_zip" ?><br>
<?= formatAddress('', $location_city, $location_state, $location_zip, '', ' ') ?><br>
<?= $location_country ?>
</div>
<?php } else { ?>

View File

@@ -102,7 +102,7 @@ ob_start();
$location_state = escapeHtml($row['location_state']);
$location_zip = escapeHtml($row['location_zip']);
?>
<option><?php echo "$location_address $location_city $location_state $location_zip"; ?></option>
<option><?php echo formatAddress($location_address, $location_city, $location_state, $location_zip, '', ' '); ?></option>
<?php
}
} ?>

View File

@@ -92,7 +92,7 @@ ob_start();
$location_city = escapeHtml($row['location_city']);
$location_state = escapeHtml($row['location_state']);
$location_zip = escapeHtml($row['location_zip']);
$location_full_address = "$location_address $location_city $location_state $location_zip";
$location_full_address = formatAddress($location_address, $location_city, $location_state, $location_zip, '', ' ');
?>
<option><?php echo $location_full_address; ?></option>

View File

@@ -92,7 +92,7 @@ ob_start();
$location_city = escapeHtml($row['location_city']);
$location_state = escapeHtml($row['location_state']);
$location_zip = escapeHtml($row['location_zip']);
$location_full_address = "$location_address $location_city $location_state $location_zip";
$location_full_address = formatAddress($location_address, $location_city, $location_state, $location_zip, '', ' ');
?>
<option><?php echo $location_full_address; ?></option>

View File

@@ -1462,11 +1462,12 @@ if (isset($_POST["export_client_pdf"])) {
$html .= '<hr>';
// Client header information (non-table)
$location_city_state_zip = formatAddress('', $location_city, $location_state, $location_zip, '', ' ');
$html .= "
<div class='client-header'>
<h3>$client_name</h3>
<p><strong>Address:</strong> $location_address</p>
<p><strong>City State Zip:</strong> $location_city $location_state $location_zip</p>
<p><strong>City State Zip:</strong> $location_city_state_zip</p>
<p><strong>Phone:</strong> $contact_phone</p>
<p><strong>Website:</strong> $client_website</p>
<p><strong>Contact:</strong> $contact_name</p>
@@ -1542,10 +1543,11 @@ if (isset($_POST["export_client_pdf"])) {
$location_zip = escapeHtml($row["location_zip"]);
$location_phone_country_code = escapeHtml($row["location_phone_country_code"]);
$location_phone = escapeHtml(formatPhoneNumber($row["location_phone"], $location_phone_country_code));
$location_full_address = formatAddress($location_address, $location_city, $location_state, $location_zip, '', ' ');
$html .= "
<tr>
<td>$location_name</td>
<td>$location_address $location_city $location_state $location_zip</td>
<td>$location_full_address</td>
<td>$location_phone</td>
</tr>";
}

View File

@@ -892,8 +892,8 @@ if (isset($_GET['export_invoice_pdf'])) {
<td width="50%" align="right" style="font-size:14pt; font-weight:bold;">' . $client_name . '</td>
</tr>
<tr>
<td style="font-size:10pt; line-height:1.4;">' . nl2br("$company_address\n$company_city $company_state $company_zip\n$company_country\n$company_phone\n$company_website\n$company_tax_id_display") . '</td>
<td style="font-size:10pt; line-height:1.4;" align="right">' . nl2br("$location_address\n$location_city $location_state $location_zip\n$location_country\n$contact_email\n$contact_phone") . '</td>
<td style="font-size:10pt; line-height:1.4;">' . nl2br(formatAddress($company_address, $company_city, $company_state, $company_zip, $company_country) . "\n$company_phone\n$company_website\n$company_tax_id_display") . '</td>
<td style="font-size:10pt; line-height:1.4;" align="right">' . nl2br(formatAddress($location_address, $location_city, $location_state, $location_zip, $location_country) . "\n$contact_email\n$contact_phone") . '</td>
</tr>
</table><br>';
@@ -1074,8 +1074,8 @@ if (isset($_GET['export_invoice_packing_slip'])) {
<td width="50%" align="right" style="font-size:14pt; font-weight:bold;">' . $client_name . '</td>
</tr>
<tr>
<td style="font-size:10pt; line-height:1.4;">' . nl2br("$company_address\n$company_city $company_state $company_zip\n$company_country\n$company_phone\n$company_website") . '</td>
<td style="font-size:10pt; line-height:1.4;" align="right">' . nl2br("$location_address\n$location_city $location_state $location_zip\n$location_country\n$contact_email\n$contact_phone") . '</td>
<td style="font-size:10pt; line-height:1.4;">' . nl2br(formatAddress($company_address, $company_city, $company_state, $company_zip, $company_country) . "\n$company_phone\n$company_website") . '</td>
<td style="font-size:10pt; line-height:1.4;" align="right">' . nl2br(formatAddress($location_address, $location_city, $location_state, $location_zip, $location_country) . "\n$contact_email\n$contact_phone") . '</td>
</tr>
</table><br>';

View File

@@ -871,8 +871,8 @@ if (isset($_GET['export_quote_pdf'])) {
<td width="50%" align="right" style="font-size:14pt; font-weight:bold;">' . $client_name . '</td>
</tr>
<tr>
<td style="font-size:10pt; line-height:1.4;">' . nl2br("$company_address\n$company_city $company_state $company_zip\n$company_country\n$company_phone\n$company_website") . '</td>
<td style="font-size:10pt; line-height:1.4;" align="right">' . nl2br("$location_address\n$location_city $location_state $location_zip\n$location_country\n$contact_email\n$contact_phone") . '</td>
<td style="font-size:10pt; line-height:1.4;">' . nl2br(formatAddress($company_address, $company_city, $company_state, $company_zip, $company_country) . "\n$company_phone\n$company_website") . '</td>
<td style="font-size:10pt; line-height:1.4;" align="right">' . nl2br(formatAddress($location_address, $location_city, $location_state, $location_zip, $location_country) . "\n$contact_email\n$contact_phone") . '</td>
</tr>
</table><br>';

View File

@@ -244,8 +244,7 @@ if (isset($_GET['quote_id'])) {
<div class="col-sm-6 <?php if (!file_exists("../uploads/settings/$company_logo")) { echo "col-sm-8"; } ?>">
<ul class="list-unstyled">
<li><h4><strong><?php echo $company_name; ?></strong></h4></li>
<li><?php echo $company_address; ?></li>
<li><?php echo "$company_city $company_state $company_zip, $company_country"; ?></li>
<li><?php echo formatAddress($company_address, $company_city, $company_state, $company_zip, $company_country, '<br>'); ?></li>
<li><?php echo "$company_email | $company_phone"; ?></li>
<li><?php echo $company_website; ?></li>
</ul>
@@ -278,8 +277,7 @@ if (isset($_GET['quote_id'])) {
<h6><strong>To:</strong></h6>
<ul class="list-unstyled mb-0">
<li><?php echo $client_name; ?></li>
<li><?php echo $location_address; ?></li>
<li><?php echo "$location_city $location_state $location_zip, $location_country"; ?></li>
<li><?php echo formatAddress($location_address, $location_city, $location_state, $location_zip, $location_country, '<br>'); ?></li>
<li><?php echo "$contact_email | $contact_phone $contact_extension"; ?></li>
</ul>
</div>

View File

@@ -209,8 +209,7 @@ if (isset($_GET['recurring_invoice_id'])) {
<div class="col-sm-6">
<ul class="list-unstyled">
<li><h4><strong><?php echo $company_name; ?></strong></h4></li>
<li><?php echo $company_address; ?></li>
<li><?php echo "$company_city $company_state $company_zip, $company_country"; ?></li>
<li><?php echo formatAddress($company_address, $company_city, $company_state, $company_zip, $company_country, '<br>'); ?></li>
<li><?php echo "$company_email | $company_phone"; ?></li>
<li><?php echo $company_website; ?></li>
</ul>
@@ -247,8 +246,7 @@ if (isset($_GET['recurring_invoice_id'])) {
<h6><strong>Bill To:</strong></h6>
<ul class="list-unstyled mb-0">
<li><?php echo $client_name; ?></li>
<li><?php echo $location_address; ?></li>
<li><?php echo "$location_city $location_state $location_zip, $location_country"; ?></li>
<li><?php echo formatAddress($location_address, $location_city, $location_state, $location_zip, $location_country, '<br>'); ?></li>
<li><?php echo "$contact_email | $contact_phone $contact_extension"; ?></li>
</ul>
</div>