use intl js lib across all phone number fields

This commit is contained in:
johnnyq
2026-08-26 13:53:27 -04:00
parent cfafc385f0
commit 96f2c697c6
107 changed files with 492 additions and 10356 deletions

View File

@@ -182,7 +182,7 @@ ob_start();
<select class="form-select select2" name="country">
<option value="">- Select Country -</option>
<?php foreach($countries_array as $country_name) { ?>
<option <?php if ($session_company_country == $country_name) { echo "selected"; } ?> ><?= $country_name ?></option>
<option <?php if ($session_company_country == $country_name) { echo "selected"; } ?> data-iso2="<?= $country_iso2_array[$country_name] ?? '' ?>"><?= $country_name ?></option>
<?php } ?>
</select>
</div>
@@ -195,8 +195,8 @@ ob_start();
<div class="mb-3">
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-phone"></i></span>
<input type="tel" class="form-control w-25 flex-grow-0" name="location_phone_country_code" placeholder="+" maxlength="4">
<input type="tel" class="form-control" name="location_phone" placeholder="Phone Number" maxlength="200">
<input type="hidden" name="location_phone_country_code">
<input type="tel" class="form-control" name="location_phone" placeholder="Phone Number" maxlength="200" data-itflow-phone="location_phone_country_code" data-itflow-phone-country-select="country">
</div>
</div>
</div>
@@ -213,8 +213,8 @@ ob_start();
<div class="mb-3">
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-fax"></i></span>
<input type="tel" class="form-control w-25 flex-grow-0" name="location_fax_country_code" placeholder="+" maxlength="4">
<input type="tel" class="form-control" name="location_fax" placeholder="Fax Number" maxlength="200">
<input type="hidden" name="location_fax_country_code">
<input type="tel" class="form-control" name="location_fax" placeholder="Fax Number" maxlength="200" data-itflow-phone="location_fax_country_code" data-itflow-phone-country-select="country">
</div>
</div>
</div>
@@ -246,8 +246,8 @@ ob_start();
<div class="mb-3">
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-phone"></i></span>
<input type="tel" class="form-control w-25 flex-grow-0" name="contact_phone_country_code" placeholder="+" maxlength="4">
<input type="tel" class="form-control" name="contact_phone" placeholder="Phone Number" maxlength="200">
<input type="hidden" name="contact_phone_country_code">
<input type="tel" class="form-control" name="contact_phone" placeholder="Phone Number" maxlength="200" data-itflow-phone="contact_phone_country_code">
</div>
</div>
</div>
@@ -264,8 +264,8 @@ ob_start();
<div class="mb-3">
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-mobile-alt"></i></span>
<input type="tel" class="form-control w-25 flex-grow-0" name="contact_mobile_country_code" placeholder="+" maxlength="4">
<input type="tel" class="form-control" name="contact_mobile" placeholder="Mobile Phone Number" maxlength="200">
<input type="hidden" name="contact_mobile_country_code">
<input type="tel" class="form-control" name="contact_mobile" placeholder="Mobile Phone Number" maxlength="200" data-itflow-phone="contact_mobile_country_code">
</div>
</div>
</div>

View File

