Skip to content

Commit 4d7d9ba

Browse files
author
wrongecho
committed
Tidy up the ticket_invoice_add_modal
1 parent 6d6689e commit 4d7d9ba

File tree

1 file changed

+16
-49
lines changed

1 file changed

+16
-49
lines changed

ticket_invoice_add_modal.php

Lines changed: 16 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
<?php
2-
// Check if ticket_id and invoice_id are set in the URL
3-
$addToExistingInvoice = isset($_GET['ticket_id']) && isset($_GET['invoice_id']);
42
$sql_invoices = mysqli_query($mysqli, "SELECT * FROM invoices WHERE invoice_status LIKE 'Draft' AND invoice_client_id = $client_id ORDER BY invoice_number ASC");
53

64
?>
@@ -17,45 +15,27 @@
1715
<form action="post.php" method="post" autocomplete="off">
1816
<input type="hidden" name="ticket_id" value="<?php echo $ticket_id; ?>">
1917
<div class="modal-body bg-white">
20-
<?php
21-
if (mysqli_num_rows($sql_invoices) > 0) {
22-
?>
23-
18+
<?php if (mysqli_num_rows($sql_invoices) > 0) { ?>
19+
2420
<ul class="nav nav-pills nav-justified mb-3">
2521
<li class="nav-item">
26-
<?php if (!$addToExistingInvoice): ?>
27-
<a class="nav-link active" data-toggle="pill" href="#pills-create-invoice"><i class="fa fa-fw fa-check mr-2"></i>Create New Invoice</a>
28-
<?php else: ?>
29-
<a class="nav-link" data-toggle="pill" href="#pills-create-invoice"><i class="fa fa-fw fa-check mr-2"></i>Create New Invoice</a>
30-
<?php endif; ?>
22+
<a class="nav-link active" data-toggle="pill" href="#pills-create-invoice"><i class="fa fa-fw fa-check mr-2"></i>Create New Invoice</a>
3123
</li>
3224
<li class="nav-item">
33-
<?php if ($addToExistingInvoice): ?>
34-
<a class="nav-link active" data-toggle="pill" href="#pills-add-to-invoice"><i class="fa fa-fw fa-plus mr-2"></i>Add to Existing Invoice</a>
35-
<?php else: ?>
36-
<a class="nav-link" data-toggle="pill" href="#pills-add-to-invoice"><i class="fa fa-fw fa-plus mr-2"></i>Add to Existing Invoice</a>
37-
<?php endif; ?>
25+
<a class="nav-link" data-toggle="pill" href="#pills-add-to-invoice"><i class="fa fa-fw fa-plus mr-2"></i>Add to Existing Invoice</a>
3826
</li>
39-
<?php
40-
} else {
41-
?>
27+
<?php } else { ?>
4228
<div class="alert alert-warning" role="alert">
4329
<i class="fa fa-fw fa-exclamation-triangle mr-2"></i>No draft invoices found. Please create a new invoice first.
4430
</div>
45-
<?php
46-
}
47-
?>
31+
<?php } ?>
4832
</ul>
4933

5034
<hr>
5135

5236
<div class="tab-content">
5337

54-
<?php if (!$addToExistingInvoice): ?>
5538
<div class="tab-pane fade show active" id="pills-create-invoice">
56-
<?php else: ?>
57-
<div class="tab-pane fade" id="pills-create-invoice">
58-
<?php endif; ?>
5939

6040
<div class="form-group">
6141
<label>Invoice Date <strong class="text-danger">*</strong></label>
@@ -109,12 +89,9 @@
10989

11090
<?php
11191

112-
if (mysqli_num_rows($sql_invoices) > 0) {
113-
if ($addToExistingInvoice): ?>
92+
if (mysqli_num_rows($sql_invoices) > 0) { ?>
93+
11494
<div class="tab-pane fade show active" id="pills-add-to-invoice">
115-
<?php else: ?>
116-
<div class="tab-pane fade" id="pills-add-to-invoice">
117-
<?php endif;?>
11895
<div class="form-group">
11996
<label>Invoice</label>
12097
<div class="input-group">
@@ -134,27 +111,20 @@
134111
$invoice_date = nullable_htmlentities($row['invoice_date']);
135112
$invoice_due = nullable_htmlentities($row['invoice_due']);
136113
$invoice_amount = floatval($row['invoice_amount']);
137-
138-
139-
if ($invoice_status == "Draft") {
140-
141114
?>
142-
<option value="<?php echo $invoice_id; ?>" <?php if ($invoice_id == $_GET['invoice_id']) {
143-
echo "selected";
144-
}?>><?php echo "$invoice_prefix$invoice_number $invoice_scope"; ?></option>
145-
<?php
146-
}
147-
}
148-
?>
115+
<option value="<?php echo $invoice_id; ?>"><?php echo "$invoice_prefix$invoice_number | $invoice_scope"; ?></option>
116+
<?php } ?>
117+
149118
</select>
150119
</div>
151120
</div>
152121
</div>
153-
<?php
154-
}
155-
?>
122+
123+
<?php } ?>
156124
</div>
125+
157126
<hr>
127+
158128
<div class="form-group">
159129
<label>Item <strong class="text-danger">*</strong></label>
160130
<div class="input-group">
@@ -222,10 +192,7 @@
222192
$tax_percent = floatval($row['tax_percent']);
223193
?>
224194
<option value="<?php echo $tax_id_select; ?>"><?php echo "$tax_name $tax_percent%"; ?></option>
225-
226-
<?php
227-
}
228-
?>
195+
<?php } ?>
229196
</select>
230197

231198
</div>

0 commit comments

Comments
 (0)