Skip to content

Commit 2fe8adc

Browse files
committed
Simplified Client URL Handling in global client header logic
1 parent a2c77cf commit 2fe8adc

11 files changed

+69
-45
lines changed

invoices.php

+10-4
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
if (isset($_GET['client_id'])) {
99
require_once "includes/inc_all_client.php";
1010
$client_query = "AND invoice_client_id = $client_id";
11+
$client_url = "client_id=$client_id&";
1112
} else {
1213
require_once "includes/inc_all.php";
1314
$client_query = '';
15+
$client_url = '';
1416
}
1517

1618
// Perms
@@ -164,7 +166,7 @@
164166
<div class="card-body">
165167
<form class="mb-4" autocomplete="off">
166168
<input type="hidden" name="status" value="<?php if (isset($_GET['status'])) { echo nullable_htmlentities($_GET['status']); } ?>">
167-
<?php if(isset($_GET['client_id'])) { ?>
169+
<?php if ($client_url) { ?>
168170
<input type="hidden" name="client_id" value="<?php echo $client_id; ?>">
169171
<?php } ?>
170172
<div class="row">
@@ -230,7 +232,7 @@
230232
Scope <?php if ($sort == 'invoice_scope') { echo $order_icon; } ?>
231233
</a>
232234
</th>
233-
<?php if(!isset($_GET['client_id'])) { ?>
235+
<?php if (!$client_url) { ?>
234236
<th>
235237
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=client_name&order=<?php echo $disp; ?>">
236238
Client <?php if ($sort == 'client_name') { echo $order_icon; } ?>
@@ -308,9 +310,13 @@
308310
?>
309311

310312
<tr>
311-
<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>
313+
<td class="text-bold">
314+
<a href="invoice.php?<?php echo $client_url; ?>invoice_id=<?php echo $invoice_id; ?>">
315+
<?php echo "$invoice_prefix$invoice_number"; ?>
316+
</a>
317+
</td>
312318
<td><?php echo $invoice_scope_display; ?></td>
313-
<?php if(!isset($_GET['client_id'])) { ?>
319+
<?php if (!$client_url) { ?>
314320
<td class="text-bold"><a href="invoices.php?client_id=<?php echo $client_id; ?>"><?php echo $client_name; ?></a></td>
315321
<?php } ?>
316322
<td class="text-bold text-right"><?php echo numfmt_format_currency($currency_format, $invoice_amount, $invoice_currency_code); ?></td>

payments.php

+10-4
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
if (isset($_GET['client_id'])) {
99
require_once "includes/inc_all_client.php";
1010
$client_query = "AND invoice_client_id = $client_id";
11+
$client_url = "client_id=$client_id&";
1112
} else {
1213
require_once "includes/inc_all.php";
1314
$client_query = '';
15+
$client_url = '';
1416
}
1517

1618
// Perms
@@ -69,7 +71,7 @@
6971

7072
<div class="card-body">
7173
<form class="mb-4" autocomplete="off">
72-
<?php if(isset($_GET['client_id'])) { ?>
74+
<?php if ($client_url) { ?>
7375
<input type="hidden" name="client_id" value="<?php echo $client_id; ?>">
7476
<?php } ?>
7577
<div class="row">
@@ -174,7 +176,7 @@
174176
Invoice <?php if ($sort == 'invoice_number') { echo $order_icon; } ?>
175177
</a>
176178
</th>
177-
<?php if(!isset($_GET['client_id'])) { ?>
179+
<?php if (!$client_url) { ?>
178180
<th>
179181
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=client_name&order=<?php echo $disp; ?>">
180182
Client <?php if ($sort == 'client_name') { echo $order_icon; } ?>
@@ -246,8 +248,12 @@
246248
<tr>
247249
<td><?php echo $payment_date; ?></td>
248250
<td><?php echo $invoice_date; ?></td>
249-
<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>
250-
<?php if(!isset($_GET['client_id'])) { ?>
251+
<td>
252+
<a href="invoice.php?<?php echo $client_url; ?>invoice_id=<?php echo $invoice_id; ?>">
253+
<?php echo "$invoice_prefix$invoice_number"; ?>
254+
</a>
255+
</td>
256+
<?php if (!$client_url) { ?>
251257
<td><a href="payments.php?client_id=<?php echo $client_id; ?>"><?php echo $client_name; ?></a></td>
252258
<?php } ?>
253259
<td class="text-right"><?php echo numfmt_format_currency($currency_format, $invoice_amount, $invoice_currency_code); ?></td>

quotes.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
if (isset($_GET['client_id'])) {
99
require_once "includes/inc_all_client.php";
1010
$client_query = "AND quote_client_id = $client_id";
11+
$client_url = "client_id=$client_id&";
1112
} else {
1213
require_once "includes/inc_all.php";
1314
$client_query = '';
15+
$client_url = '';
1416
}
1517

1618
// Perms
@@ -53,7 +55,7 @@
5355

5456
<div class="card-body">
5557
<form class="mb-4" autocomplete="off">
56-
<?php if(isset($_GET['client_id'])) { ?>
58+
<?php if ($client_url) { ?>
5759
<input type="hidden" name="client_id" value="<?php echo $client_id; ?>">
5860
<?php } ?>
5961
<div class="row">
@@ -120,7 +122,7 @@
120122
Scope <?php if ($sort == 'quote_scope') { echo $order_icon; } ?>
121123
</a>
122124
</th>
123-
<?php if (!isset($_GET['client_id'])) { ?>
125+
<?php if (!$client_url) { ?>
124126
<th>
125127
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=client_name&order=<?php echo $disp; ?>">
126128
Client <?php if ($sort == 'client_name') { echo $order_icon; } ?>
@@ -203,12 +205,12 @@
203205

204206
<tr>
205207
<td class="text-bold">
206-
<a href="quote.php?quote_id=<?php echo $quote_id; ?><?php if (isset($_GET['client_id'])) { echo "&client_id=$client_id"; } ?>">
208+
<a href="quote.php?<?php echo $client_url; ?>quote_id=<?php echo $quote_id; ?>">
207209
<?php echo "$quote_prefix$quote_number"; ?>
208210
</a>
209211
</td>
210212
<td><?php echo $quote_scope_display; ?></td>
211-
<?php if (!isset($_GET['client_id'])) { ?>
213+
<?php if (!$client_url) { ?>
212214
<td class="text-bold">
213215
<a href="quotes.php?client_id=<?php echo $client_id; ?>"><?php echo $client_name; ?></a>
214216
</td>

recurring_invoices.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
if (isset($_GET['client_id'])) {
99
require_once "includes/inc_all_client.php";
1010
$client_query = "AND recurring_client_id = $client_id";
11+
$client_url = "client_id=$client_id&";
1112
} else {
1213
require_once "includes/inc_all.php";
1314
$client_query = '';
15+
$client_url = '';
1416
}
1517

1618
// Perms
@@ -44,7 +46,7 @@
4446

4547
<div class="card-body">
4648
<form class="mb-4" autocomplete="off">
47-
<?php if(isset($_GET['client_id'])) { ?>
49+
<?php if ($client_url) { ?>
4850
<input type="hidden" name="client_id" value="<?php echo $client_id; ?>">
4951
<?php } ?>
5052
<div class="row">
@@ -115,7 +117,7 @@
115117
Scope <?php if ($sort == 'recurring_scope') { echo $order_icon; } ?>
116118
</a>
117119
</th>
118-
<?php if (!isset($_GET['client_id'])) { ?>
120+
<?php if (!$client_url) { ?>
119121
<th>
120122
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=client_name&order=<?php echo $disp; ?>">
121123
Client <?php if ($sort == 'client_name') { echo $order_icon; } ?>
@@ -208,13 +210,13 @@
208210

209211
<tr>
210212
<td class="text-bold">
211-
<a href="recurring_invoice.php?recurring_id=<?php echo $recurring_id; ?><?php if (isset($_GET['client_id'])) { echo "&client_id=$client_id"; } ?>">
213+
<a href="recurring_invoice.php?<?php echo $client_url; ?>recurring_id=<?php echo $recurring_id; ?>">
212214
<?php echo "$recurring_prefix$recurring_number"; ?>
213215
</a>
214216
</td>
215217
<td class="text-bold"><?php echo $recurring_next_date; ?></td>
216218
<td><?php echo $recurring_scope; ?></td>
217-
<?php if (!isset($_GET['client_id'])) { ?>
219+
<?php if (!$client_url) { ?>
218220
<td class="text-bold"><a href="recurring_invoices.php?client_id=<?php echo $client_id; ?>"><?php echo $client_name; ?></a></td>
219221
<?php } ?>
220222
<td class="text-bold text-right"><?php echo numfmt_format_currency($currency_format, $recurring_amount, $recurring_currency_code); ?></td>

recurring_tickets.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
if (isset($_GET['client_id'])) {
99
require_once "includes/inc_all_client.php";
1010
$client_query = "AND scheduled_ticket_client_id = $client_id";
11+
$client_url = "client_id=$client_id&";
1112
} else {
1213
require_once "includes/inc_all.php";
1314
$client_query = '';
15+
$client_url = '';
1416
}
1517

1618
// Perms
@@ -67,7 +69,7 @@
6769
<div class="card-body">
6870

6971
<form autocomplete="off">
70-
<?php if(isset($_GET['client_id'])) { ?>
72+
<?php if ($client_url) { ?>
7173
<input type="hidden" name="client_id" value="<?php echo $client_id; ?>">
7274
<?php } ?>
7375
<div class="row">
@@ -115,7 +117,7 @@
115117
<input class="form-check-input" id="selectAllCheckbox" type="checkbox" onclick="checkAll(this)">
116118
</div>
117119
</td>
118-
<?php if (!isset($_GET['client_id'])) { ?>
120+
<?php if (!$client_url) { ?>
119121
<th>
120122
<a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=client_name&order=<?php echo $disp; ?>">
121123
Client <?php if ($sort == 'client_name') { echo $order_icon; } ?>
@@ -169,7 +171,7 @@
169171
</div>
170172
</td>
171173

172-
<?php if (!isset($_GET['client_id'])) { ?>
174+
<?php if (!$client_url) { ?>
173175
<th><a href="recurring_tickets.php?client_id=<?php echo $scheduled_ticket_client_id; ?>"><?php echo $scheduled_ticket_client_name ?></a>
174176
</th>
175177
<?php } ?>

tickets.php

+8-6
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
if (isset($_GET['client_id'])) {
1010
require_once "includes/inc_all_client.php";
1111
$client_query = "AND ticket_client_id = $client_id";
12+
$client_url = "client_id=$client_id&";
1213
} else {
1314
require_once "includes/inc_all.php";
1415
$client_query = '';
16+
$client_url = '';
1517
}
1618

1719
// Perms
@@ -154,8 +156,8 @@
154156
<div class="card-header py-2">
155157
<h3 class="card-title mt-2"><i class="fa fa-fw fa-life-ring mr-2"></i>Tickets
156158
<small class="ml-3">
157-
<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> |
158-
<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>
159+
<a href="?<?php echo $client_url; ?>status=Open" class="text-light"><strong><?php echo $total_tickets_open; ?></strong> Open</a> |
160+
<a href="?<?php echo $client_url; ?>status=Closed" class="text-light"><strong><?php echo $total_tickets_closed; ?></strong> Closed</a>
159161
</small>
160162
</h3>
161163
<div class="card-tools">
@@ -176,7 +178,7 @@
176178
</div>
177179
<div class="card-body">
178180
<form autocomplete="off">
179-
<?php if(isset($_GET['client_id'])) { ?>
181+
<?php if ($client_url) { ?>
180182
<input type="hidden" name="client_id" value="<?php echo $client_id; ?>">
181183
<?php } ?>
182184
<div class="row">
@@ -229,12 +231,12 @@
229231
<i class="fa fa-fw fa-envelope mr-2"></i>My Tickets
230232
</button>
231233
<div class="dropdown-menu">
232-
<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>
234+
<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>
233235
<div class="dropdown-divider"></div>
234-
<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>
236+
<a class="dropdown-item " href="?<?php echo $client_url; ?>status=Closed&assigned=<?php echo $session_user_id ?>">Closed tickets</a>
235237
</div>
236238
</div>
237-
<a href="?<?php if (isset($_GET['client_id'])) { echo "client_id=$client_id&"; } ?>assigned=unassigned" class="btn btn-outline-danger">
239+
<a href="?<?php echo $client_url; ?>assigned=unassigned" class="btn btn-outline-danger">
238240
<i class="fa fa-fw fa-exclamation-triangle mr-2"></i>Unassigned Tickets | <strong> <?php echo $total_tickets_unassigned; ?></strong>
239241
</a>
240242

tickets_compact.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@
1818
Ticket <?php if ($sort == 'ticket_subject') { echo $order_icon; } ?>
1919
</a>
2020
</th>
21-
<?php if (!isset($_GET['client_id'])) { ?>
21+
<?php if (!$client_url) { ?>
2222
<th scope="col">
2323
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=client_name&order=<?php echo $disp; ?>">
2424
Client <?php if ($sort == 'client_name') { echo $order_icon; } ?>
2525
</a>
2626
</th>
2727
<?php } ?>
28-
<?php if (isset($_GET['client_id'])) { ?>
28+
<?php if ($client_url) { ?>
2929
<th scope="col">
30-
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=client_name&order=<?php echo $disp; ?>">
31-
Client <?php if ($sort == 'contact_name') { echo $order_icon; } ?>
30+
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=contact_name&order=<?php echo $disp; ?>">
31+
Contact <?php if ($sort == 'contact_name') { echo $order_icon; } ?>
3232
</a>
3333
</th>
3434
<?php } ?>
@@ -201,7 +201,7 @@
201201
</div>
202202

203203

204-
<a href="ticket.php?ticket_id=<?php echo $ticket_id; ?><?php if (isset($_GET['client_id'])) { echo "&client_id=$client_id"; } ?>">
204+
<a href="ticket.php?<?php echo $client_url; ?>ticket_id=<?php echo $ticket_id; ?>">
205205
<?php
206206
if (empty($ticket_closed_at) && $ticket_reply_type == "Client") {
207207
echo "<strong>$ticket_subject</strong>";
@@ -230,7 +230,7 @@
230230

231231
<!-- Ticket Contact -->
232232
<td>
233-
<?php if (!isset($_GET['client_id'])) { ?>
233+
<?php if (!$client_url) { ?>
234234
<a href="tickets.php?client_id=<?php echo $client_id; ?>"><strong><?php echo $client_name; ?></strong></a>
235235
<?php } ?>
236236
<div><?php echo $contact_display; ?></div>

tickets_kanban.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class="task"
111111

112112
<b>
113113
<?php
114-
if (!isset($_GET['client_id'])) {
114+
if (!$client_url) {
115115
if ($item['contact_name'] != ""){
116116
echo $item['client_name'] . ' - ' . $item['contact_name'];
117117
} else {

0 commit comments

Comments
 (0)