Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tidy up the ticket_invoice_add_modal #1082

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 16 additions & 49 deletions ticket_invoice_add_modal.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?php
// Check if ticket_id and invoice_id are set in the URL
$addToExistingInvoice = isset($_GET['ticket_id']) && isset($_GET['invoice_id']);
$sql_invoices = mysqli_query($mysqli, "SELECT * FROM invoices WHERE invoice_status LIKE 'Draft' AND invoice_client_id = $client_id ORDER BY invoice_number ASC");

?>
Expand All @@ -17,45 +15,27 @@
<form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="ticket_id" value="<?php echo $ticket_id; ?>">
<div class="modal-body bg-white">
<?php
if (mysqli_num_rows($sql_invoices) > 0) {
?>

<?php if (mysqli_num_rows($sql_invoices) > 0) { ?>

<ul class="nav nav-pills nav-justified mb-3">
<li class="nav-item">
<?php if (!$addToExistingInvoice): ?>
<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>
<?php else: ?>
<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>
<?php endif; ?>
<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>
</li>
<li class="nav-item">
<?php if ($addToExistingInvoice): ?>
<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>
<?php else: ?>
<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>
<?php endif; ?>
<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>
</li>
<?php
} else {
?>
<?php } else { ?>
<div class="alert alert-warning" role="alert">
<i class="fa fa-fw fa-exclamation-triangle mr-2"></i>No draft invoices found. Please create a new invoice first.
</div>
<?php
}
?>
<?php } ?>
</ul>

<hr>

<div class="tab-content">

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

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

<?php

if (mysqli_num_rows($sql_invoices) > 0) {
if ($addToExistingInvoice): ?>
if (mysqli_num_rows($sql_invoices) > 0) { ?>

<div class="tab-pane fade show active" id="pills-add-to-invoice">
<?php else: ?>
<div class="tab-pane fade" id="pills-add-to-invoice">
<?php endif;?>
<div class="form-group">
<label>Invoice</label>
<div class="input-group">
Expand All @@ -134,27 +111,20 @@
$invoice_date = nullable_htmlentities($row['invoice_date']);
$invoice_due = nullable_htmlentities($row['invoice_due']);
$invoice_amount = floatval($row['invoice_amount']);


if ($invoice_status == "Draft") {

?>
<option value="<?php echo $invoice_id; ?>" <?php if ($invoice_id == $_GET['invoice_id']) {
echo "selected";
}?>><?php echo "$invoice_prefix$invoice_number $invoice_scope"; ?></option>
<?php
}
}
?>
<option value="<?php echo $invoice_id; ?>"><?php echo "$invoice_prefix$invoice_number | $invoice_scope"; ?></option>
<?php } ?>

</select>
</div>
</div>
</div>
<?php
}
?>

<?php } ?>
</div>

<hr>

<div class="form-group">
<label>Item <strong class="text-danger">*</strong></label>
<div class="input-group">
Expand Down Expand Up @@ -222,10 +192,7 @@
$tax_percent = floatval($row['tax_percent']);
?>
<option value="<?php echo $tax_id_select; ?>"><?php echo "$tax_name $tax_percent%"; ?></option>

<?php
}
?>
<?php } ?>
</select>

</div>
Expand Down
Loading