From f49665b6d4fcb3ca9b0904451617c9bfa4dfc24f Mon Sep 17 00:00:00 2001 From: root Date: Sat, 23 Mar 2019 12:32:36 -0400 Subject: [PATCH] Print Client: Only Display Table if records > 0 moved queries to the top for clean look --- client_print.php | 131 +++++++++++++++++++++++++++++------------------ 1 file changed, 81 insertions(+), 50 deletions(-) diff --git a/client_print.php b/client_print.php index ab4b8ca1..1c6f2f1e 100644 --- a/client_print.php +++ b/client_print.php @@ -20,12 +20,46 @@ if(isset($_GET['client_id'])){ } $client_website = $row['client_website']; + //Query each table and store them in their array + $sql_contacts = mysqli_query($mysqli,"SELECT * FROM client_contacts WHERE client_id = $client_id ORDER BY client_contact_id DESC"); + $sql_locations = mysqli_query($mysqli,"SELECT * FROM client_locations WHERE client_id = $client_id ORDER BY client_location_id DESC"); + $sql_assets = mysqli_query($mysqli,"SELECT * FROM client_assets WHERE client_id = $client_id ORDER BY client_asset_id DESC"); + $sql_vendors = mysqli_query($mysqli,"SELECT * FROM client_vendors WHERE client_id = $client_id ORDER BY client_vendor_id DESC"); + $sql_logins = mysqli_query($mysqli,"SELECT * FROM client_logins WHERE client_id = $client_id ORDER BY client_login_id DESC"); + $sql_networks = mysqli_query($mysqli,"SELECT * FROM client_networks WHERE client_id = $client_id ORDER BY client_network_id DESC"); + $sql_domains = mysqli_query($mysqli,"SELECT * FROM client_domains WHERE client_id = $client_id ORDER BY client_domain_id DESC"); + $sql_applications = mysqli_query($mysqli,"SELECT * FROM client_applications WHERE client_id = $client_id ORDER BY client_application_id DESC"); + $sql_invoices = mysqli_query($mysqli,"SELECT * FROM invoices WHERE client_id = $client_id ORDER BY invoices.invoice_date DESC"); + $sql_notes = mysqli_query($mysqli,"SELECT * FROM client_notes WHERE client_id = $client_id ORDER BY client_note_id DESC"); + + //Get Counts + $row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('client_contact_id') AS num FROM client_contacts WHERE client_id = $client_id")); + $num_contacts = $row['num']; + $row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('client_location_id') AS num FROM client_locations WHERE client_id = $client_id")); + $num_locations = $row['num']; + $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('client_vendor_id') AS num FROM client_vendors WHERE client_id = $client_id")); + $num_vendors = $row['num']; + $row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('client_login_id') AS num FROM client_logins WHERE client_id = $client_id")); + $num_logins = $row['num']; + $row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('client_network_id') AS num FROM client_networks WHERE client_id = $client_id")); + $num_networks = $row['num']; + $row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('client_domain_id') AS num FROM client_domains WHERE client_id = $client_id")); + $num_domains = $row['num']; + $row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('client_application_id') AS num FROM client_applications WHERE client_id = $client_id")); + $num_applications = $row['num']; + $row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('invoice_id') AS num FROM invoices WHERE client_id = $client_id")); + $num_invoices = $row['num']; + $row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('client_note_id') AS num FROM client_notes WHERE client_id = $client_id")); + $num_notes = $row['num']; + ?> - +
@@ -68,26 +102,26 @@ if(isset($_GET['client_id'])){
    -
  • Contacts
  • -
  • Locations
  • -
  • Assets
  • -
  • Vendors
  • -
  • Logins
  • -
  • Networks
  • -
  • Domains
  • -
  • Applications
  • -
  • Invoices
  • -
  • Quotes
  • -
  • Attachements
  • -
  • Notes
  • + 0){ ?>
  • Contacts
  • + 0){ ?>
  • Locations
  • + 0){ ?>
  • Assets
  • + 0){ ?>
  • Vendors
  • + 0){ ?>
  • Logins
  • + 0){ ?>
  • Networks
  • + 0){ ?>
  • Domains
  • + 0){ ?>
  • Applications
  • + 0){ ?>
  • Invoices
  • + 0){ ?>
  • Quotes
  • + 0){ ?>
  • Attachments
  • + 0){ ?>
  • Notes
- + 0){ ?>

Contacts

@@ -101,7 +135,7 @@ if(isset($_GET['client_id'])){
+ - - + 0){ ?>

Locations

@@ -141,7 +175,7 @@ if(isset($_GET['client_id'])){
+ - - + 0){ ?>

Assets

@@ -185,7 +219,7 @@ if(isset($_GET['client_id'])){
+ - - + 0){ ?>

Vendors

@@ -223,7 +257,7 @@ if(isset($_GET['client_id'])){
+ - - + 0){ ?>

Logins

@@ -258,7 +292,7 @@ if(isset($_GET['client_id'])){
+ - - + 0){ ?>

Networks

@@ -294,7 +328,7 @@ if(isset($_GET['client_id'])){
+ - - + 0){ ?>

Domains

@@ -333,7 +367,7 @@ if(isset($_GET['client_id'])){
+ - - + 0){ ?>

Applications

@@ -370,7 +404,7 @@ if(isset($_GET['client_id'])){
+ - - + 0){ ?>

Invoices

@@ -411,7 +441,7 @@ if(isset($_GET['client_id'])){
+ - - + 0){ ?>

Notes


- + + + +