BREAKING CHANGES: Major Backend Code Changes Updated Foreign keys to prepend their table names ex invoice_client_id, switched most queries over to JOIN instead of = Combined contacts and location into client removed client email, phone etc fields, tons of small bug fixes, and other small UI changes all across the board

This commit is contained in:
johnnyq
2021-08-27 23:14:06 -04:00
parent 7fc738382b
commit f3053ffbd4
86 changed files with 2230 additions and 2047 deletions

View File

@@ -6,10 +6,12 @@ if(isset($_GET['quote_id'])){
$quote_id = intval($_GET['quote_id']);
$sql = mysqli_query($mysqli,"SELECT * FROM quotes, clients, companies
WHERE quotes.client_id = clients.client_id
AND quotes.company_id = companies.company_id
AND quotes.quote_id = $quote_id"
$sql = mysqli_query($mysqli,"SELECT * FROM quotes
LEFT JOIN clients ON quote_client_id = client_id
LEFT JOIN locations ON primary_location = location_id
LEFT JOIN contacts ON primary_contact = contact_id
LEFT JOIN companies ON quotes.company_id = companies.company_id
WHERE quote_id = $quote_id"
);
$row = mysqli_fetch_array($sql);
@@ -24,22 +26,22 @@ if(isset($_GET['quote_id'])){
$quote_note = $row['quote_note'];
$quote_url_key = $row['quote_url_key'];
$quote_created_at = $row['quote_created_at'];
$category_id = $row['category_id'];
$category_id = $row['quote_category_id'];
$client_id = $row['client_id'];
$client_name = $row['client_name'];
$client_address = $row['client_address'];
$client_city = $row['client_city'];
$client_state = $row['client_state'];
$client_zip = $row['client_zip'];
$client_email = $row['client_email'];
$client_phone = $row['client_phone'];
if(strlen($client_phone)>2){
$client_phone = substr($row['client_phone'],0,3)."-".substr($row['client_phone'],3,3)."-".substr($row['client_phone'],6,4);
$location_address = $row['location_address'];
$location_city = $row['location_city'];
$location_state = $row['location_state'];
$location_zip = $row['location_zip'];
$contact_email = $row['contact_email'];
$contact_phone = $row['contact_phone'];
if(strlen($contact_phone)>2){
$contact_phone = substr($row['contact_phone'],0,3)."-".substr($row['contact_phone'],3,3)."-".substr($row['contact_phone'],6,4);
}
$client_extension = $row['client_extension'];
$client_mobile = $row['client_mobile'];
if(strlen($client_mobile)>2){
$client_mobile = substr($row['client_mobile'],0,3)."-".substr($row['client_mobile'],3,3)."-".substr($row['client_mobile'],6,4);
$contact_extension = $row['contact_extension'];
$contact_mobile = $row['contact_mobile'];
if(strlen($contact_mobile)>2){
$contact_mobile = substr($row['contact_mobile'],0,3)."-".substr($row['contact_mobile'],3,3)."-".substr($row['contact_mobile'],6,4);
}
$client_website = $row['client_website'];
$client_currency_code = $row['client_currency_code'];
@@ -65,7 +67,7 @@ if(isset($_GET['quote_id'])){
$company_logo_base64 = base64_encode(file_get_contents($row['company_logo']));
}
$sql_history = mysqli_query($mysqli,"SELECT * FROM history WHERE quote_id = $quote_id ORDER BY history_id DESC");
$sql_history = mysqli_query($mysqli,"SELECT * FROM history WHERE history_quote_id = $quote_id ORDER BY history_id DESC");
//Set Badge color based off of quote status
if($quote_status == "Sent"){
@@ -107,7 +109,7 @@ if(isset($_GET['quote_id'])){
<i class="fas fa-fw fa-paper-plane"></i> Send
</button>
<div class="dropdown-menu">
<?php if(!empty($config_smtp_host) AND !empty($client_email)){ ?>
<?php if(!empty($config_smtp_host) AND !empty($contact_email)){ ?>
<a class="dropdown-item" href="post.php?email_quote=<?php echo $quote_id; ?>">Send Email</a>
<div class="dropdown-divider"></div>
<?php } ?>
@@ -137,7 +139,7 @@ if(isset($_GET['quote_id'])){
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#" onclick="window.print();">Print</a>
<a class="dropdown-item" href="#" onclick="pdfMake.createPdf(docDefinition).download('<?php echo "$quote_date-$company_name-$client_name-Quote-$quote_prefix$quote_number.pdf"; ?>');">Download PDF</a>
<?php if(!empty($config_smtp_host) AND !empty($client_email)){ ?>
<?php if(!empty($config_smtp_host) AND !empty($contact_email)){ ?>
<a class="dropdown-item" href="post.php?email_quote=<?php echo $quote_id; ?>">Send Email</a>
<?php } ?>
<a class="dropdown-item" target="_blank" href="guest_view_quote.php?quote_id=<?php echo "$quote_id&url_key=$quote_url_key"; ?>">Guest URL</a>
@@ -172,11 +174,11 @@ if(isset($_GET['quote_id'])){
<div class="col-sm">
<ul class="list-unstyled text-right">
<li><h4><strong><?php echo $client_name; ?></strong></h4></li>
<li><?php echo $client_address; ?></li>
<li><?php echo "$client_city $client_state $client_zip"; ?></li>
<li><?php echo "$client_phone $client_extension"; ?></li>
<li><?php echo "$client_mobile"; ?></li>
<li><?php echo $client_email; ?></li>
<li><?php echo $location_address; ?></li>
<li><?php echo "$location_city $location_state $location_zip"; ?></li>
<li><?php echo "$contact_phone $contact_extension"; ?></li>
<li><?php echo $contact_mobile; ?></li>
<li><?php echo $contact_email; ?></li>
</ul>
</div>
</div>
@@ -193,7 +195,7 @@ if(isset($_GET['quote_id'])){
</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 item_quote_id = $quote_id ORDER BY item_id ASC"); ?>
<div class="row mb-4">
<div class="col-md-12">
@@ -227,7 +229,7 @@ if(isset($_GET['quote_id'])){
$item_tax = $row['item_tax'];
$item_total = $row['item_total'];
$item_created_at = $row['item_created_at'];
$tax_id = $row['tax_id'];
$tax_id = $row['item_tax_id'];
$total_tax = $item_tax + $total_tax;
$sub_total = $item_price * $item_quantity + $sub_total;
@@ -465,7 +467,7 @@ var docDefinition = {
style: 'invoiceBillingAddress'
},
{
text: <?php echo json_encode("$client_address \n $client_city $client_state $client_zip \n $client_email \n $client_phone"); ?>,
text: <?php echo json_encode("$location_address \n $location_city $location_state $location_zip \n $contact_email \n $contact_phone"); ?>,
style: 'invoiceBillingAddressClient'
},
]
@@ -542,7 +544,7 @@ var docDefinition = {
$total_tax = 0;
$sub_total = 0;
$sql_invoice_items = mysqli_query($mysqli,"SELECT * FROM invoice_items WHERE quote_id = $quote_id ORDER BY item_id ASC");
$sql_invoice_items = mysqli_query($mysqli,"SELECT * FROM invoice_items WHERE item_quote_id = $quote_id ORDER BY item_id ASC");
while($row = mysqli_fetch_array($sql_invoice_items)){
$item_name = $row['item_name'];
@@ -552,7 +554,7 @@ var docDefinition = {
$item_subtotal = $row['item_price'];
$item_tax = $row['item_tax'];
$item_total = $row['item_total'];
$tax_id = $row['tax_id'];
$tax_id = $row['item_tax_id'];
$total_tax = $item_tax + $total_tax;
$sub_total = $item_price * $item_quantity + $sub_total;
?>