mirror of https://github.com/itflow-org/itflow
Added cancelled status to invoice, invoice copy now works, minor ui cleanups, added tickets to client page
This commit is contained in:
parent
f44b9b19fa
commit
13c330d3b1
|
|
@ -2,7 +2,7 @@
|
|||
<div class="modal-dialog">
|
||||
<div class="modal-content bg-dark">
|
||||
<div class="modal-header text-white">
|
||||
<h5 class="modal-title"><i class="fa fa-fw fa-tag mr-2"></i>New Asset</h5>
|
||||
<h5 class="modal-title"><i class="fa fa-fw fa-laptop mr-2"></i>New Asset</h5>
|
||||
<button type="button" class="close text-white" data-dismiss="modal">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
<div class="modal" id="addInvoiceCopyModal<?php echo $invoice_id; ?>" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content bg-dark">
|
||||
<div class="modal-header text-white">
|
||||
<h5 class="modal-title"><i class="fa fa-fw fa-copy mr-2"></i>Copying INV-<?php echo $invoice_number; ?></h5>
|
||||
<button type="button" class="close text-white" data-dismiss="modal">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<form action="post.php" method="post" autocomplete="off">
|
||||
<input type="hidden" name="invoice_id" value="<?php echo $invoice_id; ?>">
|
||||
<div class="modal-body bg-white">
|
||||
|
||||
<div class="form-group">
|
||||
<label>Invoice Date</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-calendar"></i></span>
|
||||
</div>
|
||||
<input type="date" class="form-control" name="date" value="<?php echo date("Y-m-d"); ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Payment Due</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-calendar-alt"></i></span>
|
||||
</div>
|
||||
<input type="date" class="form-control" name="due" required>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer bg-white">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
|
||||
<button type="submit" name="add_invoice_copy" class="btn btn-primary">Save</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
</div>
|
||||
<form action="post.php" method="post" autocomplete="off">
|
||||
<div class="modal-body bg-white">
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label>Client</label>
|
||||
<div class="input-group">
|
||||
|
|
|
|||
16
client.php
16
client.php
|
|
@ -22,7 +22,7 @@ if(isset($_GET['client_id'])){
|
|||
$client_net_terms = $row['client_net_terms'];
|
||||
|
||||
//Add up all the payments for the invoice and get the total amount paid to the invoice
|
||||
$sql_invoice_amounts = mysqli_query($mysqli,"SELECT SUM(invoice_amount) AS invoice_amounts FROM invoices WHERE client_id = $client_id AND invoice_status NOT LIKE 'Draft'");
|
||||
$sql_invoice_amounts = mysqli_query($mysqli,"SELECT SUM(invoice_amount) AS invoice_amounts FROM invoices WHERE client_id = $client_id AND invoice_status NOT LIKE 'Draft' AND invoice_status NOT LIKE 'Cancelled'");
|
||||
$row = mysqli_fetch_array($sql_invoice_amounts);
|
||||
|
||||
$invoice_amounts = $row['invoice_amounts'];
|
||||
|
|
@ -44,6 +44,9 @@ if(isset($_GET['client_id'])){
|
|||
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('client_asset_id') AS num FROM client_assets WHERE client_id = $client_id"));
|
||||
$num_assets = $row['num'];
|
||||
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('ticket_id') AS num FROM tickets WHERE client_id = $client_id"));
|
||||
$num_tickets = $row['num'];
|
||||
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('client_vendor_id') AS num FROM client_vendors WHERE client_id = $client_id"));
|
||||
$num_vendors = $row['num'];
|
||||
|
|
@ -88,9 +91,8 @@ if(isset($_GET['client_id'])){
|
|||
<div class="col">
|
||||
<h4 class="text-secondary">Address</h4>
|
||||
<a href="//maps.<?php echo $session_map_source; ?>.com/?q=<?php echo "$client_address $client_zip"; ?>" target="_blank">
|
||||
<?php echo $client_address; ?>
|
||||
<br>
|
||||
<?php echo "$client_city $client_state $client_zip"; ?>
|
||||
<div class="ml-1"><?php echo $client_address; ?></div>
|
||||
<div class="ml-1"><?php echo "$client_city $client_state $client_zip"; ?></div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col border-left">
|
||||
|
|
@ -116,10 +118,10 @@ if(isset($_GET['client_id'])){
|
|||
</div>
|
||||
<div class="col border-left">
|
||||
<h4 class="text-secondary">Standings</h4>
|
||||
<h6>Paid to Date <small class="text-secondary ml-5">$<?php echo number_format($amount_paid,2); ?></small>
|
||||
<h6>Balance <small class="text-secondary ml-5">$<?php echo number_format($balance,2); ?></small>
|
||||
<h6 class="ml-1">Paid <div class="text-secondary float-right">$<?php echo number_format($amount_paid,2); ?></div></h6>
|
||||
<h6 class="ml-1">Balance <div class="text-secondary float-right">$<?php echo number_format($balance,2); ?></div></h6>
|
||||
</div>
|
||||
<div class="col-1 border-left">
|
||||
<div class="col border-left">
|
||||
<div class="dropdown dropleft text-center">
|
||||
<button class="btn btn-dark btn-sm float-right" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="fas fa-fw fa-ellipsis-v"></i>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h6 class="float-left mt-1"><i class="fa fa-tags"></i> Assets</h6>
|
||||
<h6 class="float-left mt-1"><i class="fa fa-laptop"></i> Assets</h6>
|
||||
<button class="btn btn-primary btn-sm float-right" data-toggle="modal" data-target="#addClientAssetModal"><i class="fa fa-plus"></i></button>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
|
|
|
|||
|
|
@ -27,7 +27,15 @@
|
|||
$client_domain_registrar = $row['client_domain_registrar'];
|
||||
$client_domain_webhost = $row['client_domain_webhost'];
|
||||
$client_domain_expire = $row['client_domain_expire'];
|
||||
|
||||
|
||||
$sql_client_domain_registrar = mysqli_query($mysqli,"SELECT client_vendor_name FROM client_vendors WHERE client_vendor_id = $client_domain_registrar");
|
||||
$row = mysqli_fetch_array($sql_client_domain_registrar);
|
||||
$client_domain_registrar = $row['client_vendor_name'];
|
||||
|
||||
$sql_client_domain_webhost = mysqli_query($mysqli,"SELECT client_vendor_name FROM client_vendors WHERE client_vendor_id = $client_domain_webhost");
|
||||
$row = mysqli_fetch_array($sql_client_domain_webhost);
|
||||
$client_domain_webhost = $row['client_vendor_name'];
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<td><?php echo $client_domain_name; ?></td>
|
||||
|
|
|
|||
|
|
@ -33,16 +33,13 @@
|
|||
$invoice_date = $row['invoice_date'];
|
||||
$invoice_due = $row['invoice_due'];
|
||||
$invoice_amount = $row['invoice_amount'];
|
||||
$category_id = $row['category_id'];
|
||||
$invoice_category_id = $row['category_id'];
|
||||
$now = time();
|
||||
|
||||
if(($invoice_status == "Sent" or $invoice_status == "Partial") and strtotime($invoice_due) < $now ){
|
||||
$overdue_color = "text-danger font-weight-bold";
|
||||
$overdue_badge = "badge-danger";
|
||||
$invoice_status = "Overdue";
|
||||
}else{
|
||||
$overdue_color = "";
|
||||
$overdue_badge = "";
|
||||
}
|
||||
|
||||
//Set Badge color based off of invoice status
|
||||
|
|
@ -52,7 +49,7 @@
|
|||
$invoice_badge_color = "primary";
|
||||
}elseif($invoice_status == "Paid"){
|
||||
$invoice_badge_color = "success";
|
||||
}elseif($invoice_status == "Overdue"){
|
||||
}elseif($invoice_status == "Cancelled"){
|
||||
$invoice_badge_color = "danger";
|
||||
}else{
|
||||
$invoice_badge_color = "secondary";
|
||||
|
|
@ -66,7 +63,7 @@
|
|||
<td><?php echo $invoice_date; ?></td>
|
||||
<td><div class="<?php echo $overdue_color; ?>"><?php echo $invoice_due; ?></div></td>
|
||||
<td>
|
||||
<span class="p-2 badge badge-<?php echo $invoice_badge_color; ?> echo $overdue_badge;">
|
||||
<span class="p-2 badge badge-<?php echo $invoice_badge_color; ?>">
|
||||
<?php echo $invoice_status; ?>
|
||||
</span>
|
||||
</td>
|
||||
|
|
@ -77,7 +74,7 @@
|
|||
</button>
|
||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#editInvoiceModal<?php echo $invoice_id; ?>">Edit</a>
|
||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addinvoiceCopyModal<?php echo $invoice_id; ?>">Copy</a>
|
||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addInvoiceCopyModal<?php echo $invoice_id; ?>">Copy</a>
|
||||
<a class="dropdown-item" href="post.php?email_invoice=<?php echo $invoice_id; ?>">Send</a>
|
||||
<a class="dropdown-item" href="post.php?pdf_invoice=<?php echo $invoice_id; ?>">PDF</a>
|
||||
<a class="dropdown-item" href="post.php?delete_invoice=<?php echo $invoice_id; ?>">Delete</a>
|
||||
|
|
@ -89,7 +86,7 @@
|
|||
<?php
|
||||
|
||||
include("edit_invoice_modal.php");
|
||||
//include("add_invoice_copy_modal.php");
|
||||
include("add_invoice_copy_modal.php");
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ if(isset($_GET['client_id'])){
|
|||
WHERE invoices.client_id = $client_id
|
||||
AND payments.invoice_id = invoices.invoice_id
|
||||
AND payments.account_id = accounts.account_id
|
||||
ORDER BY payments.payment_id DESC");
|
||||
ORDER BY invoices.invoice_number DESC");
|
||||
|
||||
$sql_quotes = mysqli_query($mysqli,"SELECT * FROM quotes WHERE client_id = $client_id ORDER BY quote_number DESC");
|
||||
|
||||
|
|
@ -474,16 +474,16 @@ if(isset($_GET['client_id'])){
|
|||
$invoice_status = $row['invoice_status'];
|
||||
$invoice_date = $row['invoice_date'];
|
||||
$invoice_due = $row['invoice_due'];
|
||||
$invoice_balance = $row['invoice_balance'];
|
||||
$invoice_amount = $row['invoice_amount'];
|
||||
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<td>INV-<?php echo "$invoice_number"; ?></td>
|
||||
<td class="text-right text-monospace">$<?php echo number_format($invoice_balance,2); ?></td>
|
||||
<td><?php echo "$invoice_date"; ?></td>
|
||||
<td><?php echo "$invoice_due"; ?></td>
|
||||
<td><?php echo "$invoice_status"; ?></td>
|
||||
<td>INV-<?php echo $invoice_number; ?></td>
|
||||
<td class="text-right text-monospace">$<?php echo number_format($invoice_amount,2); ?></td>
|
||||
<td><?php echo $invoice_date; ?></td>
|
||||
<td><?php echo $invoice_due; ?></td>
|
||||
<td><?php echo $invoice_status; ?></td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ if(isset($_GET['tab'])){
|
|||
elseif($_GET['tab'] == "assets"){
|
||||
include("client_assets.php");
|
||||
}
|
||||
elseif($_GET['tab'] == "tickets"){
|
||||
include("client_tickets.php");
|
||||
}
|
||||
elseif($_GET['tab'] == "vendors"){
|
||||
include("client_vendors.php");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@
|
|||
<li class="nav-item <?php if($_GET['tab'] == "assets") { echo "active"; } ?>">
|
||||
<a class="nav-link"
|
||||
href="?client_id=<?php echo $client_id; ?>&tab=assets">
|
||||
<i class="fas fa-fw fa-tag mx-2"></i>
|
||||
<i class="fas fa-fw fa-laptop mx-2"></i>
|
||||
<span>Assets
|
||||
<?php
|
||||
if($num_assets > 0){ ?>
|
||||
|
|
@ -68,6 +68,21 @@
|
|||
</span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li class="nav-item <?php if($_GET['tab'] == "tickets") { echo "active"; } ?>">
|
||||
<a class="nav-link"
|
||||
href="?client_id=<?php echo $client_id; ?>&tab=tickets">
|
||||
<i class="fas fa-fw fa-tags mx-2"></i>
|
||||
<span>Tickets
|
||||
<?php
|
||||
if($num_tickets > 0){ ?>
|
||||
<small class="float-right badge-secondary badge-pill mt-1"><?php echo $num_tickets; ?></small>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li class="nav-item <?php if($_GET['tab'] == "vendors") { echo "active"; } ?>">
|
||||
<a class="nav-link"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,81 @@
|
|||
<?php $sql = mysqli_query($mysqli,"SELECT * FROM tickets WHERE client_id = $client_id ORDER BY ticket_id DESC"); ?>
|
||||
|
||||
<div class="card mb-3">
|
||||
<div class="card-header">
|
||||
<h5 class="float-left mt-2"><i class="fa fa-fw fa-tags mr-2"></i>Tickets</h5>
|
||||
<button type="button" class="btn btn-primary badge-pill float-right" data-toggle="modal" data-target="#addTicketModal"><i class="fas fa-fw fa-plus"></i></button>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-borderless table-hover" id="dataTable" width="100%" cellspacing="0">
|
||||
<thead class="thead-dark">
|
||||
<tr>
|
||||
<th>Number</th>
|
||||
<th>Subject</th>
|
||||
<th>Date Opened</th>
|
||||
<th>Status</th>
|
||||
<th class="text-center">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
|
||||
while($row = mysqli_fetch_array($sql)){
|
||||
$ticket_id = $row['ticket_id'];
|
||||
$ticket_subject = $row['ticket_subject'];
|
||||
$ticket_details = $row['ticket_details'];
|
||||
$ticket_status = $row['ticket_status'];
|
||||
$ticket_created_at = $row['ticket_created_at'];
|
||||
$ticket_updated_at = $row['ticket_updated_at'];
|
||||
$ticket_closed_at = $row['ticket_closed_at'];
|
||||
|
||||
if($ticket_status == "Open"){
|
||||
$ticket_badge_color = "primary";
|
||||
}elseif($ticket_status == "Resolved"){
|
||||
$ticket_badge_color = "success";
|
||||
}elseif($ticket_status == "Closed"){
|
||||
$ticket_badge_color = "secondary";
|
||||
}else{
|
||||
$ticket_badge_color = "info";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<td><a href="#" data-toggle="modal" data-target="#viewTicketModal<?php echo $ticket_id; ?>"><span class="badge badge-pill badge-secondary p-3"><?php echo $ticket_id; ?></span></a></td>
|
||||
<td><?php echo $ticket_subject; ?></td>
|
||||
<td><?php echo $ticket_created_at; ?></td>
|
||||
<td>
|
||||
<span class="p-2 badge badge-<?php echo $ticket_badge_color; ?>">
|
||||
<?php echo $ticket_status; ?>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<div class="dropdown dropleft text-center">
|
||||
<button class="btn btn-secondary btn-sm" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="fas fa-ellipsis-h"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#viewTicketModal<?php echo $ticket_id; ?>">Details</a>
|
||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#editTicketModal<?php echo $ticket_id; ?>">Edit</a>
|
||||
<a class="dropdown-item" href="post.php?delete_invoice=<?php echo $invoice_id; ?>">Delete</a>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
|
||||
include("edit_ticket_modal.php");
|
||||
include("view_ticket_modal.php");
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include("add_ticket_modal.php"); ?>
|
||||
|
|
@ -61,7 +61,7 @@
|
|||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-clock"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="hours" placeholder="Hours of operation" value="<?php echo $client_location_hours; ?> ">
|
||||
<input type="text" class="form-control" name="hours" placeholder="Hours of operation" value="<?php echo $client_location_hours; ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@
|
|||
<?php
|
||||
|
||||
$sql_income_category = mysqli_query($mysqli,"SELECT * FROM categories WHERE category_type = 'Income'");
|
||||
while($row = mysqli_fetch_array($income_category)){
|
||||
while($row = mysqli_fetch_array($sql_income_category)){
|
||||
$category_id = $row['category_id'];
|
||||
$category_name = $row['category_name'];
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
<div class="modal" id="editTicketModal<?php echo $ticket_id; ?>" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content bg-dark">
|
||||
<div class="modal-header text-white">
|
||||
<h5 class="modal-title"><i class="fa fa-fw fa-tag mr-2"></i>Edit Ticket # <?php echo $ticket_id; ?></h5>
|
||||
<button type="button" class="close text-white" data-dismiss="modal">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<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">
|
||||
|
||||
<div class="form-group">
|
||||
<label>Client</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-user"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" value="<?php echo $client_name; ?>" disabled>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Subject</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-tag"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="subject" value="<?php echo $ticket_subject; ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Details</label>
|
||||
<textarea class="form-control" rows="8" name="details" required><?php echo $ticket_details; ?></textarea>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer bg-white">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
|
||||
<button type="submit" name="edit_ticket" class="btn btn-primary">Save</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
21
invoice.php
21
invoice.php
|
|
@ -59,7 +59,7 @@ if(isset($_GET['invoice_id'])){
|
|||
$invoice_badge_color = "primary";
|
||||
}elseif($invoice_status == "Paid"){
|
||||
$invoice_badge_color = "success";
|
||||
}elseif($invoice_status == "Overdue"){
|
||||
}elseif($invoice_status == "Cancelled"){
|
||||
$invoice_badge_color = "danger";
|
||||
}else{
|
||||
$invoice_badge_color = "secondary";
|
||||
|
|
@ -86,18 +86,20 @@ if(isset($_GET['invoice_id'])){
|
|||
<div class="col-md-8">
|
||||
<div class="dropdown dropleft text-center">
|
||||
<button class="btn btn-primary btn-sm float-right" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="fas fa-ellipsis-h"></i>
|
||||
<i class="fas fa-fw fa-ellipsis-v"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#editInvoiceModal">Edit</a>
|
||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addinvoiceCopyModal<?php echo $invoice_id; ?>">Copy</a>
|
||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addinvoiceCopyModal<?php echo $invoice_id; ?>">Recurring</a>
|
||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#editInvoiceModal<?php echo $invoice_id; ?>">Edit</a>
|
||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addInvoiceCopyModal<?php echo $invoice_id; ?>">Copy</a>
|
||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addInvoiceCopyModal<?php echo $invoice_id; ?>">Recurring</a>
|
||||
<a class="dropdown-item" href="post.php?email_invoice=<?php echo $invoice_id; ?>">Send</a>
|
||||
<?php if($invoice_status == "Draft"){ ?><a class="dropdown-item" href="post.php?mark_invoice_sent=<?php echo $invoice_id; ?>">Mark Sent</a><?php } ?>
|
||||
<?php if($invoice_status !== "Paid"){ ?><a class="dropdown-item" href="#" data-toggle="modal" data-target="#addPaymentModal">Add Payment</a><?php } ?>
|
||||
<?php if($invoice_status == 'Draft'){ ?><a class="dropdown-item" href="post.php?mark_invoice_sent=<?php echo $invoice_id; ?>">Mark Sent</a><?php } ?>
|
||||
<?php if($invoice_status !== 'Paid' and $invoice_status !== 'Cancelled'){ ?><a class="dropdown-item" href="#" data-toggle="modal" data-target="#addPaymentModal">Add Payment</a><?php } ?>
|
||||
<a class="dropdown-item" href="#" onclick="window.print();">Print</a>
|
||||
<a class="dropdown-item" href="post.php?pdf_invoice=<?php echo $invoice_id; ?>">PDF</a>
|
||||
<a class="dropdown-item" href="#">Delete</a>
|
||||
<?php if($invoice_status !== 'Cancelled' and $invoice_status !== 'Paid'){ ?>
|
||||
<a class="dropdown-item" href="post.php?cancel_invoice=<?php echo $invoice_id; ?>">Cancel</a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -191,7 +193,7 @@ if(isset($_GET['invoice_id'])){
|
|||
?>
|
||||
|
||||
<tr>
|
||||
<td class="text-center d-print-none"><a class="btn btn-danger btn-sm" href="post.php?delete_invoice_item=<?php echo $invoice_item_id; ?>"><i class="fa fa-trash"></i></a></td>
|
||||
<td class="text-center d-print-none"><a class="btn btn-sm btn-danger" href="post.php?delete_invoice_item=<?php echo $invoice_item_id; ?>"><i class="fa fa-trash"></i></a></td>
|
||||
<td><?php echo $invoice_item_name; ?></td>
|
||||
<td><?php echo $invoice_item_description; ?></td>
|
||||
<td class="text-right text-monospace">$<?php echo number_format($invoice_item_price,2); ?></td>
|
||||
|
|
@ -361,6 +363,7 @@ if(isset($_GET['invoice_id'])){
|
|||
|
||||
<?php include("add_payment_modal.php"); ?>
|
||||
<?php include("edit_invoice_modal.php"); ?>
|
||||
<?php include("add_invoice_copy_modal.php"); ?>
|
||||
<?php } ?>
|
||||
|
||||
<?php include("footer.php"); ?>
|
||||
|
|
|
|||
25
invoices.php
25
invoices.php
|
|
@ -11,12 +11,23 @@
|
|||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('invoice_id') AS num FROM invoices WHERE invoice_status = 'Draft'"));
|
||||
$draft_count = $row['num'];
|
||||
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('invoice_id') AS num FROM invoices WHERE invoice_status = 'Cancelled'"));
|
||||
$cancelled_count = $row['num'];
|
||||
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('invoice_id') AS num FROM invoices WHERE invoice_due > CURDATE()"));
|
||||
$overdue_count = $row['num'];
|
||||
|
||||
$sql_total_draft = mysqli_query($mysqli,"SELECT SUM(invoice_amount) AS total_draft FROM invoices WHERE invoice_status = 'Draft'");
|
||||
$row = mysqli_fetch_array($sql_total_draft);
|
||||
$total_draft = $row['total_draft'];
|
||||
|
||||
$sql_total_sent = mysqli_query($mysqli,"SELECT SUM(invoice_amount) AS total_sent FROM invoices WHERE invoice_status = 'Sent'");
|
||||
$row = mysqli_fetch_array($sql_total_sent);
|
||||
$total_sent = $row['total_sent'];
|
||||
|
||||
$sql_total_cancelled = mysqli_query($mysqli,"SELECT SUM(invoice_amount) AS total_cancelled FROM invoices WHERE invoice_status = 'Cancelled'");
|
||||
$row = mysqli_fetch_array($sql_total_cancelled);
|
||||
$total_cancelled = $row['total_cancelled'];
|
||||
|
||||
$sql_total_partial = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS total_partial FROM payments, invoices WHERE payments.invoice_id = invoices.invoice_id AND invoices.invoice_status = 'Partial'");
|
||||
$row = mysqli_fetch_array($sql_total_partial);
|
||||
|
|
@ -66,7 +77,7 @@
|
|||
<div class="card-body-icon">
|
||||
<i class="fas fa-fw fa-pencil-ruler"></i>
|
||||
</div>
|
||||
<div class="mr-5"><?php echo $draft_count; ?> Draft <h1>$<?php echo number_format($total_paid,2); ?></h1></div>
|
||||
<div class="mr-5"><?php echo $draft_count; ?> Draft <h1>$<?php echo number_format($total_draft,2); ?></h1></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -76,7 +87,7 @@
|
|||
<div class="card-body-icon">
|
||||
<i class="fas fa-fw fa-skull-crossbones"></i>
|
||||
</div>
|
||||
<div class="mr-5"><?php echo $overdue_count; ?> Overdue <h1>$<?php echo number_format($real_overdue_amount,2); ?></h1></div>
|
||||
<div class="mr-5"><?php echo $cancelled_count; ?> Cancelled <h1>$<?php echo number_format($total_cancelled,2); ?></h1></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -113,16 +124,14 @@
|
|||
$invoice_amount = $row['invoice_amount'];
|
||||
$client_id = $row['client_id'];
|
||||
$client_name = $row['client_name'];
|
||||
$category_id = $row['category_id'];
|
||||
|
||||
$now = time();
|
||||
|
||||
if(($invoice_status == "Sent" or $invoice_status == "Partial") and strtotime($invoice_due) < $now ){
|
||||
$overdue_color = "text-danger font-weight-bold";
|
||||
$overdue_badge = "badge-danger";
|
||||
$invoice_status = "Overdue";
|
||||
}else{
|
||||
$overdue_color = "";
|
||||
$overdue_badge = "";
|
||||
}
|
||||
|
||||
//$unixtime_invoice_due = strtotime($invoice_due);
|
||||
|
|
@ -138,7 +147,7 @@
|
|||
$invoice_badge_color = "primary";
|
||||
}elseif($invoice_status == "Paid"){
|
||||
$invoice_badge_color = "success";
|
||||
}elseif($invoice_status == "Overdue"){
|
||||
}elseif($invoice_status == "Cancelled"){
|
||||
$invoice_badge_color = "danger";
|
||||
}else{
|
||||
$invoice_badge_color = "secondary";
|
||||
|
|
@ -153,7 +162,7 @@
|
|||
<td><?php echo $invoice_date; ?></td>
|
||||
<td class="<?php echo $overdue_color; ?>"><?php echo $invoice_due; ?></td>
|
||||
<td>
|
||||
<span class="p-2 badge badge-<?php echo $invoice_badge_color; ?> <?php echo $overdue_badge; ?>">
|
||||
<span class="p-2 badge badge-<?php echo $invoice_badge_color; ?>">
|
||||
<?php echo $invoice_status; ?>
|
||||
</span>
|
||||
</td>
|
||||
|
|
@ -163,7 +172,7 @@
|
|||
<i class="fas fa-ellipsis-h"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addinvoiceCopyModal<?php echo $invoice_id; ?>"><i class="fa fa-fw fa-copy"></i> Copy</a>
|
||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addInvoiceCopyModal<?php echo $invoice_id; ?>"><i class="fa fa-fw fa-copy"></i> Copy</a>
|
||||
<a class="dropdown-item" href="post.php?email_invoice=<?php echo $invoice_id; ?>"><i class="fa fa-fw fa-paper-plane"></i> Send</a>
|
||||
<a class="dropdown-item" href="post.php?pdf_invoice=<?php echo $invoice_id; ?>"><i class="fa fa-fw fa-file-pdf"></i> PDF</a>
|
||||
<a class="dropdown-item" href="post.php?delete_invoice=<?php echo $invoice_id; ?>"><i class="fa fa-fw fa-trash"></i> Delete</a>
|
||||
|
|
|
|||
78
post.php
78
post.php
|
|
@ -324,6 +324,20 @@ if(isset($_POST['add_ticket'])){
|
|||
|
||||
}
|
||||
|
||||
if(isset($_POST['edit_ticket'])){
|
||||
|
||||
$ticket_id = intval($_POST['ticket_id']);
|
||||
$subject = strip_tags(mysqli_real_escape_string($mysqli,$_POST['subject']));
|
||||
$details = strip_tags(mysqli_real_escape_string($mysqli,$_POST['details']));
|
||||
|
||||
mysqli_query($mysqli,"UPDATE tickets SET ticket_subject = '$subject', ticket_details = '$details' WHERE ticket_id = $ticket_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Ticket updated";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
|
||||
}
|
||||
|
||||
if(isset($_POST['add_vendor'])){
|
||||
|
||||
$name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']));
|
||||
|
|
@ -706,7 +720,6 @@ if(isset($_GET['delete_transfer'])){
|
|||
}
|
||||
|
||||
if(isset($_POST['add_invoice'])){
|
||||
|
||||
$client = intval($_POST['client']);
|
||||
$date = strip_tags(mysqli_real_escape_string($mysqli,$_POST['date']));
|
||||
$due = strip_tags(mysqli_real_escape_string($mysqli,$_POST['due']));
|
||||
|
|
@ -716,17 +729,12 @@ if(isset($_POST['add_invoice'])){
|
|||
$sql = mysqli_query($mysqli,"SELECT invoice_number FROM invoices ORDER BY invoice_number DESC LIMIT 1");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$invoice_number = $row['invoice_number'] + 1;
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO invoices SET invoice_number = $invoice_number, invoice_date = '$date', invoice_due = '$due', category_id = $category, invoice_status = 'Draft', client_id = $client");
|
||||
|
||||
$invoice_id = mysqli_insert_id($mysqli);
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO invoice_history SET invoice_history_date = CURDATE(), invoice_history_status = 'Draft', invoice_history_description = 'INVOICE added!', invoice_id = $invoice_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Invoice added";
|
||||
|
||||
header("Location: invoice.php?invoice_id=$invoice_id");
|
||||
|
||||
}
|
||||
|
||||
if(isset($_POST['edit_invoice'])){
|
||||
|
|
@ -744,6 +752,50 @@ if(isset($_POST['edit_invoice'])){
|
|||
|
||||
}
|
||||
|
||||
if(isset($_POST['add_invoice_copy'])){
|
||||
|
||||
$invoice_id = intval($_POST['invoice_id']);
|
||||
$date = strip_tags(mysqli_real_escape_string($mysqli,$_POST['date']));
|
||||
$due = strip_tags(mysqli_real_escape_string($mysqli,$_POST['due']));
|
||||
|
||||
//Get the last Invoice Number and add 1 for the new invoice number
|
||||
$sql = mysqli_query($mysqli,"SELECT invoice_number FROM invoices ORDER BY invoice_number DESC LIMIT 1");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$invoice_number = $row['invoice_number'] + 1;
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM invoices WHERE invoice_id = $invoice_id");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$invoice_amount = $row['invoice_amount'];
|
||||
$invoice_note = $row['invoice_note'];
|
||||
$client_id = $row['client_id'];
|
||||
$category_id = $row['category_id'];
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO invoices SET invoice_number = $invoice_number, invoice_date = '$date', invoice_due = '$due', category_id = $category_id, invoice_status = 'Draft', invoice_amount = '$invoice_amount', invoice_note = '$invoice_note', client_id = $client_id");
|
||||
|
||||
$new_invoice_id = mysqli_insert_id($mysqli);
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO invoice_history SET invoice_history_date = CURDATE(), invoice_history_status = 'Draft', invoice_history_description = 'INVOICE added!', invoice_id = $new_invoice_id");
|
||||
|
||||
$sql_invoice_items = mysqli_query($mysqli,"SELECT * FROM invoice_items WHERE invoice_id = $invoice_id");
|
||||
while($row = mysqli_fetch_array($sql_invoice_items)){
|
||||
$invoice_item_id = $row['invoice_item_id'];
|
||||
$invoice_item_name = $row['invoice_item_name'];
|
||||
$invoice_item_description = $row['invoice_item_description'];
|
||||
$invoice_item_quantity = $row['invoice_item_quantity'];
|
||||
$invoice_item_price = $row['invoice_item_price'];
|
||||
$invoice_item_subtotal = $row['invoice_item_subtotal'];
|
||||
$invoice_item_tax = $row['invoice_item_tax'];
|
||||
$invoice_item_total = $row['invoice_item_total'];
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO invoice_items SET invoice_item_name = '$invoice_item_name', invoice_item_description = '$invoice_item_description', invoice_item_quantity = $invoice_item_quantity, invoice_item_price = '$invoice_item_price', invoice_item_subtotal = '$invoice_item_subtotal', invoice_item_tax = '$invoice_item_tax', invoice_item_total = '$invoice_item_total', invoice_id = $new_invoice_id");
|
||||
}
|
||||
|
||||
$_SESSION['alert_message'] = "Invoice copied";
|
||||
|
||||
header("Location: invoice.php?invoice_id=$new_invoice_id");
|
||||
|
||||
}
|
||||
|
||||
if(isset($_POST['add_quote'])){
|
||||
|
||||
$client = intval($_POST['client']);
|
||||
|
|
@ -881,6 +933,20 @@ if(isset($_GET['mark_invoice_sent'])){
|
|||
|
||||
}
|
||||
|
||||
if(isset($_GET['cancel_invoice'])){
|
||||
|
||||
$invoice_id = intval($_GET['cancel_invoice']);
|
||||
|
||||
mysqli_query($mysqli,"UPDATE invoices SET invoice_status = 'Cancelled' WHERE invoice_id = $invoice_id");
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO invoice_history SET invoice_history_date = CURDATE(), invoice_history_status = 'Cancelled', invoice_history_description = 'INVOICE cancelled!', invoice_id = $invoice_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Invoice cancelled";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
|
||||
}
|
||||
|
||||
if(isset($_GET['delete_invoice'])){
|
||||
$invoice_id = intval($_GET['delete_invoice']);
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@
|
|||
?>
|
||||
|
||||
<tr>
|
||||
<td><a href="#" data-toggle="modal" data-target="#viewTicketModal<?php echo $ticket_id; ?>"><span class="badge badge-pill badge-secondary p-2"><?php echo $ticket_id; ?></span></a></td>
|
||||
<td><a href="#" data-toggle="modal" data-target="#viewTicketModal<?php echo $ticket_id; ?>"><span class="badge badge-pill badge-secondary p-3"><?php echo $ticket_id; ?></span></a></td>
|
||||
<td><a href="client.php?client_id=<?php echo $client_id; ?>"><?php echo $client_name; ?></a></td>
|
||||
<td><?php echo $ticket_subject; ?></td>
|
||||
<td><?php echo $ticket_created_at; ?></td>
|
||||
|
|
|
|||
|
|
@ -15,9 +15,6 @@
|
|||
<tr>
|
||||
<th>Vendor</th>
|
||||
<th>Description</th>
|
||||
<th>Phone</th>
|
||||
<th>Email</th>
|
||||
<th>Website</th>
|
||||
<th>Account Number</th>
|
||||
<th class="text-center">Actions</th>
|
||||
</tr>
|
||||
|
|
@ -46,9 +43,6 @@
|
|||
<tr>
|
||||
<td><?php echo $vendor_name; ?></td>
|
||||
<td><?php echo $vendor_description; ?></td>
|
||||
<td><?php echo $vendor_phone; ?></td>
|
||||
<td><?php echo $vendor_email; ?></td>
|
||||
<td><?php echo $vendor_website; ?></td>
|
||||
<td><?php echo $vendor_account_number; ?></td>
|
||||
<td>
|
||||
<div class="dropdown dropleft text-center">
|
||||
|
|
|
|||
Loading…
Reference in New Issue