$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 contact_email LIKE '%$query%' OR contact_name LIKE '%$query%' OR contact_phone LIKE '%$phone_query%' OR contact_mobile LIKE '%$phone_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 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_notes = $row['client_notes']; $client_meshcentral_group = $row['client_meshcentral_group']; $client_created_at = $row['client_created_at']; $client_updated_at = $row['client_updated_at']; //Client Tags $client_tag_name_display_array = array(); $client_tag_id_array = array(); $sql_client_tags = mysqli_query($mysqli,"SELECT * FROM client_tags LEFT JOIN tags ON client_tags.tag_id = tags.tag_id WHERE client_tags.client_id = $client_id"); while($row = mysqli_fetch_array($sql_client_tags)){ $client_tag_id = $row['tag_id']; $client_tag_name = $row['tag_name']; $client_tag_color = $row['tag_color']; $client_tag_icon = $row['tag_icon']; if(empty($client_tag_icon)){ $client_tag_icon = "tag"; } $client_tag_id_array[] = $client_tag_id; if(empty($client_tag_color)){ $client_tag_name_display_array[] = "$client_tag_name "; }else{ $client_tag_name_display_array[] = " $client_tag_name "; } } $client_tags_display = implode('', $client_tag_name_display_array); //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 Address Contact Billing Action



Added:



Balance
Paid