mirror of
https://github.com/itflow-org/itflow
synced 2026-08-10 09:37:15 +00:00
clientScopeSql sweep whicn now removed the extra unessesary client joins
This commit is contained in:
@@ -1442,7 +1442,7 @@ if (isset($_POST['export_assets'])) {
|
||||
$tag_query
|
||||
AND (asset_name LIKE '%$q%' OR asset_description LIKE '%$q%' OR asset_type LIKE '%$q%' OR interface_ip LIKE '%$q%' OR interface_ipv6 LIKE '%$q%' OR interface_mac LIKE '%$q%' OR asset_make LIKE '%$q%' OR asset_model LIKE '%$q%' OR asset_serial LIKE '%$q%' OR asset_os LIKE '%$q%' OR contact_name LIKE '%$q%' OR location_name LIKE '%$q%' OR client_name LIKE '%$q%' OR tag_name LIKE '%$q%')
|
||||
AND ($type_query)
|
||||
$access_permission_query
|
||||
" . clientScopeSql('asset_client_id') . "
|
||||
$location_query
|
||||
$expire_query
|
||||
$client_query
|
||||
|
||||
@@ -408,7 +408,7 @@ if (isset($_POST['export_certificates'])) {
|
||||
LEFT JOIN clients ON client_id = certificate_client_id
|
||||
WHERE $archive_query
|
||||
AND (certificate_name LIKE '%$q%' OR certificate_domain LIKE '%$q%' OR certificate_description LIKE '%$q%' OR certificate_issued_by LIKE '%$q%' OR client_name LIKE '%$q%')
|
||||
$access_permission_query
|
||||
" . clientScopeSql('certificate_client_id') . "
|
||||
$client_query
|
||||
$expire_query
|
||||
ORDER BY certificate_name ASC"
|
||||
|
||||
@@ -452,7 +452,7 @@ if (isset($_POST['export_clients'])) {
|
||||
AND $archive_query
|
||||
AND DATE(client_created_at) BETWEEN '$dtf' AND '$dtt'
|
||||
$leads_query
|
||||
$access_permission_query
|
||||
" . clientScopeSql('clients.client_id') . "
|
||||
$tag_query
|
||||
$industry_query
|
||||
$referral_query
|
||||
|
||||
@@ -1349,7 +1349,7 @@ if (isset($_POST['export_contacts'])) {
|
||||
WHERE $archive_query
|
||||
$tag_query
|
||||
AND (contact_name LIKE '%$q%' OR contact_title LIKE '%$q%' OR location_name LIKE '%$q%' OR contact_email LIKE '%$q%' OR contact_department LIKE '%$q%' OR contact_phone LIKE '%$q%' OR contact_mobile LIKE '%$q%' OR client_name LIKE '%$q%' OR tag_name LIKE '%$q%')
|
||||
$access_permission_query
|
||||
" . clientScopeSql('contact_client_id') . "
|
||||
$client_query
|
||||
$location_query
|
||||
GROUP BY contact_id
|
||||
|
||||
@@ -487,7 +487,7 @@ if (isset($_POST['export_credentials'])) {
|
||||
WHERE $archive_query
|
||||
$tag_query
|
||||
AND (c.credential_name LIKE '%$q%' OR c.credential_description LIKE '%$q%' OR c.credential_uri LIKE '%$q%' OR tag_name LIKE '%$q%' OR client_name LIKE '%$q%')
|
||||
$access_permission_query
|
||||
" . clientScopeSql('credential_client_id') . "
|
||||
$client_query
|
||||
GROUP BY c.credential_id
|
||||
ORDER BY c.credential_name ASC"
|
||||
|
||||
@@ -530,7 +530,7 @@ if (isset($_POST['export_domains'])) {
|
||||
LEFT JOIN vendors AS webhost ON domains.domain_webhost = webhost.vendor_id
|
||||
WHERE (domains.domain_name LIKE '%$q%' OR domains.domain_description LIKE '%$q%' OR registrar.vendor_name LIKE '%$q%' OR webhost.vendor_name LIKE '%$q%' OR client_name LIKE '%$q%')
|
||||
AND $archive_query
|
||||
$access_permission_query
|
||||
" . clientScopeSql('domain_client_id') . "
|
||||
$client_query
|
||||
$expire_query
|
||||
ORDER BY domains.domain_name ASC"
|
||||
|
||||
@@ -370,7 +370,7 @@ if (isset($_POST['export_expenses'])) {
|
||||
$category_query
|
||||
AND (vendor_name LIKE '%$q%' OR client_name LIKE '%$q%' OR category_name LIKE '%$q%' OR account_name LIKE '%$q%' OR expense_description LIKE '%$q%' OR expense_amount LIKE '%$q%')
|
||||
$account_query
|
||||
$access_permission_query
|
||||
" . clientScopeSql('expense_client_id') . "
|
||||
ORDER BY expense_date ASC"
|
||||
);
|
||||
|
||||
|
||||
@@ -439,7 +439,7 @@ if (isset($_POST['export_income'])) {
|
||||
LEFT JOIN categories ON invoice_category_id = category_id
|
||||
WHERE payment_archived_at IS NULL
|
||||
$payment_client_query
|
||||
$access_permission_query
|
||||
" . clientScopeSql('invoice_client_id') . "
|
||||
|
||||
UNION ALL
|
||||
|
||||
|
||||
@@ -730,7 +730,7 @@ if (isset($_POST['export_invoices'])) {
|
||||
$category_query
|
||||
AND DATE(invoice_date) BETWEEN '$dtf' AND '$dtt'
|
||||
AND (CONCAT(invoice_prefix,invoice_number) LIKE '%$q%' OR invoice_scope LIKE '%$q%' OR client_name LIKE '%$q%' OR invoice_status LIKE '%$q%' OR invoice_amount LIKE '%$q%' OR category_name LIKE '%$q%')
|
||||
$access_permission_query
|
||||
" . clientScopeSql('invoice_client_id') . "
|
||||
$client_query
|
||||
ORDER BY invoice_number ASC"
|
||||
);
|
||||
@@ -823,7 +823,7 @@ if (isset($_GET['export_invoice_pdf'])) {
|
||||
LEFT JOIN contacts ON clients.client_id = contacts.contact_client_id AND contact_primary = 1
|
||||
LEFT JOIN locations ON clients.client_id = locations.location_client_id AND location_primary = 1
|
||||
WHERE invoice_id = $invoice_id
|
||||
$access_permission_query
|
||||
" . clientScopeSql('invoice_client_id') . "
|
||||
LIMIT 1"
|
||||
);
|
||||
|
||||
@@ -1052,7 +1052,7 @@ if (isset($_GET['export_invoice_packing_slip'])) {
|
||||
LEFT JOIN contacts ON clients.client_id = contacts.contact_client_id AND contact_primary = 1
|
||||
LEFT JOIN locations ON clients.client_id = locations.location_client_id AND location_primary = 1
|
||||
WHERE invoice_id = $invoice_id
|
||||
$access_permission_query
|
||||
" . clientScopeSql('invoice_client_id') . "
|
||||
LIMIT 1"
|
||||
);
|
||||
|
||||
|
||||
@@ -463,7 +463,7 @@ if (isset($_POST['export_locations'])) {
|
||||
WHERE $archive_query
|
||||
$tag_query
|
||||
AND (location_name LIKE '%$q%' OR location_description LIKE '%$q%' OR location_address LIKE '%$q%' OR location_city LIKE '%$q%' OR location_state LIKE '%$q%' OR location_zip LIKE '%$q%' OR location_country LIKE '%$q%' OR location_phone LIKE '%$q%' OR client_name LIKE '%$q%' OR tag_name LIKE '%$q%')
|
||||
$access_permission_query
|
||||
" . clientScopeSql('location_client_id') . "
|
||||
$client_query
|
||||
GROUP BY location_id
|
||||
ORDER BY location_name ASC"
|
||||
|
||||
@@ -238,7 +238,7 @@ if (isset($_POST['export_networks'])) {
|
||||
LEFT JOIN locations ON location_id = network_location_id
|
||||
WHERE $archive_query
|
||||
AND (network_name LIKE '%$q%' OR network_description LIKE '%$q%' OR network_vlan LIKE '%$q%' OR network LIKE '%$q%' OR network_gateway LIKE '%$q%' OR network_primary_dns LIKE '%$q%' OR network_secondary_dns LIKE '%$q%' OR client_name LIKE '%$q%')
|
||||
$access_permission_query
|
||||
" . clientScopeSql('network_client_id') . "
|
||||
$location_query
|
||||
$client_query
|
||||
ORDER BY network_name ASC"
|
||||
|
||||
@@ -732,7 +732,7 @@ if (isset($_POST['export_quotes'])) {
|
||||
LEFT JOIN categories ON quote_category_id = category_id
|
||||
WHERE (CONCAT(quote_prefix,quote_number) LIKE '%$q%' OR quote_scope LIKE '%$q%' OR category_name LIKE '%$q%' OR quote_status LIKE '%$q%' OR quote_amount LIKE '%$q%' OR client_name LIKE '%$q%')
|
||||
AND DATE(quote_date) BETWEEN '$dtf' AND '$dtt'
|
||||
$access_permission_query
|
||||
" . clientScopeSql('quote_client_id') . "
|
||||
$client_query
|
||||
ORDER BY quote_number ASC"
|
||||
);
|
||||
@@ -774,7 +774,7 @@ if (isset($_GET['export_quote_pdf'])) {
|
||||
LEFT JOIN contacts ON clients.client_id = contacts.contact_client_id AND contact_primary = 1
|
||||
LEFT JOIN locations ON clients.client_id = locations.location_client_id AND location_primary = 1
|
||||
WHERE quote_id = $quote_id
|
||||
$access_permission_query
|
||||
" . clientScopeSql('quote_client_id') . "
|
||||
LIMIT 1"
|
||||
);
|
||||
|
||||
|
||||
@@ -666,7 +666,7 @@ if (isset($_POST['export_recurring_invoices'])) {
|
||||
AND DATE(recurring_invoice_created_at) BETWEEN '$dtf' AND '$dtt'
|
||||
$status_query
|
||||
$client_query
|
||||
$access_permission_query
|
||||
" . clientScopeSql('recurring_invoice_client_id') . "
|
||||
ORDER BY recurring_invoice_number ASC"
|
||||
);
|
||||
|
||||
|
||||
@@ -296,7 +296,7 @@ if (isset($_POST['export_software'])) {
|
||||
LEFT JOIN vendors ON vendor_id = software_vendor_id
|
||||
WHERE (software_name LIKE '%$q%' OR software_type LIKE '%$q%' OR software_key LIKE '%$q%' OR client_name LIKE '%$q%')
|
||||
AND $archive_query
|
||||
$access_permission_query
|
||||
" . clientScopeSql('software_client_id') . "
|
||||
$client_query
|
||||
$expire_query
|
||||
ORDER BY software_name ASC"
|
||||
|
||||
@@ -2871,12 +2871,8 @@ if (isset($_POST['export_tickets'])) {
|
||||
$ticket_project_snippet = '';
|
||||
}
|
||||
|
||||
// Client access override - the only way tickets without a client reach agents
|
||||
// with restricted client access
|
||||
$access_permission_query_overide = '';
|
||||
if ($client_access_string) {
|
||||
$access_permission_query_overide = "AND ticket_client_id IN (0,$client_access_string)";
|
||||
}
|
||||
// Tickets with no client stay visible to restricted agents - clientScopeSql() includes 0
|
||||
$access_permission_query_overide = clientScopeSql('ticket_client_id');
|
||||
|
||||
// Date Filter
|
||||
$dtf = escapeSql(!empty($_POST['dtf']) ? $_POST['dtf'] : '1970-01-01');
|
||||
|
||||
@@ -133,7 +133,7 @@ if (isset($_POST['export_trips'])) {
|
||||
AND DATE(trip_date) BETWEEN '$dtf' AND '$dtt'
|
||||
AND trip_archived_at IS NULL
|
||||
$client_query
|
||||
$access_permission_query
|
||||
" . clientScopeSql('trip_client_id') . "
|
||||
ORDER BY trip_date ASC"
|
||||
);
|
||||
|
||||
|
||||
@@ -398,7 +398,7 @@ if (isset($_POST['export_vendors'])) {
|
||||
WHERE $archive_query
|
||||
AND (vendor_name LIKE '%$q%' OR vendor_description LIKE '%$q%' OR vendor_account_number LIKE '%$q%' OR vendor_website LIKE '%$q%' OR vendor_contact_name LIKE '%$q%' OR vendor_email LIKE '%$q%' OR vendor_phone LIKE '%$q%')
|
||||
$client_query
|
||||
$access_permission_query
|
||||
" . clientScopeSql('vendor_client_id') . "
|
||||
ORDER BY vendor_name ASC"
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user