diff --git a/accounts.php b/accounts.php index c6d3044b..8a17f890 100644 --- a/accounts.php +++ b/accounts.php @@ -1,12 +1,10 @@ $sb, 'o' => $o))); diff --git a/categories.php b/categories.php index 969ea761..4ebff2e4 100644 --- a/categories.php +++ b/categories.php @@ -1,5 +1,9 @@ $sb, 'o' => $o))); diff --git a/client_assets.php b/client_assets.php index 15e3933b..ecad987e 100644 --- a/client_assets.php +++ b/client_assets.php @@ -1,4 +1,9 @@ $sb, 'o' => $o))); diff --git a/client_contacts.php b/client_contacts.php index ffcbe41a..6ee57a2d 100644 --- a/client_contacts.php +++ b/client_contacts.php @@ -1,26 +1,11 @@ $sb, 'o' => $o))); diff --git a/client_documents.php b/client_documents.php index 0cbdc6cd..c1bae3c5 100644 --- a/client_documents.php +++ b/client_documents.php @@ -1,5 +1,9 @@ $sb, 'o' => $o))); diff --git a/client_invoices.php b/client_invoices.php index 15d386d4..3a7164b2 100644 --- a/client_invoices.php +++ b/client_invoices.php @@ -1,18 +1,11 @@ $sb, 'o' => $o))); diff --git a/client_locations.php b/client_locations.php index 8bca6f6a..8b22ee13 100644 --- a/client_locations.php +++ b/client_locations.php @@ -1,25 +1,11 @@ $sb, 'o' => $o))); @@ -29,7 +15,8 @@ $sql = mysqli_query( WHERE location_client_id = $client_id AND location_archived_at IS NULL AND (location_name LIKE '%$q%' OR location_address LIKE '%$q%' OR location_phone LIKE '%$phone_query%') - ORDER BY $sb $o LIMIT $record_from, $record_to"); + ORDER BY $sb $o LIMIT $record_from, $record_to" +); $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); diff --git a/client_logs.php b/client_logs.php index af47940a..48257bdb 100644 --- a/client_logs.php +++ b/client_logs.php @@ -1,18 +1,11 @@ $sb, 'o' => $o))); diff --git a/client_networks.php b/client_networks.php index f7425a03..530b58ca 100644 --- a/client_networks.php +++ b/client_networks.php @@ -1,11 +1,10 @@ $sb, 'o' => $o))); diff --git a/client_payments.php b/client_payments.php index 601bd2dd..037640bd 100644 --- a/client_payments.php +++ b/client_payments.php @@ -1,18 +1,11 @@ $sb, 'o' => $o))); diff --git a/client_quotes.php b/client_quotes.php index b1cc0d40..8e2977b2 100644 --- a/client_quotes.php +++ b/client_quotes.php @@ -1,19 +1,11 @@ $sb, 'o' => $o))); diff --git a/client_recurring_invoices.php b/client_recurring_invoices.php index 5806daf5..1a1706ce 100644 --- a/client_recurring_invoices.php +++ b/client_recurring_invoices.php @@ -1,12 +1,10 @@ $sb, 'o' => $o))); diff --git a/client_services.php b/client_services.php index 009c46fa..93ada87d 100644 --- a/client_services.php +++ b/client_services.php @@ -1,12 +1,10 @@ $sb, 'o' => $o))); diff --git a/client_shared_items.php b/client_shared_items.php index 80dfbe71..1e1f8660 100644 --- a/client_shared_items.php +++ b/client_shared_items.php @@ -1,20 +1,10 @@ $sb, 'o' => $o))); @@ -44,7 +34,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
- +
diff --git a/client_software.php b/client_software.php index 9b8b2244..a34af2d9 100644 --- a/client_software.php +++ b/client_software.php @@ -1,11 +1,10 @@ $sb, 'o' => $o))); diff --git a/client_tickets.php b/client_tickets.php index f46a426f..0f7e1aaa 100644 --- a/client_tickets.php +++ b/client_tickets.php @@ -1,18 +1,11 @@ $sb, 'o' => $o))); diff --git a/client_trips.php b/client_trips.php index d6010fa2..a76b5237 100644 --- a/client_trips.php +++ b/client_trips.php @@ -1,28 +1,11 @@ $sb, 'o' => $o))); diff --git a/client_vendors.php b/client_vendors.php index 9a76178d..2f38e5ec 100644 --- a/client_vendors.php +++ b/client_vendors.php @@ -1,25 +1,11 @@ $sb, 'o' => $o))); diff --git a/clients.php b/clients.php index a6439d7d..a0789df3 100644 --- a/clients.php +++ b/clients.php @@ -1,105 +1,25 @@ $sortby, 'order' => $order))); +$url_query_strings_sb = http_build_query(array_merge($_GET, array('sb' => $sb, 'o' => $o))); $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_referral 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%') + WHERE (client_name LIKE '%$q%' OR client_type LIKE '%$q%' OR client_referral LIKE '%$q%' OR contact_email LIKE '%$q%' OR contact_name LIKE '%$q%' OR contact_phone LIKE '%$phone_query%' + OR contact_mobile LIKE '%$phone_query%' OR location_address LIKE '%$q%' OR location_city LIKE '%$q%' OR location_state LIKE '%$q%' OR location_zip LIKE '%$q%') AND client_archived_at IS NULL - AND DATE(client_created_at) BETWEEN '$date_from' AND '$date_to' + AND DATE(client_created_at) BETWEEN '$dtf' AND '$dtt' AND clients.company_id = $session_company_id - ORDER BY $sortby $order LIMIT $record_from, $record_to + ORDER BY $sb $o LIMIT $record_from, $record_to "); $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); @@ -121,7 +41,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
- +
@@ -129,7 +49,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
-
" id="advancedFilter"> +
" id="advancedFilter">
@@ -150,13 +70,13 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
- +
- +
@@ -167,9 +87,9 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); "> - - - + + + diff --git a/companies.php b/companies.php index 9768a30d..9df4fe52 100644 --- a/companies.php +++ b/companies.php @@ -1,11 +1,10 @@ $sb, 'o' => $o))); diff --git a/expenses.php b/expenses.php index 8992e73f..f62985fd 100644 --- a/expenses.php +++ b/expenses.php @@ -1,58 +1,11 @@ $sb, 'o' => $o))); @@ -66,7 +19,8 @@ $sql = mysqli_query( AND expense_vendor_id > 0 AND DATE(expense_date) BETWEEN '$dtf' AND '$dtt' AND (vendor_name LIKE '%$q%' OR category_name LIKE '%$q%' OR account_name LIKE '%$q%' OR expense_description LIKE '%$q%' OR expense_amount LIKE '%$q%') - ORDER BY $sb $o LIMIT $record_from, $record_to"); + ORDER BY $sb $o LIMIT $record_from, $record_to" +); $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); @@ -98,7 +52,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); -
" id="advancedFilter"> +
" id="advancedFilter">
diff --git a/invoices.php b/invoices.php index 9aa00e0d..3b43fc30 100644 --- a/invoices.php +++ b/invoices.php @@ -1,5 +1,9 @@ $sb, 'o' => $o))); @@ -216,7 +168,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
-
" id="advancedFilter"> +
" id="advancedFilter">
diff --git a/logs.php b/logs.php index 8f61377d..18301bd3 100644 --- a/logs.php +++ b/logs.php @@ -1,58 +1,11 @@ $sb, 'o' => $o))); diff --git a/notifications_dismissed.php b/notifications_dismissed.php index c1f55c9a..9972c041 100644 --- a/notifications_dismissed.php +++ b/notifications_dismissed.php @@ -1,28 +1,11 @@ $sb, 'o' => $o))); diff --git a/pagination_head.php b/pagination_head.php index 36be1200..b161c386 100644 --- a/pagination_head.php +++ b/pagination_head.php @@ -28,13 +28,72 @@ if (isset($_GET['o'])) { $disp = "ASC"; } } else { - $o = "ASC"; - $disp = "DESC"; + if ($o == "ASC") { + $disp = "DESC"; + } else { + $disp = "ASC"; + } } // Search if (isset($_GET['q'])) { $q = sanitizeInput($_GET['q']); + //Phone Numbers + $phone_query = preg_replace("/[^0-9]/", '', $q); + if (empty($phone_query)) { + $phone_query = $q; + } + //Phone Numbers + $n = preg_replace("/[^0-9]/", '', $q); + if (empty($n)) { + $n = $q; + } } else { $q = ""; + $phone_query = ""; +} + +// Sortby +if (!empty($_GET['sb'])) { + $sb = sanitizeInput($_GET['sb']); +} + +// Date Handling +if (empty($_GET['canned_date'])) { + //Prevents lots of undefined variable errors. + // $dtf and $dtt will be set by the below else to 0000-00-00 / 9999-00-00 + $_GET['canned_date'] = 'custom'; +} + +// Date Filter +if ($_GET['canned_date'] == "custom" && !empty($_GET['dtf'])) { + $dtf = sanitizeInput($_GET['dtf']); + $dtt = sanitizeInput($_GET['dtt']); +} elseif ($_GET['canned_date'] == "today") { + $dtf = date('Y-m-d'); + $dtt = date('Y-m-d'); +} elseif ($_GET['canned_date'] == "yesterday") { + $dtf = date('Y-m-d', strtotime("yesterday")); + $dtt = date('Y-m-d', strtotime("yesterday")); +} elseif ($_GET['canned_date'] == "thisweek") { + $dtf = date('Y-m-d', strtotime("monday this week")); + $dtt = date('Y-m-d'); +} elseif ($_GET['canned_date'] == "lastweek") { + $dtf = date('Y-m-d', strtotime("monday last week")); + $dtt = date('Y-m-d', strtotime("sunday last week")); +} elseif ($_GET['canned_date'] == "thismonth") { + $dtf = date('Y-m-01'); + $dtt = date('Y-m-d'); +} elseif ($_GET['canned_date'] == "lastmonth") { + $dtf = date('Y-m-d', strtotime("first day of last month")); + $dtt = date('Y-m-d', strtotime("last day of last month")); +} elseif ($_GET['canned_date'] == "thisyear") { + $dtf = date('Y-01-01'); + $dtt = date('Y-m-d'); +} elseif ($_GET['canned_date'] == "lastyear") { + $dtf = date('Y-m-d', strtotime("first day of january last year")); + $dtt = date('Y-m-d', strtotime("last day of december last year")); +} else { + $dtf = "0000-00-00"; + $dtt = "9999-00-00"; } diff --git a/payments.php b/payments.php index 019de07c..fbf2a083 100644 --- a/payments.php +++ b/payments.php @@ -1,57 +1,11 @@ $sb, 'o' => $o))); @@ -89,7 +43,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
-
" id="advancedFilter"> +
" id="advancedFilter">
diff --git a/products.php b/products.php index 3d83c82c..5a69f476 100644 --- a/products.php +++ b/products.php @@ -1,13 +1,11 @@ $sb, 'o' => $o))); diff --git a/quotes.php b/quotes.php index eaecadd5..79ac782e 100644 --- a/quotes.php +++ b/quotes.php @@ -1,57 +1,11 @@ $sb, 'o' => $o))); @@ -90,7 +44,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
-
" id="advancedFilter"> +
" id="advancedFilter">
diff --git a/recurring_invoices.php b/recurring_invoices.php index 354306c7..21cc83e1 100644 --- a/recurring_invoices.php +++ b/recurring_invoices.php @@ -1,57 +1,11 @@ $sb, 'o' => $o))); @@ -62,7 +16,7 @@ $sql = mysqli_query( LEFT JOIN categories ON recurring_category_id = category_id WHERE recurring.company_id = $session_company_id AND (CONCAT(recurring_prefix,recurring_number) LIKE '%$q%' OR recurring_frequency LIKE '%$q%' OR recurring_scope LIKE '%$q%' OR client_name LIKE '%$q%' OR category_name LIKE '%$q%') - AND DATE(recurring_next_date) BETWEEN '$dtf' AND '$dtt' + AND DATE(recurring_last_sent) BETWEEN '$dtf' AND '$dtt' ORDER BY $sb $o LIMIT $record_from, $record_to"); $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); @@ -90,7 +44,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
-
" id="advancedFilter"> +
" id="advancedFilter">
diff --git a/revenues.php b/revenues.php index 31e4b207..0ee43196 100644 --- a/revenues.php +++ b/revenues.php @@ -1,58 +1,11 @@ $sb, 'o' => $o))); @@ -91,7 +44,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
-
" id="advancedFilter"> +
" id="advancedFilter">
diff --git a/settings_api.php b/settings_api.php index 0a9e258d..ce7a9585 100644 --- a/settings_api.php +++ b/settings_api.php @@ -1,12 +1,10 @@ $sb, 'o' => $o))); diff --git a/settings_software_templates.php b/settings_software_templates.php index 7283e506..a1e5a2cb 100644 --- a/settings_software_templates.php +++ b/settings_software_templates.php @@ -1,12 +1,10 @@ $sb, 'o' => $o))); diff --git a/settings_tags.php b/settings_tags.php index 3344a2b5..1fe5280a 100644 --- a/settings_tags.php +++ b/settings_tags.php @@ -1,11 +1,10 @@ $sb, 'o' => $o))); diff --git a/settings_taxes.php b/settings_taxes.php index 2ec3b74c..4fa7a0c2 100644 --- a/settings_taxes.php +++ b/settings_taxes.php @@ -1,17 +1,16 @@ $sb, 'o' => $o))); $sql = mysqli_query( - $mysqli, + $mysqli, "SELECT * FROM taxes WHERE tax_archived_at IS NULL AND company_id = $session_company_id diff --git a/settings_vendor_templates.php b/settings_vendor_templates.php index 44b56cad..f8734bf9 100644 --- a/settings_vendor_templates.php +++ b/settings_vendor_templates.php @@ -1,25 +1,11 @@ $sb, 'o' => $o))); diff --git a/tickets.php b/tickets.php index 214af0b1..9c7f8a02 100644 --- a/tickets.php +++ b/tickets.php @@ -1,40 +1,10 @@ - $sb, 'o' => $o, 'status' => $status, 'assigned' => $ticket_assigned_filter))); @@ -207,9 +137,7 @@ $user_active_assigned_tickets = intval($row['total_tickets_assigned']);
-
" id="advancedFilter"> +
" id="advancedFilter">
diff --git a/transfers.php b/transfers.php index bd6f5378..1d51d3f1 100644 --- a/transfers.php +++ b/transfers.php @@ -1,59 +1,10 @@ $sb, 'o' => $o))); @@ -92,7 +43,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
-
" id="advancedFilter"> +
" id="advancedFilter">
diff --git a/trips.php b/trips.php index 0599093c..af1367af 100644 --- a/trips.php +++ b/trips.php @@ -1,59 +1,11 @@ $sb, 'o' => $o))); @@ -69,8 +21,6 @@ $sql = mysqli_query( ); $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); -$total_found_rows = $num_rows[0]; -$total_pages = ceil($total_found_rows / 10); ?> @@ -100,7 +50,7 @@ $total_pages = ceil($total_found_rows / 10);
-
" id="advancedFilter"> +
" id="advancedFilter">
diff --git a/users.php b/users.php index c5356b82..5734b653 100644 --- a/users.php +++ b/users.php @@ -1,11 +1,10 @@ $sb, 'o' => $o))); diff --git a/vendors.php b/vendors.php index c8039ac5..a0d587d3 100644 --- a/vendors.php +++ b/vendors.php @@ -1,35 +1,11 @@ $sb, 'o' => $o))); @@ -70,8 +46,24 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
-
" id="advancedFilter"> +
" id="advancedFilter">
+
+
+ + +
+
NamePrimary Address Primary ContactNamePrimary Address Primary Contact Billing Action