Added alert feedback boxes, little ui fixes for quote invoice and recurring added rejected instead of cancelled for quotes, and other little ui cleanups

This commit is contained in:
root 2019-05-25 21:14:08 -04:00
parent b559b58f34
commit 889a749d88
20 changed files with 847 additions and 694 deletions

View File

@ -9,6 +9,31 @@
</div>
<form action="post.php" method="post" enctype="multipart/form-data" autocomplete="off">
<div class="modal-body bg-white">
<div class="form-group">
<label>Assign a User to a 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>
<select class="form-control" name="client" <?php if(isset($_GET['client_id'])){ echo "disabled"; } ?>>
<option value="">- Client -</option>
<?php
$sql = mysqli_query($mysqli,"SELECT * FROM clients");
while($row = mysqli_fetch_array($sql)){
$client_id = $row['client_id'];
$client_name = $row['client_name'];
?>
<option <?php if($_GET['client_id'] == $client_id) { echo "selected"; } ?> value="<?php echo "$client_id"; ?>"><?php echo "$client_name"; ?></option>
<?php
}
?>
</select>
</div>
</div>
<div class="form-group">
<label>Name</label>
<div class="input-group">

View File

@ -14,7 +14,6 @@
$session_name = $row['name'];
$session_avatar = $row['avatar'];
//Detects if using an apple device and uses apple maps instead of google
$iPod = stripos($_SERVER['HTTP_USER_AGENT'],"iPod");
$iPhone = stripos($_SERVER['HTTP_USER_AGENT'],"iPhone");

View File

@ -33,21 +33,23 @@
?>
<tr>
<?php if(!empty($contact_photo)){ ?>
<td class="text-center">
<?php if(!empty($contact_photo)){ ?>
<img height="48" width="48" class="img-fluid rounded-circle" src="<?php echo $contact_photo; ?>">
<div class="text-secondary"><?php echo $contact_name; ?></div>
</td>
<?php }else{ ?>
<td class="text-center">
<?php }else{ ?>
<span class="fa-stack fa-2x">
<i class="fa fa-circle fa-stack-2x text-secondary"></i>
<span class="fa fa-stack-1x text-white"><?php echo $contact_initials; ?></span>
</span>
<br>
<?php } ?>
<div class="text-secondary"><?php echo $contact_name; ?></div>
</td>
<?php } ?>
<td><?php echo $contact_title; ?></td>
<td><a href="mailto:<?php echo $contact_email; ?>"><?php echo $contact_email; ?></a></td>
<td><?php echo $contact_phone; ?></td>

View File

@ -34,7 +34,7 @@
$invoice_date = $row['invoice_date'];
$invoice_due = $row['invoice_due'];
$invoice_amount = $row['invoice_amount'];
$invoice_category_id = $row['category_id'];
$category_id = $row['category_id'];
$category_name = $row['category_name'];
$now = time();

View File

@ -40,7 +40,7 @@
$quote_badge_color = "primary";
}elseif($quote_status == "Approved"){
$quote_badge_color = "success";
}elseif($quote_status == "Cancelled"){
}elseif($quote_status == "Rejected"){
$quote_badge_color = "danger";
}else{
$quote_badge_color = "secondary";
@ -64,8 +64,10 @@
<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="#editquoteModal<?php echo $quote_id; ?>">Edit</a>
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addquoteCopyModal<?php echo $quote_id; ?>">Copy</a>
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#editQuoteModal<?php echo $quote_id; ?>">Edit</a>
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addQuoteCopyModal<?php echo $quote_id; ?>">Copy</a>
<a class="dropdown-item" href="post.php?email_quote=<?php echo $quote_id; ?>">Send</a>
<a class="dropdown-item" href="post.php?approve_quote=<?php echo $quote_id; ?>">Approve</a>
<a class="dropdown-item" href="post.php?pdf_quote=<?php echo $quote_id; ?>">PDF</a>
<a class="dropdown-item" href="post.php?delete_quote=<?php echo $quote_id; ?>">Delete</a>
</div>
@ -74,9 +76,10 @@
</tr>
<?php
//include("edit_invoice_modal.php");
include("add_invoice_copy_modal.php");
include("edit_quote_modal.php");
include("add_quote_copy_modal.php");
}
?>

View File

@ -10,7 +10,16 @@
<form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="contact_id" value="<?php echo $contact_id; ?>">
<div class="modal-body bg-white">
<center><img class="img-fluid rounded-circle" src="<?php echo $contact_photo; ?>" height="256" width="256"></center>
<center>
<?php if(!empty($contact_photo)){ ?>
<img class="img-fluid rounded-circle" src="<?php echo $contact_photo; ?>" height="256" width="256">
<?php }else{ ?>
<span class="fa-stack fa-4x">
<i class="fa fa-circle fa-stack-2x text-secondary"></i>
<span class="fa fa-stack-1x text-white"><?php echo $contact_initials; ?></span>
</span>
<?php } ?>
</center>
<div class="form-group">
<label>Name</label>
<div class="input-group">

View File

@ -44,10 +44,10 @@
$sql_income_category = mysqli_query($mysqli,"SELECT * FROM categories WHERE category_type = 'Income'");
while($row = mysqli_fetch_array($sql_income_category)){
$category_id = $row['category_id'];
$category_name = $row['category_name'];
$category_id_select= $row['category_id'];
$category_name_select = $row['category_name'];
?>
<option <?php if($category_id == $invoice_category_id){ ?> selected <?php } ?> value="<?php echo $category_id; ?>"><?php echo $category_name; ?></option>
<option <?php if($category_id == $category_id_select){ ?> selected <?php } ?> value="<?php echo $category_id_select; ?>"><?php echo $category_name_select; ?></option>
<?php
}

View File

@ -13,7 +13,14 @@
<input type="hidden" name="current_avatar_path" value="<?php echo $avatar; ?>">
<div class="modal-body bg-white">
<center class="mb-3">
<?php if(!empty($avatar)){ ?>
<img class="img-fluid rounded-circle" src="<?php echo $avatar; ?>" height="128" width="128">
<?php }else{ ?>
<span class="fa-stack fa-4x">
<i class="fa fa-circle fa-stack-2x text-secondary"></i>
<span class="fa fa-stack-1x text-white"><?php echo $initials; ?></span>
</span>
<?php } ?>
</center>
<div class="form-group">
<label>Name</label>

View File

