$sortby, 'order' => $order))); $sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM clients LEFT JOIN contacts ON clients.primary_contact = contacts.contact_id AND contact_archived_at IS NULL LEFT JOIN locations ON clients.primary_location = locations.location_id AND location_archived_at IS NULL WHERE (client_name LIKE '%$query%' OR client_type LIKE '%$query%' OR client_support LIKE '%$query%' OR contact_email LIKE '%$query%' OR contact_name LIKE '%$query%' OR contact_phone LIKE '%$query%' OR contact_mobile LIKE '%$query%' OR location_address LIKE '%$query%' OR location_city LIKE '%$query%' OR location_state LIKE '%$query%' OR location_zip LIKE '%$query%') AND DATE(client_created_at) BETWEEN '$date_from' AND '$date_to' AND clients.company_id = $session_company_id $permission_sql ORDER BY $sortby $order LIMIT $record_from, $record_to" ); $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); ?>

Clients

" id="advancedFilter">

"> $location_city $location_state $location_zip"; } $contact_id = $row['contact_id']; $contact_name = $row['contact_name']; $contact_title = $row['contact_title']; $contact_phone = formatPhoneNumber($row['contact_phone']); $contact_extension = $row['contact_extension']; $contact_mobile = formatPhoneNumber($row['contact_mobile']); $contact_email = $row['contact_email']; $client_website = $row['client_website']; $client_currency_code = $row['client_currency_code']; $client_net_terms = $row['client_net_terms']; $client_referral = $row['client_referral']; $client_support = $row['client_support']; $client_notes = $row['client_notes']; $client_created_at = $row['client_created_at']; $client_updated_at = $row['client_updated_at']; //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 invoice_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']; $sql_amount_paid = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS amount_paid FROM payments, invoices WHERE payment_invoice_id = invoice_id AND invoice_client_id = $client_id"); $row = mysqli_fetch_array($sql_amount_paid); $amount_paid = $row['amount_paid']; $balance = $invoice_amounts - $amount_paid; //set Text color on balance if($balance > 0){ $balance_text_color = "text-danger font-weight-bold"; }else{ $balance_text_color = ""; } ?>
Name Location Contact Billing Action
fa-fw">

Added:



Balance: $
Paid: $