Simplified Client URL Handling in global client header logic

This commit is contained in:
johnnyq 2025-02-19 15:58:43 -05:00
parent a2c77cf0c2
commit 2fe8adcfca
11 changed files with 69 additions and 45 deletions

View File

@ -8,9 +8,11 @@ $order = "DESC";
if (isset($_GET['client_id'])) {
require_once "includes/inc_all_client.php";
$client_query = "AND invoice_client_id = $client_id";
$client_url = "client_id=$client_id&";
} else {
require_once "includes/inc_all.php";
$client_query = '';
$client_url = '';
}
// Perms
@ -164,7 +166,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<div class="card-body">
<form class="mb-4" autocomplete="off">
<input type="hidden" name="status" value="<?php if (isset($_GET['status'])) { echo nullable_htmlentities($_GET['status']); } ?>">
<?php if(isset($_GET['client_id'])) { ?>
<?php if ($client_url) { ?>
<input type="hidden" name="client_id" value="<?php echo $client_id; ?>">
<?php } ?>
<div class="row">
@ -230,7 +232,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
Scope <?php if ($sort == 'invoice_scope') { echo $order_icon; } ?>
</a>
</th>
<?php if(!isset($_GET['client_id'])) { ?>
<?php if (!$client_url) { ?>
<th>
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=client_name&order=<?php echo $disp; ?>">
Client <?php if ($sort == 'client_name') { echo $order_icon; } ?>
@ -308,9 +310,13 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
?>
<tr>
<td class="text-bold"><a href="invoice.php?invoice_id=<?php echo $invoice_id; ?><?php if (isset($_GET['client_id'])) { echo "&client_id=$client_id"; } ?>"><?php echo "$invoice_prefix$invoice_number"; ?></a></td>
<td class="text-bold">
<a href="invoice.php?<?php echo $client_url; ?>invoice_id=<?php echo $invoice_id; ?>">
<?php echo "$invoice_prefix$invoice_number"; ?>
</a>
</td>
<td><?php echo $invoice_scope_display; ?></td>
<?php if(!isset($_GET['client_id'])) { ?>
<?php if (!$client_url) { ?>
<td class="text-bold"><a href="invoices.php?client_id=<?php echo $client_id; ?>"><?php echo $client_name; ?></a></td>
<?php } ?>
<td class="text-bold text-right"><?php echo numfmt_format_currency($currency_format, $invoice_amount, $invoice_currency_code); ?></td>

View File

@ -8,9 +8,11 @@ $order = "DESC";
if (isset($_GET['client_id'])) {
require_once "includes/inc_all_client.php";
$client_query = "AND invoice_client_id = $client_id";
$client_url = "client_id=$client_id&";
} else {
require_once "includes/inc_all.php";
$client_query = '';
$client_url = '';
}
// Perms
@ -69,7 +71,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<div class="card-body">
<form class="mb-4" autocomplete="off">
<?php if(isset($_GET['client_id'])) { ?>
<?php if ($client_url) { ?>
<input type="hidden" name="client_id" value="<?php echo $client_id; ?>">
<?php } ?>
<div class="row">
@ -174,7 +176,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
Invoice <?php if ($sort == 'invoice_number') { echo $order_icon; } ?>
</a>
</th>
<?php if(!isset($_GET['client_id'])) { ?>
<?php if (!$client_url) { ?>
<th>
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=client_name&order=<?php echo $disp; ?>">
Client <?php if ($sort == 'client_name') { echo $order_icon; } ?>
@ -246,8 +248,12 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<tr>
<td><?php echo $payment_date; ?></td>
<td><?php echo $invoice_date; ?></td>
<td><a href="invoice.php?invoice_id=<?php echo $invoice_id; ?><?php if (isset($_GET['client_id'])) { echo "&client_id=$client_id"; } ?>"><?php echo "$invoice_prefix$invoice_number"; ?></a></td>
<?php if(!isset($_GET['client_id'])) { ?>
<td>
<a href="invoice.php?<?php echo $client_url; ?>invoice_id=<?php echo $invoice_id; ?>">
<?php echo "$invoice_prefix$invoice_number"; ?>
</a>
</td>
<?php if (!$client_url) { ?>
<td><a href="payments.php?client_id=<?php echo $client_id; ?>"><?php echo $client_name; ?></a></td>
<?php } ?>
<td class="text-right"><?php echo numfmt_format_currency($currency_format, $invoice_amount, $invoice_currency_code); ?></td>

View File

@ -8,9 +8,11 @@ $order = "DESC";
if (isset($_GET['client_id'])) {
require_once "includes/inc_all_client.php";
$client_query = "AND quote_client_id = $client_id";
$client_url = "client_id=$client_id&";
} else {
require_once "includes/inc_all.php";
$client_query = '';
$client_url = '';
}
// Perms
@ -53,7 +55,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<div class="card-body">
<form class="mb-4" autocomplete="off">
<?php if(isset($_GET['client_id'])) { ?>
<?php if ($client_url) { ?>
<input type="hidden" name="client_id" value="<?php echo $client_id; ?>">
<?php } ?>
<div class="row">
@ -120,7 +122,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
Scope <?php if ($sort == 'quote_scope') { echo $order_icon; } ?>
</a>
</th>
<?php if (!isset($_GET['client_id'])) { ?>
<?php if (!$client_url) { ?>
<th>
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=client_name&order=<?php echo $disp; ?>">
Client <?php if ($sort == 'client_name') { echo $order_icon; } ?>
@ -203,12 +205,12 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<tr>
<td class="text-bold">
<a href="quote.php?quote_id=<?php echo $quote_id; ?><?php if (isset($_GET['client_id'])) { echo "&client_id=$client_id"; } ?>">
<a href="quote.php?<?php echo $client_url; ?>quote_id=<?php echo $quote_id; ?>">
<?php echo "$quote_prefix$quote_number"; ?>
</a>
</td>
<td><?php echo $quote_scope_display; ?></td>
<?php if (!isset($_GET['client_id'])) { ?>
<?php if (!$client_url) { ?>
<td class="text-bold">
<a href="quotes.php?client_id=<?php echo $client_id; ?>"><?php echo $client_name; ?></a>
</td>

View File

@ -8,9 +8,11 @@ $order = "ASC";
if (isset($_GET['client_id'])) {
require_once "includes/inc_all_client.php";
$client_query = "AND recurring_client_id = $client_id";
$client_url = "client_id=$client_id&";
} else {
require_once "includes/inc_all.php";
$client_query = '';
$client_url = '';
}
// Perms
@ -44,7 +46,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<div class="card-body">
<form class="mb-4" autocomplete="off">
<?php if(isset($_GET['client_id'])) { ?>
<?php if ($client_url) { ?>
<input type="hidden" name="client_id" value="<?php echo $client_id; ?>">
<?php } ?>
<div class="row">
@ -115,7 +117,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
Scope <?php if ($sort == 'recurring_scope') { echo $order_icon; } ?>
</a>
</th>
<?php if (!isset($_GET['client_id'])) { ?>
<?php if (!$client_url) { ?>
<th>
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=client_name&order=<?php echo $disp; ?>">
Client <?php if ($sort == 'client_name') { echo $order_icon; } ?>
@ -208,13 +210,13 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<tr>
<td class="text-bold">
<a href="recurring_invoice.php?recurring_id=<?php echo $recurring_id; ?><?php if (isset($_GET['client_id'])) { echo "&client_id=$client_id"; } ?>">
<a href="recurring_invoice.php?<?php echo $client_url; ?>recurring_id=<?php echo $recurring_id; ?>">
<?php echo "$recurring_prefix$recurring_number"; ?>
</a>
</td>
<td class="text-bold"><?php echo $recurring_next_date; ?></td>
<td><?php echo $recurring_scope; ?></td>
<?php if (!isset($_GET['client_id'])) { ?>
<?php if (!$client_url) { ?>
<td class="text-bold"><a href="recurring_invoices.php?client_id=<?php echo $client_id; ?>"><?php echo $client_name; ?></a></td>
<?php } ?>
<td class="text-bold text-right"><?php echo numfmt_format_currency($currency_format, $recurring_amount, $recurring_currency_code); ?></td>

View File

@ -8,9 +8,11 @@ $order = "ASC";
if (isset($_GET['client_id'])) {
require_once "includes/inc_all_client.php";
$client_query = "AND scheduled_ticket_client_id = $client_id";
$client_url = "client_id=$client_id&";
} else {
require_once "includes/inc_all.php";
$client_query = '';
$client_url = '';
}
// Perms
@ -67,7 +69,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<div class="card-body">
<form autocomplete="off">
<?php if(isset($_GET['client_id'])) { ?>
<?php if ($client_url) { ?>
<input type="hidden" name="client_id" value="<?php echo $client_id; ?>">
<?php } ?>
<div class="row">
@ -115,7 +117,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<input class="form-check-input" id="selectAllCheckbox" type="checkbox" onclick="checkAll(this)">
</div>
</td>
<?php if (!isset($_GET['client_id'])) { ?>
<?php if (!$client_url) { ?>
<th>
<a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=client_name&order=<?php echo $disp; ?>">
Client <?php if ($sort == 'client_name') { echo $order_icon; } ?>
@ -169,7 +171,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
</div>
</td>
<?php if (!isset($_GET['client_id'])) { ?>
<?php if (!$client_url) { ?>
<th><a href="recurring_tickets.php?client_id=<?php echo $scheduled_ticket_client_id; ?>"><?php echo $scheduled_ticket_client_name ?></a>
</th>
<?php } ?>

View File

@ -9,9 +9,11 @@ $order = "DESC";
if (isset($_GET['client_id'])) {
require_once "includes/inc_all_client.php";
$client_query = "AND ticket_client_id = $client_id";
$client_url = "client_id=$client_id&";
} else {
require_once "includes/inc_all.php";
$client_query = '';
$client_url = '';
}
// Perms
@ -154,8 +156,8 @@ $sql_categories = mysqli_query(
<div class="card-header py-2">
<h3 class="card-title mt-2"><i class="fa fa-fw fa-life-ring mr-2"></i>Tickets
<small class="ml-3">
<a href="?<?php if (isset($_GET['client_id'])) { echo "client_id=$client_id&"; } ?>status=Open" class="text-light"><strong><?php echo $total_tickets_open; ?></strong> Open</a> |
<a href="?<?php if (isset($_GET['client_id'])) { echo "client_id=$client_id&"; } ?>status=Closed" class="text-light"><strong><?php echo $total_tickets_closed; ?></strong> Closed</a>
<a href="?<?php echo $client_url; ?>status=Open" class="text-light"><strong><?php echo $total_tickets_open; ?></strong> Open</a> |
<a href="?<?php echo $client_url; ?>status=Closed" class="text-light"><strong><?php echo $total_tickets_closed; ?></strong> Closed</a>
</small>
</h3>
<div class="card-tools">
@ -176,7 +178,7 @@ $sql_categories = mysqli_query(
</div>
<div class="card-body">
<form autocomplete="off">
<?php if(isset($_GET['client_id'])) { ?>
<?php if ($client_url) { ?>
<input type="hidden" name="client_id" value="<?php echo $client_id; ?>">
<?php } ?>
<div class="row">
@ -229,12 +231,12 @@ $sql_categories = mysqli_query(
<i class="fa fa-fw fa-envelope mr-2"></i>My Tickets
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="?<?php if (isset($_GET['client_id'])) { echo "client_id=$client_id&"; } ?>status=Open&assigned=<?php echo $session_user_id ?>">Active tickets (<?php echo $user_active_assigned_tickets ?>)</a>
<a class="dropdown-item" href="?<?php echo $client_url; ?>status=Open&assigned=<?php echo $session_user_id ?>">Active tickets (<?php echo $user_active_assigned_tickets ?>)</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item " href="<?php if (isset($_GET['client_id'])) { echo "client_id=$client_id&"; } ?>?status=Closed&assigned=<?php echo $session_user_id ?>">Closed tickets</a>
<a class="dropdown-item " href="?<?php echo $client_url; ?>status=Closed&assigned=<?php echo $session_user_id ?>">Closed tickets</a>
</div>
</div>
<a href="?<?php if (isset($_GET['client_id'])) { echo "client_id=$client_id&"; } ?>assigned=unassigned" class="btn btn-outline-danger">
<a href="?<?php echo $client_url; ?>assigned=unassigned" class="btn btn-outline-danger">
<i class="fa fa-fw fa-exclamation-triangle mr-2"></i>Unassigned Tickets | <strong> <?php echo $total_tickets_unassigned; ?></strong>
</a>

View File

@ -18,17 +18,17 @@
Ticket <?php if ($sort == 'ticket_subject') { echo $order_icon; } ?>
</a>
</th>
<?php if (!isset($_GET['client_id'])) { ?>
<?php if (!$client_url) { ?>
<th scope="col">
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=client_name&order=<?php echo $disp; ?>">
Client <?php if ($sort == 'client_name') { echo $order_icon; } ?>
</a>
</th>
<?php } ?>
<?php if (isset($_GET['client_id'])) { ?>
<?php if ($client_url) { ?>
<th scope="col">
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=client_name&order=<?php echo $disp; ?>">
Client <?php if ($sort == 'contact_name') { echo $order_icon; } ?>
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=contact_name&order=<?php echo $disp; ?>">
Contact <?php if ($sort == 'contact_name') { echo $order_icon; } ?>
</a>
</th>
<?php } ?>
@ -201,7 +201,7 @@
</div>
<a href="ticket.php?ticket_id=<?php echo $ticket_id; ?><?php if (isset($_GET['client_id'])) { echo "&client_id=$client_id"; } ?>">
<a href="ticket.php?<?php echo $client_url; ?>ticket_id=<?php echo $ticket_id; ?>">
<?php
if (empty($ticket_closed_at) && $ticket_reply_type == "Client") {
echo "<strong>$ticket_subject</strong>";
@ -230,7 +230,7 @@
<!-- Ticket Contact -->
<td>
<?php if (!isset($_GET['client_id'])) { ?>
<?php if (!$client_url) { ?>
<a href="tickets.php?client_id=<?php echo $client_id; ?>"><strong><?php echo $client_name; ?></strong></a>
<?php } ?>
<div><?php echo $contact_display; ?></div>

View File

@ -111,7 +111,7 @@ $kanban = array_values($statuses);
<b>
<?php
if (!isset($_GET['client_id'])) {
if (!$client_url) {
if ($item['contact_name'] != ""){
echo $item['client_name'] . ' - ' . $item['contact_name'];
} else {

View File

@ -22,14 +22,14 @@
Subject <?php if ($sort == 'ticket_subject') { echo $order_icon; } ?>
</a>
</th>
<?php if (!isset($_GET['client_id'])) { ?>
<?php if (!$client_url) { ?>
<th>
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=client_name&order=<?php echo $disp; ?>">
Client / <span class="text-secondary">Contact</span> <?php if ($sort == 'client_name') { echo $order_icon; } ?>
</a>
</th>
<?php } ?>
<?php if (isset($_GET['client_id'])) { ?>
<?php if ($client_url) { ?>
<th>
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=contact_name&order=<?php echo $disp; ?>">
Contact <?php if ($sort == 'contact_name') { echo $order_icon; } ?>
@ -193,14 +193,14 @@
<!-- Ticket Number -->
<td>
<a href="ticket.php?ticket_id=<?php echo $ticket_id; ?><?php if (isset($_GET['client_id'])) { echo "&client_id=$client_id"; } ?>">
<a href="ticket.php?<?php echo $client_url; ?>ticket_id=<?php echo $ticket_id; ?>">
<span class="badge badge-pill badge-secondary p-3"><?php echo "$ticket_prefix$ticket_number"; ?></span>
</a>
</td>
<!-- Ticket Subject -->
<td>
<a href="ticket.php?ticket_id=<?php echo $ticket_id; ?><?php if (isset($_GET['client_id'])) { echo "&client_id=$client_id"; } ?>"><?php echo $ticket_subject; ?></a>
<a href="ticket.php?<?php echo $client_url; ?>ticket_id=<?php echo $ticket_id; ?>"><?php echo $ticket_subject; ?></a>
<?php if($task_count && $completed_task_count > 0) { ?>
<div class="progress mt-2" style="height: 20px;">
@ -216,7 +216,7 @@
<!-- Ticket Contact -->
<td>
<?php if (!isset($_GET['client_id'])) { ?>
<?php if (!$client_url) { ?>
<a href="tickets.php?client_id=<?php echo $client_id; ?>"><strong><?php echo $client_name; ?></strong></a>
<?php } ?>
<div><?php echo $contact_display; ?></div>

View File

@ -8,9 +8,11 @@ $order = "DESC";
if (isset($_GET['client_id'])) {
require_once "includes/inc_all_client.php";
$client_query = "AND trip_client_id = $client_id";
$client_url = "client_id=$client_id&";
} else {
require_once "includes/inc_all.php";
$client_query = '';
$client_url = '';
}
//Rebuild URL
@ -50,7 +52,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<div class="card-body">
<form class="mb-4" autocomplete="off">
<?php if(isset($_GET['client_id'])) { ?>
<?php if ($client_url) { ?>
<input type="hidden" name="client_id" value="<?php echo $client_id; ?>">
<?php } ?>
<div class="row">
@ -111,7 +113,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
Date <?php if ($sort == 'trip_date') { echo $order_icon; } ?>
</a>
</th>
<?php if (!isset($_GET['client_id'])) { ?>
<?php if (!$client_url) { ?>
<th>
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=client_name&order=<?php echo $disp; ?>">
Client <?php if ($sort == 'client_name') { echo $order_icon; } ?>
@ -184,13 +186,13 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<td>
<a class="text-dark" href="#"
data-toggle="ajax-modal"
data-ajax-url="ajax/ajax_trip_edit.php<?php if (isset($_GET['client_id'])) { echo "?client_id=$client_id "; } ?>"
data-ajax-url="ajax/ajax_trip_edit.php?<?php echo $client_url; ?>"
data-ajax-id="<?php echo $trip_id; ?>"
>
<?php echo $trip_date; ?>
</a>
</td>
<?php if (!isset($_GET['client_id'])) { ?>
<?php if (!$client_url) { ?>
<td><?php echo $client_name_display; ?></td>
<?php } ?>
<td><?php echo $user_name_display; ?></td>
@ -210,14 +212,14 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#"
data-toggle="ajax-modal"
data-ajax-url="ajax/ajax_trip_edit.php<?php if (isset($_GET['client_id'])) { echo "?client_id=$client_id "; } ?>"
data-ajax-url="ajax/ajax_trip_edit.php?<?php echo $client_url; ?>"
data-ajax-id="<?php echo $trip_id; ?>"
>
<i class="fa fa-fw fa-edit mr-2"></i>Edit
</a>
<a class="dropdown-item" href="#"
data-toggle="ajax-modal"
data-ajax-url="ajax/ajax_trip_copy.php<?php if (isset($_GET['client_id'])) { echo "?client_id=$client_id "; } ?>"
data-ajax-url="ajax/ajax_trip_copy.php?<?php echo $client_url; ?>"
data-ajax-id="<?php echo $trip_id; ?>"
>
<i class="fa fa-fw fa-copy mr-2"></i>Copy

View File

@ -8,9 +8,11 @@ $order = "ASC";
if (isset($_GET['client_id'])) {
require_once "includes/inc_all_client.php";
$client_query = "AND vendor_client_id = $client_id";
$client_url = "client_id=$client_id&";
} else {
require_once "includes/inc_all.php";
$client_query = "AND vendor_client_id = 0";
$client_url = '';
}
$sql = mysqli_query(
@ -54,7 +56,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
</div>
<div class="card-body">
<form autocomplete="off">
<?php if(isset($_GET['client_id'])) { ?>
<?php if ($client_url) { ?>
<input type="hidden" name="client_id" value="<?php echo $client_id; ?>">
<?php } ?>
<input type="hidden" name="archived" value="<?php echo $archived; ?>">
@ -71,7 +73,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<div class="col-md-8">
<div class="btn-group float-right">
<a href="?<?php if(isset($_GET['client_id'])) { echo "client_id=$client_id&"; } ?>archived=<?php if($archived == 1){ echo 0; } else { echo 1; } ?>"
<a href="?<?php echo "$client_url"; ?>archived=<?php if($archived == 1){ echo 0; } else { echo 1; } ?>"
class="btn btn-<?php if($archived == 1){ echo "primary"; } else { echo "default"; } ?>">
<i class="fa fa-fw fa-archive mr-2"></i>Archived
</a>