@ -1,5 +1,7 @@
<?php
function keygen()
{
$chars = "abcdefghijklmnopqrstuvwxyz";

View File

@ -52,4 +52,21 @@
<div id="content-wrapper">
<div class="container-fluid">
<div class="container-fluid">
<?php
//Alert Feedback
if(!empty($_SESSION['alert_message'])){
?>
<div class="alert alert-info" id="alert">
<?php echo $_SESSION['alert_message']; ?>
<button class='close' data-dismiss='alert'>&times;</button>
</div>
<?php
$_SESSION['alert_type'] = '';
$_SESSION['alert_message'] = '';
}
?>

View File

@ -84,206 +84,209 @@ if(isset($_GET['invoice_id'])){
<span class="p-2 ml-2 badge badge-<?php echo $invoice_badge_color; ?>"><?php echo $invoice_status; ?></span>
</ol>
<div class="row mb-4 d-print-none">
<div class="col-md-4">
</div>
<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-fw fa-ellipsis-v"></i>
</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="#addInvoiceRecurringModal<?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' 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>
<?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>
</div>
<div class="row mb-4">
<div class="col-sm">
<div class="card">
<div class="card-header">
From
</div>
<div class="card-body">
<ul class="list-unstyled">
<li><strong><?php echo $config_company_name; ?></strong></li>
<li><?php echo $config_company_address; ?></li>
<li class="mb-3"><?php echo "$config_company_city $config_company_state $config_company_zip"; ?></li>
<li><?php echo $config_company_phone; ?></li>
<li><?php echo $config_company_email; ?></li>
</ul>
</div>
</div>
</div>
<div class="col-sm">
<div class="card">
<div class="card-header">
Bill To
</div>
<div class="card-body">
<ul class="list-unstyled">
<li><strong><?php echo $client_name; ?></strong></li>
<li><?php echo $client_address; ?></li>
<li class="mb-3"><?php echo "$client_city $client_state $client_zip"; ?></li>
<li><?php echo $client_phone; ?></li>
<li><?php echo $client_email; ?></li>
</ul>
</div>
</div>
</div>
<div class="col-sm">
<div class="card">
<div class="card-header">
Details
</div>
<div class="card-body">
<ul class="list-unstyled">
<li class="mb-1"><strong>Invoice Number:</strong> <div class="float-right">INV-<?php echo $invoice_number; ?></div></li>
<li class="mb-1"><strong>Invoice Date:</strong> <div class="float-right"><?php echo $invoice_date; ?></div></li>
<li><strong>Payment Due:</strong> <div class="float-right <?php echo $invoice_color; ?>"><?php echo $invoice_due; ?></div></li>
</ul>
</div>
</div>
</div>
</div>
<?php $sql_invoice_items = mysqli_query($mysqli,"SELECT * FROM invoice_items WHERE invoice_id = $invoice_id ORDER BY item_id ASC"); ?>
<div class="row mb-4">
<div class="col-md-12">
<div class="card">
<div class="card-header">
Items
<form action="post.php" method="post">
<input type="hidden" name="invoice_id" value="<?php echo $invoice_id; ?>">
<div class="row mb-4 d-print-none">
<div class="col-md-4">
<button class="btn btn-success btn-sm" type="submit" name="save_invoice">Save</button>
</div>
<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-fw fa-ellipsis-v"></i>
</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="#addInvoiceRecurringModal<?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' 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>
<?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>
</div>
<div class="row mb-4">
<div class="col-sm">
<div class="card">
<div class="card-header">
From
</div>
<div class="card-body">
<ul class="list-unstyled">
<li><strong><?php echo $config_company_name; ?></strong></li>
<li><?php echo $config_company_address; ?></li>
<li class="mb-3"><?php echo "$config_company_city $config_company_state $config_company_zip"; ?></li>
<li><?php echo $config_company_phone; ?></li>
<li><?php echo $config_company_email; ?></li>
</ul>
</div>
</div>
</div>
<div class="col-sm">
<div class="card">
<div class="card-header">
Bill To
</div>
<div class="card-body">
<ul class="list-unstyled">
<li><strong><?php echo $client_name; ?></strong></li>
<li><?php echo $client_address; ?></li>
<li class="mb-3"><?php echo "$client_city $client_state $client_zip"; ?></li>
<li><?php echo $client_phone; ?></li>
<li><?php echo $client_email; ?></li>
</ul>
</div>
</div>
</div>
<div class="col-sm">
<div class="card">
<div class="card-header">
Details
</div>
<div class="card-body">
<ul class="list-unstyled">
<li class="mb-1"><strong>Invoice Number:</strong> <div class="float-right">INV-<?php echo $invoice_number; ?></div></li>
<li class="mb-1"><strong>Invoice Date:</strong> <div class="float-right"><?php echo $invoice_date; ?></div></li>
<li><strong>Payment Due:</strong> <div class="float-right <?php echo $invoice_color; ?>"><?php echo $invoice_due; ?></div></li>
</ul>
</div>
</div>
</div>
</div>
<?php $sql_invoice_items = mysqli_query($mysqli,"SELECT * FROM invoice_items WHERE invoice_id = $invoice_id ORDER BY item_id ASC"); ?>
<div class="row mb-4">
<div class="col-md-12">
<div class="card">
<div class="card-header">
Items
</div>
<table class="table">
<thead>
<tr>
<th class="d-print-none"></th>
<th>Product</th>
<th>Description</th>
<th class="text-center">Qty</th>
<th class="text-right">Price</th>
<th class="text-right">Tax</th>
<th class="text-right">Total</th>
</tr>
</thead>
<tbody>
<?php
<table class="table">
<thead>
<tr>
<th class="d-print-none"></th>
<th>Item</th>
<th>Description</th>
<th class="text-right">Unit Cost</th>
<th class="text-center">Quantity</th>
<th class="text-right">Tax</th>
<th class="text-right">Line Total</th>
while($row = mysqli_fetch_array($sql_invoice_items)){
$item_id = $row['item_id'];
$item_name = $row['item_name'];
$item_description = $row['item_description'];
$item_quantity = $row['item_quantity'];
$item_price = $row['item_price'];
$item_subtotal = $row['item_price'];
$item_tax = $row['item_tax'];
$item_total = $row['item_total'];
$total_tax = $item_tax + $total_tax;
$sub_total = $item_price * $item_quantity + $sub_total;
?>
<tr>
<td class="text-center d-print-none"><a class="btn btn-sm btn-danger" href="post.php?delete_invoice_item=<?php echo $item_id; ?>"><i class="fa fa-trash"></i></a></td>
<td><?php echo $item_name; ?></td>
<td><?php echo $item_description; ?></td>
<td class="text-center"><?php echo $item_quantity; ?></td>
<td class="text-right text-monospace">$<?php echo number_format($item_price,2); ?></td>
<td class="text-right text-monospace">$<?php echo number_format($item_tax,2); ?></td>
<td class="text-right text-monospace">$<?php echo number_format($item_total,2); ?></td>
</tr>
<?php
}
?>
<tr class="d-print-none">
<td></td>
<td><input type="text" class="form-control typeahead" name="name" id="item"></td>
<td><textarea class="form-control" rows="1" name="description"></textarea></td>
<td><input type="text" class="form-control" style="text-align: right;" name="price"></td>
<td><input type="text" class="form-control" style="text-align: center;" name="qty"></td>
<td>
<select dir="rtl" class="form-control" name="tax">
<option value="0.00">None</option>
<option value="0.07">State Tax 7%</option>
</select>
</td>
<td></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="row mb-4">
<div class="col-7">
<div class="card">
<div class="card-header">
Notes
</div>
<div class="card-body">
<div class="d-none d-print-block"><?php echo $invoice_note; ?></div>
<textarea rows="6" class="form-control mb-2 d-print-none" name="invoice_note"><?php echo $invoice_note; ?></textarea>
</div>
</div>
</div>
<div class="col-3 offset-2">
<table class="table table-borderless">
<tbody>
<tr class="border-bottom">
<td>Subtotal</td>
<td class="text-right text-monospace">$<?php echo number_format($sub_total,2); ?></td>
</tr>
</thead>
<tbody>
<?php
while($row = mysqli_fetch_array($sql_invoice_items)){
$item_id = $row['item_id'];
$item_name = $row['item_name'];
$item_description = $row['item_description'];
$item_quantity = $row['item_quantity'];
$item_price = $row['item_price'];
$item_subtotal = $row['item_price'];
$item_tax = $row['item_tax'];
$item_total = $row['item_total'];
$total_tax = $item_tax + $total_tax;
$sub_total = $item_price * $item_quantity + $sub_total;
?>
<tr>
<td class="text-center d-print-none"><a class="btn btn-sm btn-danger" href="post.php?delete_invoice_item=<?php echo $item_id; ?>"><i class="fa fa-trash"></i></a></td>
<td><?php echo $item_name; ?></td>
<td><?php echo $item_description; ?></td>
<td class="text-right text-monospace">$<?php echo number_format($item_price,2); ?></td>
<td class="text-center text-monospace"><?php echo $item_quantity; ?></td>
<td class="text-right text-monospace">$<?php echo number_format($item_tax,2); ?></td>
<td class="text-right text-monospace">$<?php echo number_format($item_total,2); ?></td>
<?php if($discount > 0){ ?>
<tr class="border-bottom">
<td>Discount</td>
<td class="text-right text-monospace">$<?php echo number_format($invoice_discount,2); ?></td>
</tr>
<?php
}
?>
<tr class="d-print-none">
<form action="post.php" method="post" autocomplete="off">
<td class="text-center"><button type="submit" class="btn btn-primary btn-sm" name="add_invoice_item"><i class="fa fa-check"></i></button></td>
<input type="hidden" name="invoice_id" value="<?php echo $invoice_id; ?>">
<td><input type="text" class="form-control typeahead" name="name" id="item"></td>
<td><textarea class="form-control" rows="1" name="description"></textarea></td>
<td><input type="text" class="form-control" style="text-align: right;" name="price"></td>
<td><input type="text" class="form-control" style="text-align: center;" name="qty"></td>
<td>
<select dir="rtl" class="form-control" name="tax">
<option value="0.00">None</option>
<option value="0.07">State Tax 7%</option>
</select>
</td>
<td></td>
</form>
<?php } ?>
<?php if($total_tax > 0){ ?>
<tr class="border-bottom">
<td>Tax</td>
<td class="text-right text-monospace">$<?php echo number_format($total_tax,2); ?></td>
</tr>
<?php } ?>
<?php if($amount_paid > 0){ ?>
<tr class="border-bottom">
<td><div class="text-success">Paid to Date</div></td>
<td class="text-right text-monospace text-success">$<?php echo number_format($amount_paid,2); ?></td>
</tr>
<?php } ?>
<tr class="border-bottom">
<td><strong>Balance Due</strong></td>
<td class="text-right text-monospace"><strong>$<?php echo number_format($balance,2); ?></strong></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="row mb-4">
<div class="col-7">
<div class="card">
<div class="card-header">
Notes
</div>
<div class="card-body">
<div class="d-none d-print-block"><?php echo $invoice_note; ?></div>
<form class="d-print-none" action="post.php" method="post">
<input type="hidden" name="invoice_id" value="<?php echo $invoice_id; ?>">
<textarea rows="6" class="form-control mb-2" name="invoice_note"><?php echo $invoice_note; ?></textarea>
<button class="btn btn-primary btn-sm float-right" type="submit" name="edit_invoice_note"><i class="fa fa-fw fa-check"></i></button>
</form>
</div>
</div>
</div>
<div class="col-3 offset-2">
<table class="table table-borderless">
<tbody>
<tr class="border-bottom">
<td>Subtotal</td>
<td class="text-right text-monospace">$<?php echo number_format($sub_total,2); ?></td>
</tr>
<?php if($discount > 0){ ?>
<tr class="border-bottom">
<td>Discount</td>
<td class="text-right text-monospace">$<?php echo number_format($invoice_discount,2); ?></td>
</tr>
<?php } ?>
<?php if($total_tax > 0){ ?>
<tr class="border-bottom">
<td>Tax</td>
<td class="text-right text-monospace">$<?php echo number_format($total_tax,2); ?></td>
</tr>
<?php } ?>
<?php if($amount_paid > 0){ ?>
<tr class="border-bottom">
<td><div class="text-success">Paid to Date</div></td>
<td class="text-right text-monospace text-success">$<?php echo number_format($amount_paid,2); ?></td>
</tr>
<?php } ?>
<tr class="border-bottom">
<td><strong>Balance Due</strong></td>
<td class="text-right text-monospace"><strong>$<?php echo number_format($balance,2); ?></strong></td>
</tr>
</tbody>
</table>
</div>
</div>
</form>
<div class="row mb-3">
<div class="col-sm d-print-none">

View File

@ -176,6 +176,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="#editInvoiceModal<?php echo $invoice_id; ?>">Edit</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>
@ -188,6 +189,7 @@
<?php
include("add_invoice_copy_modal.php");
include("edit_invoice_modal.php");
}
?>

View File

@ -25,6 +25,12 @@ $(function () {
});
});
//Slide alert up after 2 secs
$("#alert").fadeTo(2000, 500).slideUp(500, function(){
$("#alert").slideUp(500);
});
new EasyMDE({
autoDownloadFontAwesome: false,
element: document.getElementById('addClientNote')

297
post.php
View File

@ -161,8 +161,6 @@ if(isset($_POST['add_user'])){
$avatar_path = "uploads/user_avatars/";
$avatar_path = $avatar_path . $user_id . '_' . time() . '_' . basename( $_FILES['avatar']['name']);
move_uploaded_file($_FILES['avatar']['tmp_name'], $avatar_path);
}else{
$avatar_path = "img/default_user_avatar.png";
}
mysqli_query($mysqli,"UPDATE users SET avatar = '$avatar_path' WHERE user_id = $user_id");
@ -884,6 +882,49 @@ if(isset($_POST['add_quote'])){
}
if(isset($_POST['save_quote'])){
$quote_id = intval($_POST['quote_id']);
if(isset($_POST['name'])){
$name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']));
$description = strip_tags(mysqli_real_escape_string($mysqli,$_POST['description']));
$qty = $_POST['qty'];
$price = $_POST['price'];
$tax = $_POST['tax'];
$subtotal = $price * $qty;
$tax = $subtotal * $tax;
$total = $subtotal + $tax;
mysqli_query($mysqli,"INSERT INTO invoice_items SET item_name = '$name', item_description = '$description', item_quantity = $qty, item_price = '$price', item_subtotal = '$subtotal', item_tax = '$tax', item_total = '$total', quote_id = $quote_id");
//Update Invoice Balances
$sql = mysqli_query($mysqli,"SELECT * FROM quotes WHERE quote_id = $quote_id");
$row = mysqli_fetch_array($sql);
$new_quote_amount = $row['quote_amount'] + $total;
mysqli_query($mysqli,"UPDATE quotes SET quote_amount = '$new_quote_amount' WHERE quote_id = $quote_id");
$_SESSION['alert_message'] = "Item added";
}
if(isset($_POST['quote_note'])){
$quote_note = strip_tags(mysqli_real_escape_string($mysqli,$_POST['quote_note']));
mysqli_query($mysqli,"UPDATE quotes SET quote_note = '$quote_note' WHERE quote_id = $quote_id");
$_SESSION['alert_message'] = "Notes added";
}
header("Location: " . $_SERVER["HTTP_REFERER"]);
}
if(isset($_POST['edit_quote'])){
$quote_id = intval($_POST['quote_id']);
@ -1010,36 +1051,6 @@ if(isset($_POST['add_quote_to_invoice'])){
}
if(isset($_POST['add_quote_item'])){
$quote_id = intval($_POST['quote_id']);
$name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']));
$description = strip_tags(mysqli_real_escape_string($mysqli,$_POST['description']));
$qty = $_POST['qty'];
$price = $_POST['price'];
$tax = $_POST['tax'];
$subtotal = $price * $qty;
$tax = $subtotal * $tax;
$total = $subtotal + $tax;
mysqli_query($mysqli,"INSERT INTO invoice_items SET item_name = '$name', item_description = '$description', item_quantity = $qty, item_price = '$price', item_subtotal = '$subtotal', item_tax = '$tax', item_total = '$total', quote_id = $quote_id");
//Update Invoice Balances
$sql = mysqli_query($mysqli,"SELECT * FROM quotes WHERE quote_id = $quote_id");
$row = mysqli_fetch_array($sql);
$new_quote_amount = $row['quote_amount'] + $total;
mysqli_query($mysqli,"UPDATE quotes SET quote_amount = '$new_quote_amount' WHERE quote_id = $quote_id");
$_SESSION['alert_message'] = "Item added";
header("Location: " . $_SERVER["HTTP_REFERER"]);
}
if(isset($_GET['delete_quote_item'])){
$item_id = intval($_GET['delete_quote_item']);
@ -1065,19 +1076,6 @@ if(isset($_GET['delete_quote_item'])){
}
if(isset($_POST['edit_quote_note'])){
$quote_id = intval($_POST['quote_id']);
$quote_note = strip_tags(mysqli_real_escape_string($mysqli,$_POST['quote_note']));
mysqli_query($mysqli,"UPDATE quotes SET quote_note = '$quote_note' WHERE quote_id = $quote_id");
$_SESSION['alert_message'] = "Notes added";
header("Location: " . $_SERVER["HTTP_REFERER"]);
}
if(isset($_GET['approve_quote'])){
$quote_id = intval($_GET['approve_quote']);
@ -1092,15 +1090,15 @@ if(isset($_GET['approve_quote'])){
}
if(isset($_GET['cancel_quote'])){
if(isset($_GET['reject_quote'])){
$quote_id = intval($_GET['cancel_quote']);
$quote_id = intval($_GET['reject_quote']);
mysqli_query($mysqli,"UPDATE quotes SET quote_status = 'Cancelled' WHERE quote_id = $quote_id");
mysqli_query($mysqli,"UPDATE quotes SET quote_status = 'Rejected' WHERE quote_id = $quote_id");
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = 'Cancelled', history_description = 'Quote cancelled!', quote_id = $quote_id");
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = 'Cancelled', history_description = 'Quote rejected!', quote_id = $quote_id");
$_SESSION['alert_message'] = "Quote cancelled";
$_SESSION['alert_message'] = "Quote rejected";
header("Location: " . $_SERVER["HTTP_REFERER"]);
@ -1155,8 +1153,8 @@ if(isset($_GET['pdf_quote'])){
<tr>
<td align='center'>$item_name</td>
<td>$item_description</td>
<td class='cost'>$$item_price</td>
<td align='center'>$item_quantity</td>
<td class='cost'>$$item_price</td>
<td class='cost'>$$item_tax</td>
<td class='cost'>$$item_total</td>
</tr>
@ -1229,12 +1227,12 @@ if(isset($_GET['pdf_quote'])){
<table class="items" width="100%" style="font-size: 9pt; border-collapse: collapse; " cellpadding="8">
<thead>
<tr>
<td width="20%">Item</td>
<td width="25%">Description</td>
<td width="15%">Unit Cost</td>
<td width="10%">Quantity</td>
<td width="15%">Tax</td>
<td width="15%">Line Total</td>
<td width="28%">Product</td>
<td width="28%">Description</td>
<td width="10%">Qty</td>
<td width="10%">Price</td>
<td width="12%">Tax</td>
<td width="12%">Total</td>
</tr>
</thead>
<tbody>
@ -1260,8 +1258,8 @@ if(isset($_GET['pdf_quote'])){
';
$mpdf = new \Mpdf\Mpdf([
'margin_left' => 20,
'margin_right' => 15,
'margin_left' => 5,
'margin_right' => 5,
'margin_top' => 48,
'margin_bottom' => 25,
'margin_header' => 10,
@ -1328,8 +1326,8 @@ if(isset($_GET['email_quote'])){
<tr>
<td align='center'>$item_name</td>
<td>$item_description</td>
<td class='cost'>$$item_price</td>
<td align='center'>$item_quantity</td>
<td class='cost'>$$item_price</td>
<td class='cost'>$$item_tax</td>
<td class='cost'>$$item_total</td>
</tr>
@ -1402,12 +1400,12 @@ if(isset($_GET['email_quote'])){
<table class="items" width="100%" style="font-size: 9pt; border-collapse: collapse; " cellpadding="8">
<thead>
<tr>
<td width="20%">Item</td>
<td width="25%">Description</td>
<td width="15%">Unit Cost</td>
<td width="10%">Quantity</td>
<td width="15%">Tax</td>
<td width="15%">Line Total</td>
<td width="28%">Product</td>
<td width="28%">Description</td>
<td width="10%">Qty</td>
<td width="10%">Price</td>
<td width="12%">Tax</td>
<td width="12%">Total</td>
</tr>
</thead>
<tbody>
@ -1433,8 +1431,8 @@ if(isset($_GET['email_quote'])){
';
$mpdf = new \Mpdf\Mpdf([
'margin_left' => 20,
'margin_right' => 15,
'margin_left' => 5,
'margin_right' => 5,
'margin_top' => 48,
'margin_bottom' => 25,
'margin_header' => 10,
@ -1548,19 +1546,6 @@ if(isset($_GET['delete_recurring'])){
}
if(isset($_POST['edit_recurring_note'])){
$recurring_id = intval($_POST['recurring_id']);
$recurring_note = strip_tags(mysqli_real_escape_string($mysqli,$_POST['recurring_note']));
mysqli_query($mysqli,"UPDATE recurring SET recurring_note = '$recurring_note' WHERE recurring_id = $recurring_id");
$_SESSION['alert_message'] = "Notes added";
header("Location: " . $_SERVER["HTTP_REFERER"]);
}
if(isset($_GET['recurring_activate'])){
$recurring_id = intval($_GET['recurring_activate']);
@ -1585,32 +1570,46 @@ if(isset($_GET['recurring_deactivate'])){
}
if(isset($_POST['add_recurring_item'])){
if(isset($_POST['save_recurring'])){
$recurring_id = intval($_POST['recurring_id']);
$name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']));
$description = strip_tags(mysqli_real_escape_string($mysqli,$_POST['description']));
$qty = $_POST['qty'];
$price = $_POST['price'];
$tax = $_POST['tax'];
$subtotal = $price * $qty;
$tax = $subtotal * $tax;
$total = $subtotal + $tax;
if(isset($_POST['name'])){
$name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']));
$description = strip_tags(mysqli_real_escape_string($mysqli,$_POST['description']));
$qty = $_POST['qty'];
$price = $_POST['price'];
$tax = $_POST['tax'];
$subtotal = $price * $qty;
$tax = $subtotal * $tax;
$total = $subtotal + $tax;
mysqli_query($mysqli,"INSERT INTO invoice_items SET item_name = '$name', item_description = '$description', item_quantity = $qty, item_price = '$price', item_subtotal = '$subtotal', item_tax = '$tax', item_total = '$total', recurring_id = $recurring_id");
mysqli_query($mysqli,"INSERT INTO invoice_items SET item_name = '$name', item_description = '$description', item_quantity = $qty, item_price = '$price', item_subtotal = '$subtotal', item_tax = '$tax', item_total = '$total', recurring_id = $recurring_id");
//Update Invoice Balances
//Update Invoice Balances
$sql = mysqli_query($mysqli,"SELECT * FROM recurring WHERE recurring_id = $recurring_id");
$row = mysqli_fetch_array($sql);
$sql = mysqli_query($mysqli,"SELECT * FROM recurring WHERE recurring_id = $recurring_id");
$row = mysqli_fetch_array($sql);
$new_recurring_amount = $row['recurring_amount'] + $total;
$new_recurring_amount = $row['recurring_amount'] + $total;
mysqli_query($mysqli,"UPDATE recurring SET recurring_amount = '$new_recurring_amount' WHERE recurring_id = $recurring_id");
mysqli_query($mysqli,"UPDATE recurring SET recurring_amount = '$new_recurring_amount' WHERE recurring_id = $recurring_id");
$_SESSION['alert_message'] = "Item added";
}
if(isset($_POST['recurring_note'])){
$recurring_note = strip_tags(mysqli_real_escape_string($mysqli,$_POST['recurring_note']));
mysqli_query($mysqli,"UPDATE recurring SET recurring_note = '$recurring_note' WHERE recurring_id = $recurring_id");
$_SESSION['alert_message'] = "Notes added";
}
$_SESSION['alert_message'] = "Item added";
header("Location: " . $_SERVER["HTTP_REFERER"]);
}
@ -1701,32 +1700,47 @@ if(isset($_GET['delete_invoice'])){
}
if(isset($_POST['add_invoice_item'])){
if(isset($_POST['save_invoice'])){
$invoice_id = intval($_POST['invoice_id']);
$name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']));
$description = strip_tags(mysqli_real_escape_string($mysqli,$_POST['description']));
$qty = $_POST['qty'];
$price = $_POST['price'];
$tax = $_POST['tax'];
$subtotal = $price * $qty;
$tax = $subtotal * $tax;
$total = $subtotal + $tax;
if(isset($_POST['name'])){
$name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']));
$description = strip_tags(mysqli_real_escape_string($mysqli,$_POST['description']));
$qty = $_POST['qty'];
$price = $_POST['price'];
$tax = $_POST['tax'];
$subtotal = $price * $qty;
$tax = $subtotal * $tax;
$total = $subtotal + $tax;
mysqli_query($mysqli,"INSERT INTO invoice_items SET item_name = '$name', item_description = '$description', item_quantity = $qty, item_price = '$price', item_subtotal = '$subtotal', item_tax = '$tax', item_total = '$total', invoice_id = $invoice_id");
mysqli_query($mysqli,"INSERT INTO invoice_items SET item_name = '$name', item_description = '$description', item_quantity = $qty, item_price = '$price', item_subtotal = '$subtotal', item_tax = '$tax', item_total = '$total', invoice_id = $invoice_id");
//Update Invoice Balances
//Update Invoice Balances
$sql = mysqli_query($mysqli,"SELECT * FROM invoices WHERE invoice_id = $invoice_id");
$row = mysqli_fetch_array($sql);
$sql = mysqli_query($mysqli,"SELECT * FROM invoices WHERE invoice_id = $invoice_id");
$row = mysqli_fetch_array($sql);
$new_invoice_amount = $row['invoice_amount'] + $total;
$new_invoice_amount = $row['invoice_amount'] + $total;
mysqli_query($mysqli,"UPDATE invoices SET invoice_amount = '$new_invoice_amount' WHERE invoice_id = $invoice_id");
mysqli_query($mysqli,"UPDATE invoices SET invoice_amount = '$new_invoice_amount' WHERE invoice_id = $invoice_id");
$_SESSION['alert_message'] = "Item added";
}
if(isset($_POST['invoice_note'])){
$invoice_note = strip_tags(mysqli_real_escape_string($mysqli,$_POST['invoice_note']));
mysqli_query($mysqli,"UPDATE invoices SET invoice_note = '$invoice_note' WHERE invoice_id = $invoice_id");
$_SESSION['alert_message'] = "Notes added";
}
$_SESSION['alert_message'] = "Item added";
header("Location: " . $_SERVER["HTTP_REFERER"]);
}
@ -1985,8 +1999,8 @@ if(isset($_GET['email_invoice'])){
<tr>
<td align='center'>$item_name</td>
<td>$item_description</td>
<td class='cost'>$$item_price</td>
<td align='center'>$item_quantity</td>
<td class='cost'>$$item_price</td>
<td class='cost'>$$item_tax</td>
<td class='cost'>$$item_total</td>
</tr>
@ -2060,12 +2074,12 @@ if(isset($_GET['email_invoice'])){
<table class="items" width="100%" style="font-size: 9pt; border-collapse: collapse; " cellpadding="8">
<thead>
<tr>
<td width="20%">Item</td>
<td width="25%">Description</td>
<td width="15%">Unit Cost</td>
<td width="10%">Quantity</td>
<td width="15%">Tax</td>
<td width="15%">Line Total</td>
<td width="28%">Product</td>
<td width="28%">Description</td>
<td width="10%">Qty</td>
<td width="10%">Price</td>
<td width="12%">Tax</td>
<td width="12%">Total</td>
</tr>
</thead>
<tbody>
@ -2088,7 +2102,7 @@ if(isset($_GET['email_invoice'])){
<td class="totals cost">$ '.number_format($amount_paid,2).' </td>
</tr>
<tr>
<td class="totals"><b>Balance due:</b></td>
<td class="totals"><b>Balance:</b></td>
<td class="totals cost"><b>$ '.number_format($balance,2).' </b></td>
</tr>
</tbody>
@ -2099,8 +2113,8 @@ if(isset($_GET['email_invoice'])){
';
$mpdf = new \Mpdf\Mpdf([
'margin_left' => 20,
'margin_right' => 15,
'margin_left' => 5,
'margin_right' => 5,
'margin_top' => 48,
'margin_bottom' => 25,
'margin_header' => 10,
@ -2239,8 +2253,8 @@ if(isset($_GET['pdf_invoice'])){
<tr>
<td align='center'>$item_name</td>
<td>$item_description</td>
<td class='cost'>$$item_price</td>
<td align='center'>$item_quantity</td>
<td class='cost'>$$item_price</td>
<td class='cost'>$$item_tax</td>
<td class='cost'>$$item_total</td>
</tr>
@ -2314,12 +2328,12 @@ if(isset($_GET['pdf_invoice'])){
<table class="items" width="100%" style="font-size: 9pt; border-collapse: collapse; " cellpadding="8">
<thead>
<tr>
<td width="20%">Item</td>
<td width="25%">Description</td>
<td width="15%">Unit Cost</td>
<td width="10%">Quantity</td>
<td width="15%">Tax</td>
<td width="15%">Line Total</td>
<td width="28%">Product</td>
<td width="28%">Description</td>
<td width="10%">Qty</td>
<td width="10%">Price</td>
<td width="12%">Tax</td>
<td width="12%">Total</td>
</tr>
</thead>
<tbody>
@ -2342,7 +2356,7 @@ if(isset($_GET['pdf_invoice'])){
<td class="totals cost">$ '.number_format($amount_paid,2).' </td>
</tr>
<tr>
<td class="totals"><b>Balance due:</b></td>
<td class="totals"><b>Balance:</b></td>
<td class="totals cost"><b>$ '.number_format($balance,2).' </b></td>
</tr>
</tbody>
@ -2353,8 +2367,8 @@ if(isset($_GET['pdf_invoice'])){
';
$mpdf = new \Mpdf\Mpdf([
'margin_left' => 20,
'margin_right' => 15,
'margin_left' => 5,
'margin_right' => 5,
'margin_top' => 48,
'margin_bottom' => 25,
'margin_header' => 10,
@ -2376,19 +2390,6 @@ if(isset($_GET['pdf_invoice'])){
}
if(isset($_POST['edit_invoice_note'])){
$invoice_id = intval($_POST['invoice_id']);
$invoice_note = strip_tags(mysqli_real_escape_string($mysqli,$_POST['invoice_note']));
mysqli_query($mysqli,"UPDATE invoices SET invoice_note = '$invoice_note' WHERE invoice_id = $invoice_id");
$_SESSION['alert_message'] = "Notes added";
header("Location: " . $_SERVER["HTTP_REFERER"]);
}
if(isset($_POST['add_contact'])){
$client_id = intval($_POST['client_id']);

348
quote.php
View File

@ -61,197 +61,197 @@ if(isset($_GET['quote_id'])){
<span class="ml-3 p-2 badge badge-<?php echo $quote_badge_color; ?>"><?php echo $quote_status; ?></span>
</ol>
<div class="row mb-4 d-print-none">
<div class="col-md-12">
<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>
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#editQuoteModal<?php echo $quote_id ?>">Edit</a>
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addQuoteCopyModal<?php echo $quote_id; ?>">Copy</a>
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addQuoteToInvoiceModal<?php echo $quote_id; ?>">Quote > Invoice</a>
<a class="dropdown-item" href="post.php?approve_quote=<?php echo $quote_id; ?>">Approve</a>
<a class="dropdown-item" href="post.php?cancel_quote=<?php echo $quote_id; ?>">Cancel</a>
<a class="dropdown-item" href="post.php?email_quote=<?php echo $quote_id; ?>">Send Email</a>
<?php if($quote_status == "Draft"){ ?><a class="dropdown-item" href="post.php?mark_quote_sent=<?php echo $quote_id; ?>">Mark Sent</a><?php } ?>
<a class="dropdown-item" href="#" onclick="window.print();">Print</a>
<a class="dropdown-item" href="post.php?pdf_quote=<?php echo $quote_id; ?>">PDF</a>
<a class="dropdown-item" href="#">Delete</a>
<form class="d-print-none" action="post.php" method="post">
<input type="hidden" name="quote_id" value="<?php echo $quote_id; ?>">
<div class="row mb-4 d-print-none">
<div class="col-md-4">
<button class="btn btn-success btn-sm" type="submit" name="save_quote">Save</button>
</div>
<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>
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#editQuoteModal<?php echo $quote_id ?>">Edit</a>
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addQuoteCopyModal<?php echo $quote_id; ?>">Copy</a>
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addQuoteToInvoiceModal<?php echo $quote_id; ?>">Quote > Invoice</a>
<a class="dropdown-item" href="post.php?approve_quote=<?php echo $quote_id; ?>">Approve</a>
<a class="dropdown-item" href="post.php?reject_quote=<?php echo $quote_id; ?>">Reject</a>
<a class="dropdown-item" href="post.php?email_quote=<?php echo $quote_id; ?>">Send Email</a>
<?php if($quote_status == "Draft"){ ?><a class="dropdown-item" href="post.php?mark_quote_sent=<?php echo $quote_id; ?>">Mark Sent</a><?php } ?>
<a class="dropdown-item" href="#" onclick="window.print();">Print</a>
<a class="dropdown-item" href="post.php?pdf_quote=<?php echo $quote_id; ?>">PDF</a>
<a class="dropdown-item" href="#">Delete</a>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row mb-4">
<div class="col-sm">
<div class="card">
<div class="card-header">
From
<div class="row mb-4">
<div class="col-sm">
<div class="card">
<div class="card-header">
From
</div>
<div class="card-body">
<ul class="list-unstyled">
<li><strong><?php echo $config_company_name; ?></strong></li>
<li><?php echo $config_company_address; ?></li>
<li class="mb-3"><?php echo "$config_company_city $config_company_state $config_company_zip"; ?></li>
<li><?php echo $config_company_phone; ?></li>
<li><?php echo $config_company_email; ?></li>
</ul>
</div>
</div>
<div class="card-body">
<ul class="list-unstyled">
<li><strong><?php echo $config_company_name; ?></strong></li>
<li><?php echo $config_company_address; ?></li>
<li class="mb-3"><?php echo "$config_company_city $config_company_state $config_company_zip"; ?></li>
<li><?php echo $config_company_phone; ?></li>
<li><?php echo $config_company_email; ?></li>
</ul>
</div>
<div class="col-sm">
<div class="card">
<div class="card-header">
Quote To
</div>
<div class="card-body">
<ul class="list-unstyled">
<li><strong><?php echo $client_name; ?></strong></li>
<li><?php echo $client_address; ?></li>
<li class="mb-3"><?php echo "$client_city $client_state $client_zip"; ?></li>
<li><?php echo $client_phone; ?></li>
<li><?php echo $client_email; ?></li>
</ul>
</div>
</div>
</div>
<div class="col-sm">
<div class="card">
<div class="card-header">
Details
</div>
<div class="card-body">
<ul class="list-unstyled">
<li class="mb-1"><strong>Quote Number:</strong> <div class="float-right">QUO-<?php echo $quote_number; ?></div></li>
<li class="mb-1"><strong>Quote Date:</strong> <div class="float-right"><?php echo $quote_date; ?></div></li>
</ul>
</div>
</div>
</div>
</div>
<div class="col-sm">
<div class="card">
<div class="card-header">
Quote To
</div>
<div class="card-body">
<ul class="list-unstyled">
<li><strong><?php echo $client_name; ?></strong></li>
<li><?php echo $client_address; ?></li>
<li class="mb-3"><?php echo "$client_city $client_state $client_zip"; ?></li>
<li><?php echo $client_phone; ?></li>
<li><?php echo $client_email; ?></li>
</ul>
</div>
</div>
</div>
<div class="col-sm">
<div class="card">
<div class="card-header">
Details
</div>
<div class="card-body">
<ul class="list-unstyled">
<li class="mb-1"><strong>Quote Number:</strong> <div class="float-right">QUO-<?php echo $quote_number; ?></div></li>
<li class="mb-1"><strong>Quote Date:</strong> <div class="float-right"><?php echo $quote_date; ?></div></li>
</ul>
</div>
</div>
</div>
</div>
<?php $sql_items = mysqli_query($mysqli,"SELECT * FROM invoice_items WHERE quote_id = $quote_id ORDER BY item_id ASC"); ?>
<?php $sql_items = mysqli_query($mysqli,"SELECT * FROM invoice_items WHERE quote_id = $quote_id ORDER BY item_id ASC"); ?>
<div class="row mb-4">
<div class="col-md-12">
<div class="card">
<div class="card-header">
Items
</div>
<div class="row mb-4">
<div class="col-md-12">
<div class="card">
<div class="card-header">
Items
</div>
<table class="table">
<thead>
<tr>
<th class="d-print-none"></th>
<th>Product</th>
<th>Description</th>
<th class="text-center">Qty</th>
<th class="text-right">Price</th>
<th class="text-right">Tax</th>
<th class="text-right">Total</th>
</tr>
</thead>
<tbody>
<?php
<table class="table">
<thead>
<tr>
<th class="d-print-none"></th>
<th>Item</th>
<th>Description</th>
<th class="text-right">Unit Cost</th>
<th class="text-center">Quantity</th>
<th class="text-right">Tax</th>
<th class="text-right">Line Total</th>
while($row = mysqli_fetch_array($sql_items)){
$item_id = $row['item_id'];
$item_name = $row['item_name'];
$item_description = $row['item_description'];
$item_quantity = $row['item_quantity'];
$item_price = $row['item_price'];
$item_subtotal = $row['item_price'];
$item_tax = $row['item_tax'];
$item_total = $row['item_total'];
$total_tax = $item_tax + $invoice_tax;
$sub_total = $item_price * $item_quantity + $sub_total;
?>
<tr>
<td class="text-center d-print-none"><a class="btn btn-danger btn-sm" href="post.php?delete_quote_item=<?php echo $item_id; ?>"><i class="fa fa-trash"></i></a></td>
<td><?php echo $item_name; ?></td>
<td><?php echo $item_description; ?></td>
<td class="text-center"><?php echo $item_quantity; ?></td>
<td class="text-right">$<?php echo number_format($item_price,2); ?></td>
<td class="text-right">$<?php echo number_format($item_tax,2); ?></td>
<td class="text-right">$<?php echo number_format($item_total,2); ?></td>
</tr>
<?php
}
?>
<tr class="d-print-none">
<input type="hidden" name="quote_id" value="<?php echo $quote_id; ?>">
<td></td>
<td><input type="text" class="form-control" name="name"></td>
<td><textarea class="form-control" rows="1" name="description"></textarea></td>
<td><input type="text" class="form-control" style="text-align: right;" name="price"></td>
<td><input type="text" class="form-control" style="text-align: center;" name="qty"></td>
<td>
<select dir="rtl" class="form-control" name="tax">
<option value="0.00">None</option>
<option value="0.07">State Tax 7%</option>
</select>
</td>
<td></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="row mb-4">
<div class="col-7">
<div class="card">
<div class="card-header">
Notes
</div>
<div class="card-body">
<div class="d-none d-print-block"><?php echo $quote_note; ?></div>
<textarea rows="6" class="form-control mb-2 d-print-none" name="quote_note"><?php echo $quote_note; ?></textarea>
</div>
</div>
</div>
<div class="col-3 offset-2">
<table class="table table-borderless">
<tbody>
<tr class="border-bottom">
<td>Subtotal</td>
<td class="text-right">$<?php echo number_format($sub_total,2); ?></td>
</tr>
</thead>
<tbody>
<?php
while($row = mysqli_fetch_array($sql_items)){
$item_id = $row['item_id'];
$item_name = $row['item_name'];
$item_description = $row['item_description'];
$item_quantity = $row['item_quantity'];
$item_price = $row['item_price'];
$item_subtotal = $row['item_price'];
$item_tax = $row['item_tax'];
$item_total = $row['item_total'];
$total_tax = $item_tax + $invoice_tax;
$sub_total = $item_price * $item_quantity + $sub_total;
?>
<tr>
<td class="text-center d-print-none"><a class="btn btn-danger btn-sm" href="post.php?delete_quote_item=<?php echo $item_id; ?>"><i class="fa fa-trash"></i></a></td>
<td><?php echo $item_name; ?></td>
<td><?php echo $item_description; ?></td>
<td class="text-right">$<?php echo number_format($item_price,2); ?></td>
<td class="text-center"><?php echo $item_quantity; ?></td>
<td class="text-right">$<?php echo number_format($item_tax,2); ?></td>
<td class="text-right">$<?php echo number_format($item_total,2); ?></td>
<?php if($discount > 0){ ?>
<tr class="border-bottom">
<td>Discount</td>
<td class="text-right">$<?php echo number_format($quote_discount,2); ?></td>
</tr>
<?php
}
?>
<tr class="d-print-none">
<form action="post.php" method="post">
<td class="text-center"><button type="submit" class="btn btn-primary btn-sm" name="add_quote_item"><i class="fa fa-check"></i></button></td>
<input type="hidden" name="quote_id" value="<?php echo $quote_id; ?>">
<td><input type="text" class="form-control" name="name"></td>
<td><textarea class="form-control" rows="1" name="description"></textarea></td>
<td><input type="text" class="form-control" style="text-align: right;" name="price"></td>
<td><input type="text" class="form-control" style="text-align: center;" name="qty"></td>
<td>
<select dir="rtl" class="form-control" name="tax">
<option value="0.00">None</option>
<option value="0.07">State Tax 7%</option>
</select>
</td>
<td></td>
</form>
<?php } ?>
<?php if($total_tax > 0){ ?>
<tr class="border-bottom">
<td>Tax</td>
<td class="text-right">$<?php echo number_format($total_tax,2); ?></td>
</tr>
<?php } ?>
<tr class="border-bottom">
<td><strong>Total</strong></td>
<td class="text-right"><strong>$<?php echo number_format($quote_amount,2); ?></strong></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="row mb-4">
<div class="col-7">
<div class="card">
<div class="card-header">
Notes
</div>
<div class="card-body">
<div class="d-none d-print-block"><?php echo $quote_note; ?></div>
<form class="d-print-none" action="post.php" method="post">
<input type="hidden" name="quote_id" value="<?php echo $quote_id; ?>">
<textarea rows="6" class="form-control mb-2" name="quote_note"><?php echo $quote_note; ?></textarea>
<button class="btn btn-primary btn-sm float-right" type="submit" name="edit_quote_note"><i class="fa fa-fw fa-check"></i></button>
</form>
</div>
</div>
</div>
<div class="col-3 offset-2">
<table class="table table-borderless">
<tbody>
<tr class="border-bottom">
<td>Subtotal</td>
<td class="text-right">$<?php echo number_format($sub_total,2); ?></td>
</tr>
<?php if($discount > 0){ ?>
<tr class="border-bottom">
<td>Discount</td>
<td class="text-right">$<?php echo number_format($quote_discount,2); ?></td>
</tr>
<?php } ?>
<?php if($total_tax > 0){ ?>
<tr class="border-bottom">
<td>Tax</td>
<td class="text-right">$<?php echo number_format($total_tax,2); ?></td>
</tr>
<?php } ?>
<tr class="border-bottom">
<td><strong>Total</strong></td>
<td class="text-right"><strong>$<?php echo number_format($quote_amount,2); ?></strong></td>
</tr>
</tbody>
</table>
</div>
</div>
</form>
<div class="row mb-3">
<div class="col-sm d-print-none">

View File

@ -51,7 +51,7 @@
$quote_badge_color = "primary";
}elseif($quote_status == "Approved"){
$quote_badge_color = "success";
}elseif($quote_status == "Cancelled"){
}elseif($quote_status == "Rejected"){
$quote_badge_color = "danger";
}else{
$quote_badge_color = "secondary";
@ -89,7 +89,7 @@
<?php
//include("edit_quote_modal.php");
include("edit_quote_modal.php");
include("add_quote_copy_modal.php");
}

View File

@ -58,138 +58,143 @@ if(isset($_GET['recurring_id'])){
<span class="ml-3 p-2 badge badge-<?php echo $status_badge_color; ?>"><?php echo $status; ?></span>
</ol>
<div class="row mb-4 d-print-none">
<div class="col-md-12">
<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>
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#editRecurringModal<?php echo $recurring_id; ?>">Edit</a>
<?php if($recurring_status == 1){ ?>
<a class="dropdown-item" href="post.php?recurring_deactivate=<?php echo $recurring_id; ?>">Deactivate</a>
<?php }else{ ?>
<a class="dropdown-item" href="post.php?recurring_activate=<?php echo $recurring_id; ?>">Activate</a>
<?php } ?>
<a class="dropdown-item" href="post.php?delete_recurring=<?php echo $recurring_id; ?>">Delete</a>
</div>
</div>
</div>
</div>
<div class="row mb-4">
<div class="col-sm">
<div class="card">
<div class="card-header">
From
</div>
<div class="card-body">
<ul class="list-unstyled">
<li><strong><?php echo $config_company_name; ?></strong></li>
<li><?php echo $config_company_address; ?></li>
<li class="mb-3"><?php echo "$config_company_city $config_company_state $config_company_zip"; ?></li>
<li><?php echo $config_company_phone; ?></li>
<li><?php echo $config_company_email; ?></li>
</ul>
<form class="d-print-none" action="post.php" method="post">
<input type="hidden" name="recurring_id" value="<?php echo $recurring_id; ?>">
<div class="row mb-4 d-print-none">
<div class="col-md-4">
<button class="btn btn-success btn-sm" type="submit" name="save_recurring">Save</button>
</div>
<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>
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#editRecurringModal<?php echo $recurring_id; ?>">Edit</a>
<?php if($recurring_status == 1){ ?>
<a class="dropdown-item" href="post.php?recurring_deactivate=<?php echo $recurring_id; ?>">Deactivate</a>
<?php }else{ ?>
<a class="dropdown-item" href="post.php?recurring_activate=<?php echo $recurring_id; ?>">Activate</a>
<?php } ?>
<a class="dropdown-item" href="post.php?delete_recurring=<?php echo $recurring_id; ?>">Delete</a>
</div>
</div>
</div>
</div>
<div class="col-sm">
<div class="card">
<div class="card-header">
Bill To
</div>
<div class="card-body">
<ul class="list-unstyled">
<li><strong><?php echo $client_name; ?></strong></li>
<li><?php echo $client_address; ?></li>
<li class="mb-3"><?php echo "$client_city $client_state $client_zip"; ?></li>
<li><?php echo $client_phone; ?></li>
<li><?php echo $client_email; ?></li>
</ul>
</div>
</div>
</div>
<div class="col-sm">
<div class="card">
<div class="card-header">
Details
</div>
<div class="card-body">
<ul class="list-unstyled">
<li class="mb-1"><strong>Frequency:</strong> <div class="float-right"><?php echo ucwords($recurring_frequency); ?>ly</div></li>
<li class="mb-1"><strong>Start Date:</strong> <div class="float-right"><?php echo $recurring_start_date; ?></div></li>
<li class="mb-1"><strong>Next Date:</strong> <div class="float-right"><?php echo $recurring_next_date; ?></div></li>
<li class="mb-1"><strong>Last Sent:</strong> <div class="float-right"><?php echo $recurring_last_sent; ?></div></li>
<li class="mb-1"><strong>Net Terms:</strong> <div class="float-right"><?php echo $client_net_terms; ?> Day</div></li>
</ul>
</div>
</div>
</div>
</div>
</div>
<?php $sql_items = mysqli_query($mysqli,"SELECT * FROM invoice_items WHERE recurring_id = $recurring_id ORDER BY item_id ASC"); ?>
<div class="row mb-4">
<div class="col-md-12">
<div class="card">
<div class="card-header">
Items
<div class="row mb-4">
<div class="col-sm">
<div class="card">
<div class="card-header">
From
</div>
<div class="card-body">
<ul class="list-unstyled">
<li><strong><?php echo $config_company_name; ?></strong></li>
<li><?php echo $config_company_address; ?></li>
<li class="mb-3"><?php echo "$config_company_city $config_company_state $config_company_zip"; ?></li>
<li><?php echo $config_company_phone; ?></li>
<li><?php echo $config_company_email; ?></li>
</ul>
</div>
</div>
</div>
<div class="col-sm">
<div class="card">
<div class="card-header">
Bill To
</div>
<div class="card-body">
<ul class="list-unstyled">
<li><strong><?php echo $client_name; ?></strong></li>
<li><?php echo $client_address; ?></li>
<li class="mb-3"><?php echo "$client_city $client_state $client_zip"; ?></li>
<li><?php echo $client_phone; ?></li>
<li><?php echo $client_email; ?></li>
</ul>
</div>
</div>
</div>
<div class="col-sm">
<div class="card">
<div class="card-header">
Details
</div>
<div class="card-body">
<ul class="list-unstyled">
<li class="mb-1"><strong>Frequency:</strong> <div class="float-right"><?php echo ucwords($recurring_frequency); ?>ly</div></li>
<li class="mb-1"><strong>Start Date:</strong> <div class="float-right"><?php echo $recurring_start_date; ?></div></li>
<li class="mb-1"><strong>Next Date:</strong> <div class="float-right"><?php echo $recurring_next_date; ?></div></li>
<li class="mb-1"><strong>Last Sent:</strong> <div class="float-right"><?php echo $recurring_last_sent; ?></div></li>
<li class="mb-1"><strong>Net Terms:</strong> <div class="float-right"><?php echo $client_net_terms; ?> Day</div></li>
</ul>
</div>
</div>
</div>
</div>
<?php $sql_items = mysqli_query($mysqli,"SELECT * FROM invoice_items WHERE recurring_id = $recurring_id ORDER BY item_id ASC"); ?>
<div class="row mb-4">
<div class="col-md-12">
<div class="card">
<div class="card-header">
Items
</div>
<table class="table">
<thead>
<tr>
<th class="d-print-none"></th>
<th>Product</th>
<th>Description</th>
<th class="text-center">Qty</th>
<th class="text-right">Price</th>
<th class="text-right">Tax</th>
<th class="text-right">Total</th>
</tr>
</thead>
<tbody>
<?php
<table class="table">
<thead>
<tr>
<th class="d-print-none"></th>
<th>Item</th>
<th>Description</th>
<th class="text-right">Unit Cost</th>
<th class="text-center">Quantity</th>
<th class="text-right">Tax</th>
<th class="text-right">Line Total</th>
</tr>
</thead>
<tbody>
<?php
while($row = mysqli_fetch_array($sql_items)){
$item_id = $row['item_id'];
$item_name = $row['item_name'];
$item_description = $row['item_description'];
$item_quantity = $row['item_quantity'];
$item_price = $row['item_price'];
$item_subtotal = $row['item_price'];
$item_tax = $row['item_tax'];
$item_total = $row['item_total'];
$total_tax = $item_tax + $total_tax;
$sub_total = $item_price * $item_quantity + $sub_total;
while($row = mysqli_fetch_array($sql_items)){
$item_id = $row['item_id'];
$item_name = $row['item_name'];
$item_description = $row['item_description'];
$item_quantity = $row['item_quantity'];
$item_price = $row['item_price'];
$item_subtotal = $row['item_price'];
$item_tax = $row['item_tax'];
$item_total = $row['item_total'];
$total_tax = $item_tax + $total_tax;
$sub_total = $item_price * $item_quantity + $sub_total;
?>
?>
<tr>
<td class="text-center d-print-none"><a class="btn btn-danger btn-sm" href="post.php?delete_recurring_item=<?php echo $item_id; ?>"><i class="fa fa-trash"></i></a></td>
<td><?php echo $item_name; ?></td>
<td><?php echo $item_description; ?></td>
<td class="text-right">$<?php echo number_format($item_price,2); ?></td>
<td class="text-center"><?php echo $item_quantity; ?></td>
<td class="text-right">$<?php echo number_format($item_tax,2); ?></td>
<td class="text-right">$<?php echo number_format($item_total,2); ?></td>
</tr>
<tr>
<td class="text-center d-print-none"><a class="btn btn-danger btn-sm" href="post.php?delete_recurring_item=<?php echo $item_id; ?>"><i class="fa fa-trash"></i></a></td>
<td><?php echo $item_name; ?></td>
<td><?php echo $item_description; ?></td>
<td class="text-center"><?php echo $item_quantity; ?></td>
<td class="text-right">$<?php echo number_format($item_price,2); ?></td>
<td class="text-right">$<?php echo number_format($item_tax,2); ?></td>
<td class="text-right">$<?php echo number_format($item_total,2); ?></td>
</tr>
<?php
<?php
}
}
?>
?>
<tr class="d-print-none">
<form action="post.php" method="post">
<td class="text-center"><button type="submit" class="btn btn-primary btn-sm" name="add_recurring_item"><i class="fa fa-check"></i></button></td>
<tr class="d-print-none">
<td></td>
<input type="hidden" name="recurring_id" value="<?php echo $recurring_id; ?>">
<td><input type="text" class="form-control" name="name"></td>
<td><textarea class="form-control" rows="1" name="description"></textarea></td>
<td><input type="text" class="form-control" style="text-align: right;" name="price"></td>
<td><input type="text" class="form-control" style="text-align: center;" name="qty"></td>
<td><input type="text" class="form-control" style="text-align: right;" name="price"></td>
<td>
<select dir="rtl" class="form-control" name="tax">
<option value="0.00">None</option>
@ -197,57 +202,53 @@ if(isset($_GET['recurring_id'])){
</select>
</td>
<td></td>
</form>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="row mb-4">
<div class="col-7">
<div class="card">
<div class="card-header">
Notes
</div>
<div class="card-body">
<div class="d-none d-print-block"><?php echo $recurring_note; ?></div>
<textarea rows="6" class="form-control mb-2 d-print-none" name="recurring_note"><?php echo $recurring_note; ?></textarea>
</div>
</div>
</div>
<div class="col-3 offset-2">
<table class="table table-borderless">
<tbody>
<tr class="border-bottom">
<td>Subtotal</td>
<td class="text-right">$<?php echo number_format($sub_total,2); ?></td>
</tr>
<?php if($discount > 0){ ?>
<tr class="border-bottom">
<td>Discount</td>
<td class="text-right">$<?php echo number_format($invoice_discount,2); ?></td>
</tr>
<?php } ?>
<?php if($total_tax > 0){ ?>
<tr class="border-bottom">
<td>Tax</td>
<td class="text-right">$<?php echo number_format($total_tax,2); ?></td>
</tr>
<?php } ?>
<tr class="border-bottom">
<td><strong>Amount</strong></td>
<td class="text-right"><strong>$<?php echo number_format($recurring_amount,2); ?></strong></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="row mb-4">
<div class="col-7">
<div class="card">
<div class="card-header">
Notes
</div>
<div class="card-body">
<div class="d-none d-print-block"><?php echo $recurring_note; ?></div>
<form class="d-print-none" action="post.php" method="post">
<input type="hidden" name="recurring_id" value="<?php echo $recurring_id; ?>">
<textarea rows="6" class="form-control mb-2" name="recurring_note"><?php echo $recurring_note; ?></textarea>
<button class="btn btn-primary btn-sm float-right" type="submit" name="edit_recurring_note"><i class="fa fa-fw fa-check"></i></button>
</form>
</div>
</div>
</div>
<div class="col-3 offset-2">
<table class="table table-borderless">
<tbody>
<tr class="border-bottom">
<td>Subtotal</td>
<td class="text-right">$<?php echo number_format($sub_total,2); ?></td>
</tr>
<?php if($discount > 0){ ?>
<tr class="border-bottom">
<td>Discount</td>
<td class="text-right">$<?php echo number_format($invoice_discount,2); ?></td>
</tr>
<?php } ?>
<?php if($total_tax > 0){ ?>
<tr class="border-bottom">
<td>Tax</td>
<td class="text-right">$<?php echo number_format($total_tax,2); ?></td>
</tr>
<?php } ?>
<tr class="border-bottom">
<td><strong>Amount</strong></td>
<td class="text-right"><strong>$<?php echo number_format($recurring_amount,2); ?></strong></td>
</tr>
</tbody>
</table>
</div>
</div>
</form>
<div class="row mb-3">
<div class="col-sm d-print-none">

58
settings-carddav.php Normal file
View File

@ -0,0 +1,58 @@
<?php include("header.php"); ?>
<?php include("settings-nav.php"); ?>
<div class="card mb-3">
<div class="card-header">
<h6 class="float-left mt-1"><i class="fa fa-fw fa-address-book mr-2"></i>CardDAV Settings</h6>
</div>
<div class="card-body">
<form class="p-3" action="post.php" method="post" autocomplete="off">
<div class="form-group">
<label>Server</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-server"></i></span>
</div>
<input type="text" class="form-control" name="config_smtp_host" placeholder="CardDAV Server Address" value="<?php echo $config_carddav_server; ?>" required autofocus>
</div>
</div>
<div class="form-group">
<label>Addressbook</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-address-book"></i></span>
</div>
<input type="text" class="form-control" name="config_carddav_username" placeholder="Address book name" value="<?php echo $config_carddav_address_book; ?>" required>
</div>
</div>
<div class="form-group">
<label>Username</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" name="config_carddav_username" placeholder="Username" value="<?php echo $config_carddav_username; ?>" required>
</div>
</div>
<div class="form-group mb-5">
<label>Password</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-lock"></i></span>
</div>
<input type="password" class="form-control" name="config_carddav_password" placeholder="Password" value="<?php echo $config_carddav_password; ?>" required>
</div>
</div>
<hr>
<button type="submit" name="edit_carddav_settings" class="btn btn-primary">Save</button>
</form>
</div>
</div>
<?php include("footer.php");

View File

@ -24,6 +24,14 @@
</a>
</li>
<li class="nav-item">
<a class="nav-link <?php if(basename($_SERVER["REQUEST_URI"]) == "settings-carddav.php") { echo "active"; } ?>"
href="settings-carddav.php">
<i class="fa fa-fw fa-2x fa-address-book"></i><br>
CardDAV
</a>
</li>
<li class="nav-item">
<a class="nav-link <?php if(basename($_SERVER["REQUEST_URI"]) == "settings-invoice.php") { echo "active"; } ?>"
href="settings-invoice.php">

View File

@ -27,11 +27,21 @@
$email = $row['email'];
$password = $row['password'];
$avatar = $row['avatar'];
$initials = initials($name);
?>
<tr>
<td class="text-center">
<img height="48" width="48" class="img-fluid rounded-circle" src="<?php echo "$avatar"; ?>">
<?php if(!empty($avatar)){ ?>
<img height="48" width="48" class="img-fluid rounded-circle" src="<?php echo $avatar; ?>">
<?php }else{ ?>
<span class="fa-stack fa-2x">
<i class="fa fa-circle fa-stack-2x text-secondary"></i>
<span class="fa fa-stack-1x text-white"><?php echo $initials; ?></span>
</span>
<br>
<?php } ?>
<div class="text-secondary"><?php echo $name; ?></div>
</td>
<td><a href="mailto:<?php echo $email; ?>"><?php echo $email; ?></a></td>