@@ -12,6 +12,20 @@ if ($client_id) {
$sql_tags_select = mysqli_query($mysqli, "SELECT tag_id, tag_name FROM tags WHERE tag_type = 3 ORDER BY tag_name ASC");
// A contact's phone belongs to the CLIENT's country, not the company's. The
// client's country lives on its primary location; falls through to the
// company default when the client has none.
$client_phone_iso2 = '';
if ($client_id) {
$sql_client_country = mysqli_query($mysqli, "SELECT location_country FROM locations
WHERE location_client_id = $client_id AND location_primary = 1 LIMIT 1");
$row_client_country = mysqli_fetch_assoc($sql_client_country);
if ($row_client_country) {
$client_phone_iso2 = $country_iso2_array[$row_client_country['location_country']] ?? '';
}
}
ob_start();
?>
@@ -20,7 +34,8 @@ ob_start();
<h5 class="modal-title"><i class="fas fa-fw fa-user-plus me-2"></i>New Contact</h5>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
</div>
<form action="post.php" method="post" enctype="multipart/form-data" autocomplete="off">
<form action="post.php" method="post" enctype="multipart/form-data" autocomplete="off"
data-itflow-phone-country="<?= escapeHtml($client_phone_iso2) ?>">
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
<div class="modal-body">
@@ -103,8 +118,8 @@ ob_start();
<div class="mb-3">
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-phone"></i></span>
<input type="tel" class="form-control w-25 flex-grow-0" name="phone_country_code" placeholder="+" maxlength="4">
<input type="tel" class="form-control" name="phone" placeholder="Phone Number" maxlength="200">
<input type="hidden" name="phone_country_code">
<input type="tel" class="form-control" name="phone" placeholder="Phone Number" maxlength="200" data-itflow-phone="phone_country_code">
</div>
</div>
</div>
@@ -121,8 +136,8 @@ ob_start();
<div class="mb-3">
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-mobile-alt"></i></span>
<input type="tel" class="form-control w-25 flex-grow-0" name="mobile_country_code" placeholder="+" maxlength="4">
<input type="tel" class="form-control" name="mobile" placeholder="Mobile Phone Number" maxlength="200">
<input type="hidden" name="mobile_country_code">
<input type="tel" class="form-control" name="mobile" placeholder="Mobile Phone Number" maxlength="200" data-itflow-phone="mobile_country_code">
</div>
</div>
</div>

View File

@@ -18,6 +18,20 @@ $sql = mysqli_query($mysqli, "SELECT contact_archived_at, contact_billing, conta
$row = mysqli_fetch_assoc($sql);
$client_id = intval($row['contact_client_id']);
// A contact's phone belongs to the CLIENT's country, not the company's. The
// client's country lives on its primary location; falls through to the
// company default when the client has none.
$client_phone_iso2 = '';
if ($client_id) {
$sql_client_country = mysqli_query($mysqli, "SELECT location_country FROM locations
WHERE location_client_id = $client_id AND location_primary = 1 LIMIT 1");
$row_client_country = mysqli_fetch_assoc($sql_client_country);
if ($row_client_country) {
$client_phone_iso2 = $country_iso2_array[$row_client_country['location_country']] ?? '';
}
}
$contact_name = escapeHtml($row['contact_name']);
$contact_title = escapeHtml($row['contact_title']);
$contact_department = escapeHtml($row['contact_department']);
@@ -59,7 +73,8 @@ ob_start();
<h5 class="modal-title"><i class='fas fa-user-edit me-2'></i>Editing Contact: <strong><?= $contact_name ?></strong></h5>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
</div>
<form action="post.php" method="post" enctype="multipart/form-data" autocomplete="off">
<form action="post.php" method="post" enctype="multipart/form-data" autocomplete="off"
data-itflow-phone-country="<?= escapeHtml($client_phone_iso2) ?>">
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
<input type="hidden" name="contact_id" value="<?= $contact_id ?>">
@@ -119,8 +134,8 @@ ob_start();
<div class="mb-3">
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-phone"></i></span>
<input type="tel" class="form-control w-25 flex-grow-0" name="phone_country_code" value="<?= "$contact_phone_country_code" ?>" placeholder="+" maxlength="4">
<input type="tel" class="form-control" name="phone" value="<?= $contact_phone ?>" placeholder="Phone Number" maxlength="200">
<input type="hidden" name="phone_country_code" value="<?= "$contact_phone_country_code" ?>">
<input type="tel" class="form-control" name="phone" value="<?= $contact_phone ?>" placeholder="Phone Number" maxlength="200" data-itflow-phone="phone_country_code">
</div>
</div>
</div>
@@ -137,8 +152,8 @@ ob_start();
<div class="mb-3">
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-mobile-alt"></i></span>
<input type="tel" class="form-control w-25 flex-grow-0" name="mobile_country_code" value="<?= "$contact_mobile_country_code" ?>" placeholder="+" maxlength="4">
<input type="tel" class="form-control" name="mobile" value="<?= $contact_mobile ?>" placeholder="Phone Number" maxlength="200">
<input type="hidden" name="mobile_country_code" value="<?= "$contact_mobile_country_code" ?>">
<input type="tel" class="form-control" name="mobile" value="<?= $contact_mobile ?>" placeholder="Phone Number" maxlength="200" data-itflow-phone="mobile_country_code">
</div>
</div>
</div>

View File

@@ -131,7 +131,7 @@ ob_start();
<select class="form-select select2" name="country">
<option value="">- Country -</option>
<?php foreach($countries_array as $country_name) { ?>
<option <?php if ($session_company_country == $country_name) { echo "selected"; } ?> ><?= $country_name ?></option>
<option <?php if ($session_company_country == $country_name) { echo "selected"; } ?> data-iso2="<?= $country_iso2_array[$country_name] ?? '' ?>"><?= $country_name ?></option>
<?php } ?>
</select>
</div>
@@ -168,8 +168,8 @@ ob_start();
<div class="mb-3">
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-phone"></i></span>
<input type="tel" class="form-control w-25 flex-grow-0" name="phone_country_code" placeholder="+" maxlength="4">
<input type="tel" class="form-control" name="phone" placeholder="Phone Number" maxlength="200">
<input type="hidden" name="phone_country_code">
<input type="tel" class="form-control" name="phone" placeholder="Phone Number" maxlength="200" data-itflow-phone="phone_country_code" data-itflow-phone-country-select="country">
</div>
</div>
</div>
@@ -186,8 +186,8 @@ ob_start();
<div class="mb-3">
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-fax"></i></span>
<input type="tel" class="form-control w-25 flex-grow-0" name="fax_country_code" placeholder="+" maxlength="4">
<input type="tel" class="form-control" name="fax" placeholder="Fax Number" maxlength="200">
<input type="hidden" name="fax_country_code">
<input type="tel" class="form-control" name="fax" placeholder="Fax Number" maxlength="200" data-itflow-phone="fax_country_code" data-itflow-phone-country-select="country">
</div>
</div>
</div>

View File

@@ -152,7 +152,7 @@ ob_start();
<select class="form-select select2" name="country">
<option value="">- Country -</option>
<?php foreach($countries_array as $country_name) { ?>
<option <?php if ($location_country == $country_name) { echo "selected"; } ?>><?= $country_name ?></option>
<option <?php if ($location_country == $country_name) { echo "selected"; } ?> data-iso2="<?= $country_iso2_array[$country_name] ?? '' ?>"><?= $country_name ?></option>
<?php } ?>
</select>
</div>
@@ -195,8 +195,8 @@ ob_start();
<div class="mb-3">
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-phone"></i></span>
<input type="tel" class="form-control w-25 flex-grow-0" name="phone_country_code" value="<?= $location_phone_country_code ?>" placeholder="+" maxlength="4">
<input type="tel" class="form-control" name="phone" value="<?= $location_phone ?>" placeholder="Phone Number" maxlength="200">
<input type="hidden" name="phone_country_code" value="<?= $location_phone_country_code ?>">
<input type="tel" class="form-control" name="phone" value="<?= $location_phone ?>" placeholder="Phone Number" maxlength="200" data-itflow-phone="phone_country_code" data-itflow-phone-country-select="country">
</div>
</div>
</div>
@@ -213,8 +213,8 @@ ob_start();
<div class="mb-3">
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-fax"></i></span>
<input type="tel" class="form-control w-25 flex-grow-0" name="fax_country_code" value="<?= $location_fax_country_code ?>" placeholder="+" maxlength="4">
<input type="tel" class="form-control" name="fax" value="<?= $location_fax ?>" placeholder="Phone Number" maxlength="200">
<input type="hidden" name="fax_country_code" value="<?= $location_fax_country_code ?>">
<input type="tel" class="form-control" name="fax" value="<?= $location_fax ?>" placeholder="Phone Number" maxlength="200" data-itflow-phone="fax_country_code" data-itflow-phone-country-select="country">
</div>
</div>
</div>

View File

@@ -76,8 +76,8 @@ ob_start();
<div class="mb-3">
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-phone"></i></span>
<input type="tel" class="form-control w-25 flex-grow-0" name="phone_country_code" placeholder="+" maxlength="4">
<input type="tel" class="form-control" name="phone" placeholder="Phone Number" maxlength="200">
<input type="hidden" name="phone_country_code">
<input type="tel" class="form-control" name="phone" placeholder="Phone Number" maxlength="200" data-itflow-phone="phone_country_code">
</div>
</div>
</div>

View File

@@ -124,8 +124,8 @@ ob_start();
<div class="mb-3">
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-phone"></i></span>
<input type="tel" class="form-control w-25 flex-grow-0" name="phone_country_code" value="<?= $vendor_phone_country_code ?>" placeholder="+" maxlength="4">
<input type="tel" class="form-control" name="phone" value="<?= $vendor_phone ?>" placeholder="Phone Number" maxlength="200">
<input type="hidden" name="phone_country_code" value="<?= $vendor_phone_country_code ?>">
<input type="tel" class="form-control" name="phone" value="<?= $vendor_phone ?>" placeholder="Phone Number" maxlength="200" data-itflow-phone="phone_country_code">
</div>
</div>
</div>